~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/DataElementService.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.util.Collection;
 
31
import java.util.Map;
 
32
 
 
33
import org.hisp.dhis.hierarchy.HierarchyViolationException;
 
34
 
 
35
/**
 
36
 * Defines service functionality for DataElements and DataElementGroups.
 
37
 * 
 
38
 * @author Kristian Nordal
 
39
 * @version $Id: DataElementService.java 6289 2008-11-14 17:53:24Z larshelg $
 
40
 */
 
41
public interface DataElementService
 
42
{
 
43
    String ID = DataElementService.class.getName();
 
44
 
 
45
    // -------------------------------------------------------------------------
 
46
    // DataElement
 
47
    // -------------------------------------------------------------------------
 
48
 
 
49
    /**
 
50
     * Adds a DataElement.
 
51
     * 
 
52
     * @param dataElement the DataElement to add.
 
53
     * @return a generated unique id of the added DataElement.
 
54
     */
 
55
    int addDataElement( DataElement dataElement );
 
56
 
 
57
    /**
 
58
     * Updates a DataElement.
 
59
     * 
 
60
     * @param dataElement the DataElement to update.
 
61
     */
 
62
    void updateDataElement( DataElement dataElement );
 
63
 
 
64
    /**
 
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.
 
68
     * 
 
69
     * @param dataElement the DataElement to delete.
 
70
     * @throws HierarchyViolationException if the DataElement has children.
 
71
     */
 
72
    void deleteDataElement( DataElement dataElement )
 
73
        throws HierarchyViolationException;
 
74
 
 
75
    /**
 
76
     * Returns a DataElement.
 
77
     * 
 
78
     * @param id the id of the DataElement to return.
 
79
     * @return the DataElement with the given id, or null if no match.
 
80
     */
 
81
    DataElement getDataElement( int id );
 
82
 
 
83
    /**
 
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.
 
87
     */
 
88
    DataElement getDataElement( String uuid );
 
89
 
 
90
    /**
 
91
     * Returns a DataElement with a given name.
 
92
     * 
 
93
     * @param name the name of the DataElement to return.
 
94
     * @return the DataElement with the given name, or null if no match.
 
95
     */
 
96
    DataElement getDataElementByName( String name );
 
97
 
 
98
    /**
 
99
     * Returns a DataElement with a given alternative name.
 
100
     * 
 
101
     * @param alternativeName the alternative name of the DataElement to return.
 
102
     * @return the DataElement with the given alternative name, or null if no
 
103
     *         match.
 
104
     */
 
105
    DataElement getDataElementByAlternativeName( String alternativeName );
 
106
 
 
107
    /**
 
108
     * Returns a DataElement with a given short name.
 
109
     * 
 
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.
 
112
     */
 
113
    DataElement getDataElementByShortName( String shortName );
 
114
 
 
115
    /**
 
116
     * Returns a DataElement with a given code.
 
117
     * 
 
118
     * @param code the code of the DataElement to return.
 
119
     * @return the DataElement with the given code, or null if no match.
 
120
     */
 
121
    DataElement getDataElementByCode( String code );
 
122
 
 
123
    /**
 
124
     * Returns all DataElements.
 
125
     * 
 
126
     * @return a collection of all DataElements, or an empty collection if there
 
127
     *         are no DataElements.
 
128
     */
 
129
    Collection<DataElement> getAllDataElements();
 
130
    
 
131
    /**
 
132
     * Returns all DataElements which are instances of CalculatedDataElement.
 
133
     * 
 
134
     * @return all DataElements which are instances of CalculatedDataElement.
 
135
     */
 
136
    Collection<CalculatedDataElement> getCalculatedDataElements();
 
137
    
 
138
    /**
 
139
     * Returns all DataElements which are not instances of CalculatedDataElements.
 
140
     * 
 
141
     * @return all DataElements which are not instances of CalculatedDataElements.
 
142
     */
 
143
    Collection<DataElement> getNonCalculatedDataElements();
 
144
    
 
145
    /**
 
146
     * Returns all DataElements with corresponding identifiers.
 
147
     * 
 
148
     * @param identifiers the collection of identifiers.
 
149
     * @return a collection of DataElements.
 
150
     */
 
151
    Collection<DataElement> getDataElements( Collection<Integer> identifiers );
 
152
    
 
153
    /**
 
154
     * Returns all DataElements with types that are possible to aggregate. The
 
155
     * types are currently INT and BOOL.
 
156
     * 
 
157
     * @return all DataElements with types that are possible to aggregate.
 
158
     */
 
159
    Collection<DataElement> getAggregateableDataElements();
 
160
    
 
161
    /**
 
162
     * Returns all active DataElements.
 
163
     * 
 
164
     * @return a collection of all active DataElements, or an empty collection
 
165
     *         if there are no active DataElements.
 
166
     */
 
167
    Collection<DataElement> getAllActiveDataElements();
 
168
 
 
169
    /**
 
170
     * Returns all DataElements with a given aggregantion operator.
 
171
     * 
 
172
     * @param aggregationOperator the aggregation operator of the DataElements
 
173
     *        to return.
 
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.
 
177
     */
 
178
    Collection<DataElement> getDataElementsByAggregationOperator( String aggregationOperator );
 
179
 
 
180
    /**
 
181
     * Returns all DataElements with the given type.
 
182
     * 
 
183
     * @param type the type.
 
184
     * @return all DataElements with the given type.
 
185
     */
 
186
    Collection<DataElement> getDataElementsByType( String type );
 
187
 
 
188
    /**
 
189
     * Returns all DataElements with the given category combo.
 
190
     * 
 
191
     * @param categoryCombo the DataElementCategoryCombo.
 
192
     * @return all DataElements with the given category combo.
 
193
     */
 
194
    Collection<DataElement> getDataElementByCategoryCombo( DataElementCategoryCombo categoryCombo );
 
195
    
 
196
    // -------------------------------------------------------------------------
 
197
    // Calculated Data Elements
 
198
    // -------------------------------------------------------------------------
 
199
 
 
200
    /**
 
201
     * Returns a CalclulatedDataElement which contains a given dataElement
 
202
     * 
 
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.
 
207
     */
 
208
    CalculatedDataElement getCalculatedDataElementByDataElement( DataElement dataElement );
 
209
    
 
210
    /**
 
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.
 
217
     */
 
218
    Collection<CalculatedDataElement> getCalculatedDataElementsByDataElements( Collection<DataElement> dataElements );
 
219
    
 
220
    /**
 
221
     * Returns all CalculatedDataElements
 
222
     * @return a collection of all CalculatedDataElements, or an empty collection
 
223
     *          if there are no CalculcatedDataELements
 
224
     */
 
225
    Collection<CalculatedDataElement> getAllCalculatedDataElements();
 
226
    
 
227
 
 
228
    /**
 
229
     * Returns a Map of factors for the DataElements in the given
 
230
     * CalculatedDataElement
 
231
     * 
 
232
     * @param calculatedDataElement CalculatedDataElement to get factors for
 
233
     * @return a map of factors for the DataElements in the given
 
234
     *         CalculatedDataElement
 
235
     */
 
236
    Map<DataElement, Integer> getDataElementFactors( CalculatedDataElement calculatedDataElement );
 
237
    
 
238
    /**
 
239
     * Returns a Map of factors for the Operands in the given
 
240
     * CalculatedDataElement
 
241
     * 
 
242
     * @param calculatedDataElement CalculatedDataElement to get factors for
 
243
     * @return a map of factors for the Operands in the given
 
244
     *         CalculatedDataElement
 
245
     */
 
246
    Map<String, Integer> getOperandFactors( CalculatedDataElement calculatedDataElement );    
 
247
    
 
248
    /**
 
249
     * Returns a collection of OperandIds in the given
 
250
     * CalculatedDataElement
 
251
     * 
 
252
     * @param calculatedDataElement CalculatedDataElement to get operands for
 
253
     * @return a collection of operands (actually string) for the expression in 
 
254
     * the given CalculatedDataElement
 
255
     */
 
256
    Collection<String> getOperandIds( CalculatedDataElement calculatedDataElement );
 
257
    
 
258
    // -------------------------------------------------------------------------
 
259
    // DataElementGroup
 
260
    // -------------------------------------------------------------------------
 
261
 
 
262
    /**
 
263
     * Adds a DataElementGroup.
 
264
     * 
 
265
     * @param dataElementGroup the DataElementGroup to add.
 
266
     * @return a generated unique id of the added DataElementGroup.
 
267
     */
 
268
    int addDataElementGroup( DataElementGroup dataElementGroup );
 
269
 
 
270
    /**
 
271
     * Updates a DataElementGroup.
 
272
     * 
 
273
     * @param dataElementGroup the DataElementGroup to update.
 
274
     */
 
275
    void updateDataElementGroup( DataElementGroup dataElementGroup );
 
276
 
 
277
    /**
 
278
     * Deletes a DataElementGroup.
 
279
     * 
 
280
     * @param dataElementGroup the DataElementGroup to delete.
 
281
     */
 
282
    void deleteDataElementGroup( DataElementGroup dataElementGroup );
 
283
 
 
284
    /**
 
285
     * Returns a DataElementGroup.
 
286
     * 
 
287
     * @param id the id of the DataElementGroup to return.
 
288
     * @return the DataElementGroup with the given id, or null if no match.
 
289
     */
 
290
    DataElementGroup getDataElementGroup( int id );
 
291
 
 
292
    /**
 
293
     * Returns the DataElementGroup with the given UUID.
 
294
     * 
 
295
     * @param id the UUID of the DataElementGroup to return.
 
296
     * @return the DataElementGroup with the given UUID, or null if no match.
 
297
     */
 
298
    DataElementGroup getDataElementGroup( String uuid );
 
299
 
 
300
    /**
 
301
     * Returns a DataElementGroup with a given name.
 
302
     * 
 
303
     * @param name the name of the DataElementGroup to return.
 
304
     * @return the DataElementGroup with the given name, or null if no match.
 
305
     */
 
306
    DataElementGroup getDataElementGroupByName( String name );
 
307
 
 
308
    /**
 
309
     * Returns all DataElementGroups.
 
310
     * 
 
311
     * @return a collection of all DataElementGroups, or an empty collection if
 
312
     *         no DataElementGroups exist.
 
313
     */
 
314
    Collection<DataElementGroup> getAllDataElementGroups();
 
315
    
 
316
    /**
 
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.
 
320
     */
 
321
    Collection<DataElementGroup> getGroupsContainingDataElement( DataElement dataElement );    
 
322
    
 
323
}