dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16905
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6567: Impl ui for new data value export
------------------------------------------------------------
revno: 6567
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-04-14 00:28:40 +0200
message:
Impl ui for new data value export
removed:
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportOptionsAction.java
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportStatusAction.java
added:
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java
modified:
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java
dhis-2/dhis-web/dhis-web-importexport/pom.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/externalExportMenu.vm
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/export.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2012-04-13 20:09:02 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2012-04-13 22:28:40 +0000
@@ -30,7 +30,6 @@
import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
import static org.hisp.dhis.system.util.DateUtils.getMediumDateString;
import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
-import static org.hisp.dhis.system.util.TextUtils.ifNotNull;
import java.io.OutputStream;
import java.util.Collection;
@@ -69,10 +68,10 @@
SqlRowSet rowSet = jdbcTemplate.queryForRowSet( getDataValueSql( dataElements, periods, orgUnits ) );
DataValueSet dataValueSet = new StreamingDataValueSet( writer );
- dataValueSet.setDataSet( ifNotNull( dataSet, dataSet.getUid() ) );
+ dataValueSet.setDataSet( dataSet != null ? dataSet.getUid() : null );
dataValueSet.setCompleteDate( getMediumDateString( completeDate ) );
- dataValueSet.setPeriod( ifNotNull( period, period.getIsoDate() ) );
- dataValueSet.setOrgUnit( ifNotNull( orgUnit, orgUnit.getUid() ) );
+ dataValueSet.setPeriod( period != null ? period.getIsoDate() : null );
+ dataValueSet.setOrgUnit( orgUnit != null ? orgUnit.getUid() : null );
while ( rowSet.next() )
{
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java 2012-04-13 10:21:57 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java 2012-04-13 22:28:40 +0000
@@ -74,19 +74,7 @@
return matcher.appendTail( buffer ).toString();
}
-
- /**
- * Returns the value argument if the object argument is not null, null otherwise.
- *
- * @param object the object.
- * @param value the value.
- * @return the value or null.
- */
- public static <T> T ifNotNull( Object object, T value )
- {
- return object != null ? value: null;
- }
-
+
/**
* Gets the sub string of the given string. If the beginIndex is larger than
* the length of the string, the empty string is returned. If the beginIndex +
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/pom.xml'
--- dhis-2/dhis-web/dhis-web-importexport/pom.xml 2012-02-20 12:01:56 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/pom.xml 2012-04-13 22:28:40 +0000
@@ -38,6 +38,10 @@
<artifactId>dhis-service-administration</artifactId>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web-commons</artifactId>
</dependency>
=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java 2012-04-13 22:28:40 +0000
@@ -0,0 +1,138 @@
+package org.hisp.dhis.importexport.action.datavalue;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import static org.hisp.dhis.system.util.DateUtils.getMediumDate;
+import static org.hisp.dhis.system.util.CodecUtils.filenameEncode;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.hisp.dhis.util.ContextUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class ExportDataValueAction
+ implements Action
+{
+ private final static String FILE_PREFIX = "Export";
+ private final static String FILE_SEPARATOR = "_";
+ private final static String FILE_EXTENSION = ".xml";
+
+ @Autowired
+ private SelectionTreeManager selectionTreeManager;
+
+ @Autowired
+ private OrganisationUnitService organisationUnitService;
+
+ @Autowired
+ private DataValueSetService dataValueSetService;
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Set<String> selectedDataSets;
+
+ public void setSelectedDataSets( Set<String> selectedDataSets )
+ {
+ this.selectedDataSets = selectedDataSets;
+ }
+
+ private String startDate;
+
+ public void setStartDate( String startDate )
+ {
+ this.startDate = startDate;
+ }
+
+ private String endDate;
+
+ public void setEndDate( String endDate )
+ {
+ this.endDate = endDate;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ Set<String> orgUnits = new HashSet<String>();
+
+ for ( OrganisationUnit unit : selectionTreeManager.getReloadedSelectedOrganisationUnits() )
+ {
+ Collection<OrganisationUnit> children = organisationUnitService.getOrganisationUnitWithChildren( unit.getId() );
+
+ for ( OrganisationUnit child : children )
+ {
+ orgUnits.add( child.getUid() );
+ }
+ }
+
+ HttpServletResponse response = ServletActionContext.getResponse();
+
+ ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, true, getFileName(), true );
+
+ dataValueSetService.writeDataValueSet( selectedDataSets, getMediumDate( startDate ), getMediumDate( endDate ), orgUnits, response.getOutputStream() );
+
+ return SUCCESS;
+ }
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private String getFileName()
+ {
+ String fileName = FILE_PREFIX + FILE_SEPARATOR + startDate + FILE_SEPARATOR + endDate;
+
+ if ( selectionTreeManager.getSelectedOrganisationUnits().size() == 1 )
+ {
+ fileName += FILE_SEPARATOR + filenameEncode( selectionTreeManager.getSelectedOrganisationUnits().iterator().next().getShortName() );
+ }
+
+ fileName += FILE_EXTENSION;
+
+ return fileName;
+ }
+}
=== removed file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java 2012-04-13 10:21:57 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java 1970-01-01 00:00:00 +0000
@@ -1,291 +0,0 @@
-package org.hisp.dhis.importexport.action.exp;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
-import static org.hisp.dhis.system.util.ConversionUtils.getIntegerCollection;
-import static org.hisp.dhis.system.util.DateUtils.getMediumDate;
-import static org.hisp.dhis.system.util.DateUtils.getMediumDateString;
-import static org.hisp.dhis.system.util.CodecUtils.filenameEncode;
-
-import java.io.InputStream;
-import java.util.Collection;
-
-import org.hisp.dhis.common.ServiceProvider;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.importexport.ExportParams;
-import org.hisp.dhis.importexport.ExportService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.oust.manager.SelectionTreeManager;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.system.util.ConversionUtils;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class DataValueExportAction
- implements Action
-{
- private final static String FILE_EXTENSION = ".zip";
- private final static String FILE_PREFIX = "Export";
- private final static String FILE_SEPARATOR = "_";
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private SelectionTreeManager selectionTreeManager;
-
- public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
- {
- this.selectionTreeManager = selectionTreeManager;
- }
-
- private ServiceProvider<ExportService> serviceProvider;
-
- public void setServiceProvider( ServiceProvider<ExportService> serviceProvider )
- {
- this.serviceProvider = serviceProvider;
- }
-
- private DataSetService dataSetService;
-
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
- private PeriodService periodService;
-
- public void setPeriodService( PeriodService periodService )
- {
- this.periodService = periodService;
- }
-
- private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private InputStream inputStream;
-
- public InputStream getInputStream()
- {
- return inputStream;
- }
-
- private String fileName;
-
- public String getFileName()
- {
- return fileName;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private String exportFormat;
-
- public String getExportFormat()
- {
- return exportFormat;
- }
-
- public void setExportFormat( String exportFormat )
- {
- this.exportFormat = exportFormat;
- }
-
- private boolean aggregatedData;
-
- public void setAggregatedData( boolean aggregatedData )
- {
- this.aggregatedData = aggregatedData;
- }
-
- private boolean excludeChildren;
-
- public void setExcludeChildren( boolean excludeChildren )
- {
- this.excludeChildren = excludeChildren;
- }
-
- private int dataSourceLevel;
-
- public void setDataSourceLevel( int dataSourceLevel )
- {
- this.dataSourceLevel = dataSourceLevel;
- }
-
- private String startDate;
-
- public void setStartDate( String startDate )
- {
- this.startDate = startDate;
- }
-
- private String endDate;
-
- public void setEndDate( String endDate )
- {
- this.endDate = endDate;
- }
-
- private Collection<String> selectedDataSets;
-
- public void setSelectedDataSets( Collection<String> selectedDataSets )
- {
- this.selectedDataSets = selectedDataSets;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- ExportParams params = new ExportParams();
-
- // ---------------------------------------------------------------------
- // Get DataElements
- // ---------------------------------------------------------------------
-
- if ( selectedDataSets != null )
- {
- params.setCategories( null );
- params.setCategoryCombos( null );
- params.setCategoryOptions( null );
- params.setCategoryOptionCombos( null );
-
- params.setDataSets( getIntegerCollection( selectedDataSets ) );
-
- params.setDataElements( getIdentifiers( DataElement.class, dataSetService.getDistinctDataElements( params.getDataSets() ) ) );
- }
-
- // ---------------------------------------------------------------------
- // Get Periods
- // ---------------------------------------------------------------------
-
- if ( startDate != null && startDate.trim().length() > 0 && endDate != null && endDate.trim().length() > 0 )
- {
- params.setStartDate( getMediumDate( startDate ) );
- params.setEndDate( getMediumDate( endDate ) );
-
- params.setPeriods( getIdentifiers( Period.class,
- periodService.getIntersectingPeriods( getMediumDate( startDate ), getMediumDate( endDate ) ) ) );
- }
-
- // ---------------------------------------------------------------------
- // Get OrganisationUnit
- // ---------------------------------------------------------------------
-
- Collection<OrganisationUnit> selectedUnits = selectionTreeManager.getReloadedSelectedOrganisationUnits();
-
- if ( selectedUnits != null )
- {
- if ( aggregatedData )
- {
- for ( OrganisationUnit unit : selectedUnits )
- {
- params.getOrganisationUnits().addAll( ConversionUtils.getIdentifiers( OrganisationUnit.class,
- organisationUnitService.getOrganisationUnitsAtLevel( dataSourceLevel, unit ) ) );
- }
- }
- else
- {
- for ( OrganisationUnit unit : selectedUnits )
- {
- if ( excludeChildren )
- {
- params.getOrganisationUnits().add( unit.getId() );
- }
- else
- {
- params.getOrganisationUnits().addAll( ConversionUtils.getIdentifiers( OrganisationUnit.class,
- organisationUnitService.getOrganisationUnitWithChildren( unit.getId() ) ) );
- }
- }
- }
- }
-
- params.setIncludeDataValues( true );
- params.setIncludeCompleteDataSetRegistrations( true );
- params.setAggregatedData( aggregatedData );
-
- // ---------------------------------------------------------------------
- // Export
- // ---------------------------------------------------------------------
-
- ExportService exportService = serviceProvider.provide( exportFormat );
-
- inputStream = exportService.exportData( params );
-
- fileName = getFileName( params );
-
- return SUCCESS;
- }
-
- // -------------------------------------------------------------------------
- // Supportive methods
- // -------------------------------------------------------------------------
-
- private String getFileName( ExportParams params )
- {
- String fileName = FILE_PREFIX + FILE_SEPARATOR +
- getMediumDateString( getMediumDate( startDate ) ) + FILE_SEPARATOR +
- getMediumDateString( getMediumDate( endDate ) );
-
- if ( selectionTreeManager.getSelectedOrganisationUnits().size() == 1 )
- {
- fileName += FILE_SEPARATOR + filenameEncode( selectionTreeManager.getSelectedOrganisationUnits().iterator().next().getShortName() );
- }
-
- if ( params.getDataSets().size() == 1 )
- {
- fileName += FILE_SEPARATOR + filenameEncode( dataSetService.getDataSet( params.getDataSets().iterator().next() ).getName() );
- }
-
- fileName += FILE_EXTENSION;
-
- return fileName;
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportOptionsAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportOptionsAction.java 1970-01-01 00:00:00 +0000
@@ -1,118 +0,0 @@
-package org.hisp.dhis.importexport.action.exp;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.oust.manager.SelectionTreeManager;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- * @version $Id: GetOptionsAction.java 2869 2007-02-20 14:26:09Z andegje $
- */
-public class GetExportOptionsAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataSetService dataSetService;
-
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
- private SelectionTreeManager selectionTreeManager;
-
- public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
- {
- this.selectionTreeManager = selectionTreeManager;
- }
-
- private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private String exportFormat;
-
- public String getExportFormat()
- {
- return exportFormat;
- }
-
- public void setExportFormat( String format )
- {
- this.exportFormat = format;
- }
-
- private List<DataSet> dataSets;
-
- public List<DataSet> getDataSets()
- {
- return dataSets;
- }
-
- private List<OrganisationUnitLevel> levels;
-
- public List<OrganisationUnitLevel> getLevels()
- {
- return levels;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- selectionTreeManager.clearSelectedOrganisationUnits();
-
- dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
-
- levels = new ArrayList<OrganisationUnitLevel>( organisationUnitService.getOrganisationUnitLevels() );
-
- return SUCCESS;
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportStatusAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportStatusAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportStatusAction.java 1970-01-01 00:00:00 +0000
@@ -1,112 +0,0 @@
-package org.hisp.dhis.importexport.action.exp;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import static org.hisp.dhis.util.InternalProcessUtil.*;
-
-import org.amplecode.cave.process.ProcessCoordinator;
-import org.amplecode.cave.process.ProcessExecutor;
-import org.amplecode.cave.process.state.MessageState;
-import org.hisp.dhis.i18n.I18n;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class GetExportStatusAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private ProcessCoordinator processCoordinator;
-
- public void setProcessCoordinator( ProcessCoordinator processCoordinator )
- {
- this.processCoordinator = processCoordinator;
- }
-
- private I18n i18n;
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private String statusMessage = new String();
-
- public String getStatusMessage()
- {
- return statusMessage;
- }
-
- private boolean finished = false;
-
- public boolean getFinished()
- {
- return finished;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- {
- if ( processIsRunning( PROCESS_KEY_EXPORT ) )
- {
- String id = getCurrentRunningProcess( PROCESS_KEY_EXPORT );
-
- ProcessExecutor executor = processCoordinator.getProcess( id );
-
- if ( executor != null && executor.getProcess() != null && executor.getState() != null )
- {
- MessageState state = (MessageState) executor.getState();
-
- statusMessage = i18n.getString( state.getMessage() );
-
- finished = state.isEnded();
- }
- }
- else
- {
- statusMessage = i18n.getString( "no_process_running" );
-
- finished = false;
- }
-
- return SUCCESS;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-04-11 20:16:18 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-04-13 22:28:40 +0000
@@ -11,6 +11,10 @@
<property name="category" value="DATAVALUE_IMPORT" />
</bean>
+ <!-- Data value export -->
+
+ <bean id="org.hisp.dhis.importexport.action.datavalue.ExportDataValueAction" class="org.hisp.dhis.importexport.action.datavalue.ExportDataValueAction"/>
+
<!-- Import -->
<bean id="org.hisp.dhis.importexport.action.imp.ImportAction" class="org.hisp.dhis.importexport.action.imp.ImportAction"
@@ -117,27 +121,6 @@
<property name="importObjectService" ref="org.hisp.dhis.importexport.ImportObjectService" />
</bean>
- <bean id="org.hisp.dhis.importexport.action.exp.DataValueExportAction" class="org.hisp.dhis.importexport.action.exp.DataValueExportAction"
- scope="prototype">
- <property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
- <property name="serviceProvider" ref="exportServiceProvider" />
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- </bean>
-
- <bean id="org.hisp.dhis.importexport.action.exp.GetExportOptionsAction" class="org.hisp.dhis.importexport.action.exp.GetExportOptionsAction"
- scope="prototype">
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- </bean>
-
- <bean id="org.hisp.dhis.importexport.action.exp.GetExportStatusAction" class="org.hisp.dhis.importexport.action.exp.GetExportStatusAction"
- scope="prototype">
- <property name="processCoordinator" ref="processCoordinator" />
- </bean>
-
<bean id="org.hisp.dhis.importexport.action.exp.GetDetailedExportOptionsAction" class="org.hisp.dhis.importexport.action.exp.GetDetailedExportOptionsAction"
scope="prototype">
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml 2012-04-11 20:16:18 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml 2012-04-13 22:28:40 +0000
@@ -33,6 +33,19 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <!-- Data value export -->
+
+ <action name="displayDataValueExportForm" class="org.hisp.dhis.importexport.action.NoAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-importexport/exportDataValueForm.vm</param>
+ <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+ <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/export.js</param>
+ </action>
+
+ <action name="exportDataValue" class="org.hisp.dhis.importexport.action.datavalue.ExportDataValueAction">
+ <result name="success" type="outputStreamResult" />
+ </action>
+
<!-- Menu -->
<action name="displayExternalImportMenu" class="org.hisp.dhis.importexport.action.NoAction">
@@ -157,13 +170,6 @@
<param name="javascripts">javascript/detailedExport.js</param>
</action>
- <action name="displayDataValueExportForm" class="org.hisp.dhis.importexport.action.exp.GetExportOptionsAction">
- <result name="success" type="velocity">/main.vm</result>
- <param name="page">/dhis-web-importexport/exportDataValueForm.vm</param>
- <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
- <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/export.js</param>
- </action>
-
<action name="exportMetaData" class="org.hisp.dhis.importexport.action.exp.MetaDataExportAction">
<result name="success" type="stream">
<param name="contentType">application/zip</param>
@@ -182,20 +188,6 @@
</result>
</action>
- <action name="exportDataValue" class="org.hisp.dhis.importexport.action.exp.DataValueExportAction">
- <result name="success" type="stream">
- <param name="contentType">application/zip</param>
- <param name="inputName">inputStream</param>
- <param name="contentDisposition">filename="${fileName}"</param>
- <param name="bufferSize">10240</param>
- </result>
- </action>
-
- <action name="getExportStatus" class="org.hisp.dhis.importexport.action.exp.GetExportStatusAction">
- <result name="success" type="velocity-xml">/dhis-web-importexport/responseExportStatus.vm</result>
- <param name="onExceptionReturn">plainTextError</param>
- </action>
-
<action name="getDataElementList" class="org.hisp.dhis.importexport.action.exp.GetDataElementListAction">
<result name="success" type="velocity-json">/dhis-web-importexport/responseDataElements.vm</result>
<param name="onExceptionReturn">plainTextError</param>
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm 2012-03-07 10:32:33 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm 2012-04-13 22:28:40 +0000
@@ -5,34 +5,38 @@
selectionTreeSelection.setMultipleSelectionAllowed( true );
selectionTree.clearSelectedOrganisationUnits();
selectionTree.buildSelectionTree();
+
+ jQuery("#availableDataSets").dhisAjaxSelect({
+ source: "../api/dataSets.json?links=false&paging=false",
+ iterator: "dataSets",
+ connectedTo: 'selectedDataSets',
+ handler: function(item) {
+ var option = jQuery("<option />");
+ option.text( item.name );
+ option.attr( "value", item.id );
- selectionTreeSelection.setListenerFunction( setSelectedOrganisationUnitIds );
+ return option;
+ }
+ });
});
- var selectedOrganisationUnitIds = null;
-
- function setSelectedOrganisationUnitIds( ids )
- {
- selectedOrganisationUnitIds = ids;
- }
-
var i18n_select_organisation_unit = '$encoder.jsEscape( $i18n.getString( "select_organisation_unit" ), "'")';
var i18n_select_startdate = '$encoder.jsEscape( $i18n.getString( "select_startdate" ), "'")';
var i18n_select_enddate = '$encoder.jsEscape( $i18n.getString( "select_enddate" ), "'")';
var i18n_select_datasets = '$encoder.jsEscape( $i18n.getString( "select_datasets" ), "'")';
</script>
-<h3>$i18n.getString( "$exportFormat" ) $i18n.getString( "data_export" ) #openHelp( "export" )</h3>
+<h3>$i18n.getString( "data_export" ) #openHelp( "export" )</h3>
<form id="exportForm" name="exportForm" method="post" action="exportDataValue.action">
<input type="hidden" name="exportFormat" value="$!exportFormat">
-<table width="730">
+<table width="708">
<colgroup>
<col width="325">
- <col width="80">
+ <col>
<col width="325">
</colgroup>
@@ -43,52 +47,13 @@
</tr>
<tr>
<td colspan="3">
- <div id="selectionTree" style="width:730px; height:220px"></div>
+ <div id="selectionTree" style="width:700px; height:220px"></div>
</td>
</tr>
<tr>
<td colspan="3" height="15"></td>
</tr>
-
- <!-- Datatype -->
-
- <tr>
- <th>$i18n.getString( "data_type" )</th>
- <td></td>
- <th>$i18n.getString( "data_source" )</th>
- </tr>
- <tr>
- <td>
- <select id="aggregatedData" name="aggregatedData" style="width:325px" onchange="setDataType()">
- <option value="false" selected="selected">$i18n.getString( "regular_data" )</option>
- <option value="true">$i18n.getString( "aggregated_data" )</option>
- </select>
- </td>
- <td></td>
- <td>
- <div id="regularDataDiv" style="display:block">
- <select id="excludeChildren" name="excludeChildren" style="width:325px">
- <option value="false" selected="selected">$i18n.getString( "organisation_unit_with_children" )</option>
- <option value="true">$i18n.getString( "organisation_unit_only" )</option>
- </select>
- </div>
- <div id="aggregatedDataDiv" style="display:none">
- <select id="dataSourceLevel" name="dataSourceLevel" style="width:180px">
- #foreach ( $level in $levels )
- <option value="$level.level">$level.name</option>
- #end
- </select>
- <select id="generateDataSource" name="generateDataSource" style="width:140px">
- <option value="false">$i18n.getString( "use_existing_data" )</option>
- <option value="true">$i18n.getString( "generate_data" )</option>
- </select>
- </div>
- </td>
- </tr>
- <tr>
- <td colspan="3" height="15"></td>
- </tr>
-
+
<!-- Timespan -->
<tr>
@@ -114,21 +79,16 @@
</tr>
<tr>
<td>
- <select multiple size="6" id="availableDataSets" name="availableDataSets" style="width:325px" ondblclick="moveSelectedById( 'availableDataSets', 'selectedDataSets' )">
- #foreach ( $dataSet in $dataSets )
- <option value="$dataSet.id">$dataSet.name</option>
- #end
- </select>
- </td>
- <td align="center">
- <input type="button" value=">" title="$i18n.getString('move_selected')" style="width:40px" onclick="moveSelectedById( 'availableDataSets', 'selectedDataSets' )"><br>
- <input type="button" value="<" title="$i18n.getString('move_all')" style="width:40px" onclick="moveSelectedById( 'selectedDataSets', 'availableDataSets' )"><br>
- <input type="button" value=">>" title="$i18n.getString('remove_selected')" style="width:40px" onclick="moveAllById( 'availableDataSets', 'selectedDataSets' )"><br>
- <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:40px" onclick="moveAllById( 'selectedDataSets', 'availableDataSets' )">
+ <select multiple id="availableDataSets" name="availableDataSets" style="height: 200px; width: 100%;"></select>
+ </td>
+ <td>
+ <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableDataSets' );"/><br/>
+ <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'selectedDataSets' );"/><br/>
+ <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableDataSets' );"/><br/>
+ <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'selectedDataSets' );"/>
</td>
<td>
- <select multiple size="6" id="selectedDataSets" name="selectedDataSets" style="width:325px" ondblclick="moveSelectedById( 'selectedDataSets', 'availableDataSets' )">
- </select>
+ <select multiple id="selectedDataSets" name="selectedDataSets" style="height: 200px; width: 100%; margin-top: 22px;"></select>
</td>
</tr>
@@ -142,5 +102,3 @@
</table>
</form>
-
-<span id="message"></span>
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/externalExportMenu.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/externalExportMenu.vm 2012-03-04 13:26:24 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/externalExportMenu.vm 2012-04-13 22:28:40 +0000
@@ -4,7 +4,6 @@
<ul class="introList">
#introListImgItem( "displayMetaDataExportForm.action?exportFormat=DHIS14XML" "DHIS14_metadata_export" "dhis14" )
#introListImgItem( "displayDetailedMetaDataExportForm.action?exportFormat=DHIS14XML" "DHIS14_detailed_metadata_export" "dhis14" )
- #introListImgItem( "displayDataValueExportForm.action?exportFormat=DHIS14XML" "DHIS14_data_export" "dhis14" )
#introListImgItem( "displayMetaDataExportForm.action?exportFormat=PDF" "pdf_metadata_export" "pdf" )
#introListImgItem( "displayMetaDataExportForm.action?exportFormat=XLS" "xls_metadata_export" "excel" )
</ul>
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/export.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/export.js 2011-01-21 04:35:42 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/export.js 2012-04-13 22:28:40 +0000
@@ -1,109 +1,10 @@
// -----------------------------------------------------------------------------
-// DataMartExport
+// Export
// -----------------------------------------------------------------------------
function exportDataValue()
{
- if ( validateDataValueExportForm() )
- {
- var aggregatedData = getListValue( "aggregatedData" );
-
- if ( aggregatedData == "true" )
- {
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( validateAggregatedExportCompleted );
- request.send( "validateAggregatedExport.action" );
- }
- else
- {
- submitDataValueExportForm();
- }
- }
-}
-
-function validateAggregatedExportCompleted( messageElement )
-{
- var type = messageElement.getAttribute( 'type' );
- var message = messageElement.firstChild.nodeValue;
-
- if ( type == 'success' )
- {
- var generateDataSource = getListValue( "generateDataSource" );
-
- if ( generateDataSource && generateDataSource == "true" )
- {
- var request = new Request();
- request.sendAsPost( getDataMartExportParams() );
- request.setCallbackSuccess( exportDataMartReceived );
- request.send( "exportDataMart.action" );
- }
- else
- {
- submitDataValueExportForm();
- }
- }
- else if ( type == 'error' )
- {
- document.getElementById( 'message' ).innerHTML = message;
- document.getElementById( 'message' ).style.display = 'block';
- }
-}
-
-function exportDataMartReceived( messageElement )
-{
- getExportStatus();
-}
-
-function getExportStatus()
-{
- var url = "getExportStatus.action";
-
- var request = new Request();
- request.setResponseTypeXML( "status" );
- request.setCallbackSuccess( exportStatusReceived );
- request.send( url );
-}
-
-function exportStatusReceived( xmlObject )
-{
- var statusMessage = getElementValue( xmlObject, "statusMessage" );
- var finished = getElementValue( xmlObject, "finished" );
-
- if ( finished == "true" )
- {
- submitDataValueExportForm();
- }
- else
- {
- setMessage( statusMessage );
-
- setTimeout( "getExportStatus();", 2000 );
- }
-}
-
-// -----------------------------------------------------------------------------
-// Supportive methods
-// -----------------------------------------------------------------------------
-
-function getDataMartExportParams()
-{
- var params = getParamString( "selectedDataSets", "selectedDataSets" );
-
- params += "startDate=" + document.getElementById( "startDate" ).value + "&";
- params += "endDate=" + document.getElementById( "endDate" ).value + "&";
- params += "dataSourceLevel=" + getListValue( "dataSourceLevel" );
-
- return params;
-}
-
-// -----------------------------------------------------------------------------
-// Export
-// -----------------------------------------------------------------------------
-
-function submitDataValueExportForm()
-{
selectAll( document.getElementById( "selectedDataSets" ) );
if ( validateDataValueExportForm() )
@@ -112,22 +13,6 @@
}
}
-function setDataType()
-{
- var aggregatedData = getListValue( "aggregatedData" );
-
- if ( aggregatedData == "true" )
- {
- showById( "aggregatedDataDiv" );
- hideById( "regularDataDiv" );
- }
- else
- {
- hideById( "aggregatedDataDiv" );
- showById( "regularDataDiv" );
- }
-}
-
// -----------------------------------------------------------------------------
// MetaDataExport
// -----------------------------------------------------------------------------
@@ -161,33 +46,33 @@
return false;
}
- hideMessage();
+ hideHeaderMessage();
return true;
}
function validateDataValueExportForm()
{
- if ( selectedOrganisationUnitIds == null || selectedOrganisationUnitIds.length == 0 )
+ if ( !selectionTreeSelection.isSelected() )
{
- setMessage( i18n_select_organisation_unit );
+ setHeaderDelayMessage( i18n_select_organisation_unit );
return false;
}
if ( !hasText( "startDate" ) )
{
- setMessage( i18n_select_startdate );
+ setHeaderDelayMessage( i18n_select_startdate );
return false;
}
if ( !hasText( "endDate" ) )
{
- setMessage( i18n_select_enddate );
+ setHeaderDelayMessage( i18n_select_enddate );
return false;
}
if ( !hasElements( "selectedDataSets" ) )
{
- setMessage( i18n_select_datasets );
+ setHeaderDelayMessage( i18n_select_datasets );
return false;
}
- hideMessage();
+ hideHeaderMessage();
return true;
}