1 package org.splat.dal.bo.som;
4 * @author Daniel Brunier-Coulin
5 * @copyright OPEN CASCADE 2012
8 import java.io.Serializable;
10 import org.splat.dal.bo.kernel.Persistent;
11 import org.splat.kernel.InvalidPropertyException;
12 import org.splat.kernel.MissedPropertyException;
13 import org.splat.kernel.MultiplyDefinedException;
14 import org.splat.service.technical.ProjectSettingsService;
15 import org.splat.som.Step;
18 public class SimulationContext extends Persistent implements Serializable {
20 private SimulationContextType type; // User extendable types
22 private ProgressState state;
26 private static final long serialVersionUID = 422889133378471949L;
28 // ==============================================================================================================================
30 // ==============================================================================================================================
32 // Fields initialization class
33 public static class Properties extends Persistent.Properties {
34 // ------------------------------------------------------------
35 private SimulationContextType type = null;
36 private ProjectSettingsService.Step step = null;
37 private ProgressState state = null;
38 private String value = null;
42 public void clear () {
49 public ProgressState getProgressState () {
52 public SimulationContextType getType () {
55 public String getValue () {
59 // - Setters of SimulationContext properties
61 public Properties setState (ProgressState state) throws InvalidPropertyException
63 if (state != ProgressState.inCHECK && state != ProgressState.APPROVED) {
64 throw new InvalidPropertyException("state");
69 public Properties setStep (ProjectSettingsService.Step step) throws InvalidPropertyException
74 public Properties setValue (String value) throws InvalidPropertyException
76 if (value.length() == 0) throw new InvalidPropertyException("value");
80 public Properties setType (SimulationContextType type)
85 // - Global validity check
87 public void checkValidity () throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException
89 if (type == null) throw new MissedPropertyException("type");
90 if (step == null) throw new MissedPropertyException("step");
91 if (value == null) throw new MissedPropertyException("value");
94 // Database fetch constructor
95 protected SimulationContext () {
97 // Internal constructor
98 public SimulationContext (Properties kprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
99 super(kprop); // Throws one of the above exception if not valid
101 step = kprop.step.getNumber();
105 if (state == null) state = ProgressState.inCHECK;
108 // ==============================================================================================================================
109 // Public member functions
110 // ==============================================================================================================================
112 public boolean equals (SimulationContext given) {
113 // -----------------------------------------------
114 if (isSaved()) return (this.getIndex() == given.getIndex());
115 if (!this.getType().getName().equals(given.getType().getName())) return false;
116 if (this.getValue().equals(given.getValue())) return true;
120 public String getValue () {
121 // -------------------------
125 public ProgressState getProgressState () {
126 // ----------------------------------------
132 * @param state the state to set
134 public void setProgressState(ProgressState state) {
138 public SimulationContextType getType () {
139 // ---------------------------------------
143 public boolean isInto (Step container) {
144 // --------------------------------------
145 return (step == container.getNumber());
148 public boolean isShared () {
149 // --------------------------
150 return (counter > 1);
156 public int getCounter() {
161 * @param aValue a counter value to set
163 public void setCounter(int aValue) {