1
package org.hisp.dhis.dataset;
4
* Copyright (c) 2004-2007, University of Oslo All rights reserved.
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met: *
7
* Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer. * Redistributions in binary
9
* form must reproduce the above copyright notice, this list of conditions and
10
* the following disclaimer in the documentation and/or other materials provided
11
* with the distribution. * Neither the name of the HISP project nor the names
12
* of its contributors may be used to endorse or promote products derived from
13
* this software without specific prior written permission. THIS SOFTWARE IS
14
* PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17
* EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
import java.util.Collection;
27
import java.util.Date;
29
import org.apache.commons.collections.CollectionUtils;
30
import org.hisp.dhis.period.Period;
31
import org.hisp.dhis.source.Source;
34
* @author Lars Helge Overland
37
public class DefaultCompleteDataSetRegistrationService
38
implements CompleteDataSetRegistrationService
40
// -------------------------------------------------------------------------
42
// -------------------------------------------------------------------------
44
private CompleteDataSetRegistrationStore completeDataSetRegistrationStore;
46
public void setCompleteDataSetRegistrationStore( CompleteDataSetRegistrationStore completeDataSetRegistrationStore )
48
this.completeDataSetRegistrationStore = completeDataSetRegistrationStore;
51
// -------------------------------------------------------------------------
52
// CompleteDataSetRegistrationService
53
// -------------------------------------------------------------------------
55
public void saveCompleteDataSetRegistration( CompleteDataSetRegistration registration )
57
completeDataSetRegistrationStore.saveCompleteDataSetRegistration( registration );
59
public void deleteCompleteDataSetRegistration( CompleteDataSetRegistration registration )
61
completeDataSetRegistrationStore.deleteCompleteDataSetRegistration( registration );
64
public CompleteDataSetRegistration getCompleteDataSetRegistration( DataSet dataSet, Period period, Source source )
66
return completeDataSetRegistrationStore.getCompleteDataSetRegistration( dataSet, period, source );
69
public Collection<CompleteDataSetRegistration> getAllCompleteDataSetRegistrations()
71
return completeDataSetRegistrationStore.getAllCompleteDataSetRegistrations();
74
public Collection<CompleteDataSetRegistration> getCompleteDataSetRegistrations(
75
Collection<DataSet> dataSets, Collection<? extends Source> sources, Collection<Period> periods )
77
return completeDataSetRegistrationStore.getCompleteDataSetRegistrations( dataSets, sources, periods );
80
@SuppressWarnings( "unchecked" )
81
public int getCompleteDataSetRegistrationsForDataSet( DataSet dataSet, Collection<? extends Source> sources, Period period )
83
Collection<? extends Source> intersectingSources = CollectionUtils.intersection( sources, dataSet.getSources() );
85
if ( intersectingSources == null || intersectingSources.size() == 0 )
90
return completeDataSetRegistrationStore.getCompleteDataSetRegistrations( dataSet, intersectingSources, period ).size();
93
@SuppressWarnings( "unchecked" )
94
public int getCompleteDataSetRegistrationsForDataSet( DataSet dataSet, Collection<? extends Source> sources, Period period, Date deadline )
96
Collection<? extends Source> intersectingSources = CollectionUtils.intersection( sources, dataSet.getSources() );
98
if ( intersectingSources == null || intersectingSources.size() == 0 )
103
return completeDataSetRegistrationStore.getCompleteDataSetRegistrations( dataSet, intersectingSources, period, deadline ).size();
106
public void deleteCompleteDataSetRegistrations( DataSet dataSet )
108
completeDataSetRegistrationStore.deleteCompleteDataSetRegistrations( dataSet );