Salome HOME
Refactoring of Database, replacing SQL by DAOs calls. Methods for search by criteria...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / Document.java
1 package org.splat.dal.bo.som;
2
3 /**
4  * 
5  * @author    Daniel Brunier-Coulin
6  * @copyright OPEN CASCADE 2012
7  */
8
9 import java.text.DecimalFormat;
10 import java.text.SimpleDateFormat;
11 import java.util.Arrays;
12 import java.util.Calendar;
13 import java.util.Date;
14 import java.util.Iterator;
15 import java.util.List;
16 import java.util.Vector;
17
18 import org.hibernate.Hibernate;
19 import org.hibernate.Session;
20
21 import org.splat.dal.bo.kernel.Persistent;
22 import org.splat.dal.bo.kernel.Relation;
23 import org.splat.dal.bo.kernel.User;
24 import org.splat.dal.bo.som.Timestamp.ComparatorByDate;
25 import org.splat.dal.dao.som.Database;
26 import org.splat.kernel.NotApplicableException;
27 import org.splat.kernel.InvalidPropertyException;
28 import org.splat.kernel.MissedPropertyException;
29 import org.splat.kernel.MultiplyDefinedException;
30 import org.splat.manox.Reader;
31 import org.splat.manox.Toolbox;
32 import org.splat.service.StudyService;
33 import org.splat.service.technical.ProjectSettingsService;
34 import org.splat.service.technical.ProjectSettingsServiceImpl;
35 import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
36 import org.splat.som.Revision;
37 import org.splat.som.Step;
38
39 public class Document extends Entity {
40
41         // Persistent fields
42         private DocumentType type; // User expendable types
43         private File myfile;
44         private String did;
45         private int step;
46         private ProgressState state;
47         private String name;
48         private String version;
49         private int countag;
50         private int history;
51         private User author;
52         private Date lasdate;
53         private ProjectSettingsService _projectSettingsService;
54         private StudyService _studyService;
55
56         // Transient fields
57         public static String suformat = "00"; // Format of the suffix number of document did and file name
58
59         // ==============================================================================================================================
60         // Construction
61         // ==============================================================================================================================
62
63         // Fields initialization class
64         public static class Properties extends Persistent.Properties {
65                 // ------------------------------------------------------------
66                 private DocumentType type = null;
67                 private String did = null; // Only for searching from a given reference
68                 private ProjectElement owner = null; // Only for constructing a document
69                 private ProjectSettingsService.Step step = null;
70                 private ProgressState state = null;
71                 private String name = null;
72                 protected String format = null;
73                 private String version = null;
74                 private User author = null;
75                 protected Date date = null;
76                 private String summary = null; // Only for versioning a document
77                 private String path = null; // Only for searching from a given path
78
79                 // - Public services
80
81                 public void clear() {
82                         super.clear();
83                         type = null;
84                         did = null;
85                         owner = null;
86                         step = null;
87                         state = null;
88                         name = null;
89                         format = null;
90                         version = null;
91                         author = null;
92                         date = null;
93                         summary = null;
94                         path = null;
95                 }
96
97                 public Properties copy() {
98                         Properties copy = new Properties();
99                         copy.type = this.type;
100                         copy.did = this.did;
101                         copy.owner = this.owner;
102                         copy.step = this.step;
103                         copy.state = this.state;
104                         copy.name = this.name;
105                         copy.format = this.format;
106                         copy.version = this.version;
107                         copy.author = this.author;
108                         copy.date = this.date;
109                         copy.summary = this.summary;
110                         copy.path = this.path;
111                         return copy;
112                 }
113
114                 // - Protected services
115
116                 public User getAuthor() {
117                         return author;
118                 }
119
120                 public String getDescription() {
121                         return summary;
122                 }
123
124                 public String getLocalPath() {
125                         return path;
126                 }
127
128                 public String getReference() {
129                         return did;
130                 }
131
132                 public ProjectSettingsService.Step getStep() {
133                         return step;
134                 }
135
136                 public DocumentType getType() {
137                         return type;
138                 }
139
140                 // - Property setters
141
142                 public Properties setAuthor(User user) {
143                         this.author = user;
144                         return this;
145                 }
146
147                 public Properties setDate(Date date) {
148                         this.date = date;
149                         return this;
150                 }
151
152                 /**
153                  * Get the date.
154                  * @return the date
155                  */
156                 public Date getDate() {
157                         return date;
158                 }
159
160                 public Properties setDescription(String summary)
161                                 throws InvalidPropertyException {
162                         if (summary.length() == 0)
163                                 throw new InvalidPropertyException("description");
164                         this.summary = summary;
165                         return this;
166                 }
167
168                 public Properties setDocument(Document base) {
169                         type = base.type;
170                         step = ProjectSettingsServiceImpl.getStep(base.step);
171                         name = base.name;
172                         format = base.getFormat();
173                         state = ProgressState.inWORK; // For incrementing the version number at save time
174                         version = base.version;
175                         return this;
176                 }
177
178                 public Properties setExternReference(String ref)
179                                 throws InvalidPropertyException {
180                         if (ref.length() == 0)
181                                 throw new InvalidPropertyException("reference");
182                         if (ref.equals(new Revision().toString()))
183                                 throw new InvalidPropertyException("reference"); // Internal version number
184                         this.version = ref;
185                         return this;
186                 }
187
188                 public Properties setFormat(String format)
189                                 throws InvalidPropertyException {
190                         if (format.length() == 0)
191                                 throw new InvalidPropertyException("format");
192                         this.format = format;
193                         return this;
194                 }
195
196                 // Required only for passing search arguments
197                 public Properties setLocalPath(String path)
198                                 throws InvalidPropertyException {
199                         if (path.length() == 0)
200                                 throw new InvalidPropertyException("path");
201                         this.path = path;
202                         return this;
203                 }
204
205                 public Properties setName(String name) throws InvalidPropertyException {
206                         if (name.length() == 0)
207                                 throw new InvalidPropertyException("name");
208                         this.name = name;
209                         return this;
210                 }
211                 
212                 public String getName() {
213                         return this.name;
214                 }
215
216                 public Properties setOwner(ProjectElement owner) {
217                         this.owner = owner;
218                         return this;
219                 }
220
221                 public ProjectElement getOwner() {
222                         return this.owner;
223                 }
224                 // Required only for passing search arguments
225                 public Properties setReference(String did)
226                                 throws InvalidPropertyException {
227                         if (did.length() == 0)
228                                 throw new InvalidPropertyException("reference");
229                         this.did = did;
230                         return this;
231                 }
232
233                 public Properties setState(ProgressState state)
234                                 throws InvalidPropertyException {
235                         if (state == ProgressState.inPROGRESS
236                                         || state == ProgressState.TEMPLATE)
237                                 throw new InvalidPropertyException("state"); // Non document states
238                         this.state = state;
239                         return this;
240                 }
241
242                 public Properties setStep(ProjectSettingsService.Step step) {
243                         this.step = step;
244                         return this;
245                 }
246
247                 public Properties setType(DocumentType type) {
248                         this.type = type;
249                         return this;
250                 }
251
252                 // - Global validity check
253
254                 public void checkValidity() throws MissedPropertyException,
255                                 InvalidPropertyException, MultiplyDefinedException {
256                         if (type == null)
257                                 throw new MissedPropertyException("type");
258                         if (owner == null)
259                                 throw new MissedPropertyException("owner");
260                         if (step == null)
261                                 throw new MissedPropertyException("step");
262                         if (author == null)
263                                 throw new MissedPropertyException("author");
264                         if (format == null)
265                                 throw new MissedPropertyException("format");
266                         if (owner instanceof Study && !step.appliesTo(Study.class))
267                                 throw new InvalidPropertyException("step");
268                         if (!type.isContentInto(step))
269                                 throw new InvalidPropertyException("step");
270                         if (state != null && state != ProgressState.EXTERN) {
271                                 // inDRAFT, inCHECK or APPROVED + version = imposed version (future use)
272                                 // inWORK + version = base version incremented at save time (used for versioning)
273                                 if (version == null)
274                                         throw new InvalidPropertyException("state");
275                         }
276                         if (version != null) {
277                                 if (state == null)
278                                         state = ProgressState.EXTERN;
279                         }
280                 }
281         }
282
283         // Database fetch constructor
284         protected Document() {
285         }
286
287         // Internal constructor
288         public Document(Properties dprop) throws MissedPropertyException,
289                         InvalidPropertyException, MultiplyDefinedException {
290                 // -------------------------------------
291                 super(dprop); // Throws one of the above exception if not valid
292                 myfile = new File(null, dprop.format, dprop.date); // The path is initialized below
293                 type = dprop.type;
294                 step = dprop.step.getNumber();
295                 name = dprop.name;
296                 version = dprop.version;
297                 author = dprop.author;
298                 countag = 0;
299                 history = 0;
300                 lasdate = myfile.getDate(); // Today if not defined in the properties
301
302                 state = dprop.state;
303                 if (state == null) {
304                         state = ProgressState.inWORK; // Promoted when saving this document
305                         version = new Revision().toString();
306                 }
307                 if (name == null) { // Newed document
308                         this.name = "%n"; // Named later at publication
309                         this.history = -1; // Marks the document as undefined for future assignment
310                 }
311         }
312
313         // ==============================================================================================================================
314         // Public member functions
315         // ==============================================================================================================================
316
317         public File getAttachedFile(String format) {
318                 // -------------------------------------------
319                 List<Relation> exports = getRelations(ConvertsRelation.class);
320
321                 for (Iterator<Relation> i = exports.iterator(); i.hasNext();) {
322                         File export = (File) i.next().getTo();
323                         if (export.getFormat().equals(format))
324                                 return export;
325                 }
326                 return null;
327         }
328
329         public User getAuthor() {
330                 // ------------------------
331                 return author;
332         }
333
334         public Date getCreationDate() {
335                 // ------------------------------
336                 return myfile.getDate();
337         }
338
339         public Date getLastModificationDate() {
340                 // --------------------------------------
341                 return lasdate;
342         }
343         
344         public void setLastModificationDate(Date aDate) {
345                 lasdate = aDate;
346         }
347
348         public String getFormat() {
349                 // --------------------------
350                 return myfile.getFormat();
351         }
352
353         public Document getPreviousVersion() {
354                 // -------------------------------------
355                 Relation previous = getFirstRelation(VersionsRelation.class);
356                 if (previous != null)
357                         return (Document) previous.getTo();
358                 else
359                         return null;
360         }
361
362         public ProgressState getProgressState() {
363                 // ----------------------------------------
364                 return state;
365         }
366
367         /**
368          * Returns the path where all physical files attached to this document are saved. This path is relative to the vault of the repository
369          * and include the file name, without extension, common to all physical files attached to this document.
370          * 
371          * @return the path of the document
372          */
373         public String getRelativePath() {
374                 // --------------------------------
375                 String[] table = myfile.getRelativePath().split("\\x2E");
376                 StringBuffer path = new StringBuffer(table[0]);
377                 for (int i = 1; i < table.length - 1; i++)
378                         path.append('.').append(table[i]);
379                 return path.toString();
380         }
381
382         /**
383          * Returns the global unique reference of this document lineage. The document reference is common to all versions of the document
384          * (versioning a document does not change its reference). It is made of the owner study reference suffixed by a document identifier
385          * unique in the scope of the study.
386          * 
387          * @return the document reference
388          */
389         public String getReference() {
390                 // -----------------------------
391                 return did;
392         }
393
394         public File getSourceFile() {
395                 // ----------------------------
396                 return myfile;
397         }
398
399         /**
400          * Returns the stamps such as review and approval attached to this document, if exist. If several stamps exist, they are returned in
401          * ascending order of dates.
402          * 
403          * @return the stamps of the document in ascending order of dates, or an empty array if no stamp exist.
404          */
405         public Timestamp[] getStamps() {
406                 // -------------------------------
407                 Vector<Timestamp> stamps = new Vector<Timestamp>();
408
409                 for (Iterator<Relation> i = this.getAllRelations().iterator(); i
410                                 .hasNext();) {
411                         Relation link = i.next();
412                         if (link instanceof StampRelation)
413                                 stamps.add(((StampRelation) link).getTo());
414                 }
415                 Timestamp[] result = stamps.toArray(new Timestamp[stamps.size()]);
416                 ComparatorByDate bydate = new Timestamp.ComparatorByDate();
417
418                 Arrays.sort(result, bydate);
419                 return result;
420         }
421
422         /**
423          * Returns the title of this document.
424          * 
425          * @return the document title, or an empty string is this document is undefined.
426          * @see #isUndefined()
427          */
428         public String getTitle() {
429                 // -------------------------
430                 if (this.isUndefined())
431                         return "";
432                 else
433                         return name;
434         }
435         
436         /**
437          * Set document title.
438          * @param aTitle document title to set
439          */
440         public void setTitle(String aTitle) {
441                 this.name = aTitle;
442         }
443
444         public DocumentType getType() {
445                 // ------------------------------
446                 return type;
447         }
448
449         /**
450          * Returns the version number of this document. The version number, when exists, is either of the internal form (m.n.s) usable for
451          * building a Revision object, or any string in case of external document (document with EXTERN state).<br/> <br/> Note: document slots
452          * have a version number equal to "0.0.0".
453          * 
454          * @return the version number of this document, or null if this is EXTERN.
455          * @see #isUndefined()
456          */
457         public String getVersion() {
458                 // ---------------------------
459                 return version;
460         }
461
462         /**
463          * Returns true if this document is undefined. An undefined document is a meta-document created for reserving the persistent reference
464          * of a new document before saving (or importing) this later into the repository. The working copy of a such document may include this
465          * reference.
466          * 
467          * @see #getTitle()
468          * @see #getVersion()
469          * @see #initialize(Properties)
470          */
471         public boolean isUndefined() {
472                 // -----------------------------
473                 return (history == -1);
474         }
475
476         public boolean isInto(Step container) {
477                 // --------------------------------------
478                 return (step == container.getNumber());
479         }
480
481         public boolean isPublished() {
482                 // -----------------------------
483                 return (countag > 0);
484         }
485
486         public boolean isShared() {
487                 // --------------------------
488                 return (countag + history > 1);
489         }
490
491         public boolean isVersioned() {
492                 // -----------------------------
493                 return (history > 0);
494         }
495
496         // ==============================================================================================================================
497         // Public services
498         // ==============================================================================================================================
499
500         public static DocumentType createType(DocumentType.Properties tprop)
501                         throws MissedPropertyException, InvalidPropertyException,
502                         MultiplyDefinedException, RuntimeException {
503                 // ---------------------------------------------------------------------
504                 // TODO: Check for duplicate definition
505                 DocumentType type = new DocumentType(tprop);
506                 Session session = Database.getSession();
507                 session.save(type);
508
509                 return type;
510         }
511
512         public static Properties extractProperties(java.io.File file) {
513                 // --------------------------------------------------------------
514                 Properties fprop = new Properties();
515                 Reader tool = Toolbox.getReader(file);
516                 String value;
517                 if (tool != null)
518                         try {
519                                 value = tool.extractProperty("title");
520                                 if (value != null)
521                                         fprop.setName(value);
522
523                                 value = tool.extractProperty("reference");
524                                 if (value != null)
525                                         fprop.setReference(value);
526                         } catch (Exception e) {
527                         }
528                 return fprop;
529         }
530
531         @SuppressWarnings("unchecked")
532         public static List<DocumentType> selectAllTypes() {
533                 // --------------------------------------------------
534                 String query = "from DocumentType";
535
536                 List<DocumentType> types = Database.getSession().createQuery(query)
537                                 .list();
538                 for (Iterator<DocumentType> i = types.iterator(); i.hasNext();) {
539                         Hibernate.initialize(i.next()); // Supposed fetching document types
540                 }
541                 return types;
542         }
543
544         @SuppressWarnings("unchecked")
545         public static List<DocumentType> selectResultTypes() {
546                 // -----------------------------------------------------
547                 String query = "from DocumentType where result is not null order by result asc";
548
549                 return Database.getSession().createQuery(query).list();
550         }
551
552         public static DocumentType selectType(String name) {
553                 // ---------------------------------------------------
554                 String query = new StringBuffer("from DocumentType where name='")
555                                 .append(name).append("'").toString();
556
557                 return (DocumentType) Database.getSession().createQuery(query)
558                                 .uniqueResult();
559         }
560
561         public static DocumentType selectType(long index) {
562                 // -------------------------------------------------
563                 String query = new StringBuffer("from DocumentType where rid='")
564                                 .append(index).append("'").toString();
565
566                 return (DocumentType) Database.getSession().createQuery(query)
567                                 .uniqueResult();
568         }
569
570         @SuppressWarnings("unchecked")
571         public static List<DocumentType> selectTypesOf(
572                         ProjectSettingsService.Step step) {
573                 // --------------------------------------------------------------------------
574                 Integer number = step.getNumber();
575                 String query = new StringBuffer("from DocumentType").append(
576                                 " where step like '%-").append(number).append("-%'").toString();
577
578                 List<DocumentType> types = Database.getSession().createQuery(query)
579                                 .list();
580                 for (Iterator<DocumentType> i = types.iterator(); i.hasNext();) {
581                         Hibernate.initialize(i.next()); // For fetching document types
582                 }
583                 return types;
584         }
585
586         // ==============================================================================================================================
587         // Protected services
588         // ==============================================================================================================================
589
590         protected ConvertsRelation attach(String format) {
591                 // -------------------------------------------------
592                 return attach(format, null);
593         }
594
595         protected ConvertsRelation attach(String format, String description) {
596                 // ---------------------------------------------------------------------
597                 String path = this.getRelativePath();
598                 File export = new File(path + "." + format);
599                 ConvertsRelation attach = new ConvertsRelation(this, export,
600                                 description);
601                 Session session = Database.getSession();
602
603                 session.save(export);
604                 session.save(attach);
605
606                 this.addRelation(attach); // Updates this
607
608                 return attach;
609         }
610
611         public boolean buildReferenceFrom(ProjectElement scope, Document lineage) {
612                 // -----------------------------------------------------------------------------
613                 if (state != ProgressState.inWORK)
614                         return false;
615                 Study owner = null;
616                 Scenario context = null;
617                 if (scope instanceof Study)
618                         owner = (Study) scope;
619                 else {
620                         context = ((Scenario) scope);
621                         owner = context.getOwnerStudy();
622                 }
623                 did = lineage.did;
624                 if (context != null && (lineage.isVersioned() || owner.shares(lineage))) {
625                         version = new Revision(version).setBranch(context.getReference())
626                                         .toString();
627                 }
628                 return true;
629         }
630
631         public boolean buildReferenceFrom(Study scope) {
632                 // --------------------------------------------------
633                 if (state != ProgressState.inWORK && state != ProgressState.EXTERN)
634                         return false;
635                 DecimalFormat tostring = new DecimalFormat(suformat);
636
637                 did = did.replace("%" + suformat, tostring.format(scope
638                                 .getLastLocalIndex()));
639                 return true;
640         }
641
642         public boolean demote() {
643                 // ---------------------------
644                 ValidationStep torem;
645
646                 if (state == ProgressState.inCHECK) {
647                         state = ProgressState.inDRAFT;
648                         torem = ValidationStep.REVIEW;
649                         // This operation must not change the version number of documents.
650                         // Consequently, inDRAFT documents may have a minor version number equal to zero.
651                 } else if (state == ProgressState.inDRAFT) {
652                         state = ProgressState.inWORK;
653                         torem = ValidationStep.PROMOTION;
654                 } else {
655                         return false;
656                 }
657                 for (Iterator<Relation> i = this.getAllRelations().iterator(); i
658                                 .hasNext();) {
659                         Relation link = i.next();
660                         if (!(link instanceof StampRelation))
661                                 continue;
662                         if (((StampRelation) link).getStampType() != torem)
663                                 continue;
664                         i.remove();
665                         break;
666                 }
667                 Database.getSession().update(this);
668                 return true;
669         }
670
671         /**
672          * Increments the reference count of this document following its publication into a Study step.
673          * 
674          * @see #release()
675          */
676         public void hold() {
677                 // ----------------------
678                 countag += 1;
679                 if (this.isSaved())
680                         Database.getSession().update(this);
681         }
682
683         public boolean promote(Timestamp stamp) {
684                 // -------------------------------------------
685                 ProgressState newstate = null;
686
687                 if (state == ProgressState.inWORK) {
688                         newstate = ProgressState.inDRAFT; // Promotion to being reviewed
689                 } else if (state == ProgressState.inDRAFT) {
690                         newstate = ProgressState.inCHECK; // Promotion to approval
691                         Revision myvers = new Revision(version);
692                         if (myvers.isMinor()) {
693                                 version = myvers.incrementAs(newstate).toString();
694                                 // TODO: If my physical file is programatically editable, update its (property) version number
695                                 // ISSUE: What about attached files such as PDF if exist, should we remove them ?
696                         }
697                 } else if (state == ProgressState.inCHECK) {
698                         newstate = ProgressState.APPROVED;
699                 }
700                 this.state = newstate;
701                 if (stamp != null)
702                         this.addRelation(stamp.getContext());
703                 Database.getSession().update(this);
704                 return true;
705         }
706
707         /**
708          * Decrements the reference count of this document following the removal of a Publication from a Study step.
709          * 
710          * @see #hold()
711          */
712         public void release() {
713                 // -------------------------
714                 countag -= 1;
715                 if (this.isSaved())
716                         Database.getSession().update(this);
717         }
718
719         protected void rename(String title) throws InvalidPropertyException {
720                 // ------------------------------------
721                 if (title.length() == 0)
722                         throw new InvalidPropertyException("name");
723
724                 Calendar current = Calendar.getInstance();
725                 this.name = title;
726                 this.lasdate = current.getTime(); // Today
727                 Database.getSession().update(this);
728         }
729
730         public void updateAs(Revision newvers) {
731                 // ------------------------------------------
732                 version = newvers.setBranch(version).toString(); // Branch names are propagated by the versionning
733                 ProgressState newstate = ProgressState.inCHECK;
734                 if (newvers.isMinor())
735                         newstate = ProgressState.inWORK;
736                 state = null; // Just to tell updateAs(sate) to not increment the version number
737                 updateAs(newstate);
738         }
739
740         public void updateAs(ProgressState state) {
741                 // ---------------------------------------------
742                 Document previous = null;
743
744                 // Set of version number
745                 if (state == ProgressState.EXTERN) {
746                         if (this.state != ProgressState.EXTERN)
747                                 this.version = null; // Strange use-case...
748                 } else {
749                         Revision myvers = new Revision(version);
750                         if (!myvers.isNull()) { // Versionning context
751                                 for (Iterator<Relation> i = getAllRelations().iterator(); i
752                                                 .hasNext();) {
753                                         Relation link = i.next();
754                                         if (!link.getClass().equals(VersionsRelation.class))
755                                                 continue;
756                                         previous = (Document) link.getTo(); // Versioned document
757                                         break;
758                                 }
759                         }
760                         if (this.state != null)
761                                 myvers.incrementAs(state); // Incrementation if the reversion number is not imposed
762                         this.version = myvers.toString();
763                 }
764                 // Update this document and the previous version, if exit
765                 Session session = Database.getSession();
766                 if (previous != null) {
767                         previous.history += 1;
768                         session.update(previous);
769                 }
770                 this.state = state;
771                 session.update(this);
772         }
773
774         // protected void upgrade () {
775         // -------------------------
776         // if (this.state != ProgressState.inWORK) return;
777         //
778         // Calendar current = Calendar.getInstance();
779         // for (Iterator<Relation> i=getAllRelations().iterator(); i.hasNext();) {
780         // Relation link = i.next();
781         // if (!link.getClass().equals(UsesRelation.class)) continue;
782         //
783         // Document used = (Document)link.getTo();
784         // if (!used.isVersioned()) continue;
785         // TODO: Update the uses relation
786         // }
787         // this.promote();
788         // this.lasdate = current.getTime(); // Today
789         // Database.getSession().update(this);
790         //
791         // TODO: Promote documents using this one
792         // }
793
794         /**
795          * @return
796          */
797         private ProjectSettingsService getProjectSettingsService() {
798                 return _projectSettingsService;
799         }
800
801         public void setProjectSettingsService(
802                         ProjectSettingsService projectSettingsService) {
803                 _projectSettingsService = projectSettingsService;
804         }
805
806         /**
807          * @return
808          */
809         public StudyService getStudyService() {
810                 return _studyService;
811         }
812
813         public void setStudyService(StudyService studyService) {
814                 _studyService = studyService;
815         }
816
817         /**
818          * Get the step.
819          * @return the step
820          */
821         public int getStep() {
822                 return step;
823         }
824
825         /**
826          * Set the step.
827          * @param step the step to set
828          */
829         public void setStep(int step) {
830                 this.step = step;
831         }
832
833         /**
834          * Get the did.
835          * @return the did
836          */
837         public String getDid() {
838                 return did;
839         }
840
841         /**
842          * Set the did.
843          * @param did the did to set
844          */
845         public void setDid(String did) {
846                 this.did = did;
847         }
848
849         /**
850          * Get the myfile.
851          * @return the myfile
852          */
853         public File getFile() {
854                 return myfile;
855         }
856
857         /**
858          * Set the myfile.
859          * @param myfile the myfile to set
860          */
861         public void setFile(File myfile) {
862                 this.myfile = myfile;
863         }
864
865         /**
866          * Get the history.
867          * @return the history
868          */
869         public int getHistory() {
870                 return history;
871         }
872
873         /**
874          * Set the history.
875          * @param history the history to set
876          */
877         public void setHistory(int history) {
878                 this.history = history;
879         }
880 }