Source code: org/biomage/BioMaterial/Treatment.java
1 /***************************************************************************
2 * *
3 * C O P Y R I G H T N O T I C E *
4 * Copyright (c) 2001 by: *
5 * * The MicroArray Gene Expression Database group (MGED) *
6 * * Rosetta Inpharmatics *
7 * *
8 * All Rights Reserved. *
9 * *
10 * Permission is hereby granted, free of charge, to any person *
11 * obtaining a copy of this software and associated documentation files *
12 * (the "Software"), to deal in the Software without restriction, *
13 * including without limitation the rights to use, copy, modify, merge, *
14 * publish, distribute, sublicense, and/or sell copies of the Software, *
15 * and to permit persons to whom the Software is furnished to do so, *
16 * subject to the following conditions: *
17 * *
18 * The above copyright notice and this permission notice shall be *
19 * included in all copies or substantial portions of the Software. *
20 * *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *
25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *
26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
28 * SOFTWARE. *
29 ***************************************************************************
30 * *
31 * Created by the create_mage_java_classes java program based on the *
32 * information in the xmi file created from the MAGE-OM UML model, *
33 * copyright European Bioinformatics Institute (EBI) for MGED and Rosetta *
34 * Informatics. *
35 * *
36 * The ideas and work are built on the previous work in perl of Jason *
37 * Stewart, Open Informatics, and Robert M. Hubley, Institute for Systems *
38 * Biology *
39 * *
40 * @author Michael Miller, Rosetta Inpharmatics *
41 * @version Revision: 1.0 *
42 * @date Thu, Feb 21, 2002 10:46:10 AM *
43 * *
44 ***************************************************************************
45 */
46
47 /**
48 * org.biomage.BioMaterial
49 *
50 */
51 package org.biomage.BioMaterial;
52
53 /**
54 * Import list for Treatment
55 *
56 */
57 import java.io.Serializable;
58 import java.util.*;
59 import org.xml.sax.Attributes;
60 import java.io.Writer;
61 import java.io.IOException;
62 import org.biomage.Interface.HasCompoundMeasurements;
63 import org.biomage.Interface.HasSourceBioMaterialMeasurements;
64 import org.biomage.Interface.HasActionMeasurement;
65 import org.biomage.Interface.HasAction;
66 import org.biomage.BioEvent.BioEvent;
67 import org.biomage.Description.OntologyEntry;
68 import org.biomage.Measurement.Measurement;
69
70 /**
71 * The process by which a biomaterial is created (from source
72 * biomaterials). Treatments have an order and an action.
73 *
74 */
75 public
76 class Treatment
77 extends BioEvent
78 implements Serializable,
79 HasCompoundMeasurements,
80 HasSourceBioMaterialMeasurements,
81 HasActionMeasurement,
82 HasAction
83 {
84 /**
85 * The chronological order in which a treatment occurred (in
86 * relation to other treatments). More than one treatment can have the
87 * same chronological order indicating that they happened (or were
88 * caused to happen) simultaneously.
89 *
90 */
91 int order;
92
93 /**
94 * The compounds and their amounts used in the treatment.
95 *
96 */
97 private CompoundMeasurements_list compoundMeasurements = new CompoundMeasurements_list();
98
99 /**
100 * The BioMaterials and the amounts used in the treatment
101 *
102 */
103 private SourceBioMaterialMeasurements_list sourceBioMaterialMeasurements = new SourceBioMaterialMeasurements_list();
104
105 /**
106 * Measures events like duration, centrifuge speed, etc.
107 *
108 */
109 private Measurement actionMeasurement;
110
111
112 /**
113 * The event that occurred (e.g. grow, wait, add, etc...). The
114 * actions should be a recommended vocabulary
115 *
116 */
117 private OntologyEntry action;
118
119
120 /**
121 * Default constructor.
122 *
123 */
124 public
125 Treatment()
126 {
127 super();
128 }
129
130 /**
131 * Attribute constructor.
132 *
133 * Looks up the attributes in the parameter and casts them from strings
134 * appropriately
135 * @param atts: the attribute list.
136 *
137 */
138 // TODO Work in progress (attribute constructor).
139 public
140 Treatment(Attributes atts)
141 {
142 super(atts);
143
144 {
145 int nIndex = atts.getIndex("", "order");
146 if (nIndex != -1)
147 {
148 order = Integer.parseInt(atts.getValue(nIndex));
149 }
150 }
151
152 }
153
154 /**
155 * writeMAGEML
156 * <p>
157 * This method is responsible for assembling the attribute and
158 * association data into XML. It creates the object tag and then calls
159 * the writeAttributes and writeAssociation methods.
160 * <p>
161 *
162 */
163 public
164 void
165 writeMAGEML(Writer out)
166 throws IOException
167 {
168 out.write("<Treatment");
169 writeAttributes(out);
170 out.write(">");
171 writeAssociations(out);
172 out.write("</Treatment>");
173 }
174
175 /**
176 * writeAttributes
177 * <p>
178 * This method is responsible for assembling the attribute data into
179 * XML. It calls the super method to write out all attributes of this
180 * class and it's ancestors.
181 * <p>
182 *
183 */
184 public
185 void
186 writeAttributes(Writer out)
187 throws IOException
188 {
189 super.writeAttributes(out);
190 out.write(" order=\"" + order + "\"");
191 }
192
193 /**
194 * writeAssociations
195 * <p>
196 * This method is responsible for assembling the association data
197 * into XML. It calls the super method to write out all associations of
198 * this class's ancestors.
199 * <p>
200 *
201 */
202 public
203 void
204 writeAssociations(Writer out)
205 throws IOException
206 {
207 super.writeAssociations(out);
208 if ( action != null ){
209 out.write("<Action_assn>");
210 action.writeMAGEML(out);
211 out.write("</Action_assn>");
212 }
213 if ( actionMeasurement != null ){
214 out.write("<ActionMeasurement_assn>");
215 actionMeasurement.writeMAGEML(out);
216 out.write("</ActionMeasurement_assn>");
217 }
218 if ( compoundMeasurements.size() > 0 ){
219 out.write("<CompoundMeasurements_assnlist>");
220 for ( int i = 0; i < compoundMeasurements.size(); i++) {
221 ((CompoundMeasurement)compoundMeasurements.elementAt(i)).writeMAGEML(out);
222 }
223 out.write("</CompoundMeasurements_assnlist>");
224 }
225 if ( sourceBioMaterialMeasurements.size() > 0 ){
226 out.write("<SourceBioMaterialMeasurements_assnlist>");
227 for ( int i = 0; i < sourceBioMaterialMeasurements.size(); i++) {
228 ((BioMaterialMeasurement)sourceBioMaterialMeasurements.elementAt(i)).writeMAGEML(out);
229 }
230 out.write("</SourceBioMaterialMeasurements_assnlist>");
231 }
232 }
233
234 /**
235 * Set method for order
236 * <p>
237 * @param value to set
238 * <p>
239 *
240 */
241 public
242 void
243 setOrder(
244 int order
245 )
246 {
247 this.order = order;
248 }
249
250 /**
251 * Get method for order
252 * <p>
253 * @return value of the attribute
254 * <p>
255 *
256 */
257 public
258 int
259 getOrder()
260 {
261 return order;
262 }
263
264 /**
265 * Set method for compoundMeasurements
266 * <p>
267 * @param value to set
268 * <p>
269 *
270 */
271 public
272 void
273 setCompoundMeasurements(
274 CompoundMeasurements_list compoundMeasurements
275 )
276 {
277 ((List)this.compoundMeasurements).addAll((List)compoundMeasurements);
278 }
279
280 /**
281 * Get method for compoundMeasurements
282 * <p>
283 * @return value of the attribute
284 * <p>
285 *
286 */
287 public
288 CompoundMeasurements_list
289 getCompoundMeasurements()
290 {
291 return compoundMeasurements;
292 }
293
294 /**
295 * Method to add CompoundMeasurement to CompoundMeasurements_list
296 *
297 */
298 public
299 void
300 addToCompoundMeasurements(
301 CompoundMeasurement compoundMeasurement
302 )
303 {
304 this.compoundMeasurements.add(compoundMeasurement);
305 }
306
307 /**
308 * Method to add CompoundMeasurement at position to
309 * CompoundMeasurements_list
310 *
311 */
312 public
313 void
314 addToCompoundMeasurements(
315 int position,
316 CompoundMeasurement compoundMeasurement
317 )
318 {
319 this.compoundMeasurements.add(position, compoundMeasurement);
320 }
321
322 /**
323 * Method to get CompoundMeasurement from CompoundMeasurements_list
324 *
325 */
326 public
327 CompoundMeasurement
328 getFromCompoundMeasurements(
329 int position
330 )
331 {
332 return (CompoundMeasurement) this.compoundMeasurements.get(position);
333 }
334
335 /**
336 * Method to remove by position from CompoundMeasurements_list
337 *
338 */
339 public
340 void
341 removeElementAtFromCompoundMeasurements(
342 int position
343 )
344 {
345 this.compoundMeasurements.removeElementAt(position);
346 }
347
348 /**
349 * Method to remove first CompoundMeasurement from
350 * CompoundMeasurements_list
351 *
352 */
353 public
354 void
355 removeFromCompoundMeasurements(
356 CompoundMeasurement compoundMeasurement
357 )
358 {
359 this.compoundMeasurements.remove(compoundMeasurement);
360 }
361
362 /**
363 * Set method for sourceBioMaterialMeasurements
364 * <p>
365 * @param value to set
366 * <p>
367 *
368 */
369 public
370 void
371 setSourceBioMaterialMeasurements(
372 SourceBioMaterialMeasurements_list sourceBioMaterialMeasurements
373 )
374 {
375 ((List)this.sourceBioMaterialMeasurements).addAll((List)sourceBioMaterialMeasurements);
376 }
377
378 /**
379 * Get method for sourceBioMaterialMeasurements
380 * <p>
381 * @return value of the attribute
382 * <p>
383 *
384 */
385 public
386 SourceBioMaterialMeasurements_list
387 getSourceBioMaterialMeasurements()
388 {
389 return sourceBioMaterialMeasurements;
390 }
391
392 /**
393 * Method to add BioMaterialMeasurement to
394 * SourceBioMaterialMeasurements_list
395 *
396 */
397 public
398 void
399 addToSourceBioMaterialMeasurements(
400 BioMaterialMeasurement bioMaterialMeasurement
401 )
402 {
403 this.sourceBioMaterialMeasurements.add(bioMaterialMeasurement);
404 }
405
406 /**
407 * Method to add BioMaterialMeasurement at position to
408 * SourceBioMaterialMeasurements_list
409 *
410 */
411 public
412 void
413 addToSourceBioMaterialMeasurements(
414 int position,
415 BioMaterialMeasurement bioMaterialMeasurement
416 )
417 {
418 this.sourceBioMaterialMeasurements.add(position, bioMaterialMeasurement);
419 }
420
421 /**
422 * Method to get BioMaterialMeasurement from
423 * SourceBioMaterialMeasurements_list
424 *
425 */
426 public
427 BioMaterialMeasurement
428 getFromSourceBioMaterialMeasurements(
429 int position
430 )
431 {
432 return (BioMaterialMeasurement) this.sourceBioMaterialMeasurements.get(position);
433 }
434
435 /**
436 * Method to remove by position from
437 * SourceBioMaterialMeasurements_list
438 *
439 */
440 public
441 void
442 removeElementAtFromSourceBioMaterialMeasurements(
443 int position
444 )
445 {
446 this.sourceBioMaterialMeasurements.removeElementAt(position);
447 }
448
449 /**
450 * Method to remove first BioMaterialMeasurement from
451 * SourceBioMaterialMeasurements_list
452 *
453 */
454 public
455 void
456 removeFromSourceBioMaterialMeasurements(
457 BioMaterialMeasurement bioMaterialMeasurement
458 )
459 {
460 this.sourceBioMaterialMeasurements.remove(bioMaterialMeasurement);
461 }
462
463 /**
464 * Set method for actionMeasurement
465 * <p>
466 * @param value to set
467 * <p>
468 *
469 */
470 public
471 void
472 setActionMeasurement(
473 Measurement actionMeasurement
474 )
475 {
476 this.actionMeasurement = actionMeasurement;
477 }
478
479 /**
480 * Get method for actionMeasurement
481 * <p>
482 * @return value of the attribute
483 * <p>
484 *
485 */
486 public
487 Measurement
488 getActionMeasurement()
489 {
490 return actionMeasurement;
491 }
492
493 /**
494 * Set method for action
495 * <p>
496 * @param value to set
497 * <p>
498 *
499 */
500 public
501 void
502 setAction(
503 OntologyEntry action
504 )
505 {
506 this.action = action;
507 }
508
509 /**
510 * Get method for action
511 * <p>
512 * @return value of the attribute
513 * <p>
514 *
515 */
516 public
517 OntologyEntry
518 getAction()
519 {
520 return action;
521 }
522
523 }