~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/DataElementStore.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
 
 
32
import org.hisp.dhis.hierarchy.HierarchyViolationException;
 
33
 
 
34
/**
 
35
 * Defines the functionality for persisting DataElements and DataElementGroups.
 
36
 * 
 
37
 * @author Torgeir Lorange Ostby
 
38
 * @version $Id: DataElementStore.java 6289 2008-11-14 17:53:24Z larshelg $
 
39
 */
 
40
public interface DataElementStore
 
41
{
 
42
    String ID = DataElementStore.class.getName();
 
43
 
 
44
    // -------------------------------------------------------------------------
 
45
    // DataElement
 
46
    // -------------------------------------------------------------------------
 
47
 
 
48
    /**
 
49
     * Adds a DataElement.
 
50
     * 
 
51
     * @param dataElement the DataElement to add.
 
52
     * @return a generated unique id of the added DataElement.
 
53
     */
 
54
    int addDataElement( DataElement dataElement );
 
55
 
 
56
    /**
 
57
     * Updates a DataElement.
 
58
     * 
 
59
     * @param dataElement the DataElement to update.
 
60
     */
 
61
    void updateDataElement( DataElement dataElement );
 
62
 
 
63
    /**
 
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.
 
67
     * 
 
68
     * @param dataElement the DataElement to delete.
 
69
     * @throws HierarchyViolationException if the DataElement has children.
 
70
     */
 
71
    void deleteDataElement( DataElement dataElement )
 
72
        throws HierarchyViolationException;
 
73
 
 
74
    /**
 
75
     * Returns a DataElement.
 
76
     * 
 
77
     * @param id the id of the DataElement to return.
 
78
     * @return the DataElement with the given id, or null if no match.
 
79
     */
 
80
    DataElement getDataElement( int id );
 
81
    
 
82
    /**
 
83
     * Returns the DataElement with the given UUID.
 
84
     * 
 
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 with types that are possible to aggregate. The
 
133
     * types are currently INT and BOOL.
 
134
     * 
 
135
     * @return all DataElements with types that are possible to aggregate.
 
136
     */
 
137
    Collection<DataElement> getAggregateableDataElements();
 
138
    
 
139
    /**
 
140
     * Returns all active DataElements.
 
141
     * 
 
142
     * @return a collection of all active DataElements, or an empty collection
 
143
     *         if there are no active DataElements.
 
144
     */
 
145
    Collection<DataElement> getAllActiveDataElements();
 
146
 
 
147
    /**
 
148
     * Returns all DataElements with a given aggregantion operator.
 
149
     * 
 
150
     * @param aggregationOperator the aggregation operator of the DataElements
 
151
     *        to return.
 
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.
 
155
     */
 
156
    Collection<DataElement> getDataElementsByAggregationOperator( String aggregationOperator );
 
157
 
 
158
    /**
 
159
     * Returns all DataElements with the given type.
 
160
     * 
 
161
     * @param type the type.
 
162
     * @return all DataElements with the given type.
 
163
     */
 
164
    Collection<DataElement> getDataElementsByType( String type );
 
165
    
 
166
    /**
 
167
     * Returns all DataElements with the given category combo.
 
168
     * 
 
169
     * @param categoryCombo the DataElementCategoryCombo.
 
170
     * @return all DataElements with the given category combo.
 
171
     */
 
172
    Collection<DataElement> getDataElementByCategoryCombo( DataElementCategoryCombo categoryCombo );
 
173
    
 
174
    // -------------------------------------------------------------------------
 
175
    // Calculated Data Elements
 
176
    // -------------------------------------------------------------------------
 
177
 
 
178
    /**
 
179
     * Returns a CalclulatedDataElement which contains a given dataElement
 
180
     * 
 
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.
 
185
     */
 
186
    CalculatedDataElement getCalculatedDataElementByDataElement( DataElement dataElement );
 
187
    
 
188
    /**
 
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.
 
195
     */
 
196
    Collection<CalculatedDataElement> getCalculatedDataElementsByDataElements( Collection<DataElement> dataElements );
 
197
    
 
198
    /**
 
199
     * Returns all CalculatedDataElements
 
200
     * @return a collection of all CalculatedDataElements, or an empty collection
 
201
     *          if there are no CalculcatedDataELements
 
202
     */
 
203
    Collection<CalculatedDataElement> getAllCalculatedDataElements();
 
204
    
 
205
    // -------------------------------------------------------------------------
 
206
    // DataElementGroup
 
207
    // -------------------------------------------------------------------------
 
208
 
 
209
    /**
 
210
     * Adds a DataElementGroup.
 
211
     * 
 
212
     * @param dataElementGroup the DataElementGroup to add.
 
213
     * @return a generated unique id of the added DataElementGroup.
 
214
     */
 
215
    int addDataElementGroup( DataElementGroup dataElementGroup );
 
216
 
 
217
    /**
 
218
     * Updates a DataElementGroup.
 
219
     * 
 
220
     * @param dataElementGroup the DataElementGroup to update.
 
221
     */
 
222
    void updateDataElementGroup( DataElementGroup dataElementGroup );
 
223
 
 
224
    /**
 
225
     * Deletes a DataElementGroup.
 
226
     * 
 
227
     * @param dataElementGroup the DataElementGroup to delete.
 
228
     */
 
229
    void deleteDataElementGroup( DataElementGroup dataElementGroup );
 
230
 
 
231
    /**
 
232
     * Returns a DataElementGroup.
 
233
     * 
 
234
     * @param id the id of the DataElementGroup to return.
 
235
     * @return the DataElementGroup with the given id, or null if no match.
 
236
     */
 
237
    DataElementGroup getDataElementGroup( int id );
 
238
 
 
239
    /**
 
240
     * Returns the DataElementGroup with the given UUID.
 
241
     * 
 
242
     * @param id the UUID.
 
243
     * @return the DataElementGroup with the given uuid, or null if no match.
 
244
     */
 
245
    DataElementGroup getDataElementGroup( String uuid );
 
246
 
 
247
    /**
 
248
     * Returns a DataElementGroup with a given name.
 
249
     * 
 
250
     * @param name the name of the DataElementGroup to return.
 
251
     * @return the DataElementGroup with the given name, or null if no match.
 
252
     */
 
253
    DataElementGroup getDataElementGroupByName( String name );
 
254
 
 
255
    /**
 
256
     * Returns all DataElementGroups.
 
257
     * 
 
258
     * @return a collection of all DataElementGroups, or an empty collection if
 
259
     *         no DataElementGroups exist.
 
260
     */
 
261
    Collection<DataElementGroup> getAllDataElementGroups();
 
262
 
 
263
}