~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.hisp.dhis.datavalue;
 
2
 
 
3
/*
 
4
 * Copyright (c) 2004-2007, University of Oslo
 
5
 * All rights reserved.
 
6
 *
 
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.
 
17
 *
 
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.
 
28
 */
 
29
 
 
30
import java.io.Serializable;
 
31
import java.util.Date;
 
32
 
 
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;
 
37
 
 
38
/**
 
39
 * @author Kristian Nordal
 
40
 * @version $Id: DataValue.java 4638 2008-02-25 10:06:47Z larshelg $
 
41
 */
 
42
public class DataValue
 
43
    implements Serializable
 
44
{
 
45
    /**
 
46
     * Part of the DataValue's composite ID
 
47
     */
 
48
    private DataElement dataElement;
 
49
 
 
50
    /**
 
51
     * Part of the DataValue's composite ID
 
52
     */
 
53
    private Period period;
 
54
 
 
55
    /**
 
56
     * Part of the DataValue's composite ID
 
57
     */
 
58
    private Source source;
 
59
 
 
60
    private String value;
 
61
 
 
62
    private String storedBy;
 
63
 
 
64
    private Date timestamp;
 
65
 
 
66
    private String comment;
 
67
    
 
68
    private DataElementCategoryOptionCombo optionCombo;
 
69
 
 
70
    // -------------------------------------------------------------------------
 
71
    // Constructors
 
72
    // -------------------------------------------------------------------------
 
73
 
 
74
    public DataValue()
 
75
    {
 
76
    }
 
77
 
 
78
    public DataValue( DataElement dataElement, Period period, Source source )
 
79
    {
 
80
        this.dataElement = dataElement;
 
81
        this.period = period;
 
82
        this.source = source;
 
83
    }
 
84
 
 
85
    public DataValue( DataElement dataElement, Period period, Source source, DataElementCategoryOptionCombo optionCombo )
 
86
    {
 
87
        this.dataElement = dataElement;
 
88
        this.period = period;
 
89
        this.source = source;
 
90
        this.optionCombo = optionCombo;
 
91
    }
 
92
 
 
93
    public DataValue( DataElement dataElement, Period period, Source source, String value )
 
94
    {
 
95
        this.dataElement = dataElement;
 
96
        this.period = period;
 
97
        this.source = source;
 
98
        this.value = value;
 
99
    }
 
100
 
 
101
    public DataValue( DataElement dataElement, Period period, Source source, String value, DataElementCategoryOptionCombo optionCombo )
 
102
    {
 
103
        this.dataElement = dataElement;
 
104
        this.period = period;
 
105
        this.source = source;
 
106
        this.value = value;
 
107
        this.optionCombo = optionCombo;
 
108
    }
 
109
 
 
110
    public DataValue( DataElement dataElement, Period period, Source source, String value, String storedBy,
 
111
        Date timestamp, String comment )
 
112
    {
 
113
        this.dataElement = dataElement;
 
114
        this.period = period;
 
115
        this.source = source;
 
116
        this.value = value;
 
117
        this.storedBy = storedBy;
 
118
        this.timestamp = timestamp;
 
119
        this.comment = comment;
 
120
    }
 
121
    
 
122
    public DataValue( DataElement dataElement, Period period, Source source, String value, String storedBy,
 
123
            Date timestamp, String comment, DataElementCategoryOptionCombo optionCombo )
 
124
    {
 
125
            this.dataElement = dataElement;
 
126
            this.period = period;
 
127
            this.source = source;
 
128
            this.value = value;
 
129
            this.storedBy = storedBy;
 
130
            this.timestamp = timestamp;
 
131
            this.comment = comment;
 
132
            this.optionCombo = optionCombo;
 
133
    }
 
134
 
 
135
    // -------------------------------------------------------------------------
 
136
    // hashCode and equals
 
137
    // -------------------------------------------------------------------------
 
138
 
 
139
    @Override
 
140
    public boolean equals( Object o )
 
141
    {
 
142
        if ( this == o )
 
143
        {
 
144
            return true;
 
145
        }
 
146
 
 
147
        if ( o == null )
 
148
        {
 
149
            return false;
 
150
        }
 
151
 
 
152
        if ( !(o instanceof DataValue) )
 
153
        {
 
154
            return false;
 
155
        }
 
156
 
 
157
        final DataValue other = (DataValue) o;
 
158
 
 
159
        return dataElement.equals( other.getDataElement() ) && optionCombo.equals( other.getOptionCombo() ) 
 
160
            && period.equals( other.getPeriod() ) && source.equals( other.getSource() );
 
161
    }
 
162
 
 
163
    @Override
 
164
    public int hashCode()
 
165
    {
 
166
        final int prime = 31;
 
167
        int result = 1;
 
168
 
 
169
        result = result * prime + optionCombo.hashCode();
 
170
        result = result * prime + period.hashCode();
 
171
        result = result * prime + dataElement.hashCode();
 
172
        result = result * prime + source.hashCode();
 
173
 
 
174
        return result;
 
175
    }
 
176
 
 
177
    // -------------------------------------------------------------------------
 
178
    // Getters and setters
 
179
    // -------------------------------------------------------------------------
 
180
 
 
181
    public DataElement getDataElement()
 
182
    {
 
183
        return dataElement;
 
184
    }
 
185
 
 
186
    public void setDataElement( DataElement dataElement )
 
187
    {
 
188
        this.dataElement = dataElement;
 
189
    }
 
190
 
 
191
    public Period getPeriod()
 
192
    {
 
193
        return period;
 
194
    }
 
195
 
 
196
    public void setPeriod( Period period )
 
197
    {
 
198
        this.period = period;
 
199
    }
 
200
 
 
201
    public Source getSource()
 
202
    {
 
203
        return source;
 
204
    }
 
205
 
 
206
    public void setSource( Source source )
 
207
    {
 
208
        this.source = source;
 
209
    }
 
210
 
 
211
    public String getValue()
 
212
    {
 
213
        return value;
 
214
    }
 
215
 
 
216
    public void setValue( String value )
 
217
    {
 
218
        this.value = value;
 
219
    }
 
220
 
 
221
    public String getStoredBy()
 
222
    {
 
223
        return storedBy;
 
224
    }
 
225
 
 
226
    public void setStoredBy( String storedBy )
 
227
    {
 
228
        this.storedBy = storedBy;
 
229
    }
 
230
 
 
231
    public Date getTimestamp()
 
232
    {
 
233
        return timestamp;
 
234
    }
 
235
 
 
236
    public void setTimestamp( Date timestamp )
 
237
    {
 
238
        this.timestamp = timestamp;
 
239
    }
 
240
 
 
241
    public String getComment()
 
242
    {
 
243
        return comment;
 
244
    }
 
245
 
 
246
    public void setComment( String comment )
 
247
    {
 
248
        this.comment = comment;
 
249
    }
 
250
    
 
251
    public DataElementCategoryOptionCombo getOptionCombo()
 
252
    {
 
253
        return optionCombo;
 
254
    }
 
255
 
 
256
    public void setOptionCombo( DataElementCategoryOptionCombo optionCombo )
 
257
    {
 
258
        this.optionCombo = optionCombo;
 
259
    }
 
260
 
 
261
}