1
package org.hisp.dhis.datavalue;
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.dataelement.DataElement;
33
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
34
import org.hisp.dhis.period.Period;
35
import org.hisp.dhis.source.Source;
38
* The DataValueService interface defines how to work with data values.
40
* @author Kristian Nordal
41
* @version $Id: DataValueService.java 5715 2008-09-17 14:05:28Z larshelg $
43
public interface DataValueService
45
String ID = DataValueService.class.getName();
48
* @deprecated To be removed
50
public static final String FLAG = "RoutineData";
52
// -------------------------------------------------------------------------
54
// -------------------------------------------------------------------------
57
* Adds a DataValue. If both the value and the comment properties of the
58
* specified DataValue object are null, then the object should not be
61
* @param dataValue the DataValue to add.
63
void addDataValue( DataValue dataValue );
66
* Updates a DataValue. If both the value and the comment properties of the
67
* specified DataValue object are null, then the object should be deleted
68
* from the underlying storage.
70
* @param dataValue the DataValue to update.
72
void updateDataValue( DataValue dataValue );
75
* Deletes a DataValue.
77
* @param dataValue the DataValue to delete.
79
void deleteDataValue( DataValue dataValue );
82
* Deletes all DataValues connected to a Source.
84
* @param source the Source for which the DataValues should be deleted.
85
* @return the number of deleted DataValues.
87
int deleteDataValuesBySource( Source source );
90
* Deletes all DataValues registered for the given DataElemt.
92
* @param dataElement the DataElement for which the DataValues should be deleted.
93
* @return the number of deleted DataValues.
95
int deleteDataValuesByDataElement( DataElement dataElement );
98
* Returns a DataValue.
100
* @param source the Source of the DataValue.
101
* @param dataElement the DataElement of the DataValue.
102
* @param period the Period of the DataValue.
103
* @return the DataValue which corresponds to the given parameters, or null
106
DataValue getDataValue( Source source, DataElement dataElement, Period period );
109
* Returns a DataValue.
111
* @param source the Source of the DataValue.
112
* @param dataElement the DataElement of the DataValue.
113
* @param period the Period of the DataValue.
114
* @return the DataValue which corresponds to the given parameters, or null
117
DataValue getDataValue( Source source, DataElement dataElement, Period period, DataElementCategoryOptionCombo optionCombo );
119
// -------------------------------------------------------------------------
120
// Collections of DataValues
121
// -------------------------------------------------------------------------
124
* Returns all DataValues.
126
* @return a collection of all DataValues.
128
Collection<DataValue> getAllDataValues();
131
* Returns all DataValues for a given Source and Period.
133
* @param source the Source of the DataValues.
134
* @param period the Period of the DataValues.
135
* @return a collection of all DataValues which match the given Source and
136
* Period, or an empty collection if no values match.
138
Collection<DataValue> getDataValues( Source source, Period period );
141
* Returns all DataValues for a given Source and DataElement.
143
* @param source the Source of the DataValues.
144
* @param dataElement the DataElement of the DataValues.
145
* @return a collection of all DataValues which match the given Source and
146
* DataElement, or an empty collection if no values match.
148
Collection<DataValue> getDataValues( Source source, DataElement dataElement );
151
* Returns all DataValues for a given collection of Sources and a
154
* @param sources the Sources of the DataValues.
155
* @param dataElement the DataElement of the DataValues.
156
* @return a collection of all DataValues which match any of the given
157
* Sources and the DataElement, or an empty collection if no values
160
Collection<DataValue> getDataValues( Collection<Source> sources, DataElement dataElement );
163
* Returns all DataValues for a given Source, Period, collection of
164
* DataElements and collection of optioncombos.
166
* @param source the Source of the DataValues.
167
* @param period the Period of the DataValues.
168
* @param dataElements the DataElements of the DataValues.
169
* @return a collection of all DataValues which match the given Source,
170
* Period, and any of the DataElements, or an empty collection if no
173
Collection<DataValue> getDataValues( Source source, Period period, Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> optionCombos );
176
* Returns all DataValues for a given Source, Period, and collection of
179
* @param source the Source of the DataValues.
180
* @param period the Period of the DataValues.
181
* @param dataElements the DataElements of the DataValues.
182
* @return a collection of all DataValues which match the given Source,
183
* Period, and any of the DataElements, or an empty collection if no
186
Collection<DataValue> getDataValues( Source source, Period period, Collection<DataElement> dataElements );
189
* Returns all DataValues for a given DataElement, collection of Periods, and
190
* collection of Sources
191
* @param dataElement the dataElements of the DataValues.
192
* @param periods the periods of the DataValues.
193
* @param sources the Sources of the DataValues.
194
* @return a collection of all DataValues which match the given DataElement,
195
* Periods, and Sources.
197
Collection<DataValue> getDataValues( DataElement dataElement, Collection<Period> periods,
198
Collection<? extends Source> sources );
201
* Returns all DataValues for a given DataElement, DataElementCategoryOptionCombo,
202
* collection of Periods, and collection of Sources.
204
* @param dataElement the DataElements of the DataValues.
205
* @param optionCombo the DataElementCategoryOptionCombo of the DataValues.
206
* @param periods the Periods of the DataValues.
207
* @param sources the Sources of the DataValues.
208
* @return a collection of all DataValues which match the given DataElement,
209
* Periods, and Sources.
211
Collection<DataValue> getDataValues( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
212
Collection<Period> periods, Collection<? extends Source> sources );
215
* Returns all DataValues for a given collection of DataElements, collection of Periods, and
216
* collection of Sources, limited by a given start indexs and number of elements to return.
218
* @param dataElements the DataElements of the DataValue.
219
* @param periods the Periods of the DataValue.
220
* @param sources the Sources of the DataValues.
221
* @param firstResult the zero-based index of the first DataValue in the collection to return.
222
* @param maxResults the maximum number of DataValues to return. 0 means no restrictions.
223
* @return a collection of all DataValues which match the given collection of DataElements,
224
* Periods, and Sources, limited by the firstResult and maxResults property.
226
Collection<DataValue> getDataValues( Collection<DataElement> dataElements, Collection<Period> periods,
227
Collection<? extends Source> sources, int firstResult, int maxResults );
230
* Returns all DataValues for a given collection of DataElementCategoryOptionCombos.
232
* @param optionCombos the DataElementCategoryOptionCombos of the DataValue.
233
* @return a collection of all DataValues which match the given collection of
234
* DataElementCategoryOptionCombos.
236
Collection<DataValue> getDataValues( Collection<DataElementCategoryOptionCombo> optionCombos );
239
* Returns all DataValues for a given collection of DataElements.
241
* @param dataElement the DataElements of the DataValue.
242
* @return a collection of all DataValues which mach the given collection of DataElements.
244
Collection<DataValue> getDataValues( DataElement dataElement );