1 package org.splat.dal.bo.som;
3 * Class of meta files representing physical files under the control of Study Manager.
4 * Typically, the files represented by this class are source files of Documents and exports in different formats.
5 * The path of such files is relative to the vault of the repository of Study Manager.
6 * When creating a Document, as the source file is produced by the caller which creates the Document, the corresponding
7 * physical file may not exist at instantiation time.
9 * @author Daniel Brunier-Coulin
10 * @copyright OPEN CASCADE 2012-2014
13 import java.util.Calendar;
14 import java.util.Date;
16 import org.splat.dal.bo.kernel.Persistent;
17 import org.splat.dal.dao.som.Database;
20 public class File extends Persistent {
23 protected String format;
24 protected String path;
28 private java.io.File myfile; // For optimization
30 // ==============================================================================================================================
32 // ==============================================================================================================================
34 // Database fetch constructor
39 // Internal constructors
40 public File (final String path) {
41 // ----------------------------
42 Calendar current = Calendar.getInstance();
43 String[] table = path.split("\\x2E");
45 this.format = table[table.length-1];
46 this.path = path; // The corresponding physical file may not exist yet
47 this.date = current.getTime(); // Today
50 protected File (final String path, final String format, final Date date) {
51 // ------------------------------------------------------
52 this.path = path; // The corresponding physical file may not exist yet
53 this.format = format; // The format name may be different from the physical file extension
56 Calendar current = Calendar.getInstance();
57 this.date = current.getTime(); // Today
62 // ==============================================================================================================================
63 // Public member functions
64 // ==============================================================================================================================
66 * Returns the data file associated to this meta file.
68 * @return the associated data file. If this meta data is an empty document, the returned file does not exist.
70 public java.io.File asFile () {
71 // -----------------------------
73 myfile = new java.io.File(Database.getRepositoryVaultPath() + path);
78 public Date getDate () {
79 // ----------------------
83 public String getFormat () {
84 // --------------------------
88 public String getName () {
89 // ------------------------
90 return this.asFile().getName();
93 public String getRelativePath () {
94 // --------------------------------
98 public boolean exists () { // Shortcut
99 // ------------------------
100 return (this.asFile().exists());
103 // ==============================================================================================================================
105 // ==============================================================================================================================
107 public void changePath (final String path) {
108 // ---------------------------------------
114 * @param date the date to set
116 public void setDate(final Date date) {