Salome HOME
27ad7afadddc435bf671dee8812bbe764a0a1470
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / VersionsRelation.java
1 package org.splat.dal.bo.som;
2 /**
3  * 
4  * @author    Daniel Brunier-Coulin
5  * @copyright OPEN CASCADE 2012-2015
6  */
7
8 import org.splat.dal.bo.kernel.Persistent;
9 import org.splat.dal.bo.kernel.Relation;
10
11
12 public class VersionsRelation extends Relation {
13
14 //  Persistent field
15     private  Document refer;
16
17 //  Transient fields
18     private  boolean  got;              // For optimizing getDescription()
19     private  String   description;      // Null if this is not described
20
21 //  ==============================================================================================================================
22 //  Constructors
23 //  ==============================================================================================================================
24
25 //  Database fetch constructor
26     protected VersionsRelation () {
27 //  -----------------------------
28       got         = false;
29       description = null;
30     }
31 //  Initialization constructors
32     public VersionsRelation (final Document from, final Document to) {
33 //  -------------------------------------------------------
34       super(from);
35       this.refer       = to;
36       this.got         = true;
37       this.description = null;          // Conversion not described
38     }
39     public VersionsRelation (final Document from, final Document to, final String description) {
40 //  ---------------------------------------------------------------------------
41       super(from);
42       this.refer       = to;
43       this.got         = true;
44       this.description = description;   // May be null
45       if (description != null) {
46                 this.setAttribute( new DescriptionAttribute(this, description) );
47         }
48     }
49
50 //  ==============================================================================================================================
51 //  Public member functions
52 //  ==============================================================================================================================
53
54     public String getDescription () {
55 //  -------------------------------
56       if (!got) {
57         DescriptionAttribute field = (DescriptionAttribute)this.getAttribute(DescriptionAttribute.class);
58         if (field != null) {
59                         description = field.getValue();
60                 }
61         got = true;                     // Don't need to be modified later as set and remove attribute functions are private to this class
62       }
63       return description;               // May be null
64     }
65
66     @Override
67         public Document getTo () {
68 //  -------------------------
69       return refer;
70     }
71     @Override
72         public void setTo (final Persistent to) {
73 //  ------------------------------------
74       refer = (Document)to;
75     }
76 }