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
* Defines the functionality for persisting DataValues.
40
* @author Torgeir Lorange Ostby
41
* @version $Id: DataValueStore.java 5715 2008-09-17 14:05:28Z larshelg $
43
public interface DataValueStore
45
String ID = DataValueStore.class.getName();
47
// -------------------------------------------------------------------------
49
// -------------------------------------------------------------------------
54
* @param dataValue the DataValue to add.
56
void addDataValue( DataValue dataValue );
59
* Updates a DataValue.
61
* @param dataValue the DataValue to update.
63
void updateDataValue( DataValue dataValue );
66
* Deletes a DataValue.
68
* @param dataValue the DataValue to delete.
70
void deleteDataValue( DataValue dataValue );
73
* Deletes all DataValues registered for the given Source.
75
* @param source the Source for which the DataValues should be deleted.
76
* @return the number of deleted DataValues.
78
int deleteDataValuesBySource( Source source );
81
* Deletes all DataValues registered for the given DataElement.
83
* @param dataElement the DataElement for which the DataValues should be deleted.
84
* @return the number of deleted DataValues.
86
int deleteDataValuesByDataElement( DataElement dataElement );
89
* Returns a DataValue.
91
* @param source the Source of the DataValue.
92
* @param dataElement the DataElement of the DataValue.
93
* @param period the Period of the DataValue.
94
* @return the DataValue which corresponds to the given parameters, or null
97
DataValue getDataValue( Source source, DataElement dataElement, Period period );
100
* Returns a DataValue.
102
* @param source the Source of the DataValue.
103
* @param dataElement the DataElement of the DataValue.
104
* @param period the Period of the DataValue.
105
* @return the DataValue which corresponds to the given parameters, or null
108
DataValue getDataValue( Source source, DataElement dataElement, Period period, DataElementCategoryOptionCombo optionCombo );
110
// -------------------------------------------------------------------------
111
// Collections of DataValues
112
// -------------------------------------------------------------------------
115
* Returns all DataValues.
117
* @return a collection of all DataValues.
119
Collection<DataValue> getAllDataValues();
122
* Returns all DataValues for a given Source and Period.
124
* @param source the Source of the DataValues.
125
* @param period the Period of the DataValues.
126
* @return a collection of all DataValues which match the given Source and
127
* Period, or an empty collection if no values match.
129
Collection<DataValue> getDataValues( Source source, Period period );
132
* Returns all DataValues for a given Source and DataElement.
134
* @param source the Source of the DataValues.
135
* @param dataElement the DataElement of the DataValues.
136
* @return a collection of all DataValues which match the given Source and
137
* DataElement, or an empty collection if no values match.
139
Collection<DataValue> getDataValues( Source source, DataElement dataElement );
142
* Returns all DataValues for a given collection of Sources and a
145
* @param sources the Sources of the DataValues.
146
* @param dataElement the DataElement of the DataValues.
147
* @return a collection of all DataValues which match any of the given
148
* Sources and the DataElement, or an empty collection if no values
151
Collection<DataValue> getDataValues( Collection<? extends Source> sources, DataElement dataElement );
154
* Returns all DataValues for a given Source, Period, and collection of
157
* @param source the Source of the DataValues.
158
* @param period the Period of the DataValues.
159
* @param dataElements the DataElements of the DataValues.
160
* @return a collection of all DataValues which match the given Source,
161
* Period, and any of the DataElements, or an empty collection if no
164
Collection<DataValue> getDataValues( Source source, Period period, Collection<DataElement> dataElements );
167
* Returns all DataValues for a given Source, Period, collection of
168
* DataElements and collection of optioncombos.
170
* @param source the Source of the DataValues.
171
* @param period the Period of the DataValues.
172
* @param dataElements the DataElements of the DataValues.
173
* @return a collection of all DataValues which match the given Source,
174
* Period, and any of the DataElements, or an empty collection if no
177
Collection<DataValue> getDataValues( Source source, Period period, Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> optionCombos );
180
* Returns all DataValues for a given DataElement, collection of Periods, and
181
* collection of Sources.
183
* @param dataElement the DataElements of the DataValues.
184
* @param periods the Periods of the DataValues.
185
* @param sources the Sources of the DataValues.
186
* @return a collection of all DataValues which match the given DataElement,
187
* Periods, and Sources.
189
Collection<DataValue> getDataValues( DataElement dataElement, Collection<Period> periods,
190
Collection<? extends Source> sources );
193
* Returns all DataValues for a given DataElement, DataElementCategoryOptionCombo,
194
* collection of Periods, and collection of Sources.
196
* @param dataElement the DataElements of the DataValues.
197
* @param optionCombo the DataElementCategoryOptionCombo of the DataValues.
198
* @param periods the Periods of the DataValues.
199
* @param sources the Sources of the DataValues.
200
* @return a collection of all DataValues which match the given DataElement,
201
* Periods, and Sources.
203
Collection<DataValue> getDataValues( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
204
Collection<Period> periods, Collection<? extends Source> sources );
207
* Returns all DataValues for a given collection of DataElements, collection of Periods, and
208
* collection of Sources, limited by a given start indexs and number of elements to return.
210
* @param dataElements the DataElements of the DataValue.
211
* @param periods the Periods of the DataValue.
212
* @param sources the Sources of the DataValues.
213
* @param firstResult the zero-based index of the first DataValue in the collection to return.
214
* @param maxResults the maximum number of DataValues to return. 0 means no restrictions.
215
* @return a collection of all DataValues which match the given collection of DataElements,
216
* Periods, and Sources, limited by the firstResult and maxResults property.
218
Collection<DataValue> getDataValues( Collection<DataElement> dataElements, Collection<Period> periods,
219
Collection<? extends Source> sources, int firstResult, int maxResults );
222
* Returns all DataValues for a given collection of DataElementCategoryOptionCombos.
224
* @param optionCombos the DataElementCategoryOptionCombos of the DataValue.
225
* @return a collection of all DataValues which match the given collection of
226
* DataElementCategoryOptionCombos.
228
Collection<DataValue> getDataValues( Collection<DataElementCategoryOptionCombo> optionCombos );
231
* Returns all DataValues for a given collection of DataElements.
233
* @param dataElement the DataElements of the DataValue.
234
* @return a collection of all DataValues which mach the given collection of DataElements.
236
Collection<DataValue> getDataValues( DataElement dataElement );