4 * @author Daniel Brunier-Coulin
5 * @copyright OPEN CASCADE 2012
8 import org.splat.kernel.Persistent;
11 public class KnowledgeElementType extends Persistent {
14 private ProgressState state;
16 // ==============================================================================================================================
18 // ==============================================================================================================================
20 // Database fetch constructor
21 protected KnowledgeElementType () {
23 // Initialization constructor
24 protected KnowledgeElementType (String name) {
25 // --------------------------------------------
28 this.state = ProgressState.inCHECK;
31 // ==============================================================================================================================
32 // Public member functions
33 // ==============================================================================================================================
35 public boolean approve () {
36 // -------------------------
37 if (state != ProgressState.inCHECK) return false;
38 this.state = ProgressState.APPROVED; // The type name is supposed being localized
39 if (this.isSaved()) Database.getSession().update(this);
43 public boolean equals(Object entity) {
44 // ------------------------------------
45 if (entity == null) return false;
46 if (entity instanceof String) {
47 return this.name.equals((String)entity); // Names are unique
49 if (entity instanceof KnowledgeElementType) {
50 KnowledgeElementType object = (KnowledgeElementType)entity;
51 int he = object.getIndex();
52 int me = this.getIndex();
53 if (me*he != 0) return (he == me);
54 else return this.getName().equals(object.getName());
60 public String getName () {
61 // ------------------------
65 public boolean isApproved () {
66 // ----------------------------
67 return (state == ProgressState.APPROVED);
70 public boolean isReserved () {
71 // ----------------------------
72 return (state == ProgressState.inWORK);
75 // ==============================================================================================================================
77 // ==============================================================================================================================
79 * Reserves this type for the management of simulation contexts.
80 * For being able to get the studies in which simulation contexts are used, all study scenarios are indexed through this
81 * knowledge element type, whether they include knowledge elements or not.
83 protected boolean reserve () {
84 // ----------------------------
85 if (state != ProgressState.inCHECK) return false;
86 this.state = ProgressState.inWORK;
87 if (this.isSaved()) Database.getSession().update(this);