1
package org.hisp.dhis.dataelement;
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.HashSet;
34
import org.hisp.dhis.common.MetaObject;
35
import org.hisp.dhis.datadictionary.ExtendedDataElement;
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.
47
* @author Kristian Nordal
48
* @version $Id: DataElement.java 5540 2008-08-19 10:47:07Z larshelg $
50
public class DataElement
51
implements Serializable, MetaObject
53
public static final String TYPE_STRING = "string";
55
public static final String TYPE_INT = "int";
57
public static final String TYPE_BOOL = "bool";
59
public static final String AGGREGATION_OPERATOR_SUM = "sum";
61
public static final String AGGREGATION_OPERATOR_AVERAGE ="average";
63
public static final String AGGREGATION_OPERATOR_COUNT = "count";
66
* The database internal identifier for this DataElement.
71
* The Universally Unique Identifer for this DataElement.
76
* The name of this DataElement. Required and unique.
81
* An alternative name of this DataElement. Optional but unique.
83
private String alternativeName;
86
* An short name representing this DataElement. Optional but unique.
88
private String shortName;
91
* An code representing this DataElement. Optional but unique.
96
* Description of this DataElement.
98
private String description;
101
* If this DataElement is active or not (enabled or disabled).
103
private boolean active;
106
* The type of this DataElement; e.g. DataElement.TYPE_INT or
107
* DataElement.TYPE_BOOL.
112
* The aggregation operator of this DataElement; e.g. DataElement.SUM og
113
* DataElement.AVERAGE.
115
private String aggregationOperator;
118
* A Collection of children DataElements.
120
private Set<DataElement> children = new HashSet<DataElement>();
123
* The parent DataElement for this DataElement.
125
private DataElement parent;
128
* Extended information about the DataElement.
130
private ExtendedDataElement extended;
133
* A combination of categories to capture data.
135
private DataElementCategoryCombo categoryCombo;
138
* Defines a custom sort order.
140
private Integer sortOrder;
143
* URL for lookup of additional information on the web.
147
// -------------------------------------------------------------------------
149
// -------------------------------------------------------------------------
155
// -------------------------------------------------------------------------
156
// hashCode, equals and toString
157
// -------------------------------------------------------------------------
160
public int hashCode()
162
return name.hashCode();
166
public boolean equals( Object o )
178
if ( !(o instanceof DataElement) )
183
final DataElement other = (DataElement) o;
185
return name.equals( other.getName() );
189
public String toString()
191
return "[" + name + "]";
194
// -------------------------------------------------------------------------
195
// Getters and setters
196
// -------------------------------------------------------------------------
203
public void setId( int id )
208
public String getUuid()
213
public void setUuid( String uuid )
218
public String getName()
223
public void setName( String name )
228
public String getAlternativeName()
230
return alternativeName;
233
public void setAlternativeName( String alternativeName )
235
this.alternativeName = alternativeName;
238
public String getShortName()
243
public void setShortName( String shortName )
245
this.shortName = shortName;
248
public String getCode()
253
public void setCode( String code )
258
public String getDescription()
263
public void setDescription( String description )
265
this.description = description;
268
public boolean isActive()
273
public void setActive( boolean active )
275
this.active = active;
278
public String getType()
283
public void setType( String type )
288
public String getAggregationOperator()
290
return aggregationOperator;
293
public void setAggregationOperator( String aggregationOperator )
295
this.aggregationOperator = aggregationOperator;
298
public Set<DataElement> getChildren()
303
public void setChildren( Set<DataElement> children )
305
this.children = children;
308
public DataElement getParent()
313
public void setParent( DataElement parent )
315
this.parent = parent;
318
public ExtendedDataElement getExtended()
323
public void setExtended( ExtendedDataElement extended )
325
this.extended = extended;
329
public DataElementCategoryCombo getCategoryCombo()
331
return categoryCombo;
334
public void setCategoryCombo( DataElementCategoryCombo categoryCombo )
336
this.categoryCombo = categoryCombo;
339
public Integer getSortOrder()
344
public void setSortOrder( Integer sortOrder )
346
this.sortOrder = sortOrder;
349
public String getUrl()
354
public void setUrl( String url )