Salome HOME
Update copyrights 2014.
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / Timestamp.java
1 package org.splat.dal.bo.som;
2 /**
3  * 
4  * @author    Daniel Brunier-Coulin
5  * @copyright OPEN CASCADE 2012-2014
6  */
7
8 import java.util.Comparator;
9 import java.util.Date;
10
11 import org.splat.dal.bo.kernel.Any;
12 import org.splat.dal.bo.kernel.Attribute;
13 import org.splat.dal.bo.kernel.User;
14
15
16 public class Timestamp extends Any {
17
18     private  StampRelation  context;
19     private  ValidationStep mytype;
20     private  User           author;
21     private  Date           sdate;
22
23     public static class ComparatorByDate implements Comparator<Timestamp> {
24 //  ---------------------------------------------------------------------
25       public int compare(Timestamp t1, Timestamp t2)
26       {
27         return t1.getDate().compareTo(t2.getDate());
28       }
29     }
30
31 //  ==============================================================================================================================
32 //  Construction
33 //  ==============================================================================================================================
34
35 //  Database fetch constructor
36     protected Timestamp () {
37     }
38 //  Internal constructors
39     public Timestamp (ValidationStep type, Document from, User to, Date sdate) {
40 //  -----------------------------------------------------------------------------
41       super((Attribute)null);       // For building the collection of attributes
42       this.mytype  = type;
43       this.author  = to;
44       this.sdate   = sdate;
45       this.context = new StampRelation(from, this);
46     }
47
48 //  ==============================================================================================================================
49 //  Public member functions
50 //  ==============================================================================================================================
51
52     public User getAuthor () {
53 //  ------------------------
54       return author;
55     }
56
57     public String getComment () {
58 //  ---------------------------
59       CommentAttribute   field  = (CommentAttribute)this.getAttribute(CommentAttribute.class);
60       String             result = null;
61       if (field != null) result = field.getValue();
62       return result;
63     }
64
65     public Date getDate () {
66 //  ----------------------
67       return sdate;
68     }
69
70     public ValidationStep getType () {
71 //  --------------------------------
72       return mytype;
73     }
74
75     public void setComment (String comment) {
76 //  ---------------------------------------
77       if (comment != null) this.setAttribute( new CommentAttribute(this, comment) );
78     }
79
80 //  ==============================================================================================================================
81 //  Protected services
82 //  ==============================================================================================================================
83
84     public StampRelation getContext () {
85 //  -------------------------------------
86       return context;
87     }
88 }