1
package org.hisp.dhis.datavalue;
4
* Copyright (c) 2004-2007, University of Oslo
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright notice, this
10
* list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
* * Neither the name of the HISP project nor the names of its contributors may
15
* be used to endorse or promote products derived from this software without
16
* specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
import java.io.Serializable;
31
import java.util.Date;
33
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
34
import org.hisp.dhis.dataelement.DataElement;
35
import org.hisp.dhis.period.Period;
36
import org.hisp.dhis.source.Source;
39
* @author Kristian Nordal
40
* @version $Id: DataValue.java 4638 2008-02-25 10:06:47Z larshelg $
42
public class DataValue
43
implements Serializable
46
* Part of the DataValue's composite ID
48
private DataElement dataElement;
51
* Part of the DataValue's composite ID
53
private Period period;
56
* Part of the DataValue's composite ID
58
private Source source;
62
private String storedBy;
64
private Date timestamp;
66
private String comment;
68
private DataElementCategoryOptionCombo optionCombo;
70
// -------------------------------------------------------------------------
72
// -------------------------------------------------------------------------
78
public DataValue( DataElement dataElement, Period period, Source source )
80
this.dataElement = dataElement;
85
public DataValue( DataElement dataElement, Period period, Source source, DataElementCategoryOptionCombo optionCombo )
87
this.dataElement = dataElement;
90
this.optionCombo = optionCombo;
93
public DataValue( DataElement dataElement, Period period, Source source, String value )
95
this.dataElement = dataElement;
101
public DataValue( DataElement dataElement, Period period, Source source, String value, DataElementCategoryOptionCombo optionCombo )
103
this.dataElement = dataElement;
104
this.period = period;
105
this.source = source;
107
this.optionCombo = optionCombo;
110
public DataValue( DataElement dataElement, Period period, Source source, String value, String storedBy,
111
Date timestamp, String comment )
113
this.dataElement = dataElement;
114
this.period = period;
115
this.source = source;
117
this.storedBy = storedBy;
118
this.timestamp = timestamp;
119
this.comment = comment;
122
public DataValue( DataElement dataElement, Period period, Source source, String value, String storedBy,
123
Date timestamp, String comment, DataElementCategoryOptionCombo optionCombo )
125
this.dataElement = dataElement;
126
this.period = period;
127
this.source = source;
129
this.storedBy = storedBy;
130
this.timestamp = timestamp;
131
this.comment = comment;
132
this.optionCombo = optionCombo;
135
// -------------------------------------------------------------------------
136
// hashCode and equals
137
// -------------------------------------------------------------------------
140
public boolean equals( Object o )
152
if ( !(o instanceof DataValue) )
157
final DataValue other = (DataValue) o;
159
return dataElement.equals( other.getDataElement() ) && optionCombo.equals( other.getOptionCombo() )
160
&& period.equals( other.getPeriod() ) && source.equals( other.getSource() );
164
public int hashCode()
166
final int prime = 31;
169
result = result * prime + optionCombo.hashCode();
170
result = result * prime + period.hashCode();
171
result = result * prime + dataElement.hashCode();
172
result = result * prime + source.hashCode();
177
// -------------------------------------------------------------------------
178
// Getters and setters
179
// -------------------------------------------------------------------------
181
public DataElement getDataElement()
186
public void setDataElement( DataElement dataElement )
188
this.dataElement = dataElement;
191
public Period getPeriod()
196
public void setPeriod( Period period )
198
this.period = period;
201
public Source getSource()
206
public void setSource( Source source )
208
this.source = source;
211
public String getValue()
216
public void setValue( String value )
221
public String getStoredBy()
226
public void setStoredBy( String storedBy )
228
this.storedBy = storedBy;
231
public Date getTimestamp()
236
public void setTimestamp( Date timestamp )
238
this.timestamp = timestamp;
241
public String getComment()
246
public void setComment( String comment )
248
this.comment = comment;
251
public DataElementCategoryOptionCombo getOptionCombo()
256
public void setOptionCombo( DataElementCategoryOptionCombo optionCombo )
258
this.optionCombo = optionCombo;