1 package org.splat.dal.bo.som;
5 * @author Daniel Brunier-Coulin
6 * @copyright OPEN CASCADE 2012
9 import java.io.Serializable;
11 import org.splat.dal.bo.kernel.Persistent;
12 import org.splat.kernel.InvalidPropertyException;
13 import org.splat.service.technical.ProjectSettingsService;
16 * Persistent simulation context type.
18 public class SimulationContextType extends Persistent implements Serializable {
21 * Serialization version id.
23 private static final long serialVersionUID = 4819425038576161242L;
31 * Context progress state.
33 private ProgressState state;
35 * Context type first applicable step.
39 // ==============================================================================================================================
41 // ==============================================================================================================================
44 * Search properties class.
46 public static class Properties {
47 private ProgressState state = null;
48 private ProjectSettingsService.Step step = null;
50 public ProgressState getProgressState() {
54 public ProjectSettingsService.Step getStep() {
58 public Properties setProgressState(final ProgressState state) {
63 public Properties setStep(final ProjectSettingsService.Step step) {
70 * Database fetch constructor.
72 protected SimulationContextType() {
77 * Initialization constructor.
82 * first applicable step for this type of context
83 * @throws InvalidPropertyException
84 * from constructor of parent class
86 public SimulationContextType(final String name,
87 final ProjectSettingsService.Step step)
88 throws InvalidPropertyException {
91 this.state = ProgressState.inCHECK;
92 this.step = step.getNumber();
95 // ==============================================================================================================================
96 // Public member functions
97 // ==============================================================================================================================
100 * Saved context types are equal if their persistent ids are equal. <BR>
101 * Before becoming persistent context types are compared by their names.
104 * object to compare with
105 * @return true if this context type equals to the given object
106 * @see org.splat.dal.bo.kernel.Persistent#equals(java.lang.Object)
109 public boolean equals(final Object entity) {
111 if (entity == null) {
114 if (entity instanceof String) {
115 return this.name.equals(entity); // Names are unique
116 } else if (entity instanceof SimulationContextType) {
117 SimulationContextType object = (SimulationContextType) entity;
118 long he = object.getIndex();
119 long me = this.getIndex();
121 return this.getName().equals(object.getName());
131 * Get context type name.
133 * @return context type name
135 public String getName() {
140 * Check if contexts of this type are attached to the given study step.
144 * @return true if contexts of this type are attached to the given study step
146 public boolean isAttachedTo(final ProjectSettingsService.Step step) {
147 return (this.step == step.getNumber());
151 * Check if the context is approved.
153 * @return true if the context is approved
155 public boolean isApproved() {
156 return (state == ProgressState.APPROVED);
164 public ProgressState getState() {
174 public void setState(final ProgressState state) {
183 public int getStep() {
193 public void setStep(final int step) {