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;
33
import org.hisp.dhis.hierarchy.HierarchyViolationException;
36
* Defines service functionality for DataElements and DataElementGroups.
38
* @author Kristian Nordal
39
* @version $Id: DataElementService.java 6289 2008-11-14 17:53:24Z larshelg $
41
public interface DataElementService
43
String ID = DataElementService.class.getName();
45
// -------------------------------------------------------------------------
47
// -------------------------------------------------------------------------
52
* @param dataElement the DataElement to add.
53
* @return a generated unique id of the added DataElement.
55
int addDataElement( DataElement dataElement );
58
* Updates a DataElement.
60
* @param dataElement the DataElement to update.
62
void updateDataElement( DataElement dataElement );
65
* Deletes a DataElement. The DataElement is also removed from any
66
* DataElementGroups it is a member of. It is not possible to delete a
67
* DataElement with children.
69
* @param dataElement the DataElement to delete.
70
* @throws HierarchyViolationException if the DataElement has children.
72
void deleteDataElement( DataElement dataElement )
73
throws HierarchyViolationException;
76
* Returns a DataElement.
78
* @param id the id of the DataElement to return.
79
* @return the DataElement with the given id, or null if no match.
81
DataElement getDataElement( int id );
84
* 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 which are instances of CalculatedDataElement.
134
* @return all DataElements which are instances of CalculatedDataElement.
136
Collection<CalculatedDataElement> getCalculatedDataElements();
139
* Returns all DataElements which are not instances of CalculatedDataElements.
141
* @return all DataElements which are not instances of CalculatedDataElements.
143
Collection<DataElement> getNonCalculatedDataElements();
146
* Returns all DataElements with corresponding identifiers.
148
* @param identifiers the collection of identifiers.
149
* @return a collection of DataElements.
151
Collection<DataElement> getDataElements( Collection<Integer> identifiers );
154
* Returns all DataElements with types that are possible to aggregate. The
155
* types are currently INT and BOOL.
157
* @return all DataElements with types that are possible to aggregate.
159
Collection<DataElement> getAggregateableDataElements();
162
* Returns all active DataElements.
164
* @return a collection of all active DataElements, or an empty collection
165
* if there are no active DataElements.
167
Collection<DataElement> getAllActiveDataElements();
170
* Returns all DataElements with a given aggregantion operator.
172
* @param aggregationOperator the aggregation operator of the DataElements
174
* @return a collection of all DataElements with the given aggregation
175
* operator, or an empty collection if no DataElements have the
176
* aggregation operator.
178
Collection<DataElement> getDataElementsByAggregationOperator( String aggregationOperator );
181
* Returns all DataElements with the given type.
183
* @param type the type.
184
* @return all DataElements with the given type.
186
Collection<DataElement> getDataElementsByType( String type );
189
* Returns all DataElements with the given category combo.
191
* @param categoryCombo the DataElementCategoryCombo.
192
* @return all DataElements with the given category combo.
194
Collection<DataElement> getDataElementByCategoryCombo( DataElementCategoryCombo categoryCombo );
196
// -------------------------------------------------------------------------
197
// Calculated Data Elements
198
// -------------------------------------------------------------------------
201
* Returns a CalclulatedDataElement which contains a given dataElement
203
* @param dataElement the DataElement which is contained by the
204
* CalculatedDataElement to return.
205
* @return a CalculatedDataElement which contains the given DataElement, or
206
* null if the DataElement is not part of a CalculatedDataElement.
208
CalculatedDataElement getCalculatedDataElementByDataElement( DataElement dataElement );
211
* Returns CalculatedDataElements which contain any of the given DataElements
212
* @param dataElements Collection of DataElements which can be contained by
213
* the returned CalculatedDataElements
214
* @return a collection of CalculatedDataElements which contain any of the
215
* given DataElements, or an empty collection if no
216
* CalculatedDataElements contain any of the DataElements.
218
Collection<CalculatedDataElement> getCalculatedDataElementsByDataElements( Collection<DataElement> dataElements );
221
* Returns all CalculatedDataElements
222
* @return a collection of all CalculatedDataElements, or an empty collection
223
* if there are no CalculcatedDataELements
225
Collection<CalculatedDataElement> getAllCalculatedDataElements();
229
* Returns a Map of factors for the DataElements in the given
230
* CalculatedDataElement
232
* @param calculatedDataElement CalculatedDataElement to get factors for
233
* @return a map of factors for the DataElements in the given
234
* CalculatedDataElement
236
Map<DataElement, Integer> getDataElementFactors( CalculatedDataElement calculatedDataElement );
239
* Returns a Map of factors for the Operands in the given
240
* CalculatedDataElement
242
* @param calculatedDataElement CalculatedDataElement to get factors for
243
* @return a map of factors for the Operands in the given
244
* CalculatedDataElement
246
Map<String, Integer> getOperandFactors( CalculatedDataElement calculatedDataElement );
249
* Returns a collection of OperandIds in the given
250
* CalculatedDataElement
252
* @param calculatedDataElement CalculatedDataElement to get operands for
253
* @return a collection of operands (actually string) for the expression in
254
* the given CalculatedDataElement
256
Collection<String> getOperandIds( CalculatedDataElement calculatedDataElement );
258
// -------------------------------------------------------------------------
260
// -------------------------------------------------------------------------
263
* Adds a DataElementGroup.
265
* @param dataElementGroup the DataElementGroup to add.
266
* @return a generated unique id of the added DataElementGroup.
268
int addDataElementGroup( DataElementGroup dataElementGroup );
271
* Updates a DataElementGroup.
273
* @param dataElementGroup the DataElementGroup to update.
275
void updateDataElementGroup( DataElementGroup dataElementGroup );
278
* Deletes a DataElementGroup.
280
* @param dataElementGroup the DataElementGroup to delete.
282
void deleteDataElementGroup( DataElementGroup dataElementGroup );
285
* Returns a DataElementGroup.
287
* @param id the id of the DataElementGroup to return.
288
* @return the DataElementGroup with the given id, or null if no match.
290
DataElementGroup getDataElementGroup( int id );
293
* Returns the DataElementGroup with the given UUID.
295
* @param id the UUID of the DataElementGroup to return.
296
* @return the DataElementGroup with the given UUID, or null if no match.
298
DataElementGroup getDataElementGroup( String uuid );
301
* Returns a DataElementGroup with a given name.
303
* @param name the name of the DataElementGroup to return.
304
* @return the DataElementGroup with the given name, or null if no match.
306
DataElementGroup getDataElementGroupByName( String name );
309
* Returns all DataElementGroups.
311
* @return a collection of all DataElementGroups, or an empty collection if
312
* no DataElementGroups exist.
314
Collection<DataElementGroup> getAllDataElementGroups();
317
* Returns all DataElementGroups which contain the given DataElement.
318
* @param dataElement the DataElement which the DataElementGroups must contain.
319
* @return a collection of all DataElementGroups that contain the given DataElement.
321
Collection<DataElementGroup> getGroupsContainingDataElement( DataElement dataElement );