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.dal.dao.som.Database;
12 import org.splat.kernel.InvalidPropertyException;
13 import org.splat.service.technical.ProjectSettingsService;
14 import org.splat.service.technical.ProjectSettingsService.Step;
15 import org.splat.service.technical.ProjectSettingsServiceImpl;
18 public class SimulationContextType extends Persistent implements Serializable {
22 private ProgressState state;
25 // Required by the serialization
26 private static final long serialVersionUID = 4819425038576161242L;
28 // ==============================================================================================================================
30 // ==============================================================================================================================
32 // Search properties class
33 public static class Properties {
34 // ------------------------------
35 private ProgressState state = null;
36 private ProjectSettingsService.Step step = null;
38 protected ProgressState getProgressState () {
41 protected ProjectSettingsService.Step getStep () {
44 public Properties setState (ProgressState state) {
48 public Properties setStep (ProjectSettingsService.Step step) {
53 // Database fetch constructor
54 protected SimulationContextType () {
56 // Initialization constructor
57 protected SimulationContextType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException {
58 // ------------------------------------------------------------------------
61 this.state = ProgressState.inCHECK;
62 this.step = step.getNumber();
65 // ==============================================================================================================================
66 // Public member functions
67 // ==============================================================================================================================
69 public boolean approve () {
70 // -------------------------
71 if (state != ProgressState.inCHECK) return false;
72 this.state = ProgressState.APPROVED; // The type name is supposed being localized
73 Database.getSession().update(this);
77 public boolean equals(Object entity) {
78 // ------------------------------------
79 if (entity == null) return false;
80 if (entity instanceof String) {
81 return this.name.equals((String)entity); // Names are unique
83 if (entity instanceof SimulationContextType) {
84 SimulationContextType object = (SimulationContextType)entity;
85 long he = object.getIndex();
86 long me = this.getIndex();
87 if (me*he != 0) return (he == me);
88 else return this.getName().equals(object.getName());
94 public ProjectSettingsService.Step getAttachedStep () {
95 // ----------------------------------------------
96 return ProjectSettingsServiceImpl.getStep(step);
99 public String getName () {
100 // ------------------------
104 public boolean isAttachedTo (ProjectSettingsService.Step step) {
105 // -------------------------------------------------------
106 if (this.step == step.getNumber()) return true;
110 public boolean isApproved () {
111 // ----------------------------
112 return (state == ProgressState.APPROVED);