Salome HOME
088fde6ee839e2a0a2c165dc4f75eaf23392b322
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / KnowledgeElementType.java
1 package org.splat.dal.bo.som;
2
3 /**
4  * 
5  * @author    Daniel Brunier-Coulin
6  * @copyright OPEN CASCADE 2012-2015
7  */
8
9 import org.splat.dal.bo.kernel.Persistent;
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
24         // Initialization constructor
25         public KnowledgeElementType(final String name) {
26                 super();
27                 this.name = name;
28                 this.state = ProgressState.inCHECK;
29         }
30
31         // ==============================================================================================================================
32         // Public member functions
33         // ==============================================================================================================================
34
35         @Override
36         public boolean equals(final Object entity) {
37                 if (entity == null) {
38                         return false;
39                 }
40                 if (entity instanceof String) {
41                         return this.name.equals(entity); // Names are unique
42                 } else if (entity instanceof KnowledgeElementType) {
43                         KnowledgeElementType object = (KnowledgeElementType) entity;
44                         long he = object.getIndex();
45                         long me = this.getIndex();
46                         if (me * he != 0) {
47                                 return (he == me);
48                         } else {
49                                 return this.getName().equals(object.getName());
50                         }
51                 } else {
52                         return false;
53                 }
54         }
55
56         public String getName() {
57                 return name;
58         }
59
60         /**
61          * Get i18n type name key.
62          * 
63          * @return the i18n key
64          */
65         public String getKey() {
66                 return "type.knowledge." + name;
67         }
68
69         public boolean isApproved() {
70                 return (state == ProgressState.APPROVED);
71         }
72
73         public boolean isReserved() {
74                 return (state == ProgressState.inWORK);
75         }
76
77         /**
78          * Get the state.
79          * 
80          * @return the state
81          */
82         public ProgressState getState() {
83                 return state;
84         }
85
86         /**
87          * Set the state.
88          * 
89          * @param state
90          *            the state to set
91          */
92         public void setState(final ProgressState state) {
93                 this.state = state;
94         }
95 }