Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / SimulationContextType.java
1 package org.splat.dal.bo.som;
2 /**
3  * 
4  * @author    Daniel Brunier-Coulin
5  * @copyright OPEN CASCADE 2012
6  */
7
8 import java.io.Serializable;
9
10 import org.splat.dal.bo.kernel.Persistent;
11 import org.splat.kernel.InvalidPropertyException;
12 import org.splat.service.technical.ProjectSettingsService;
13
14
15 public class SimulationContextType extends Persistent implements Serializable {
16         
17 //  Persistent fields
18     private String         name;
19     private ProgressState  state;
20         private int            step;
21
22 //  Required by the serialization
23         private static final long serialVersionUID = 4819425038576161242L;
24
25 //  ==============================================================================================================================
26 //  Constructors
27 //  ==============================================================================================================================
28
29 //  Search properties class
30     public static class Properties {
31 //  ------------------------------
32       private ProgressState         state = null;
33       private ProjectSettingsService.Step  step  = null;
34
35       public ProgressState getProgressState () {
36         return state;
37       }
38       public ProjectSettingsService.Step getStep () {
39         return step;
40       }
41       public Properties setProgressState (ProgressState state) {
42         this.state = state;
43         return this;
44       }
45       public Properties setStep (ProjectSettingsService.Step  step) {
46         this.step = step;
47         return this;
48       }
49     }
50 //  Database fetch constructor
51     protected SimulationContextType () {
52     }
53 //  Initialization constructor
54     public SimulationContextType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException {
55 //  ------------------------------------------------------------------------
56       super();
57       this.name  = name;
58       this.state = ProgressState.inCHECK;
59       this.step  = step.getNumber();
60     }
61
62 //  ==============================================================================================================================
63 //  Public member functions
64 //  ==============================================================================================================================
65
66     public boolean equals(Object entity) {
67 //  ------------------------------------
68       if (entity == null) return false;
69       if (entity instanceof String) {
70         return this.name.equals((String)entity);   // Names are unique
71       } else
72       if (entity instanceof SimulationContextType) {
73           SimulationContextType object = (SimulationContextType)entity;
74         long   he = object.getIndex();
75         long   me = this.getIndex();
76         if (me*he != 0) return (he == me);
77         else            return this.getName().equals(object.getName());
78       } else {
79         return false;
80       }
81     }
82
83     public String getName () {
84 //  ------------------------
85       return name;
86     }
87
88     public boolean isAttachedTo (ProjectSettingsService.Step step) {
89 //  -------------------------------------------------------
90       if (this.step == step.getNumber()) return true;
91       return false;
92     }
93
94     public boolean isApproved () {
95 //  ----------------------------
96       return (state == ProgressState.APPROVED);
97     }
98     /**
99          * Get the state.
100          * @return the state
101          */
102         public ProgressState getState() {
103                 return state;
104         }
105         /**
106          * Set the state.
107          * @param state the state to set
108          */
109         public void setState(ProgressState state) {
110                 this.state = state;
111         }
112         /**
113          * Get the step.
114          * @return the step
115          */
116         public int getStep() {
117                 return step;
118         }
119         /**
120          * Set the step.
121          * @param step the step to set
122          */
123         public void setStep(int step) {
124                 this.step = step;
125         }
126
127 }