~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/datavalue/DataValueService.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.datavalue;
 
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.dataelement.DataElement;
 
33
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 
34
import org.hisp.dhis.period.Period;
 
35
import org.hisp.dhis.source.Source;
 
36
 
 
37
/**
 
38
 * The DataValueService interface defines how to work with data values.
 
39
 * 
 
40
 * @author Kristian Nordal
 
41
 * @version $Id: DataValueService.java 5715 2008-09-17 14:05:28Z larshelg $
 
42
 */
 
43
public interface DataValueService
 
44
{
 
45
    String ID = DataValueService.class.getName();
 
46
 
 
47
    /**
 
48
     * @deprecated To be removed
 
49
     */
 
50
    public static final String FLAG = "RoutineData";
 
51
 
 
52
    // -------------------------------------------------------------------------
 
53
    // Basic DataValue
 
54
    // -------------------------------------------------------------------------
 
55
 
 
56
    /**
 
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
 
59
     * persisted.
 
60
     * 
 
61
     * @param dataValue the DataValue to add.
 
62
     */
 
63
    void addDataValue( DataValue dataValue );
 
64
 
 
65
    /**
 
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.
 
69
     * 
 
70
     * @param dataValue the DataValue to update.
 
71
     */
 
72
    void updateDataValue( DataValue dataValue );
 
73
 
 
74
    /**
 
75
     * Deletes a DataValue.
 
76
     * 
 
77
     * @param dataValue the DataValue to delete.
 
78
     */
 
79
    void deleteDataValue( DataValue dataValue );
 
80
    
 
81
    /**
 
82
     * Deletes all DataValues connected to a Source.
 
83
     * 
 
84
     * @param source the Source for which the DataValues should be deleted.
 
85
     * @return the number of deleted DataValues.
 
86
     */
 
87
    int deleteDataValuesBySource( Source source );
 
88
 
 
89
    /**
 
90
     * Deletes all DataValues registered for the given DataElemt.
 
91
     * 
 
92
     * @param dataElement the DataElement for which the DataValues should be deleted.
 
93
     * @return the number of deleted DataValues.
 
94
     */
 
95
    int deleteDataValuesByDataElement( DataElement dataElement );
 
96
 
 
97
    /**
 
98
     * Returns a DataValue.
 
99
     * 
 
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
 
104
     *         if no match.
 
105
     */
 
106
    DataValue getDataValue( Source source, DataElement dataElement, Period period );
 
107
    
 
108
    /**
 
109
     * Returns a DataValue.
 
110
     * 
 
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
 
115
     *         if no match.
 
116
     */
 
117
    DataValue getDataValue( Source source, DataElement dataElement, Period period, DataElementCategoryOptionCombo optionCombo );
 
118
 
 
119
    // -------------------------------------------------------------------------
 
120
    // Collections of DataValues
 
121
    // -------------------------------------------------------------------------
 
122
 
 
123
    /**
 
124
     * Returns all DataValues.
 
125
     * 
 
126
     * @return a collection of all DataValues.
 
127
     */
 
128
    Collection<DataValue> getAllDataValues();
 
129
    
 
130
    /**
 
131
     * Returns all DataValues for a given Source and Period.
 
132
     * 
 
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.
 
137
     */
 
138
    Collection<DataValue> getDataValues( Source source, Period period );
 
139
 
 
140
    /**
 
141
     * Returns all DataValues for a given Source and DataElement.
 
142
     * 
 
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.
 
147
     */
 
148
    Collection<DataValue> getDataValues( Source source, DataElement dataElement );
 
149
 
 
150
    /**
 
151
     * Returns all DataValues for a given collection of Sources and a
 
152
     * DataElement.
 
153
     * 
 
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
 
158
     *         match.
 
159
     */
 
160
    Collection<DataValue> getDataValues( Collection<Source> sources, DataElement dataElement );
 
161
    
 
162
    /**
 
163
     * Returns all DataValues for a given Source, Period, collection of
 
164
     * DataElements and collection of optioncombos.
 
165
     * 
 
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
 
171
     *         values match.
 
172
     */
 
173
    Collection<DataValue> getDataValues( Source source, Period period, Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> optionCombos );
 
174
 
 
175
    /**
 
176
     * Returns all DataValues for a given Source, Period, and collection of
 
177
     * DataElements.
 
178
     * 
 
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
 
184
     *         values match.
 
185
     */
 
186
    Collection<DataValue> getDataValues( Source source, Period period, Collection<DataElement> dataElements );
 
187
    
 
188
    /**
 
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.
 
196
     */
 
197
    Collection<DataValue> getDataValues( DataElement dataElement, Collection<Period> periods, 
 
198
        Collection<? extends Source> sources );
 
199
 
 
200
    /**
 
201
     * Returns all DataValues for a given DataElement, DataElementCategoryOptionCombo,
 
202
     * collection of Periods, and collection of Sources.
 
203
     * 
 
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.
 
210
     */
 
211
    Collection<DataValue> getDataValues( DataElement dataElement, DataElementCategoryOptionCombo optionCombo, 
 
212
        Collection<Period> periods, Collection<? extends Source> sources );
 
213
    
 
214
    /**
 
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.
 
217
     * 
 
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.
 
225
     */
 
226
    Collection<DataValue> getDataValues( Collection<DataElement> dataElements, Collection<Period> periods, 
 
227
        Collection<? extends Source> sources, int firstResult, int maxResults );    
 
228
    
 
229
    /**
 
230
     * Returns all DataValues for a given collection of DataElementCategoryOptionCombos.
 
231
     * 
 
232
     * @param optionCombos the DataElementCategoryOptionCombos of the DataValue.
 
233
     * @return a collection of all DataValues which match the given collection of
 
234
     *         DataElementCategoryOptionCombos.
 
235
     */
 
236
    Collection<DataValue> getDataValues( Collection<DataElementCategoryOptionCombo> optionCombos );
 
237
    
 
238
    /**
 
239
     * Returns all DataValues for a given collection of DataElements.
 
240
     * 
 
241
     * @param dataElement the DataElements of the DataValue.
 
242
     * @return a collection of all DataValues which mach the given collection of DataElements.
 
243
     */
 
244
    Collection<DataValue> getDataValues( DataElement dataElement );
 
245
    
 
246
}