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.util.Collection;
32
import org.hisp.dhis.hierarchy.HierarchyViolationException;
35
* Defines the functionality for persisting DataElements and DataElementGroups.
37
* @author Torgeir Lorange Ostby
38
* @version $Id: DataElementStore.java 6289 2008-11-14 17:53:24Z larshelg $
40
public interface DataElementStore
42
String ID = DataElementStore.class.getName();
44
// -------------------------------------------------------------------------
46
// -------------------------------------------------------------------------
51
* @param dataElement the DataElement to add.
52
* @return a generated unique id of the added DataElement.
54
int addDataElement( DataElement dataElement );
57
* Updates a DataElement.
59
* @param dataElement the DataElement to update.
61
void updateDataElement( DataElement dataElement );
64
* Deletes a DataElement. The DataElement is also removed from any
65
* DataElementGroups it is a member of. It is not possible to delete a
66
* DataElement with children.
68
* @param dataElement the DataElement to delete.
69
* @throws HierarchyViolationException if the DataElement has children.
71
void deleteDataElement( DataElement dataElement )
72
throws HierarchyViolationException;
75
* Returns a DataElement.
77
* @param id the id of the DataElement to return.
78
* @return the DataElement with the given id, or null if no match.
80
DataElement getDataElement( int id );
83
* Returns the DataElement with the given UUID.
85
* @param uuid the UUID.
86
* @return the DataElement with the given UUID, or null if no match.
88
DataElement getDataElement( String uuid );
91
* Returns a DataElement with a given name.
93
* @param name the name of the DataElement to return.
94
* @return the DataElement with the given name, or null if no match.
96
DataElement getDataElementByName( String name );
99
* Returns a DataElement with a given alternative name.
101
* @param alternativeName the alternative name of the DataElement to return.
102
* @return the DataElement with the given alternative name, or null if no
105
DataElement getDataElementByAlternativeName( String alternativeName );
108
* Returns a DataElement with a given short name.
110
* @param shortName the short name of the DataElement to return.
111
* @return the DataElement with the given short name, or null if no match.
113
DataElement getDataElementByShortName( String shortName );
116
* Returns a DataElement with a given code.
118
* @param code the code of the DataElement to return.
119
* @return the DataElement with the given code, or null if no match.
121
DataElement getDataElementByCode( String code );
124
* Returns all DataElements.
126
* @return a collection of all DataElements, or an empty collection if there
127
* are no DataElements.
129
Collection<DataElement> getAllDataElements();
132
* Returns all DataElements with types that are possible to aggregate. The
133
* types are currently INT and BOOL.
135
* @return all DataElements with types that are possible to aggregate.
137
Collection<DataElement> getAggregateableDataElements();
140
* Returns all active DataElements.
142
* @return a collection of all active DataElements, or an empty collection
143
* if there are no active DataElements.
145
Collection<DataElement> getAllActiveDataElements();
148
* Returns all DataElements with a given aggregantion operator.
150
* @param aggregationOperator the aggregation operator of the DataElements
152
* @return a collection of all DataElements with the given aggregation
153
* operator, or an empty collection if no DataElements have the
154
* aggregation operator.
156
Collection<DataElement> getDataElementsByAggregationOperator( String aggregationOperator );
159
* Returns all DataElements with the given type.
161
* @param type the type.
162
* @return all DataElements with the given type.
164
Collection<DataElement> getDataElementsByType( String type );
167
* Returns all DataElements with the given category combo.
169
* @param categoryCombo the DataElementCategoryCombo.
170
* @return all DataElements with the given category combo.
172
Collection<DataElement> getDataElementByCategoryCombo( DataElementCategoryCombo categoryCombo );
174
// -------------------------------------------------------------------------
175
// Calculated Data Elements
176
// -------------------------------------------------------------------------
179
* Returns a CalclulatedDataElement which contains a given dataElement
181
* @paran dataElement the DataElement which is contained by the
182
* CalculatedDataElement to return.
183
* @return a CalculatedDataElement which contains the given DataElement, or
184
* null if the DataElement is not part of a CalculatedDataElement.
186
CalculatedDataElement getCalculatedDataElementByDataElement( DataElement dataElement );
189
* Returns CalculatedDataElements which contain any of the given DataElements
190
* @param dataElements Collection of DataElements which can be contained by
191
* the returned CalculatedDataElements
192
* @return a collection of CalculatedDataElements which contain any of the
193
* given DataElements, or an empty collection if no
194
* CalculatedDataElements contain any of the DataElements.
196
Collection<CalculatedDataElement> getCalculatedDataElementsByDataElements( Collection<DataElement> dataElements );
199
* Returns all CalculatedDataElements
200
* @return a collection of all CalculatedDataElements, or an empty collection
201
* if there are no CalculcatedDataELements
203
Collection<CalculatedDataElement> getAllCalculatedDataElements();
205
// -------------------------------------------------------------------------
207
// -------------------------------------------------------------------------
210
* Adds a DataElementGroup.
212
* @param dataElementGroup the DataElementGroup to add.
213
* @return a generated unique id of the added DataElementGroup.
215
int addDataElementGroup( DataElementGroup dataElementGroup );
218
* Updates a DataElementGroup.
220
* @param dataElementGroup the DataElementGroup to update.
222
void updateDataElementGroup( DataElementGroup dataElementGroup );
225
* Deletes a DataElementGroup.
227
* @param dataElementGroup the DataElementGroup to delete.
229
void deleteDataElementGroup( DataElementGroup dataElementGroup );
232
* Returns a DataElementGroup.
234
* @param id the id of the DataElementGroup to return.
235
* @return the DataElementGroup with the given id, or null if no match.
237
DataElementGroup getDataElementGroup( int id );
240
* Returns the DataElementGroup with the given UUID.
242
* @param id the UUID.
243
* @return the DataElementGroup with the given uuid, or null if no match.
245
DataElementGroup getDataElementGroup( String uuid );
248
* Returns a DataElementGroup with a given name.
250
* @param name the name of the DataElementGroup to return.
251
* @return the DataElementGroup with the given name, or null if no match.
253
DataElementGroup getDataElementGroupByName( String name );
256
* Returns all DataElementGroups.
258
* @return a collection of all DataElementGroups, or an empty collection if
259
* no DataElementGroups exist.
261
Collection<DataElementGroup> getAllDataElementGroups();