Salome HOME
Copyrights update 2015.
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / dto / KnowledgeElementDTO.java
1 package org.splat.service.dto;
2
3 /**
4  * 
5  * @author    Daniel Brunier-Coulin
6  * @copyright OPEN CASCADE 2012-2015
7  */
8
9 import java.text.DecimalFormat;
10 import java.util.ArrayList;
11 import java.util.Date;
12 import java.util.List;
13
14 import org.splat.dal.bo.som.ProgressState;
15 import org.splat.som.Step;
16
17 /**
18  * DTO for an open knowledge element.
19  */
20 public class KnowledgeElementDTO {
21
22         /**
23          * Primary key.
24          */
25         private long _index;
26         /**
27          * User extendable knowledge type.
28          */
29         private KnowledgeElementTypeDTO _type;
30         /**
31          * Knowledge element progress state.
32          */
33         private ProgressState _progressState;
34         /**
35          * Knowledge title.
36          */
37         private String _title;
38         /**
39          * Knowledge text.
40          */
41         private String _value;
42         /**
43          * Knowledge author.
44          */
45         private UserDTO _author;
46         /**
47          * Knowledge modification date.
48          */
49         private Date _date;
50         /**
51          * Study steps involving this knowledge.
52          */
53         private transient final List<Step> _involving = new ArrayList<Step>();
54         /**
55          * Parent study title.
56          */
57         private String _studyTitle;
58         /**
59          * Parent scenario title.
60          */
61         private String _scenarioTitle;
62
63         /**
64          * Default constructor. 
65          */
66         public KnowledgeElementDTO() {
67                 // Create empty bean.
68         }
69
70         /**
71          * Constructor with fields values.
72          * 
73          * @param index
74          *            knowledge element primary key
75          * @param title
76          *            knowledge title
77          * @param value
78          *            knowledge value
79          */
80         public KnowledgeElementDTO(final long index, final String title,
81                         final String value) {
82                 _index = index;
83                 _title = title;
84                 _value = value;
85         }
86
87         /**
88          * Compare this knowledge element with the given one.
89          * 
90          * @param given
91          *            the knowledge element to compare to
92          * @return true if knowledge elements are equal
93          */
94         public boolean equals(final KnowledgeElementDTO given) { // NOPMD: RKV: TODO: to be refined
95                 return (this.getType().equals(given.getType()) && this.getValue()
96                                 .equals(given.getValue()));
97         }
98
99         /**
100          * Get knowledge author.
101          * 
102          * @return the author as user DTO
103          */
104         public UserDTO getAuthor() {
105                 return _author;
106         }
107
108         /**
109          * Get knowledge modification date.
110          * 
111          * @return the modification date
112          */
113         public Date getDate() {
114                 return _date;
115         }
116
117         /**
118          * Get knowledge progress state.
119          * 
120          * @return the knowledge state
121          */
122         public ProgressState getProgressState() {
123                 return _progressState;
124         }
125
126         /**
127          * Get knowledge title.
128          * 
129          * @return the title
130          */
131         public String getTitle() {
132                 return _title;
133         }
134
135         /**
136          * Get knowledge reference.
137          * 
138          * @return the reference
139          */
140         public String getReference() {
141                 DecimalFormat toString = new DecimalFormat("00000"); // Supports 99 999 knowledge elements
142                 return "KE" + toString.format(this.getIndex());
143         }
144
145         /**
146          * Get knowledge type.
147          * 
148          * @return the knowledge type
149          */
150         public KnowledgeElementTypeDTO getType() {
151                 return _type;
152         }
153
154         /**
155          * Get knowledge text.
156          * 
157          * @return the knowledge text
158          */
159         public String getValue() {
160                 return _value;
161         }
162
163         /**
164          * Set a status of this knowledge.
165          * 
166          * @param aState
167          *            knowledge element progress state to set
168          */
169         public void setProgressState(final ProgressState aState) {
170                 _progressState = aState;
171         }
172
173         /**
174          * Set a title of the knowledge.
175          * 
176          * @param aTitle
177          *            a title to set
178          */
179         public void setTitle(final String aTitle) {
180                 _title = aTitle;
181         }
182
183         /**
184          * Set the value.
185          * 
186          * @param value
187          *            the value to set
188          */
189         public void setValue(final String value) {
190                 this._value = value;
191         }
192
193         /**
194          * Get list of involving steps.
195          * 
196          * @return list of steps
197          */
198         public List<Step> getInvolving() {
199                 return _involving;
200         }
201
202         /**
203          * Get title of the parent study.
204          * 
205          * @return study title
206          */
207         public String getStudyTitle() {
208                 return _studyTitle;
209         }
210
211         /**
212          * Get title of the parent scenario.
213          * 
214          * @return scenario title
215          */
216         public String getScenarioTitle() {
217                 return _scenarioTitle;
218         }
219
220         /**
221          * Get the rid.
222          * 
223          * @return the rid
224          */
225         public long getIndex() {
226                 return _index;
227         }
228
229         /**
230          * Set the rid.
231          * 
232          * @param rid
233          *            the rid to set
234          */
235         public void setIndex(final long rid) {
236                 this._index = rid;
237         }
238
239         /**
240          * Set the studyTitle.
241          * 
242          * @param studyTitle
243          *            the studyTitle to set
244          */
245         public void setStudyTitle(final String studyTitle) {
246                 this._studyTitle = studyTitle;
247         }
248
249         /**
250          * Set the scenarioTitle.
251          * 
252          * @param scenarioTitle
253          *            the scenarioTitle to set
254          */
255         public void setScenarioTitle(final String scenarioTitle) {
256                 this._scenarioTitle = scenarioTitle;
257         }
258
259         /**
260          * Set the type.
261          * 
262          * @param type
263          *            the type to set
264          */
265         public void setType(final KnowledgeElementTypeDTO type) {
266                 this._type = type;
267         }
268
269         /**
270          * Set the author.
271          * 
272          * @param author
273          *            the author to set
274          */
275         public void setAuthor(final UserDTO author) {
276                 this._author = author;
277         }
278
279         /**
280          * Set the date.
281          * 
282          * @param date
283          *            the date to set
284          */
285         public void setDate(final Date date) {
286                 this._date = date;
287         }
288 }