1
package org.hisp.dhis.importexport.action.imp;
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.util.Collection;
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;
44
import com.opensymphony.xwork.ActionSupport;
47
* @author Lars Helge Overland
50
public class GetMatchOptionsAction
53
// -------------------------------------------------------------------------
55
// -------------------------------------------------------------------------
57
private String objectType;
59
public String getObjectType()
64
public void setObjectType( String type )
66
this.objectType = type;
69
private Integer objectId;
71
public Integer getObjectId()
76
public void setObjectId( Integer id )
81
// -------------------------------------------------------------------------
83
// -------------------------------------------------------------------------
85
private Object importObject;
87
public Object getImportObject()
92
private Collection<? extends Object> objects;
94
public Collection<? extends Object> getObjects()
99
// -------------------------------------------------------------------------
101
// -------------------------------------------------------------------------
103
private ImportObjectService importObjectService;
105
public void setImportObjectService( ImportObjectService importObjectService )
107
this.importObjectService = importObjectService;
110
private DataElementService dataElementService;
112
public void setDataElementService( DataElementService dataElementService )
114
this.dataElementService = dataElementService;
117
private IndicatorService indicatorService;
119
public void setIndicatorService( IndicatorService indicatorService )
121
this.indicatorService = indicatorService;
124
private DataDictionaryService dataDictionaryService;
126
public void setDataDictionaryService( DataDictionaryService dataDictionaryService )
128
this.dataDictionaryService = dataDictionaryService;
131
private DataSetService dataSetService;
133
public void setDataSetService( DataSetService dataSetService )
135
this.dataSetService = dataSetService;
138
private OrganisationUnitService organisationUnitService;
140
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
142
this.organisationUnitService = organisationUnitService;
145
private OrganisationUnitGroupService organisationUnitGroupService;
147
public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
149
this.organisationUnitGroupService = organisationUnitGroupService;
152
private ValidationRuleService validationRuleService;
154
public void setValidationRuleService( ValidationRuleService validationRuleService )
156
this.validationRuleService = validationRuleService;
159
private ReportTableStore reportTableStore;
161
public void setReportTableStore( ReportTableStore reportTableStore )
163
this.reportTableStore = reportTableStore;
166
private OlapURLService olapURLService;
168
public void setOlapURLService( OlapURLService olapURLService )
170
this.olapURLService = olapURLService;
173
// -------------------------------------------------------------------------
174
// Action implementation
175
// -------------------------------------------------------------------------
177
public String execute()
180
importObject = importObjectService.getImportObject( Integer.valueOf( objectId ) );
182
if ( objectType.equals( ClassMapUtil.ObjectType.DATAELEMENT.name() ) )
184
objects = dataElementService.getNonCalculatedDataElements();
186
else if ( objectType.equals( ClassMapUtil.ObjectType.CALCULATEDDATAELEMENT.name() ) )
188
objects = dataElementService.getCalculatedDataElements();
190
else if ( objectType.equals( ClassMapUtil.ObjectType.DATAELEMENTGROUP.name() ) )
192
objects = dataElementService.getAllDataElementGroups();
194
else if ( objectType.equals( ClassMapUtil.ObjectType.INDICATORTYPE.name() ) )
196
objects = indicatorService.getAllIndicatorTypes();
198
else if ( objectType.equals( ClassMapUtil.ObjectType.INDICATOR.name() ) )
200
objects = indicatorService.getAllIndicators();
202
else if ( objectType.equals( ClassMapUtil.ObjectType.INDICATORGROUP.name() ) )
204
objects = indicatorService.getAllIndicatorGroups();
206
else if ( objectType.equals( ClassMapUtil.ObjectType.DATADICTIONARY.name() ) )
208
objects = dataDictionaryService.getAllDataDictionaries();
210
else if ( objectType.equals( ClassMapUtil.ObjectType.DATASET.name() ) )
212
objects = dataSetService.getAllDataSets();
214
else if ( objectType.equals( ClassMapUtil.ObjectType.ORGANISATIONUNIT.name() ) )
216
objects = organisationUnitService.getAllOrganisationUnits();
218
else if ( objectType.equals( ClassMapUtil.ObjectType.ORGANISATIONUNITGROUP.name() ) )
220
objects = organisationUnitGroupService.getAllOrganisationUnitGroups();
222
else if ( objectType.equals( ClassMapUtil.ObjectType.ORGANISATIONUNITGROUPSET.name() ) )
224
objects = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
226
else if ( objectType.equals( ClassMapUtil.ObjectType.ORGANISATIONUNITLEVEL.name() ) )
228
objects = organisationUnitService.getOrganisationUnitLevels();
230
else if ( objectType.equals( ClassMapUtil.ObjectType.VALIDATIONRULE.name() ) )
232
objects = validationRuleService.getAllValidationRules();
234
else if ( objectType.equals( ClassMapUtil.ObjectType.REPORTTABLE.name() ) )
236
objects = reportTableStore.getAllReportTables();
238
else if ( objectType.equals( ClassMapUtil.ObjectType.OLAPURL.name() ) )
240
objects = olapURLService.getAllOlapURLs();