Salome HOME
Modifications done to respect PMD rules. Versioning a document is fixed. Validation...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / KnowledgeElementType.java
1 package org.splat.dal.bo.som;
2 /**
3  * 
4  * @author    Daniel Brunier-Coulin
5  * @copyright OPEN CASCADE 2012
6  */
7
8 import org.splat.dal.bo.kernel.Persistent;
9
10
11 public class KnowledgeElementType extends Persistent {
12         
13     private String         name;
14     private ProgressState  state;
15
16 //  ==============================================================================================================================
17 //  Constructors
18 //  ==============================================================================================================================
19
20         //  Database fetch constructor
21     protected KnowledgeElementType () {
22     }
23 //  Initialization constructor
24     public KnowledgeElementType (String name) {
25 //  --------------------------------------------
26       super();
27       this.name  = name;
28       this.state = ProgressState.inCHECK;
29     }
30
31 //  ==============================================================================================================================
32 //  Public member functions
33 //  ==============================================================================================================================
34
35     public boolean equals(Object entity) {
36 //  ------------------------------------
37       if (entity == null) return false;
38       if (entity instanceof String) {
39         return this.name.equals((String)entity);   // Names are unique
40       } else
41       if (entity instanceof KnowledgeElementType) {
42         KnowledgeElementType object = (KnowledgeElementType)entity;
43         long   he = object.getIndex();
44         long   me = this.getIndex();
45         if (me*he != 0) return (he == me);
46         else            return this.getName().equals(object.getName());
47       } else {
48         return false;
49       }
50     }
51
52     public String getName () {
53 //  ------------------------
54       return name;
55     }
56
57     public boolean isApproved () {
58 //  ----------------------------
59       return (state == ProgressState.APPROVED);
60     }
61
62     public boolean isReserved () {
63 //  ----------------------------
64       return (state == ProgressState.inWORK);
65     }
66     /**
67          * Get the state.
68          * @return the state
69          */
70         public ProgressState getState() {
71                 return state;
72         }
73         /**
74          * Set the state.
75          * @param state the state to set
76          */
77         public void setState(ProgressState state) {
78                 this.state = state;
79         }
80 }