001/*
002 $Id: BioMaterialEventData.java 3207 2009-04-09 06:48:11Z gregory $
003
004 Copyright (C) 2006, 2007 Gregory Vincic, Olle Mansson
005
006 This file is part of Proteios.
007 Available at http://www.proteios.org/
008
009 Proteios is free software; you can redistribute it and/or modify it
010 under the terms of the GNU General Public License as published by
011 the Free Software Foundation; either version 2 of the License, or
012 (at your option) any later version.
013
014 Proteios is distributed in the hope that it will be useful, but
015 WITHOUT ANY WARRANTY; without even the implied warranty of
016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017 General Public License for more details.
018
019 You should have received a copy of the GNU General Public License
020 along with this program; if not, write to the Free Software
021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
022 02111-1307, USA.
023 */
024package org.proteios.core.data;
025
026import java.util.Date;
027import java.util.HashMap;
028import java.util.Map;
029
030/**
031 * This class is used to register events for measured biomaterials.
032 * 
033 * @author Nicklas
034 * @version 2.0
035 * @see org.proteios.core.BioMaterialEvent
036 * @see <a
037 *      href="../../../../../../../development/overview/data/biomaterial.html">Biomaterials
038 *      overview</a>
039 * @base.modified $Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $
040 * @hibernate.class table="`BioMaterialEvents`" lazy="false"
041 *                  discriminator-value="-1"
042 * @hibernate.discriminator column="`discriminator`" type="int"
043 */
044public abstract class BioMaterialEventData
045                extends BasicData
046{
047        public BioMaterialEventData()
048        {}
049
050        private MeasuredBioMaterialData bioMaterial;
051
052
053        /**
054         * Get the single biomaterial used by this event.
055         * 
056         * @hibernate.many-to-one column="`biomaterial_id`" not-null="false"
057         *                        outer-join="false" update="false"
058         */
059        public MeasuredBioMaterialData getBioMaterial()
060        {
061                return bioMaterial;
062        }
063
064
065        public void setBioMaterial(MeasuredBioMaterialData bioMaterial)
066        {
067                this.bioMaterial = bioMaterial;
068        }
069
070        private Float usedQuantity;
071
072
073        /**
074         * Get the used quantity of the biomaterial affected by this event,
075         * measured in microliters. This can be both positive and negative.
076         * 
077         * @hibernate.property column="`used_quantity`" type="float"
078         *                     not-null="false"
079         */
080        public Float getUsedQuantityInMicroLiters()
081        {
082                return usedQuantity;
083        }
084
085
086        public void setUsedQuantityInMicroLiters(Float usedQuantity)
087        {
088                this.usedQuantity = usedQuantity;
089        }
090
091        private UserData user;
092
093
094        /**
095         * Get the user that is responsible for this event, typically this is the
096         * user that entered the information in the database.
097         * 
098         * @hibernate.many-to-one column="`user_id`" not-null="false"
099         *                        outer-join="false" update="false"
100         */
101        public UserData getUser()
102        {
103                return user;
104        }
105
106
107        public void setUser(UserData user)
108        {
109                this.user = user;
110        }
111
112        private ProtocolData protocol;
113
114
115        /**
116         * Get the protocol used in this event.
117         * 
118         * @hibernate.many-to-one column="`protocol_id`" not-null="false"
119         *                        outer-join="false"
120         */
121        public ProtocolData getProtocol()
122        {
123                return protocol;
124        }
125
126
127        public void setProtocol(ProtocolData protocol)
128        {
129                this.protocol = protocol;
130        }
131
132        private Date entryDate;
133
134
135        /**
136         * Get the date this event was added to the database.
137         * 
138         * @hibernate.property column="`entry_date`" not-null="true"
139         *                     update="false"
140         */
141        public Date getEntryDate()
142        {
143                return entryDate;
144        }
145
146
147        public void setEntryDate(Date entryDate)
148        {
149                this.entryDate = entryDate;
150        }
151
152        private Date eventDate;
153
154
155        /**
156         * Get the date this event happened in the lab.
157         * 
158         * @hibernate.property column="`event_date`" not-null="false"
159         */
160        public Date getEventDate()
161        {
162                return eventDate;
163        }
164
165
166        public void setEventDate(Date eventDate)
167        {
168                this.eventDate = eventDate;
169        }
170
171        /**
172         * The maximum length of the comment about this event.
173         */
174        public static final int MAX_COMMENT_LENGTH = 65535;
175        private String comment;
176
177
178        /**
179         * Get the comment about this event.
180         * 
181         * @hibernate.property column="`comment`" type="text" not-null="false"
182         */
183        public String getComment()
184        {
185                return comment;
186        }
187
188
189        public void setComment(String comment)
190        {
191                this.comment = comment;
192        }
193
194        private Map<MeasuredBioMaterialData, UsedQuantity> sources;
195
196
197        /**
198         * Get a map containing the source biomaterials and the used quantity for
199         * this event.
200         * 
201         * @hibernate.map table="`BioMaterialEventSources`" lazy="true"
202         *                cascade="delete"
203         * @hibernate.collection-key column="`event_id`"
204         * @hibernate.index-many-to-many column="`biomaterial_id`"
205         *                               class="org.proteios.core.data.MeasuredBioMaterialData"
206         * @hibernate.collection-composite-element class="org.proteios.core.data.UsedQuantity"
207         */
208        public Map<MeasuredBioMaterialData, UsedQuantity> getSources()
209        {
210                if (sources == null)
211                        sources = new HashMap<MeasuredBioMaterialData, UsedQuantity>();
212                return sources;
213        }
214
215
216        void setSources(Map<MeasuredBioMaterialData, UsedQuantity> sources)
217        {
218                this.sources = sources;
219        }
220
221        /**
222         * Separation method information.
223         */
224        private SeparationMethodData separationMethod;
225
226
227        /**
228         * @hibernate.many-to-one column="`separation_method_id`" cascade="delete"
229         *                        not-null="false" outer-join="false"
230         */
231        public SeparationMethodData getSeparationMethod()
232        {
233                return this.separationMethod;
234        }
235
236
237        /**
238         */
239        public void setSeparationMethod(SeparationMethodData separationMethod)
240        {
241                this.separationMethod = separationMethod;
242        }
243
244        private BioMaterialEventData previousBioMaterialEvent;
245
246
247        /**
248         * This function returns the previous event that is directly linked to this
249         * event. It can be used for linking series of separation events and
250         * possibly more.
251         * 
252         * @hibernate.many-to-one column="`previousBioMaterialEventId`"
253         *                        not-null="false"
254         * @return Returns the previousBioMaterialEvent.
255         */
256        public BioMaterialEventData getPreviousBioMaterialEvent()
257        {
258                return previousBioMaterialEvent;
259        }
260
261
262        /**
263         * This function sets the previous event that is directly linked to this event. 
264         * It can be used for linking series of separation events and possibly more
265         * 
266         * @param previousBioMaterialEvent The previousBioMaterialEvent to set.
267         */
268        public void setPreviousBioMaterialEvent(
269                        BioMaterialEventData previousBioMaterialEvent)
270        {
271                this.previousBioMaterialEvent = previousBioMaterialEvent;
272        }
273}