~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/action/GenerateGraphicalAnalyserFormAction.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.dashboard.ga.action;
 
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.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;
 
36
 
 
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;
 
55
 
 
56
import com.opensymphony.xwork.ActionSupport;
 
57
 
 
58
public class GenerateGraphicalAnalyserFormAction
 
59
    extends ActionSupport
 
60
{
 
61
    // -------------------------------------------------------------------------
 
62
    // Dependencies
 
63
    // -------------------------------------------------------------------------
 
64
 
 
65
    private IndicatorService indicatorService;
 
66
 
 
67
    public void setIndicatorService( IndicatorService indicatorService )
 
68
    {
 
69
        this.indicatorService = indicatorService;
 
70
    }
 
71
 
 
72
    private DataElementService dataElementService;
 
73
 
 
74
    public void setDataElementService( DataElementService dataElementService )
 
75
    {
 
76
        this.dataElementService = dataElementService;
 
77
    }
 
78
 
 
79
    private PeriodStore periodStore;
 
80
 
 
81
    public void setPeriodStore( PeriodStore periodStore )
 
82
    {
 
83
        this.periodStore = periodStore;
 
84
    }
 
85
 
 
86
    private OrganisationUnitService organisationUnitService;
 
87
 
 
88
    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
 
89
    {
 
90
        this.organisationUnitService = organisationUnitService;
 
91
    }
 
92
 
 
93
    private OrganisationUnitGroupService organisationUnitGroupService;
 
94
    
 
95
    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
 
96
    {
 
97
        this.organisationUnitGroupService = organisationUnitGroupService;
 
98
    }
 
99
    
 
100
    // -------------------------------------------------------------------------
 
101
    // Comparator
 
102
    // -------------------------------------------------------------------------
 
103
 
 
104
    private Comparator<DataElementGroup> dataElementGroupComparator;
 
105
 
 
106
    public void setDataElementGroupComparator( Comparator<DataElementGroup> dataElementGroupComparator )
 
107
    {
 
108
        this.dataElementGroupComparator = dataElementGroupComparator;
 
109
    }
 
110
 
 
111
    
 
112
    // -------------------------------------------------------------------------
 
113
    // Constants
 
114
    // -------------------------------------------------------------------------
 
115
 
 
116
    private final static int ALL = 0;
 
117
 
 
118
    private final static int DATAVALUE = 1;
 
119
 
 
120
    private final static int INDICATORVALUE = 2;
 
121
 
 
122
    public int getALL()
 
123
    {
 
124
        return ALL;
 
125
    }
 
126
 
 
127
    public int getDATAVALUE()
 
128
    {
 
129
        return DATAVALUE;
 
130
    }
 
131
 
 
132
    public int getINDICATORVALUE()
 
133
    {
 
134
        return INDICATORVALUE;
 
135
    }
 
136
 
 
137
    /* Parameters */
 
138
    private List<DataElement> dataElements;
 
139
 
 
140
    public List<DataElement> getDataElements()
 
141
    {
 
142
        return dataElements;
 
143
    }
 
144
 
 
145
    private List<DataElementGroup> dataElementGroups;
 
146
 
 
147
    public List<DataElementGroup> getDataElementGroups()
 
148
    {
 
149
        return dataElementGroups;
 
150
    }
 
151
 
 
152
    private List<Indicator> indicators;
 
153
 
 
154
    public List<Indicator> getIndicators()
 
155
    {
 
156
        return indicators;
 
157
    }
 
158
 
 
159
    private List<IndicatorGroup> indicatorGroups;
 
160
 
 
161
    public List<IndicatorGroup> getIndicatorGroups()
 
162
    {
 
163
        return indicatorGroups;
 
164
    }
 
165
 
 
166
    private Collection<OrganisationUnit> organisationUnits;
 
167
 
 
168
    public Collection<OrganisationUnit> getOrganisationUnits()
 
169
    {
 
170
        return organisationUnits;
 
171
    }
 
172
 
 
173
    private Collection<OrganisationUnitGroupSet> organisationUnitGroupSets;
 
174
 
 
175
    public Collection<OrganisationUnitGroupSet> getOrganisationUnitGroupSets()
 
176
    {
 
177
        return organisationUnitGroupSets;
 
178
    }
 
179
 
 
180
    
 
181
    private List<Period> monthlyPeriods;
 
182
 
 
183
    public List<Period> getMonthlyPeriods()
 
184
    {
 
185
        return monthlyPeriods;
 
186
    }
 
187
 
 
188
    private SimpleDateFormat simpleDateFormat;
 
189
 
 
190
    public SimpleDateFormat getSimpleDateFormat()
 
191
    {
 
192
        return simpleDateFormat;
 
193
    }
 
194
 
 
195
    public String execute()
 
196
        throws Exception
 
197
    {
 
198
        /* OrganisationUnit */
 
199
        //organisationUnits = organisationUnitService.getAllOrganisationUnits();
 
200
        organisationUnitGroupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
 
201
        
 
202
        /* DataElements and Groups */
 
203
        //dataElements = new ArrayList<DataElement>(dataElementService.getAllDataElements());
 
204
        dataElementGroups = new ArrayList<DataElementGroup>(dataElementService.getAllDataElementGroups());
 
205
 
 
206
        //Collections.sort(dataElements, new DataElementNameComparator());
 
207
        Collections.sort( dataElementGroups, new DataElementGroupNameComparator() );
 
208
        
 
209
        /* Indicators and Groups */
 
210
        //indicators = new ArrayList<Indicator>(indicatorService.getAllIndicators());
 
211
        indicatorGroups = new ArrayList<IndicatorGroup>(indicatorService.getAllIndicatorGroups());
 
212
        
 
213
        //Collections.sort(indicators, new IndicatorNameComparator());
 
214
        Collections.sort(indicatorGroups, new IndicatorGroupNameComparator());
 
215
        
 
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" );
 
220
 
 
221
        return SUCCESS;
 
222
    }
 
223
 
 
224
}