Salome HOME
PMD plugin is refreshed. Some code is modified to respect PMD rules. Ant build proced...
[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 (final ProgressState state) {
42         this.state = state;
43         return this;
44       }
45       public Properties setStep (final 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 (final String name, final 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     @Override
67         public boolean equals(final Object entity) {
68 //  ------------------------------------
69       if (entity == null) {
70                 return false;
71         }
72       if (entity instanceof String) {
73         return this.name.equals(entity);   // Names are unique
74       } else if (entity instanceof SimulationContextType) {
75           SimulationContextType object = (SimulationContextType)entity;
76         long   he = object.getIndex();
77         long   me = this.getIndex();
78         if (me*he != 0) {
79                 return (he == me);
80         } else {
81                 return this.getName().equals(object.getName());
82         }
83       } else {
84         return false;
85       }
86     }
87
88     public String getName () {
89 //  ------------------------
90       return name;
91     }
92
93     public boolean isAttachedTo (final ProjectSettingsService.Step step) {
94 //  -------------------------------------------------------
95       if (this.step == step.getNumber()) {
96                 return true;
97         }
98       return false;
99     }
100
101     public boolean isApproved () {
102 //  ----------------------------
103       return (state == ProgressState.APPROVED);
104     }
105     /**
106          * Get the state.
107          * @return the state
108          */
109         public ProgressState getState() {
110                 return state;
111         }
112         /**
113          * Set the state.
114          * @param state the state to set
115          */
116         public void setState(final ProgressState state) {
117                 this.state = state;
118         }
119         /**
120          * Get the step.
121          * @return the step
122          */
123         public int getStep() {
124                 return step;
125         }
126         /**
127          * Set the step.
128          * @param step the step to set
129          */
130         public void setStep(final int step) {
131                 this.step = step;
132         }
133
134 }