~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/dataelement/DataElement.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.dataelement;
 
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.HashSet;
 
32
import java.util.Set;
 
33
 
 
34
import org.hisp.dhis.common.MetaObject;
 
35
import org.hisp.dhis.datadictionary.ExtendedDataElement;
 
36
 
 
37
/**
 
38
 * A DataElement is a definition (meta-information about) of the entities that
 
39
 * are captured in the system. An example from public health care is a
 
40
 * DataElement representing the number BCG doses; A DataElement with "BCG dose"
 
41
 * as name, with type DataElement.TYPE_INT. DataElements can be structured
 
42
 * hierarchically, one DataElement can have a parent and a collection of
 
43
 * children. The sum of the children represent the same entity as the parent.
 
44
 * Hiearchies of DataElements are used to give more fine- or course-grained
 
45
 * representations of the entities.
 
46
 * 
 
47
 * @author Kristian Nordal
 
48
 * @version $Id: DataElement.java 5540 2008-08-19 10:47:07Z larshelg $
 
49
 */
 
50
public class DataElement
 
51
    implements Serializable, MetaObject
 
52
{
 
53
    public static final String TYPE_STRING = "string";
 
54
 
 
55
    public static final String TYPE_INT = "int";
 
56
 
 
57
    public static final String TYPE_BOOL = "bool";
 
58
 
 
59
    public static final String AGGREGATION_OPERATOR_SUM = "sum";
 
60
 
 
61
    public static final String AGGREGATION_OPERATOR_AVERAGE ="average";
 
62
    
 
63
    public static final String AGGREGATION_OPERATOR_COUNT = "count";
 
64
 
 
65
    /**
 
66
     * The database internal identifier for this DataElement.
 
67
     */
 
68
    private int id;
 
69
    
 
70
    /**
 
71
     * The Universally Unique Identifer for this DataElement. 
 
72
     */    
 
73
    private String uuid;
 
74
 
 
75
    /**
 
76
     * The name of this DataElement. Required and unique.
 
77
     */
 
78
    private String name;
 
79
 
 
80
    /**
 
81
     * An alternative name of this DataElement. Optional but unique.
 
82
     */
 
83
    private String alternativeName;
 
84
 
 
85
    /**
 
86
     * An short name representing this DataElement. Optional but unique.
 
87
     */
 
88
    private String shortName;
 
89
 
 
90
    /**
 
91
     * An code representing this DataElement. Optional but unique.
 
92
     */
 
93
    private String code;
 
94
 
 
95
    /**
 
96
     * Description of this DataElement.
 
97
     */
 
98
    private String description;
 
99
 
 
100
    /**
 
101
     * If this DataElement is active or not (enabled or disabled).
 
102
     */
 
103
    private boolean active;
 
104
 
 
105
    /**
 
106
     * The type of this DataElement; e.g. DataElement.TYPE_INT or
 
107
     * DataElement.TYPE_BOOL.
 
108
     */
 
109
    private String type;
 
110
 
 
111
    /**
 
112
     * The aggregation operator of this DataElement; e.g. DataElement.SUM og
 
113
     * DataElement.AVERAGE.
 
114
     */
 
115
    private String aggregationOperator;
 
116
 
 
117
    /**
 
118
     * A Collection of children DataElements.
 
119
     */
 
120
    private Set<DataElement> children = new HashSet<DataElement>();
 
121
 
 
122
    /**
 
123
     * The parent DataElement for this DataElement.
 
124
     */
 
125
    private DataElement parent;
 
126
    
 
127
    /**
 
128
     * Extended information about the DataElement.
 
129
     */
 
130
    private ExtendedDataElement extended;
 
131
 
 
132
    /**
 
133
     * A combination of categories to capture data.
 
134
     */    
 
135
    private DataElementCategoryCombo categoryCombo;
 
136
    
 
137
    /**
 
138
     * Defines a custom sort order.
 
139
     */
 
140
    private Integer sortOrder;
 
141
    
 
142
    /**
 
143
     * URL for lookup of additional information on the web.
 
144
     */
 
145
    private String url;
 
146
    
 
147
    // -------------------------------------------------------------------------
 
148
    // Constructors
 
149
    // -------------------------------------------------------------------------
 
150
 
 
151
    public DataElement()
 
152
    {
 
153
    }
 
154
 
 
155
    // -------------------------------------------------------------------------
 
156
    // hashCode, equals and toString
 
157
    // -------------------------------------------------------------------------
 
158
 
 
159
    @Override
 
160
    public int hashCode()
 
161
    {
 
162
        return name.hashCode();
 
163
    }
 
164
 
 
165
    @Override
 
166
    public boolean equals( Object o )
 
167
    {
 
168
        if ( this == o )
 
169
        {
 
170
            return true;
 
171
        }
 
172
 
 
173
        if ( o == null )
 
174
        {
 
175
            return false;
 
176
        }
 
177
 
 
178
        if ( !(o instanceof DataElement) )
 
179
        {
 
180
            return false;
 
181
        }
 
182
 
 
183
        final DataElement other = (DataElement) o;
 
184
 
 
185
        return name.equals( other.getName() );
 
186
    }
 
187
 
 
188
    @Override
 
189
    public String toString()
 
190
    {
 
191
        return "[" + name + "]";
 
192
    }
 
193
 
 
194
    // -------------------------------------------------------------------------
 
195
    // Getters and setters
 
196
    // -------------------------------------------------------------------------
 
197
 
 
198
    public int getId()
 
199
    {
 
200
        return id;
 
201
    }
 
202
 
 
203
    public void setId( int id )
 
204
    {
 
205
        this.id = id;
 
206
    }
 
207
 
 
208
    public String getUuid()
 
209
    {
 
210
        return uuid;
 
211
    }
 
212
 
 
213
    public void setUuid( String uuid )
 
214
    {
 
215
        this.uuid = uuid;
 
216
    }
 
217
 
 
218
    public String getName()
 
219
    {
 
220
        return name;
 
221
    }
 
222
 
 
223
    public void setName( String name )
 
224
    {
 
225
        this.name = name;
 
226
    }
 
227
 
 
228
    public String getAlternativeName()
 
229
    {
 
230
        return alternativeName;
 
231
    }
 
232
 
 
233
    public void setAlternativeName( String alternativeName )
 
234
    {
 
235
        this.alternativeName = alternativeName;
 
236
    }
 
237
 
 
238
    public String getShortName()
 
239
    {
 
240
        return shortName;
 
241
    }
 
242
 
 
243
    public void setShortName( String shortName )
 
244
    {
 
245
        this.shortName = shortName;
 
246
    }
 
247
 
 
248
    public String getCode()
 
249
    {
 
250
        return code;
 
251
    }
 
252
 
 
253
    public void setCode( String code )
 
254
    {
 
255
        this.code = code;
 
256
    }
 
257
 
 
258
    public String getDescription()
 
259
    {
 
260
        return description;
 
261
    }
 
262
 
 
263
    public void setDescription( String description )
 
264
    {
 
265
        this.description = description;
 
266
    }
 
267
 
 
268
    public boolean isActive()
 
269
    {
 
270
        return active;
 
271
    }
 
272
 
 
273
    public void setActive( boolean active )
 
274
    {
 
275
        this.active = active;
 
276
    }
 
277
 
 
278
    public String getType()
 
279
    {
 
280
        return type;
 
281
    }
 
282
 
 
283
    public void setType( String type )
 
284
    {
 
285
        this.type = type;
 
286
    }
 
287
 
 
288
    public String getAggregationOperator()
 
289
    {
 
290
        return aggregationOperator;
 
291
    }
 
292
 
 
293
    public void setAggregationOperator( String aggregationOperator )
 
294
    {
 
295
        this.aggregationOperator = aggregationOperator;
 
296
    }
 
297
 
 
298
    public Set<DataElement> getChildren()
 
299
    {
 
300
        return children;
 
301
    }
 
302
 
 
303
    public void setChildren( Set<DataElement> children )
 
304
    {
 
305
        this.children = children;
 
306
    }
 
307
 
 
308
    public DataElement getParent()
 
309
    {
 
310
        return parent;
 
311
    }
 
312
 
 
313
    public void setParent( DataElement parent )
 
314
    {
 
315
        this.parent = parent;
 
316
    }
 
317
 
 
318
    public ExtendedDataElement getExtended()
 
319
    {
 
320
        return extended;
 
321
    }
 
322
 
 
323
    public void setExtended( ExtendedDataElement extended )
 
324
    {
 
325
        this.extended = extended;
 
326
    }
 
327
    
 
328
 
 
329
    public DataElementCategoryCombo getCategoryCombo()
 
330
    {
 
331
        return categoryCombo;
 
332
    }
 
333
 
 
334
    public void setCategoryCombo( DataElementCategoryCombo categoryCombo )
 
335
    {
 
336
        this.categoryCombo = categoryCombo;
 
337
    }
 
338
 
 
339
    public Integer getSortOrder()
 
340
    {
 
341
        return sortOrder;
 
342
    }
 
343
 
 
344
    public void setSortOrder( Integer sortOrder )
 
345
    {
 
346
        this.sortOrder = sortOrder;
 
347
    }
 
348
 
 
349
    public String getUrl()
 
350
    {
 
351
        return url;
 
352
    }
 
353
 
 
354
    public void setUrl( String url )
 
355
    {
 
356
        this.url = url;
 
357
    }
 
358
}