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

« back to all changes in this revision

Viewing changes to dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetMatchOptionsAction.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.importexport.action.imp;
 
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.datadictionary.DataDictionaryService;
 
33
import org.hisp.dhis.dataelement.DataElementService;
 
34
import org.hisp.dhis.dataset.DataSetService;
 
35
import org.hisp.dhis.importexport.ImportObjectService;
 
36
import org.hisp.dhis.importexport.action.util.ClassMapUtil;
 
37
import org.hisp.dhis.indicator.IndicatorService;
 
38
import org.hisp.dhis.olap.OlapURLService;
 
39
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 
40
import org.hisp.dhis.organisationunit.OrganisationUnitService;
 
41
import org.hisp.dhis.reporttable.ReportTableStore;
 
42
import org.hisp.dhis.validation.ValidationRuleService;
 
43
 
 
44
import com.opensymphony.xwork.ActionSupport;
 
45
 
 
46
/**
 
47
 * @author Lars Helge Overland
 
48
 * @version $Id$
 
49
 */
 
50
public class GetMatchOptionsAction
 
51
    extends ActionSupport  
 
52
{
 
53
    // -------------------------------------------------------------------------
 
54
    // Input
 
55
    // -------------------------------------------------------------------------
 
56
 
 
57
    private String objectType;
 
58
 
 
59
    public String getObjectType()
 
60
    {
 
61
        return objectType;
 
62
    }
 
63
 
 
64
    public void setObjectType( String type )
 
65
    {
 
66
        this.objectType = type;
 
67
    }
 
68
    
 
69
    private Integer objectId;
 
70
 
 
71
    public Integer getObjectId()
 
72
    {
 
73
        return objectId;
 
74
    }
 
75
 
 
76
    public void setObjectId( Integer id )
 
77
    {
 
78
        this.objectId = id;
 
79
    }
 
80
    
 
81
    // -------------------------------------------------------------------------
 
82
    // Output
 
83
    // -------------------------------------------------------------------------
 
84
 
 
85
    private Object importObject;
 
86
 
 
87
    public Object getImportObject()
 
88
    {
 
89
        return importObject;
 
90
    }    
 
91
    
 
92
    private Collection<? extends Object> objects;
 
93
 
 
94
    public Collection<? extends Object> getObjects()
 
95
    {
 
96
        return objects;
 
97
    }
 
98
    
 
99
    // -------------------------------------------------------------------------
 
100
    // Dependencies
 
101
    // -------------------------------------------------------------------------
 
102
 
 
103
    private ImportObjectService importObjectService;
 
104
 
 
105
    public void setImportObjectService( ImportObjectService importObjectService )
 
106
    {
 
107
        this.importObjectService = importObjectService;
 
108
    }
 
109
 
 
110
    private DataElementService dataElementService;
 
111
 
 
112
    public void setDataElementService( DataElementService dataElementService )
 
113
    {
 
114
        this.dataElementService = dataElementService;
 
115
    }
 
116
    
 
117
    private IndicatorService indicatorService;
 
118
 
 
119
    public void setIndicatorService( IndicatorService indicatorService )
 
120
    {
 
121
        this.indicatorService = indicatorService;
 
122
    }
 
123
 
 
124
    private DataDictionaryService dataDictionaryService;
 
125
 
 
126
    public void setDataDictionaryService( DataDictionaryService dataDictionaryService )
 
127
    {
 
128
        this.dataDictionaryService = dataDictionaryService;
 
129
    }
 
130
    
 
131
    private DataSetService dataSetService;
 
132
 
 
133
    public void setDataSetService( DataSetService dataSetService )
 
134
    {
 
135
        this.dataSetService = dataSetService;
 
136
    }
 
137
    
 
138
    private OrganisationUnitService organisationUnitService;
 
139
 
 
140
    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
 
141
    {
 
142
        this.organisationUnitService = organisationUnitService;
 
143
    }
 
144
    
 
145
    private OrganisationUnitGroupService organisationUnitGroupService;
 
146
 
 
147
    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
 
148
    {
 
149
        this.organisationUnitGroupService = organisationUnitGroupService;
 
150
    }
 
151
 
 
152
    private ValidationRuleService validationRuleService;
 
153
 
 
154
    public void setValidationRuleService( ValidationRuleService validationRuleService )
 
155
    {
 
156
        this.validationRuleService = validationRuleService;
 
157
    }
 
158
    
 
159
    private ReportTableStore reportTableStore;
 
160
 
 
161
    public void setReportTableStore( ReportTableStore reportTableStore )
 
162
    {
 
163
        this.reportTableStore = reportTableStore;
 
164
    }
 
165
    
 
166
    private OlapURLService olapURLService;
 
167
 
 
168
    public void setOlapURLService( OlapURLService olapURLService )
 
169
    {
 
170
        this.olapURLService = olapURLService;
 
171
    }
 
172
    
 
173
    // -------------------------------------------------------------------------
 
174
    // Action implementation
 
175
    // -------------------------------------------------------------------------
 
176
 
 
177
    public String execute()
 
178
        throws Exception
 
179
    {
 
180
        importObject = importObjectService.getImportObject( Integer.valueOf( objectId ) );
 
181
        
 
182
        if ( objectType.equals( ClassMapUtil.ObjectType.DATAELEMENT.name() ) )
 
183
        {
 
184
            objects = dataElementService.getNonCalculatedDataElements();
 
185
        }
 
186
        else if ( objectType.equals( ClassMapUtil.ObjectType.CALCULATEDDATAELEMENT.name() ) )
 
187
        {
 
188
            objects = dataElementService.getCalculatedDataElements();
 
189
        }
 
190
        else if ( objectType.equals( ClassMapUtil.ObjectType.DATAELEMENTGROUP.name() ) )
 
191
        {
 
192
            objects = dataElementService.getAllDataElementGroups();        
 
193
        }
 
194
        else if ( objectType.equals( ClassMapUtil.ObjectType.INDICATORTYPE.name() ) )
 
195
        {
 
196
            objects = indicatorService.getAllIndicatorTypes();
 
197
        }
 
198
        else if ( objectType.equals( ClassMapUtil.ObjectType.INDICATOR.name() ) ) 
 
199
        {
 
200
            objects = indicatorService.getAllIndicators();
 
201
        }
 
202
        else if ( objectType.equals( ClassMapUtil.ObjectType.INDICATORGROUP.name() ) )
 
203
        {
 
204
            objects = indicatorService.getAllIndicatorGroups();
 
205
        }
 
206
        else if ( objectType.equals( ClassMapUtil.ObjectType.DATADICTIONARY.name() ) )
 
207
        {
 
208
            objects = dataDictionaryService.getAllDataDictionaries();
 
209
        }
 
210
        else if ( objectType.equals( ClassMapUtil.ObjectType.DATASET.name() ) )
 
211
        {
 
212
            objects = dataSetService.getAllDataSets();
 
213
        }
 
214
        else if ( objectType.equals( ClassMapUtil.ObjectType.ORGANISATIONUNIT.name() ) )
 
215
        {
 
216
            objects = organisationUnitService.getAllOrganisationUnits();
 
217
        }
 
218
        else if ( objectType.equals( ClassMapUtil.ObjectType.ORGANISATIONUNITGROUP.name() ) )
 
219
        {
 
220
            objects = organisationUnitGroupService.getAllOrganisationUnitGroups();
 
221
        }
 
222
        else if ( objectType.equals( ClassMapUtil.ObjectType.ORGANISATIONUNITGROUPSET.name() ) )
 
223
        {
 
224
            objects = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
 
225
        }
 
226
        else if ( objectType.equals( ClassMapUtil.ObjectType.ORGANISATIONUNITLEVEL.name() ) )
 
227
        {
 
228
            objects = organisationUnitService.getOrganisationUnitLevels();
 
229
        }
 
230
        else if ( objectType.equals( ClassMapUtil.ObjectType.VALIDATIONRULE.name() ) )
 
231
        {
 
232
            objects = validationRuleService.getAllValidationRules();
 
233
        }
 
234
        else if ( objectType.equals( ClassMapUtil.ObjectType.REPORTTABLE.name() ) )
 
235
        {
 
236
            objects = reportTableStore.getAllReportTables();
 
237
        }
 
238
        else if ( objectType.equals( ClassMapUtil.ObjectType.OLAPURL.name() ) )
 
239
        {
 
240
            objects = olapURLService.getAllOlapURLs();
 
241
        }
 
242
        
 
243
        return SUCCESS;
 
244
    }
 
245
}