~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/aggregation/AggregatedDataValue.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.aggregation;
 
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
 
 
32
/**
 
33
 * @author Lars Helge Overland
 
34
 * @version $Id: AggregatedDataValue.java 2694 2007-01-12 19:19:46Z torgeilo $
 
35
 */
 
36
public class AggregatedDataValue
 
37
    implements Serializable
 
38
{
 
39
    private int dataElementId;
 
40
    
 
41
    private int categoryOptionComboId;
 
42
    
 
43
    private int periodId;
 
44
    
 
45
    private int periodTypeId;
 
46
    
 
47
    private int organisationUnitId;
 
48
    
 
49
    private int level;
 
50
    
 
51
    private double value;
 
52
 
 
53
    // ----------------------------------------------------------------------
 
54
    // Constructors
 
55
    // ----------------------------------------------------------------------
 
56
    
 
57
    public AggregatedDataValue()
 
58
    {   
 
59
    }
 
60
 
 
61
    /**
 
62
     * @param dataElementId data element id
 
63
     * @param categoryOptionComboId category option combo id
 
64
     * @param periodId period id
 
65
     * @param periodTypeId period type id
 
66
     * @param organisationUnitId organisation unit id
 
67
     * @param level level
 
68
     * @param value value
 
69
     */
 
70
    public AggregatedDataValue( int dataElementId, int categoryOptionComboId, int periodId, int periodTypeId, int organisationUnitId, int level, double value ) 
 
71
    {
 
72
        this.dataElementId = dataElementId;
 
73
        this.categoryOptionComboId = categoryOptionComboId;
 
74
        this.periodId = periodId;
 
75
        this.periodTypeId = periodTypeId;
 
76
        this.organisationUnitId = organisationUnitId;
 
77
        this.level = level;
 
78
        this.value = value;
 
79
    }
 
80
 
 
81
    // ----------------------------------------------------------------------
 
82
    // Logic
 
83
    // ----------------------------------------------------------------------
 
84
    
 
85
    public void clear()
 
86
    {
 
87
        this.dataElementId = 0;
 
88
        this.categoryOptionComboId = 0;
 
89
        this.periodId = 0;
 
90
        this.periodTypeId = 0;
 
91
        this.organisationUnitId = 0;
 
92
        this.level = 0;
 
93
        this.value = 0.0;
 
94
    }
 
95
    
 
96
    // ----------------------------------------------------------------------
 
97
    // Getters and setters
 
98
    // ----------------------------------------------------------------------
 
99
    
 
100
    public int getDataElementId()
 
101
    {
 
102
        return dataElementId;
 
103
    }
 
104
 
 
105
    public void setDataElementId( int dataElementId )
 
106
    {
 
107
        this.dataElementId = dataElementId;
 
108
    }
 
109
 
 
110
    public int getCategoryOptionComboId()
 
111
    {
 
112
        return categoryOptionComboId;
 
113
    }
 
114
 
 
115
    public void setCategoryOptionComboId( int categoryOptionComboId )
 
116
    {
 
117
        this.categoryOptionComboId = categoryOptionComboId;
 
118
    }
 
119
 
 
120
    public int getLevel()
 
121
    {
 
122
        return level;
 
123
    }
 
124
 
 
125
    public void setLevel( int level )
 
126
    {
 
127
        this.level = level;
 
128
    }
 
129
 
 
130
    public int getOrganisationUnitId()
 
131
    {
 
132
        return organisationUnitId;
 
133
    }
 
134
 
 
135
    public void setOrganisationUnitId( int organisationUnitId )
 
136
    {
 
137
        this.organisationUnitId = organisationUnitId;
 
138
    }
 
139
 
 
140
    public int getPeriodId()
 
141
    {
 
142
        return periodId;
 
143
    }
 
144
 
 
145
    public void setPeriodId( int periodId )
 
146
    {
 
147
        this.periodId = periodId;
 
148
    }
 
149
 
 
150
    public int getPeriodTypeId()
 
151
    {
 
152
        return periodTypeId;
 
153
    }
 
154
 
 
155
    public void setPeriodTypeId( int periodTypeId )
 
156
    {
 
157
        this.periodTypeId = periodTypeId;
 
158
    }
 
159
 
 
160
    public double getValue()
 
161
    {
 
162
        return value;
 
163
    }
 
164
 
 
165
    public void setValue( double value )
 
166
    {
 
167
        this.value = value;
 
168
    }
 
169
    
 
170
    // ----------------------------------------------------------------------
 
171
    // hashCode and equals
 
172
    // ----------------------------------------------------------------------
 
173
 
 
174
    public int hashCode()
 
175
    {
 
176
        return dataElementId * periodId * organisationUnitId * 17;
 
177
    }
 
178
    
 
179
    public boolean equals( Object object )
 
180
    {
 
181
        if ( this == object )
 
182
        {
 
183
            return true;
 
184
        }
 
185
        
 
186
        if ( object == null || !( object instanceof AggregatedDataValue ) )
 
187
        {
 
188
            return false;
 
189
        }
 
190
        
 
191
        AggregatedDataValue that = (AggregatedDataValue) object;
 
192
        
 
193
        return this.dataElementId == that.getDataElementId() &&
 
194
            this.periodId == that.getPeriodId() &&
 
195
            this.organisationUnitId == that.getOrganisationUnitId();
 
196
    }
 
197
}