1
package org.hisp.dhis.dashboard.ga.action;
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.text.SimpleDateFormat;
31
import java.util.ArrayList;
32
import java.util.Collection;
33
import java.util.Collections;
34
import java.util.Comparator;
35
import java.util.List;
37
import org.hisp.dhis.dashboard.util.PeriodStartDateComparator;
38
import org.hisp.dhis.dataelement.DataElement;
39
import org.hisp.dhis.dataelement.DataElementGroup;
40
import org.hisp.dhis.dataelement.DataElementService;
41
import org.hisp.dhis.dataelement.comparator.DataElementGroupNameComparator;
42
import org.hisp.dhis.dataelement.comparator.DataElementNameComparator;
43
import org.hisp.dhis.indicator.Indicator;
44
import org.hisp.dhis.indicator.IndicatorGroup;
45
import org.hisp.dhis.indicator.IndicatorService;
46
import org.hisp.dhis.indicator.comparator.IndicatorGroupNameComparator;
47
import org.hisp.dhis.indicator.comparator.IndicatorNameComparator;
48
import org.hisp.dhis.organisationunit.OrganisationUnit;
49
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
50
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
51
import org.hisp.dhis.organisationunit.OrganisationUnitService;
52
import org.hisp.dhis.period.MonthlyPeriodType;
53
import org.hisp.dhis.period.Period;
54
import org.hisp.dhis.period.PeriodStore;
56
import com.opensymphony.xwork.ActionSupport;
58
public class GenerateGraphicalAnalyserFormAction
61
// -------------------------------------------------------------------------
63
// -------------------------------------------------------------------------
65
private IndicatorService indicatorService;
67
public void setIndicatorService( IndicatorService indicatorService )
69
this.indicatorService = indicatorService;
72
private DataElementService dataElementService;
74
public void setDataElementService( DataElementService dataElementService )
76
this.dataElementService = dataElementService;
79
private PeriodStore periodStore;
81
public void setPeriodStore( PeriodStore periodStore )
83
this.periodStore = periodStore;
86
private OrganisationUnitService organisationUnitService;
88
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
90
this.organisationUnitService = organisationUnitService;
93
private OrganisationUnitGroupService organisationUnitGroupService;
95
public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
97
this.organisationUnitGroupService = organisationUnitGroupService;
100
// -------------------------------------------------------------------------
102
// -------------------------------------------------------------------------
104
private Comparator<DataElementGroup> dataElementGroupComparator;
106
public void setDataElementGroupComparator( Comparator<DataElementGroup> dataElementGroupComparator )
108
this.dataElementGroupComparator = dataElementGroupComparator;
112
// -------------------------------------------------------------------------
114
// -------------------------------------------------------------------------
116
private final static int ALL = 0;
118
private final static int DATAVALUE = 1;
120
private final static int INDICATORVALUE = 2;
127
public int getDATAVALUE()
132
public int getINDICATORVALUE()
134
return INDICATORVALUE;
138
private List<DataElement> dataElements;
140
public List<DataElement> getDataElements()
145
private List<DataElementGroup> dataElementGroups;
147
public List<DataElementGroup> getDataElementGroups()
149
return dataElementGroups;
152
private List<Indicator> indicators;
154
public List<Indicator> getIndicators()
159
private List<IndicatorGroup> indicatorGroups;
161
public List<IndicatorGroup> getIndicatorGroups()
163
return indicatorGroups;
166
private Collection<OrganisationUnit> organisationUnits;
168
public Collection<OrganisationUnit> getOrganisationUnits()
170
return organisationUnits;
173
private Collection<OrganisationUnitGroupSet> organisationUnitGroupSets;
175
public Collection<OrganisationUnitGroupSet> getOrganisationUnitGroupSets()
177
return organisationUnitGroupSets;
181
private List<Period> monthlyPeriods;
183
public List<Period> getMonthlyPeriods()
185
return monthlyPeriods;
188
private SimpleDateFormat simpleDateFormat;
190
public SimpleDateFormat getSimpleDateFormat()
192
return simpleDateFormat;
195
public String execute()
198
/* OrganisationUnit */
199
//organisationUnits = organisationUnitService.getAllOrganisationUnits();
200
organisationUnitGroupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
202
/* DataElements and Groups */
203
//dataElements = new ArrayList<DataElement>(dataElementService.getAllDataElements());
204
dataElementGroups = new ArrayList<DataElementGroup>(dataElementService.getAllDataElementGroups());
206
//Collections.sort(dataElements, new DataElementNameComparator());
207
Collections.sort( dataElementGroups, new DataElementGroupNameComparator() );
209
/* Indicators and Groups */
210
//indicators = new ArrayList<Indicator>(indicatorService.getAllIndicators());
211
indicatorGroups = new ArrayList<IndicatorGroup>(indicatorService.getAllIndicatorGroups());
213
//Collections.sort(indicators, new IndicatorNameComparator());
214
Collections.sort(indicatorGroups, new IndicatorGroupNameComparator());
216
/* Monthly Periods */
217
monthlyPeriods = new ArrayList<Period>( periodStore.getPeriodsByPeriodType( new MonthlyPeriodType() ) );
218
Collections.sort( monthlyPeriods, new PeriodStartDateComparator() );
219
simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd" );