4 * @author Daniel Brunier-Coulin
5 * @copyright OPEN CASCADE 2012
8 import java.io.Serializable;
10 import org.splat.kernel.InvalidPropertyException;
11 import org.splat.kernel.Persistent;
14 public class SimulationContextType extends Persistent implements Serializable {
18 private ProgressState state;
21 // Required by the serialization
22 private static final long serialVersionUID = 4819425038576161242L;
24 // ==============================================================================================================================
26 // ==============================================================================================================================
28 // Search properties class
29 public static class Properties {
30 // ------------------------------
31 private ProgressState state = null;
32 private ProjectSettings.Step step = null;
34 protected ProgressState getProgressState () {
37 protected ProjectSettings.Step getStep () {
40 public Properties setState (ProgressState state) {
44 public Properties setStep (ProjectSettings.Step step) {
49 // Database fetch constructor
50 protected SimulationContextType () {
52 // Initialization constructor
53 protected SimulationContextType (String name, ProjectSettings.Step step) throws InvalidPropertyException {
54 // ------------------------------------------------------------------------
57 this.state = ProgressState.inCHECK;
58 this.step = step.getNumber();
61 // ==============================================================================================================================
62 // Public member functions
63 // ==============================================================================================================================
65 public boolean approve () {
66 // -------------------------
67 if (state != ProgressState.inCHECK) return false;
68 this.state = ProgressState.APPROVED; // The type name is supposed being localized
69 Database.getSession().update(this);
73 public boolean equals(Object entity) {
74 // ------------------------------------
75 if (entity == null) return false;
76 if (entity instanceof String) {
77 return this.name.equals((String)entity); // Names are unique
79 if (entity instanceof SimulationContextType) {
80 SimulationContextType object = (SimulationContextType)entity;
81 int he = object.getIndex();
82 int me = this.getIndex();
83 if (me*he != 0) return (he == me);
84 else return this.getName().equals(object.getName());
90 public ProjectSettings.Step getAttachedStep () {
91 // ----------------------------------------------
92 return ProjectSettings.getStep(step);
95 public String getName () {
96 // ------------------------
100 public boolean isAttachedTo (ProjectSettings.Step step) {
101 // -------------------------------------------------------
102 if (this.step == step.getNumber()) return true;
106 public boolean isApproved () {
107 // ----------------------------
108 return (state == ProgressState.APPROVED);