1
package org.hisp.dhis.rt.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.io.InputStream;
31
import java.util.Collection;
33
import org.hisp.dhis.i18n.I18n;
34
import org.hisp.dhis.i18n.I18nFormat;
35
import org.hisp.dhis.organisationunit.OrganisationUnit;
36
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
37
import org.hisp.dhis.rt.report.ReportStore;
39
import com.opensymphony.xwork.ActionContext;
40
import com.opensymphony.xwork.ActionSupport;
43
* @author Lars Helge Overland
44
* @version $Id: AbstractAction.java 2871 2007-02-20 16:04:11Z andegje $
46
public abstract class AbstractAction
49
// -----------------------------------------------------------------------
51
// -----------------------------------------------------------------------
53
protected ReportStore reportStore;
55
protected OrganisationUnitSelectionManager selectionManager;
57
public void setReportStore( ReportStore reportStore )
59
this.reportStore = reportStore;
62
public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
64
this.selectionManager = selectionManager;
67
// -----------------------------------------------------------------------
69
// -----------------------------------------------------------------------
71
protected final String REPORT = "Report";
73
protected final String REPORT_TYPE = "ReportType";
75
protected final String HTML_BUFFER = "HTML_buffer";
77
protected final int ALL = 0;
84
// -----------------------------------------------------------------------
86
// -----------------------------------------------------------------------
88
protected String report;
90
protected String reportName;
92
protected Collection dataElementId;
94
protected Collection indicatorId;
96
protected int dataElementGroupId;
98
protected int indicatorGroupId;
100
protected int designTemplate;
102
protected int chartTemplate;
104
protected String elementId;
106
protected String startDate;
108
protected String endDate;
110
protected String message;
112
protected int organisationUnitId;
114
protected InputStream inputStream;
116
public String getReport()
121
public void setReport( String report )
123
this.report = report;
126
public String getReportName()
131
public void setReportName( String reportName )
133
this.reportName = reportName;
136
public Collection getDataElementId()
138
return dataElementId;
141
public void setDataElementId( Collection dataElementId )
143
this.dataElementId = dataElementId;
146
public Collection getIndicatorId()
151
public void setIndicatorId( Collection indicatorId )
153
this.indicatorId = indicatorId;
156
public int getDataElementGroupId()
158
return dataElementGroupId;
161
public void setDataElementGroupId( int dataElementGroupId )
163
this.dataElementGroupId = dataElementGroupId;
166
public int getIndicatorGroupId()
168
return indicatorGroupId;
171
public void setIndicatorGroupId( int indicatorGroupId )
173
this.indicatorGroupId = indicatorGroupId;
176
public int getChartTemplate()
178
return chartTemplate;
181
public void setChartTemplate( int chartTemplate )
183
this.chartTemplate = chartTemplate;
186
public int getDesignTemplate()
188
return designTemplate;
191
public void setDesignTemplate( int designTemplate )
193
this.designTemplate = designTemplate;
196
public void setElementId( String elementId )
198
this.elementId = elementId;
201
public String getEndDate()
206
public void setEndDate( String endDate )
208
this.endDate = endDate;
211
public String getStartDate()
216
public void setStartDate( String startDate )
218
this.startDate = startDate;
221
public String getMessage()
226
public void setMessage( String message )
228
this.message = message;
231
public InputStream getInputStream()
236
public void setInputStream( InputStream inputStream )
238
this.inputStream = inputStream;
241
// -----------------------------------------------------------------------
243
// -----------------------------------------------------------------------
247
public void setI18n( I18n i18n )
252
protected I18nFormat format;
254
public void setFormat( I18nFormat format )
256
this.format = format;
259
// -----------------------------------------------------------------------
260
// Organisation Unit Tree
261
// -----------------------------------------------------------------------
263
protected int getSelectedOrganisationUnitId()
265
int organisationUnitId = 0;
267
OrganisationUnit selectedUnit = selectionManager.getSelectedOrganisationUnit();
269
if ( selectedUnit != null )
271
organisationUnitId = selectedUnit.getId();
274
return organisationUnitId;
277
// -----------------------------------------------------------------------
279
// -----------------------------------------------------------------------
281
protected final Object getSessionVar( String name )
283
return ActionContext.getContext().getSession().get( name );
286
@SuppressWarnings( "unchecked" )
287
protected final void setSessionVar( String name, Object value )
289
ActionContext.getContext().getSession().put( name, value );
292
protected final boolean containsSessionVar( String name )
294
return ActionContext.getContext().getSession().containsKey( name );
297
protected final void removeSessionVar( String name )
299
ActionContext.getContext().getSession().remove( name );
302
// -----------------------------------------------------------------------
304
// -----------------------------------------------------------------------
306
protected boolean reportName()
308
if ( reportName == null || reportName.equals( "" ) )
310
message = i18n.getString( "error_reportName" );
316
protected boolean report()
318
if ( report == null || report.equals( "" ) )
320
message = i18n.getString( "error_report" );
326
protected boolean startDate()
328
if ( format.parseDate( startDate ) == null )
330
message = i18n.getString( "error_startDate" );
336
protected boolean endDate()
338
if ( format.parseDate( endDate ) == null )
340
message = i18n.getString( "error_endDate" );
346
protected boolean indicatorId()
348
if ( indicatorId == null )
350
message = i18n.getString( "error_indicatorId" );
356
protected boolean dataElementId()
358
if ( dataElementId == null )
360
message = i18n.getString( "error_dataElementId" );
366
protected boolean organisationUnitId()
368
if ( organisationUnitId == 0 )
370
message = i18n.getString( "error_organisationUnitId" );