~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/DataValueStore.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
 * Defines the functionality for persisting DataValues.
 
39
 * 
 
40
 * @author Torgeir Lorange Ostby
 
41
 * @version $Id: DataValueStore.java 5715 2008-09-17 14:05:28Z larshelg $
 
42
 */
 
43
public interface DataValueStore
 
44
{
 
45
    String ID = DataValueStore.class.getName();
 
46
 
 
47
    // -------------------------------------------------------------------------
 
48
    // Basic DataValue
 
49
    // -------------------------------------------------------------------------
 
50
 
 
51
    /**
 
52
     * Adds a DataValue.
 
53
     * 
 
54
     * @param dataValue the DataValue to add.
 
55
     */
 
56
    void addDataValue( DataValue dataValue );
 
57
 
 
58
    /**
 
59
     * Updates a DataValue.
 
60
     * 
 
61
     * @param dataValue the DataValue to update.
 
62
     */
 
63
    void updateDataValue( DataValue dataValue );
 
64
 
 
65
    /**
 
66
     * Deletes a DataValue.
 
67
     * 
 
68
     * @param dataValue the DataValue to delete.
 
69
     */
 
70
    void deleteDataValue( DataValue dataValue );
 
71
    
 
72
    /**
 
73
     * Deletes all DataValues registered for the given Source.
 
74
     * 
 
75
     * @param source the Source for which the DataValues should be deleted.
 
76
     * @return the number of deleted DataValues.
 
77
     */
 
78
    int deleteDataValuesBySource( Source source );
 
79
    
 
80
    /**
 
81
     * Deletes all DataValues registered for the given DataElement.
 
82
     * 
 
83
     * @param dataElement the DataElement for which the DataValues should be deleted.
 
84
     * @return the number of deleted DataValues.
 
85
     */
 
86
    int deleteDataValuesByDataElement( DataElement dataElement );
 
87
    
 
88
    /**
 
89
     * Returns a DataValue.
 
90
     * 
 
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
 
95
     *         if no match.
 
96
     */
 
97
    DataValue getDataValue( Source source, DataElement dataElement, Period period );
 
98
    
 
99
    /**
 
100
     * Returns a DataValue.
 
101
     * 
 
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
 
106
     *         if no match.
 
107
     */
 
108
    DataValue getDataValue( Source source, DataElement dataElement, Period period, DataElementCategoryOptionCombo optionCombo );
 
109
 
 
110
    // -------------------------------------------------------------------------
 
111
    // Collections of DataValues
 
112
    // -------------------------------------------------------------------------
 
113
 
 
114
    /**
 
115
     * Returns all DataValues.
 
116
     * 
 
117
     * @return a collection of all DataValues.
 
118
     */
 
119
    Collection<DataValue> getAllDataValues();
 
120
    
 
121
    /**
 
122
     * Returns all DataValues for a given Source and Period.
 
123
     * 
 
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.
 
128
     */
 
129
    Collection<DataValue> getDataValues( Source source, Period period );
 
130
    
 
131
    /**
 
132
     * Returns all DataValues for a given Source and DataElement.
 
133
     * 
 
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.
 
138
     */
 
139
    Collection<DataValue> getDataValues( Source source, DataElement dataElement );
 
140
 
 
141
    /**
 
142
     * Returns all DataValues for a given collection of Sources and a
 
143
     * DataElement.
 
144
     * 
 
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
 
149
     *         match.
 
150
     */
 
151
    Collection<DataValue> getDataValues( Collection<? extends Source> sources, DataElement dataElement );
 
152
 
 
153
    /**
 
154
     * Returns all DataValues for a given Source, Period, and collection of
 
155
     * DataElements.
 
156
     * 
 
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
 
162
     *         values match.
 
163
     */
 
164
    Collection<DataValue> getDataValues( Source source, Period period, Collection<DataElement> dataElements );
 
165
    
 
166
    /**
 
167
     * Returns all DataValues for a given Source, Period, collection of
 
168
     * DataElements and collection of optioncombos.
 
169
     * 
 
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
 
175
     *         values match.
 
176
     */
 
177
    Collection<DataValue> getDataValues( Source source, Period period, Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> optionCombos );
 
178
    
 
179
    /**
 
180
     * Returns all DataValues for a given DataElement, collection of Periods, and 
 
181
     * collection of Sources.
 
182
     * 
 
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.
 
188
     */
 
189
    Collection<DataValue> getDataValues( DataElement dataElement, Collection<Period> periods, 
 
190
        Collection<? extends Source> sources );
 
191
    
 
192
    /**
 
193
     * Returns all DataValues for a given DataElement, DataElementCategoryOptionCombo,
 
194
     * collection of Periods, and collection of Sources.
 
195
     * 
 
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.
 
202
     */
 
203
    Collection<DataValue> getDataValues( DataElement dataElement, DataElementCategoryOptionCombo optionCombo, 
 
204
        Collection<Period> periods, Collection<? extends Source> sources );
 
205
    
 
206
    /**
 
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.
 
209
     * 
 
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.
 
217
     */
 
218
    Collection<DataValue> getDataValues( Collection<DataElement> dataElements, Collection<Period> periods, 
 
219
        Collection<? extends Source> sources, int firstResult, int maxResults );
 
220
    
 
221
    /**
 
222
     * Returns all DataValues for a given collection of DataElementCategoryOptionCombos.
 
223
     * 
 
224
     * @param optionCombos the DataElementCategoryOptionCombos of the DataValue.
 
225
     * @return a collection of all DataValues which match the given collection of
 
226
     *         DataElementCategoryOptionCombos.
 
227
     */
 
228
    Collection<DataValue> getDataValues( Collection<DataElementCategoryOptionCombo> optionCombos );
 
229
    
 
230
    /**
 
231
     * Returns all DataValues for a given collection of DataElements.
 
232
     * 
 
233
     * @param dataElement the DataElements of the DataValue.
 
234
     * @return a collection of all DataValues which mach the given collection of DataElements.
 
235
     */
 
236
    Collection<DataValue> getDataValues( DataElement dataElement );   
 
237
}