dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13290
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4211: Further separation of shared classes on import-export for hr
------------------------------------------------------------
revno: 4211
committer: John Francis Mukulu <john.f.mukulu@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-07-26 10:48:47 +0300
message:
Further separation of shared classes on import-export for hr
added:
local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrExportPipeThread.java
local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrExportService.java
local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrImportInternalProcess.java
local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/dxf/exporter/
local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultHrDXFExportService.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetDataElementListAction.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportOptionsAction.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportStatusAction.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/GetHrImportOptionsAction.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/GetImportStatusAction.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util/
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util/ClassMapUtil.java
local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util/ImportExportInternalProcessUtil.java
local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/importForm.vm
local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/export.js
local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/import.js
local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/process.js
modified:
local/tz/dhis-web-hrentry/pom.xml
local/tz/dhis-web-hrentry/src/main/resources/struts.xml
local/tz/pom.xml
--
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
=== added file 'local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrExportPipeThread.java'
--- local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrExportPipeThread.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrExportPipeThread.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,203 @@
+package org.hisp.dhis.importexport;
+
+/*
+ * Copyright (c) 2004-2010, 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 java.util.zip.ZipOutputStream;
+
+import org.amplecode.staxwax.writer.XMLWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.SessionFactory;
+import org.hisp.dhis.importexport.mapping.NameMappingUtil;
+import org.hisp.dhis.system.process.OpenSessionThread;
+import org.hisp.dhis.system.util.StreamUtils;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class HrExportPipeThread
+ extends OpenSessionThread
+{
+ protected static final Log log = LogFactory.getLog( HrExportPipeThread.class );
+
+ private static final String XML_VERSION = "1.0";
+
+ private List<XMLHrConverter> xmlConverters = new ArrayList<XMLHrConverter>();
+
+ // -------------------------------------------------------------------------
+ // Parameters
+ // -------------------------------------------------------------------------
+
+ protected ZipOutputStream zipOutputStream;
+
+ public void setZipOutputStream( ZipOutputStream zipOutputStream )
+ {
+ this.zipOutputStream = zipOutputStream;
+ }
+
+ protected HrExportParams params;
+
+ public void setParams( HrExportParams params )
+ {
+ this.params = params;
+ }
+
+ protected XMLWriter writer;
+
+ public void setWriter( XMLWriter writer )
+ {
+ this.writer = writer;
+ }
+
+ private String encoding;
+
+ public void setEncoding( String encoding )
+ {
+ this.encoding = encoding;
+ }
+
+ private String rootName;
+
+ public void setRootName( String rootName )
+ {
+ this.rootName = rootName;
+ }
+
+ private String[] rootProperties = new String[0];
+
+ public void setRootProperties( String[] rootProperties )
+ {
+ this.rootProperties = rootProperties;
+ }
+
+ // -------------------------------------------------------------------------
+ // Constructor
+ // -------------------------------------------------------------------------
+
+ public HrExportPipeThread( SessionFactory sessionFactory )
+ {
+ super( sessionFactory );
+ }
+
+ // -------------------------------------------------------------------------
+ // PipeThread methods
+ // -------------------------------------------------------------------------
+
+ public void registerXMLHrConverter( XMLHrConverter converter )
+ {
+ this.xmlConverters.add( converter );
+ }
+
+ // -------------------------------------------------------------------------
+ // Thread implementation
+ // -------------------------------------------------------------------------
+
+ public void doRun()
+ {
+ try
+ {
+ log.info( "Export started" );
+
+ openDocument( writer );
+
+ // -----------------------------------------------------------------
+ // XML
+ // -----------------------------------------------------------------
+
+ beforeXML( writer );
+
+ for ( XMLHrConverter converter : xmlConverters )
+ {
+ converter.write( writer, params );
+ }
+
+ afterXML( writer );
+
+ closeDocument( writer );
+
+ StreamUtils.closeZipEntry( zipOutputStream );
+
+ log.info( "Export done" );
+ }
+ catch ( Exception ex )
+ {
+ ex.printStackTrace();
+
+ throw new RuntimeException( "Writing failed" + ex );
+ }
+ finally
+ {
+ writer.closeWriter();
+
+ StreamUtils.closeOutputStream( zipOutputStream );
+
+ NameMappingUtil.clearMapping();
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Overridable methods
+ // -------------------------------------------------------------------------
+
+ protected void beforeXSD( XMLWriter writer )
+ {
+ }
+
+ protected void afterXSD( XMLWriter writer )
+ {
+ }
+
+ protected void beforeXML( XMLWriter writer )
+ {
+ }
+
+ protected void afterXML( XMLWriter writer )
+ {
+ }
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private void openDocument( XMLWriter writer )
+ {
+ writer.openDocument( encoding, XML_VERSION );
+
+ writer.openElement( rootName, rootProperties );
+ }
+
+ private void closeDocument( XMLWriter writer )
+ {
+ writer.closeElement();
+
+ writer.closeDocument();
+ }
+}
=== added file 'local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrExportService.java'
--- local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrExportService.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrExportService.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,39 @@
+package org.hisp.dhis.importexport;
+
+/*
+ * Copyright (c) 2004-2010, 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.io.InputStream;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id: ExportService.java 4646 2008-02-26 14:54:29Z larshelg $
+ */
+public interface HrExportService
+{
+ InputStream exportData( HrExportParams params );
+}
=== added file 'local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrImportInternalProcess.java'
--- local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrImportInternalProcess.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/HrImportInternalProcess.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,91 @@
+package org.hisp.dhis.importexport;
+
+/*
+ * Copyright (c) 2004-2010, 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.io.InputStream;
+
+import org.amplecode.cave.process.SerialToGroup;
+import org.hisp.dhis.system.process.AbstractStatementInternalProcess;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id: ImportInternalProcess.java 6443 2008-11-22 10:12:11Z larshelg $
+ */
+public class HrImportInternalProcess
+ extends AbstractStatementInternalProcess implements SerialToGroup
+{
+ private static final String PROCESS_GROUP = "ImportProcessGroup";
+
+ // -------------------------------------------------------------------------
+ // Properties
+ // -------------------------------------------------------------------------
+
+ protected ImportParams params;
+
+ public final void setImportParams( ImportParams params )
+ {
+ this.params = params;
+ }
+
+ protected InputStream inputStream;
+
+ public final void setInputStream( InputStream inputStream )
+ {
+ this.inputStream = inputStream;
+ }
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ImportService importService;
+
+ public void setImportService( ImportService importService )
+ {
+ this.importService = importService;
+ }
+
+ // -------------------------------------------------------------------------
+ // SerialToGroup implementation
+ // -------------------------------------------------------------------------
+
+ public String getGroup()
+ {
+ return PROCESS_GROUP;
+ }
+
+ // -------------------------------------------------------------------------
+ // AbstractStatementInternalProcess implementation
+ // -------------------------------------------------------------------------
+
+ public void executeStatements()
+ throws Exception
+ {
+ importService.importData( params, inputStream, getState() );
+ }
+}
=== added directory 'local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/dxf/exporter'
=== added file 'local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultHrDXFExportService.java'
--- local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultHrDXFExportService.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-service-importexport-hr/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultHrDXFExportService.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,257 @@
+package org.hisp.dhis.importexport.dxf.exporter;
+
+/*
+ * Copyright (c) 2004-2010, 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.importexport.ImportParams.ATTRIBUTE_NAMESPACE;
+import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.ATTRIBUTE_EXPORTED;
+import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.ATTRIBUTE_MINOR_VERSION;
+import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.DXFROOT;
+import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.MINOR_VERSION_12;
+import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.NAMESPACE_10;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.amplecode.staxwax.factory.XMLFactory;
+import org.amplecode.staxwax.writer.XMLWriter;
+import org.hibernate.SessionFactory;
+import org.hisp.dhis.hr.AttributeGroupService;
+import org.hisp.dhis.hr.AttributeOptionGroupService;
+import org.hisp.dhis.hr.AttributeOptionsService;
+import org.hisp.dhis.hr.AttributeService;
+import org.hisp.dhis.hr.DataTypeService;
+import org.hisp.dhis.hr.DataValuesService;
+import org.hisp.dhis.hr.HistoryService;
+import org.hisp.dhis.hr.HrDataSetService;
+import org.hisp.dhis.hr.InputTypeService;
+import org.hisp.dhis.hr.PersonService;
+import org.hisp.dhis.hr.TrainingService;
+import org.hisp.dhis.importexport.HrExportParams;
+import org.hisp.dhis.importexport.HrExportPipeThread;
+import org.hisp.dhis.importexport.HrExportService;
+import org.hisp.dhis.importexport.dxf.converter.DataTypeConverter;
+import org.hisp.dhis.importexport.dxf.converter.AttributeConverter;
+import org.hisp.dhis.importexport.dxf.converter.AttributeAssociationConverter;
+import org.hisp.dhis.importexport.dxf.converter.AttributeOptionsAssociationConverter;
+import org.hisp.dhis.importexport.dxf.converter.AttributeGroupConverter;
+import org.hisp.dhis.importexport.dxf.converter.AttributeOptionGroupConverter;
+import org.hisp.dhis.importexport.dxf.converter.AttributeOptionsConverter;
+import org.hisp.dhis.importexport.dxf.converter.DataValuesConverter;
+import org.hisp.dhis.importexport.dxf.converter.HistoryConverter;
+import org.hisp.dhis.importexport.dxf.converter.HrDataSetConverter;
+import org.hisp.dhis.importexport.dxf.converter.HrDataSetMemberConverter;
+import org.hisp.dhis.importexport.dxf.converter.InputTypeConverter;
+import org.hisp.dhis.importexport.dxf.converter.PersonConverter;
+import org.hisp.dhis.importexport.dxf.converter.TrainingConverter;
+import org.hisp.dhis.system.util.DateUtils;
+
+/**
+ * @author John Francis Mukulu <john.f.mukulu@xxxxxxxxx>
+ * @version $Id: DefaultDXFHrExportService.java 5960 2008-10-17 14:07:50Z larshelg
+ * $
+ */
+public class DefaultHrDXFExportService
+ implements HrExportService
+{
+ private static final String ZIP_ENTRY_NAME = "Export.xml";
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private SessionFactory sessionFactory;
+
+ public void setSessionFactory( SessionFactory sessionFactory )
+ {
+ this.sessionFactory = sessionFactory;
+ }
+
+
+ // ----------------------------------
+ // Setters for Hr service classes
+ // ----------------------------------
+
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
+ private AttributeOptionsService attributeOptionsService;
+
+ public void setAttributeOptionsService( AttributeOptionsService attributeOptionsService )
+ {
+ this.attributeOptionsService = attributeOptionsService;
+ }
+
+ private HrDataSetService hrDataSetService;
+
+ public void setHrDataSetService( HrDataSetService hrDataSetService )
+ {
+ this.hrDataSetService = hrDataSetService;
+ }
+
+ private PersonService personService;
+
+ public void setPersonService( PersonService personService )
+ {
+ this.personService = personService;
+ }
+
+ private DataValuesService dataValuesService;
+
+ public void setDataValuesService( DataValuesService dataValuesService )
+ {
+ this.dataValuesService = dataValuesService;
+ }
+
+ private HistoryService historyService;
+
+ public void setHistoryService( HistoryService historyService )
+ {
+ this.historyService = historyService;
+ }
+
+ private TrainingService trainingService;
+
+ public void setTrainingService( TrainingService trainingService )
+ {
+ this.trainingService = trainingService;
+ }
+
+ private AttributeGroupService attributeGroupService;
+
+ public void setAttributeGroupService( AttributeGroupService attributeGroupService )
+ {
+ this.attributeGroupService = attributeGroupService;
+ }
+
+ private AttributeOptionGroupService attributeOptionGroupService;
+
+ public void setAttributeOptionGroupService( AttributeOptionGroupService attributeOptionGroupService )
+ {
+ this.attributeOptionGroupService = attributeOptionGroupService;
+ }
+
+ private InputTypeService inputTypeService;
+
+ public void setInputTypeService( InputTypeService inputTypeService )
+ {
+ this.inputTypeService = inputTypeService;
+ }
+
+ private DataTypeService dataTypeService;
+
+ public void setDataTypeService( DataTypeService dataTypeService )
+ {
+ this.dataTypeService = dataTypeService;
+ }
+
+ // -------------------------------------------------------------------------
+ // HrExportService implementation
+ // -------------------------------------------------------------------------
+
+ public InputStream exportData( HrExportParams params )
+ {
+ try
+ {
+ // -----------------------------------------------------------------
+ // Pipes are input/output pairs. Data written on the output stream
+ // shows up on the input stream at the other end of the pipe.
+ // -----------------------------------------------------------------
+
+ PipedOutputStream out = new PipedOutputStream();
+
+ PipedInputStream in = new PipedInputStream( out );
+
+ ZipOutputStream zipOut = new ZipOutputStream( out );
+
+ zipOut.putNextEntry( new ZipEntry( ZIP_ENTRY_NAME ) );
+
+ XMLWriter writer = XMLFactory.getPlainXMLWriter( zipOut );
+
+ // -----------------------------------------------------------------
+ // Writes to one end of the pipe
+ // -----------------------------------------------------------------
+
+ String[] rootProperties = { ATTRIBUTE_NAMESPACE, NAMESPACE_10, ATTRIBUTE_MINOR_VERSION, MINOR_VERSION_12,
+ ATTRIBUTE_EXPORTED, DateUtils.getMediumDateString() };
+
+ HrExportPipeThread thread = new HrExportPipeThread( sessionFactory );
+
+ thread.setZipOutputStream( zipOut );
+ thread.setParams( params );
+ thread.setWriter( writer );
+ thread.setRootName( DXFROOT );
+ thread.setRootProperties( rootProperties );
+
+ if ( params.isHrDomain() )
+ {
+ // ---------------------------------------------------------------
+ // HR XMLCovenverters
+ // ---------------------------------------------------------------
+ thread.registerXMLHrConverter( new DataTypeConverter( dataTypeService) );
+ thread.registerXMLHrConverter( new InputTypeConverter( inputTypeService) );
+ thread.registerXMLHrConverter( new AttributeConverter( attributeService) );
+ thread.registerXMLHrConverter( new AttributeOptionsConverter( attributeOptionsService ) );
+ thread.registerXMLHrConverter( new AttributeGroupConverter( attributeGroupService ) );
+ thread.registerXMLHrConverter( new AttributeAssociationConverter( attributeGroupService ) );
+ thread.registerXMLHrConverter( new AttributeOptionGroupConverter( attributeOptionGroupService ) );
+ thread.registerXMLHrConverter( new AttributeOptionsAssociationConverter( attributeOptionGroupService ) );
+ thread.registerXMLHrConverter( new HrDataSetConverter( hrDataSetService ) );
+ thread.registerXMLHrConverter( new HrDataSetMemberConverter( hrDataSetService, attributeService ) );
+
+ thread.registerXMLHrConverter( new PersonConverter( personService) );
+ thread.registerXMLHrConverter( new HistoryConverter( historyService ) );
+ thread.registerXMLHrConverter( new TrainingConverter( trainingService ) );
+ thread.registerXMLHrConverter( new DataValuesConverter( dataValuesService ) );
+ // ------------------------------------------------------------------
+ }
+
+ thread.start();
+
+ // -----------------------------------------------------------------
+ // Reads at the other end of the pipe
+ // -----------------------------------------------------------------
+
+ InputStream bis = new BufferedInputStream( in );
+
+ return bis;
+ }
+ catch ( IOException ex )
+ {
+ throw new RuntimeException( "Error occured during export to stream", ex );
+ }
+ }
+}
=== modified file 'local/tz/dhis-web-hrentry/pom.xml'
--- local/tz/dhis-web-hrentry/pom.xml 2011-07-05 18:05:44 +0000
+++ local/tz/dhis-web-hrentry/pom.xml 2011-07-26 07:48:47 +0000
@@ -41,6 +41,12 @@
<artifactId>dhis-service-hr</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-importexport-hr</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
=== added directory 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport'
=== added directory 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action'
=== added directory 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp'
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,408 @@
+package org.hisp.dhis.importexport.action.exp;
+
+/*
+ * Copyright (c) 2004-2010, 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.DateUtils.getMediumDate;
+import static org.hisp.dhis.system.util.DateUtils.getMediumDateString;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.text.SimpleDateFormat;
+
+import org.hisp.dhis.common.ServiceProvider;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.hr.Attribute;
+import org.hisp.dhis.hr.AttributeService;
+import org.hisp.dhis.hr.DataTypeService;
+import org.hisp.dhis.hr.HrDataSetService;
+import org.hisp.dhis.hr.InputTypeService;
+import org.hisp.dhis.hr.PersonService;
+//import org.hisp.dhis.importexport.HrExportParams;
+//import org.hisp.dhis.importexport.HrExportService;
+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.ActionSupport;
+
+/**
+ * @author John Francis Mukulu <john.f.mukulu@xxxxxxxxx>
+ * @version $Id$
+ */
+public class DataValueExportAction
+ extends ActionSupport
+{
+ 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<HrExportService> serviceProvider;
+//
+// public void setServiceProvider( ServiceProvider<HrExportService> serviceProvider )
+// {
+// this.serviceProvider = serviceProvider;
+// }
+
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ private HrDataSetService hrDataSetService;
+
+ public void setHrDataSetService( HrDataSetService hrDataSetService )
+ {
+ this.hrDataSetService = hrDataSetService;
+ }
+
+ private PersonService personService;
+
+ public void setPersonService( PersonService personService )
+ {
+ this.personService = personService;
+ }
+
+ private DataTypeService dataTypeService;
+
+ public void setDataTypeService( DataTypeService dataTypeService )
+ {
+ this.dataTypeService = dataTypeService;
+ }
+
+ private InputTypeService inputTypeService;
+
+ public void setInputTypeService( InputTypeService inputTypeService )
+ {
+ this.inputTypeService = inputTypeService;
+ }
+
+ private AttributeService attributeService;
+
+ public void setAttributeService(AttributeService attributeService)
+ {
+ this.attributeService = attributeService;
+ }
+ public AttributeService getAttributeService()
+ {
+ return attributeService;
+ }
+
+ 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;
+ }
+
+ public Collection<Integer> getIntegerCollection(Collection<String> stringInputs )
+ {
+ Collection<Integer> integers = new ArrayList<Integer>(stringInputs.size());
+ for(String stringInput: stringInputs)
+ {
+ integers.add(Integer.valueOf(stringInput) );
+ }
+ return integers;
+ }
+
+ // -------------------------------------------------------------------------
+ // 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 String domainType;
+
+ public void setDomainType( String domainType )
+ {
+ this.domainType = domainType;
+ }
+
+ public String getDomainType()
+ {
+ return domainType;
+ }
+
+ 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;
+ }
+
+ private Collection<String> selectedHrDataSets;
+
+ public void setSelectedHrDataSets( Collection<String> selectedHrDataSets )
+ {
+ this.selectedHrDataSets = selectedHrDataSets;
+ }
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+ public void setMessage( String message )
+ {
+ this.message = message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+// HrExportParams params = new HrExportParams();
+
+ // ---------------------------------------------------------------------
+ // 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() ) ) );
+ }
+ if( selectedHrDataSets != null )
+ {
+// params.setIsHrDomain(true);
+// params.setIncludeHrMetadata(true);
+// params.setAttributeOptions(null);
+// params.setAttributes(null);
+// params.setAttributeGroups(null);
+// params.setAttributeOptionGroups(null);
+// params.setHistory(null);
+// params.setTraining(null);
+// params.setPerson( null );
+// params.setHrDataSets( this.getIntegerCollection( selectedHrDataSets ) );
+// params.setAttributes( getIdentifiers( Attribute.class, hrDataSetService.getDistinctAttributes(params.getHrDataSets()) ) );
+ }
+
+
+ // ---------------------------------------------------------------------
+ // 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() ) ) );
+ }
+ }
+ }
+ }
+
+// if ( selectedDataSets != null ) params.setIncludeDataValues( true );
+// params.setIncludeCompleteDataSetRegistrations( true );
+// params.setAggregatedData( aggregatedData );
+
+ // ---------------------------------------------------------------------
+ // Export
+ // ---------------------------------------------------------------------
+
+// HrExportService exportService = serviceProvider.provide( exportFormat );
+//
+// inputStream = exportService.exportData( params );
+//
+// fileName = getFileName( params );
+
+ return SUCCESS;
+ }
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+// private String getFileName( HrExportParams params )
+// {
+// String fileName = FILE_PREFIX + FILE_SEPARATOR +
+// getMediumDateString( getMediumDate( startDate ) ) + FILE_SEPARATOR +
+// getMediumDateString( getMediumDate( endDate ) );
+//
+// if( selectedHrDataSets != null ) {
+// fileName = FILE_PREFIX + FILE_SEPARATOR + "HumanResource" + FILE_SEPARATOR +
+// new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(Calendar.getInstance().getTime()) ;
+// }
+//
+// 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;
+// }
+
+ private String fileNameEncode( String in )
+ {
+ if ( in == null )
+ {
+ return "";
+ }
+
+ in = in.replaceAll( " ", FILE_SEPARATOR );
+
+ return in;
+ }
+}
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetDataElementListAction.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetDataElementListAction.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetDataElementListAction.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,181 @@
+package org.hisp.dhis.importexport.action.exp;
+
+/*
+ * Copyright (c) 2004-2010, 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.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.hisp.dhis.datadictionary.DataDictionary;
+import org.hisp.dhis.datadictionary.DataDictionaryService;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Torgeir Lorange Ostby
+ * @version $Id: GetDataElementListAction.java 5573 2008-08-22 03:39:55Z
+ * ch_bharath1 $
+ */
+public class GetDataElementListAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ private DataDictionaryService dataDictionaryService;
+
+ public void setDataDictionaryService( DataDictionaryService dataDictionaryService )
+ {
+ this.dataDictionaryService = dataDictionaryService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Comparator
+ // -------------------------------------------------------------------------
+
+ private Comparator<DataElement> dataElementComparator;
+
+ public void setDataElementComparator( Comparator<DataElement> dataElementComparator )
+ {
+ this.dataElementComparator = dataElementComparator;
+ }
+
+ // -------------------------------------------------------------------------
+ // DisplayPropertyHandler
+ // -------------------------------------------------------------------------
+
+ private DisplayPropertyHandler displayPropertyHandler;
+
+ public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
+ {
+ this.displayPropertyHandler = displayPropertyHandler;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private List<DataElement> dataElements = new ArrayList<DataElement>();
+
+ public List<DataElement> getDataElements()
+ {
+ return dataElements;
+ }
+
+ private List<DataElementGroup> dataElementGroups;
+
+ public List<DataElementGroup> getDataElementGroups()
+ {
+ return dataElementGroups;
+ }
+
+ private List<DataDictionary> dataDictionaries;
+
+ public List<DataDictionary> getDataDictionaries()
+ {
+ return dataDictionaries;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private Integer dataDictionaryId;
+
+ public Integer getDataDictionaryId()
+ {
+ return dataDictionaryId;
+ }
+
+ public void setDataDictionaryId( Integer dataDictionaryId )
+ {
+ this.dataDictionaryId = dataDictionaryId;
+ }
+
+ private Integer dataElementGroupId;
+
+ public void setDataElementGroupId( Integer dataElementGroupId )
+ {
+ this.dataElementGroupId = dataElementGroupId;
+ }
+
+ public Integer getDataElementGroupId()
+ {
+ return dataElementGroupId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implemantation
+ // -------------------------------------------------------------------------
+
+ @SuppressWarnings( "unchecked" )
+ public String execute()
+ {
+ if ( dataDictionaryId != null && dataElementGroupId == null )
+ {
+ dataElements = new ArrayList<DataElement>( dataDictionaryService.getDataDictionary( dataDictionaryId ).getDataElements() );
+ }
+ else if ( dataDictionaryId == null && dataElementGroupId != null )
+ {
+ dataElements = new ArrayList<DataElement>( dataElementService.getDataElementGroup( dataElementGroupId ).getMembers() );
+ }
+ else if ( dataDictionaryId != null && dataElementGroupId != null )
+ {
+ Collection<DataElement> dictionary = dataDictionaryService.getDataDictionary( dataDictionaryId ).getDataElements();
+
+ Collection<DataElement> members = dataElementService.getDataElementGroup( dataElementGroupId ).getMembers();
+
+ dataElements = new ArrayList<DataElement>( CollectionUtils.intersection( dictionary, members ) );
+ }
+ else
+ {
+ dataElements = new ArrayList<DataElement>( dataElementService.getAllDataElements() );
+ }
+
+ Collections.sort( dataElements, dataElementComparator );
+
+ displayPropertyHandler.handle( dataElements );
+
+ return SUCCESS;
+ }
+}
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportOptionsAction.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportOptionsAction.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportOptionsAction.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,155 @@
+package org.hisp.dhis.importexport.action.exp;
+
+/*
+ * Copyright (c) 2004-2010, 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.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.hr.Attribute;
+import org.hisp.dhis.hr.HrDataSet;
+import org.hisp.dhis.hr.HrDataSetService;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id: GetOptionsAction.java 2869 2007-02-20 14:26:09Z andegje $
+ */
+public class GetExportOptionsAction
+ extends ActionSupport
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private HrDataSetService hrDataSetService;
+
+ public void setHrDataSetService( HrDataSetService hrDataSetService )
+ {
+ this.hrDataSetService = hrDataSetService;
+ }
+
+ private ProgramService programService;
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
+ 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<HrDataSet> hrDataSets;
+
+ public List<HrDataSet> getHrDataSets()
+ {
+ return hrDataSets;
+ }
+
+ private List<Program> programs;
+
+ public List<Program> getPrograms()
+ {
+ return programs;
+ }
+
+ 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() );
+
+ hrDataSets = new ArrayList<HrDataSet>( hrDataSetService.getAllHrDataSets() );
+
+ levels = new ArrayList<OrganisationUnitLevel>( organisationUnitService.getOrganisationUnitLevels() );
+
+ return SUCCESS;
+ }
+}
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportStatusAction.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportStatusAction.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/GetExportStatusAction.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,112 @@
+package org.hisp.dhis.importexport.action.exp;
+
+/*
+ * Copyright (c) 2004-2010, 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;
+ }
+}
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,362 @@
+package org.hisp.dhis.importexport.action.exp;
+
+/*
+ * Copyright (c) 2004-2010, 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.io.InputStream;
+
+import org.hisp.dhis.common.ServiceProvider;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
+//import org.hisp.dhis.importexport.ExportParams;
+//import org.hisp.dhis.importexport.ExportService;
+//import org.hisp.dhis.importexport.ImportDataValueService;
+//import org.hisp.dhis.importexport.ImportObjectService;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * @author John Francis Mukulu <john.f.mukulu@xxxxxxxxx>
+ * @version $Id$
+ */
+public class MetaDataExportAction
+ extends ActionSupport
+{
+ private static final String FILENAME = "Export_meta.zip";
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+// private ServiceProvider<ExportService> serviceProvider;
+//
+// public void setServiceProvider( ServiceProvider<ExportService> serviceProvider )
+// {
+// this.serviceProvider = serviceProvider;
+// }
+//
+// private ImportObjectService importObjectService;
+//
+// public void setImportObjectService( ImportObjectService importObjectService )
+// {
+// this.importObjectService = importObjectService;
+// }
+//
+// private ImportDataValueService importDataValueService;
+//
+// public void setImportDataValueService( ImportDataValueService importDataValueService )
+// {
+// this.importDataValueService = importDataValueService;
+// }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ private I18nFormat format;
+
+ public void setFormat( I18nFormat format )
+ {
+ this.format = format;
+ }
+
+ // -------------------------------------------------------------------------
+ // 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 dataElements;
+
+ public void setDataElements( boolean dataElements )
+ {
+ this.dataElements = dataElements;
+ }
+
+ private boolean dataElementGroups;
+
+ public void setDataElementGroups( boolean dataElementGroups )
+ {
+ this.dataElementGroups = dataElementGroups;
+ }
+
+ private boolean dataElementGroupSets;
+
+ public void setDataElementGroupSets( boolean dataElementGroupSets )
+ {
+ this.dataElementGroupSets = dataElementGroupSets;
+ }
+
+ private boolean dataDictionaries;
+
+ public void setDataDictionaries( boolean dataDictionaries )
+ {
+ this.dataDictionaries = dataDictionaries;
+ }
+
+ private boolean dataSets;
+
+ public void setDataSets( boolean dataSets )
+ {
+ this.dataSets = dataSets;
+ }
+
+ private boolean indicators;
+
+ public void setIndicators( boolean indicators )
+ {
+ this.indicators = indicators;
+ }
+
+ private boolean indicatorGroups;
+
+ public void setIndicatorGroups( boolean indicatorGroups )
+ {
+ this.indicatorGroups = indicatorGroups;
+ }
+
+ private boolean indicatorGroupSets;
+
+ public void setIndicatorGroupSets( boolean indicatorGroupSets )
+ {
+ this.indicatorGroupSets = indicatorGroupSets;
+ }
+
+ private boolean organisationUnits;
+
+ public void setOrganisationUnits( boolean organisationUnits )
+ {
+ this.organisationUnits = organisationUnits;
+ }
+
+ private boolean organisationUnitGroups;
+
+ public void setOrganisationUnitGroups( boolean organisationUnitGroups )
+ {
+ this.organisationUnitGroups = organisationUnitGroups;
+ }
+
+ private boolean organisationUnitGroupSets;
+
+ public void setOrganisationUnitGroupSets( boolean organisationUnitGroupSets )
+ {
+ this.organisationUnitGroupSets = organisationUnitGroupSets;
+ }
+
+ private boolean organisationUnitLevels;
+
+ public void setOrganisationUnitLevels( boolean organisationUnitLevels )
+ {
+ this.organisationUnitLevels = organisationUnitLevels;
+ }
+
+ private boolean validationRules;
+
+ public void setValidationRules( boolean validationRules )
+ {
+ this.validationRules = validationRules;
+ }
+
+ private boolean reports;
+
+ public void setReports( boolean reports )
+ {
+ this.reports = reports;
+ }
+
+ private boolean reportTables;
+
+ public void setReportTables( boolean reportTables )
+ {
+ this.reportTables = reportTables;
+ }
+
+ private boolean charts;
+
+ public void setCharts( boolean charts )
+ {
+ this.charts = charts;
+ }
+
+ private boolean olapUrls;
+
+ public void setOlapUrls( boolean olapUrls )
+ {
+ this.olapUrls = olapUrls;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+// importDataValueService.deleteImportDataValues();
+// importObjectService.deleteImportObjects();
+//
+// ExportParams params = new ExportParams();
+//
+// if ( dataElements || dataElementGroups || indicators || dataSets || validationRules || reportTables || charts )
+// {
+// params.setCategories( null );
+// params.setCategoryCombos( null );
+// params.setCategoryOptions( null );
+// params.setCategoryOptionCombos( null );
+// params.setDataElements( null );
+// params.setCalculatedDataElements( null );
+// }
+//
+// if ( dataElementGroups )
+// {
+// params.setDataElementGroups( null );
+// }
+//
+// if ( dataElementGroupSets )
+// {
+// params.setDataElementGroupSets( null );
+// }
+//
+// if ( indicators || indicatorGroups || reportTables || charts )
+// {
+// params.setIndicators( null );
+//
+// params.setIndicatorTypes( null );
+// }
+//
+// if ( indicatorGroups )
+// {
+// params.setIndicatorGroups( null );
+// }
+//
+// if ( indicatorGroupSets )
+// {
+// params.setIndicatorGroupSets( null );
+// }
+//
+// if ( dataDictionaries )
+// {
+// params.setDataDictionaries( null );
+// }
+//
+// if ( dataSets || reportTables )
+// {
+// params.setDataSets( null );
+// }
+//
+// if ( organisationUnits || organisationUnitGroups || reportTables || charts )
+// {
+// params.setOrganisationUnits( null );
+// }
+//
+// if ( organisationUnitGroups || organisationUnitGroupSets )
+// {
+// params.setOrganisationUnitGroups( null );
+// }
+//
+// if ( organisationUnitGroupSets )
+// {
+// params.setOrganisationUnitGroupSets( null );
+// }
+//
+// if ( organisationUnitLevels )
+// {
+// params.setOrganisationUnitLevels( null );
+// }
+//
+// if ( validationRules )
+// {
+// params.setValidationRules( null );
+// }
+//
+// if ( reports )
+// {
+// params.setReports( null );
+// }
+//
+// if ( reportTables )
+// {
+// params.setReportTables( null );
+// params.setPeriods( null ); // TODO Include only relevant periods
+// }
+//
+// if ( charts )
+// {
+// params.setCharts( null );
+// params.setPeriods( null );
+// }
+//
+// if ( olapUrls )
+// {
+// params.setOlapUrls( null );
+// }
+//
+// params.setIncludeDataValues( false );
+//
+// params.setI18n( i18n );
+// params.setFormat( format );
+//
+// ExportService exportService = serviceProvider.provide( exportFormat );
+//
+// inputStream = exportService.exportData( params );
+
+ fileName = FILENAME;
+
+ return SUCCESS;
+ }
+}
=== added directory 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp'
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/GetHrImportOptionsAction.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/GetHrImportOptionsAction.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/GetHrImportOptionsAction.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,85 @@
+package org.hisp.dhis.importexport.action.imp;
+
+/*
+ * Copyright (c) 2004-2010, 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.importexport.action.util.ImportExportInternalProcessUtil.*;
+import org.hisp.dhis.external.configuration.NoConfigurationFoundException;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class GetHrImportOptionsAction
+ extends ActionSupport
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String importFormat;
+
+ public String getImportFormat()
+ {
+ return importFormat;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & output report params
+ // -------------------------------------------------------------------------
+
+ private String type;
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType( String type )
+ {
+ this.type = type;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ importFormat = getCurrentRunningProcessImportFormat();
+
+ return SUCCESS;
+ }
+}
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/GetImportStatusAction.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/GetImportStatusAction.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/GetImportStatusAction.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,161 @@
+package org.hisp.dhis.importexport.action.imp;
+
+/*
+ * Copyright (c) 2004-2010, 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.importexport.action.util.ImportExportInternalProcessUtil.*;
+import static org.hisp.dhis.util.InternalProcessUtil.PROCESS_KEY_IMPORT;
+
+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.ActionSupport;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class GetImportStatusAction
+ extends ActionSupport
+{
+ private static final String ACTION_INFO = "info";
+ private static final String ACTION_PREVIEW = "preview";
+ private static final String ACTION_ANALYSIS = "analysis";
+
+ // -------------------------------------------------------------------------
+ // 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 actionType = "";
+
+ public String getActionType()
+ {
+ return actionType;
+ }
+
+ private String statusMessage = "";
+
+ public String getStatusMessage()
+ {
+ return statusMessage;
+ }
+
+ private String fileMessage = "";
+
+ public String getFileMessage()
+ {
+ return fileMessage;
+ }
+
+ private boolean running = false;
+
+ public boolean isRunning()
+ {
+ return running;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ if ( processIsRunning( PROCESS_KEY_IMPORT ) )
+ {
+ String id = getCurrentRunningProcess( PROCESS_KEY_IMPORT );
+
+ ProcessExecutor executor = processCoordinator.getProcess( id );
+
+ if ( executor != null && executor.getProcess() != null && executor.getState() != null && executor.getState() instanceof MessageState )
+ {
+ MessageState state = (MessageState) executor.getState();
+
+ setOutput( null, i18n.getString( state.getMessage() ), getCurrentImportFileName() );
+
+ String type = getCurrentRunningProcessType();
+
+ if ( type.equalsIgnoreCase( TYPE_PREVIEW ) && state.isEnded() )
+ {
+ actionType = ACTION_PREVIEW;
+
+ setCurrentRunningProcessType( TYPE_IMPORT );
+ }
+ else if ( type.equalsIgnoreCase( TYPE_ANALYSIS ) && state.isEnded() )
+ {
+ actionType = ACTION_ANALYSIS;
+ }
+ else
+ {
+ actionType = ACTION_INFO;
+ }
+
+ if ( !state.isEnded() && !state.isCancelled() )
+ {
+ running = true;
+ }
+ }
+ }
+ else
+ {
+ setOutput( ACTION_INFO, i18n.getString( "no_import_process_running" ), i18n.getString( "no_current_file" ) );
+ }
+
+ return SUCCESS;
+ }
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private void setOutput( String actionType, String statusMessage, String fileMessage )
+ {
+ this.actionType = actionType;
+ this.statusMessage = statusMessage;
+ this.fileMessage = fileMessage;
+ }
+}
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,229 @@
+package org.hisp.dhis.importexport.action.imp;
+
+/*
+ * Copyright (c) 2004-2010, 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.importexport.action.util.ImportExportInternalProcessUtil.getCurrentRunningProcessImportFormat;
+//import static org.hisp.dhis.importexport.action.util.ImportExportInternalProcessUtil.setCurrentImportFileName;
+//import static org.hisp.dhis.importexport.action.util.ImportExportInternalProcessUtil.setCurrentRunningProcessType;
+import static org.hisp.dhis.system.util.ConversionUtils.getList;
+import static org.hisp.dhis.util.InternalProcessUtil.PROCESS_KEY_IMPORT;
+import static org.hisp.dhis.util.InternalProcessUtil.setCurrentRunningProcess;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.List;
+
+import org.amplecode.cave.process.ProcessCoordinator;
+import org.amplecode.cave.process.ProcessExecutor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.i18n.I18n;
+//import org.hisp.dhis.importexport.HrImportInternalProcess;
+//import org.hisp.dhis.importexport.ImportParams;
+//import org.hisp.dhis.importexport.ImportStrategy;
+//import org.hisp.dhis.importexport.ImportType;
+import org.hisp.dhis.system.util.DateUtils;
+import org.hisp.dhis.user.CurrentUserService;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class ImportAction
+ extends ActionSupport
+{
+ private static final String IMPORT_INTERNAL_PROCESS_ID_POSTFIX = "ImportService";
+
+ private static final Log log = LogFactory.getLog( ImportAction.class );
+
+ private static final List<String> ALLOWED_CONTENT_TYPES = getList(
+ "application/x-zip-compressed",
+ "application/zip",
+ "application/x-gzip",
+ "application/octet-stream",
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ "text/xml" );
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProcessCoordinator processCoordinator;
+
+ public void setProcessCoordinator( ProcessCoordinator processCoordinator )
+ {
+ this.processCoordinator = processCoordinator;
+ }
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & output report params
+ // -------------------------------------------------------------------------
+
+ private String type;
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType( String type )
+ {
+ this.type = type;
+ }
+
+ private String incomingRecords;
+
+ public void setIncomingRecords( String incomingRecords )
+ {
+ this.incomingRecords = incomingRecords;
+ }
+
+ private boolean dataValues;
+
+ public void setDataValues( boolean dataValues )
+ {
+ this.dataValues = dataValues;
+ }
+
+ private boolean skipCheckMatching;
+
+ public void setSkipCheckMatching( boolean skipCheckMatching )
+ {
+ this.skipCheckMatching = skipCheckMatching;
+ }
+
+ private String lastUpdated;
+
+ public void setLastUpdated( String lastUpdated )
+ {
+ this.lastUpdated = lastUpdated;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input file upload
+ // -------------------------------------------------------------------------
+
+ private File file;
+
+ public void setUpload( File file )
+ {
+ this.file = file;
+ }
+
+ private String fileName;
+
+ public void setUploadFileName( String fileName )
+ {
+ this.fileName = fileName;
+ }
+
+ private String contentType;
+
+ public void setUploadContentType( String contentType )
+ {
+ this.contentType = contentType;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+// String importFormat = getCurrentRunningProcessImportFormat();
+
+ InputStream in = null;
+
+ // ---------------------------------------------------------------------
+ // Import parameters
+ // ---------------------------------------------------------------------
+
+// ImportParams params = new ImportParams();
+//
+// ImportStrategy strategy = ImportStrategy.valueOf( incomingRecords );
+//
+// params.setType( ImportType.valueOf( type ) );
+// params.setImportStrategy( strategy );
+// params.setDataValues( dataValues );
+// params.setSkipCheckMatching( skipCheckMatching );
+// params.setLastUpdated( ( lastUpdated != null && lastUpdated.trim().length() > 0 ) ? DateUtils.getMediumDate( lastUpdated ) : null );
+//
+ // ---------------------------------------------------------------------
+ // Process
+ // ---------------------------------------------------------------------
+
+// String importType = importFormat + IMPORT_INTERNAL_PROCESS_ID_POSTFIX;
+
+ String owner = currentUserService.getCurrentUsername();
+
+// ProcessExecutor executor = processCoordinator.newProcess( importType, owner );
+
+// HrImportInternalProcess importProcess = (HrImportInternalProcess) executor.getProcess();
+//
+// importProcess.setImportParams( params );
+// importProcess.setInputStream( in );
+
+// processCoordinator.requestProcessExecution( executor );
+//
+// setCurrentRunningProcess( PROCESS_KEY_IMPORT, executor.getId() );
+// setCurrentRunningProcessType( type );
+// setCurrentImportFileName( fileName );
+
+ return SUCCESS;
+ }
+}
=== added directory 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util'
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util/ClassMapUtil.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util/ClassMapUtil.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util/ClassMapUtil.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,145 @@
+package org.hisp.dhis.importexport.action.util;
+
+/*
+ * Copyright (c) 2004-2010, 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.common.Objects.DATADICTIONARY;
+import static org.hisp.dhis.common.Objects.DATAELEMENT;
+import static org.hisp.dhis.common.Objects.DATAELEMENTGROUP;
+import static org.hisp.dhis.common.Objects.DATAELEMENTGROUPSET;
+import static org.hisp.dhis.common.Objects.DATASET;
+import static org.hisp.dhis.common.Objects.DATAVALUE;
+import static org.hisp.dhis.common.Objects.INDICATOR;
+import static org.hisp.dhis.common.Objects.INDICATORGROUP;
+import static org.hisp.dhis.common.Objects.INDICATORGROUPSET;
+import static org.hisp.dhis.common.Objects.INDICATORTYPE;
+import static org.hisp.dhis.common.Objects.ORGANISATIONUNIT;
+import static org.hisp.dhis.common.Objects.ORGANISATIONUNITGROUP;
+import static org.hisp.dhis.common.Objects.ORGANISATIONUNITGROUPSET;
+import static org.hisp.dhis.common.Objects.ORGANISATIONUNITLEVEL;
+import static org.hisp.dhis.common.Objects.REPORTTABLE;
+import static org.hisp.dhis.common.Objects.VALIDATIONRULE;
+
+//import static org.hisp.dhis.common.Objects.ATTRIBUTE;
+//import static org.hisp.dhis.common.Objects.ATTRIBUTEGROUP;
+//import static org.hisp.dhis.common.Objects.ATTRIBUTEOPTIONGROUP;
+//import static org.hisp.dhis.common.Objects.ATTRIBUTEOPTIONS;
+//import static org.hisp.dhis.common.Objects.HRDATASET;
+//import static org.hisp.dhis.common.Objects.DATAVALUES;
+//import static org.hisp.dhis.common.Objects.TRAINING;
+//import static org.hisp.dhis.common.Objects.HISTORY;
+//import static org.hisp.dhis.common.Objects.INPUTTYPE;
+//import static org.hisp.dhis.common.Objects.DATATYPE;
+//import static org.hisp.dhis.common.Objects.PERSON;
+import static org.hisp.dhis.common.Objects.valueOf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.h2.value.DataType;
+import org.hisp.dhis.common.Objects;
+import org.hisp.dhis.datadictionary.DataDictionary;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.hr.Attribute;
+import org.hisp.dhis.hr.AttributeGroup;
+import org.hisp.dhis.hr.AttributeOptionGroup;
+import org.hisp.dhis.hr.AttributeOptions;
+import org.hisp.dhis.hr.DataValues;
+import org.hisp.dhis.hr.History;
+import org.hisp.dhis.hr.HrDataSet;
+import org.hisp.dhis.hr.InputType;
+import org.hisp.dhis.hr.Person;
+import org.hisp.dhis.hr.Training;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.reporttable.ReportTable;
+import org.hisp.dhis.validation.ValidationRule;
+
+/**
+ * @author John Francis Mukulu <john.f.mukulu@xxxxxxxxx>
+ * @version $Id$
+ */
+public class ClassMapUtil
+{
+ private static Map<Objects, Class<?>> classMap;
+
+ static
+ {
+ classMap = new HashMap<Objects, Class<?>>();
+
+ classMap.put( DATAELEMENT, DataElement.class );
+ classMap.put( DATAELEMENTGROUP, DataElementGroup.class );
+ classMap.put( DATAELEMENTGROUPSET, DataElementGroupSet.class );
+ classMap.put( INDICATORTYPE, IndicatorType.class );
+ classMap.put( INDICATOR, Indicator.class );
+ classMap.put( INDICATORGROUP, IndicatorGroup.class );
+ classMap.put( INDICATORGROUPSET, IndicatorGroupSet.class );
+ classMap.put( DATADICTIONARY, DataDictionary.class );
+ classMap.put( DATASET, DataSet.class );
+ classMap.put( ORGANISATIONUNIT, OrganisationUnit.class );
+ classMap.put( ORGANISATIONUNITGROUP, OrganisationUnitGroup.class );
+ classMap.put( ORGANISATIONUNITGROUPSET, OrganisationUnitGroupSet.class );
+ classMap.put( ORGANISATIONUNITLEVEL, OrganisationUnitLevel.class );
+ classMap.put( VALIDATIONRULE, ValidationRule.class );
+ classMap.put( REPORTTABLE, ReportTable.class );
+
+ classMap.put( DATAVALUE, DataValue.class );
+// classMap.put( ATTRIBUTE, Attribute.class);
+// classMap.put( ATTRIBUTEOPTIONS, AttributeOptions.class);
+// classMap.put( ATTRIBUTEGROUP, AttributeGroup.class);
+// classMap.put( ATTRIBUTEOPTIONGROUP, AttributeOptionGroup.class);
+// classMap.put( HRDATASET, HrDataSet.class);
+// classMap.put( DATAVALUES, DataValues.class);
+// classMap.put( TRAINING, Training.class);
+// classMap.put( HISTORY, History.class);
+// classMap.put( INPUTTYPE, InputType.class);
+// classMap.put( DATATYPE, DataType.class);
+// classMap.put( PERSON, Person.class);
+ }
+
+ public static Class<?> getClass( String type )
+ {
+ try
+ {
+ return classMap.get( valueOf( type ) );
+ }
+ catch ( IllegalArgumentException ex )
+ {
+ return null;
+ }
+ }
+}
=== added file 'local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util/ImportExportInternalProcessUtil.java'
--- local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util/ImportExportInternalProcessUtil.java 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/java/org/hisp/dhis/importexport/action/util/ImportExportInternalProcessUtil.java 2011-07-26 07:48:47 +0000
@@ -0,0 +1,93 @@
+package org.hisp.dhis.importexport.action.util;
+
+/*
+ * Copyright (c) 2004-2010, 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 org.hisp.dhis.util.InternalProcessUtil;
+import org.hisp.dhis.util.SessionUtils;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class ImportExportInternalProcessUtil
+ extends InternalProcessUtil
+{
+ private static final String DEFAULT_IMPORT_FORMAT = "DXF";
+
+ public static final String TYPE_IMPORT = "import";
+ public static final String TYPE_PREVIEW = "preview";
+ public static final String TYPE_ANALYSIS = "analysis";
+
+ private static final String KEY_PROCESS_TYPE = "CurrentRunningImportInternalProcessType";
+ private static final String KEY_PROCESS_IMPORT_FORMAT = "CurrentRunningImportInternalProcessImportFormat";
+ private static final String KEY_PROCESS_IMPORT_FILENAME = "CurrentRunningImportFileName";
+
+ // -----------------------------------------------------------------------
+ // InternalProcess type
+ // -----------------------------------------------------------------------
+
+ public static void setCurrentRunningProcessType( String type )
+ {
+ SessionUtils.setSessionVar( KEY_PROCESS_TYPE, type );
+ }
+
+ public static String getCurrentRunningProcessType()
+ {
+ return String.valueOf( SessionUtils.getSessionVar( KEY_PROCESS_TYPE ) );
+ }
+
+ // -----------------------------------------------------------------------
+ // InternalProcess import format
+ // -----------------------------------------------------------------------
+
+ public static void setCurrentRunningProcessImportFormat( String importFormat )
+ {
+ SessionUtils.setSessionVar( KEY_PROCESS_IMPORT_FORMAT, importFormat );
+ }
+
+ public static String getCurrentRunningProcessImportFormat()
+ {
+ String importFormat = String.valueOf( SessionUtils.getSessionVar( KEY_PROCESS_IMPORT_FORMAT ) );
+
+ return importFormat != null ? importFormat : DEFAULT_IMPORT_FORMAT;
+ }
+
+ // -----------------------------------------------------------------------
+ // InternalProcess import file name
+ // -----------------------------------------------------------------------
+
+ public static void setCurrentImportFileName( String fileName )
+ {
+ SessionUtils.setSessionVar( KEY_PROCESS_IMPORT_FILENAME, fileName );
+ }
+
+ public static String getCurrentImportFileName()
+ {
+ return String.valueOf( SessionUtils.getSessionVar( KEY_PROCESS_IMPORT_FILENAME ) );
+ }
+}
=== modified file 'local/tz/dhis-web-hrentry/src/main/resources/struts.xml'
--- local/tz/dhis-web-hrentry/src/main/resources/struts.xml 2011-07-11 16:20:55 +0000
+++ local/tz/dhis-web-hrentry/src/main/resources/struts.xml 2011-07-26 07:48:47 +0000
@@ -265,10 +265,9 @@
<!-- HR Import Export -->
<action name="displayHrImportForm" class="org.hisp.dhis.importexport.action.imp.GetHrImportOptionsAction">
- <result name="dhis14" type="redirect">displayConfigDhis14Form.action</result>
<result name="success" type="velocity">/main.vm</result>
- <param name="page">/dhis-web-importexport/importForm.vm</param>
- <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+ <param name="page">/dhis-web-hrentry/importForm.vm</param>
+ <param name="menu">/dhis-web-hrentry/menu.vm</param>
<param name="javascripts">javascript/import.js,javascript/process.js</param>
</action>
<action name="import" class="org.hisp.dhis.importexport.action.imp.ImportAction">
=== added file 'local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/importForm.vm'
--- local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/importForm.vm 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/importForm.vm 2011-07-26 07:48:47 +0000
@@ -0,0 +1,140 @@
+
+<script type="text/javascript">
+ getImportStatus();
+</script>
+
+<h3>$i18n.getString( "$importFormat" ) $i18n.getString( "import" ) #openHelp( "import" )</h3>
+
+<form id="importForm" name="importForm" method="post" enctype="multipart/form-data" action="import.action">
+
+<!-- Import options -->
+
+<table width="325">
+
+ <tr>
+ <th>$i18n.getString( "type" )</th>
+ </tr>
+ <tr>
+ <td>
+ <select id="type" name="type" style="width:100%">
+ #if ( $importFormat != "DHIS14XML" )
+ <option value="IMPORT"#if( $type == "IMPORT" ) selected="selected"#end>$i18n.getString( "import" )</option>
+ #end
+ <option value="PREVIEW"#if( $type == "PREVIEW" ) selected="selected"#end>$i18n.getString( "preview" )</option>
+ <option value="ANALYSIS"#if( $type == "ANALYSIS" ) selected="selected"#end>$i18n.getString( "analysis" )</option>
+ </select>
+ </td>
+ </tr>
+
+ #if ( $importFormat == "DHIS14FILE" )
+
+ <tr>
+ <td height="10"></td>
+ </tr>
+ <tr>
+ <th>$i18n.getString( "last_updated_leave_blank_for_all" )</th>
+ </tr>
+ <tr>
+ <td><input type="text" id="lastUpdated" name="lastUpdated" style="width:250px"></td>
+ </tr>
+
+ <script type="text/javascript">
+ jQuery(function(){
+ datePicker( 'lastUpdated' );
+ });
+ </script>
+
+ #else
+
+ <tr>
+ <td height="10"></td>
+ </tr>
+ <tr>
+ <th colspan="2">$i18n.getString( "file" )</th>
+ </tr>
+ <tr>
+ <td colspan="2"><input type="file" id="upload" name="upload" size="45"></td>
+ </tr>
+
+ #end
+
+</table>
+
+<div id="optionDiv" style="display:none">
+
+<table width="325">
+
+ <tr>
+ <td height="10"></td>
+ </tr>
+ <tr>
+ <th>$i18n.getString( "accept_incoming_records" )</th>
+ </tr>
+ <tr>
+ <td>
+ <select id="incomingRecords" name="incomingRecords" style="width:100%">
+ <option value="NEW_AND_UPDATES">$i18n.getString( "new_and_updates" )</option>
+ <option value="NEW_NO_UPDATES">$i18n.getString( "new_no_updates" )</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td height="10"></td>
+ </tr>
+ <tr>
+ <th>$i18n.getString( "include_datavalues" )</th>
+ </tr>
+ <tr>
+ <td>
+ <select id="dataValues" name="dataValues" style="width:100%">
+ <option value="true">$i18n.getString( "yes" )</option>
+ <option value="false">$i18n.getString( "no" )</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td height="10"></td>
+ </tr>
+ <tr>
+ <th>$i18n.getString( "skip_check_matching" )</th>
+ </tr>
+ <tr>
+ <td>
+ <select id="skipCheckMatching" name="skipCheckMatching" style="width:100%">
+ <option value="false">$i18n.getString( "no" )</option>
+ <option value="true">$i18n.getString( "yes_empty_database" )</option>
+ </select>
+ </td>
+ </tr>
+
+</table>
+
+</div>
+
+<!-- Submit -->
+
+<table width="325">
+
+ <tr>
+ <td colspan="2">
+ <input type="button" value="$i18n.getString( 'import' )" onclick="submitImportForm()" style="width:50%"><input
+ type="button" id="optionButton" value="$i18n.getString( 'show_advanced_options' )" onclick="showAdvancedOptions()" style="width:50%">
+ </td>
+ </tr>
+
+</table>
+
+</form>
+
+<span id="message"></span>
+
+<span id="info"></span>
+
+<script type="text/javascript">
+ var i18n_done = '$encoder.jsEscape( $i18n.getString( "done" ), "'" )';
+ var i18n_importing = '$encoder.jsEscape( $i18n.getString( "importing" ), "'" )';
+ var i18n_show_advanced_options = '$encoder.jsEscape( $i18n.getString( "show_advanced_options" ), "'" )';
+ var i18n_hide_advanced_options = '$encoder.jsEscape( $i18n.getString( "hide_advanced_options" ), "'" )';
+ var i18n_completed = '$encoder.jsEscape( $i18n.getString( "completed" ), "'" )';
+ var i18n_current_import_file = '$encoder.jsEscape( $i18n.getString( "current_import_file" ), "'" )';
+</script>
=== added file 'local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/export.js'
--- local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/export.js 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/export.js 2011-07-26 07:48:47 +0000
@@ -0,0 +1,306 @@
+
+// -----------------------------------------------------------------------------
+// DataMartExport
+// -----------------------------------------------------------------------------
+
+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 exportHrDataValue()
+{
+ if ( validateHrDataValueExportForm() )
+ {
+ submitHrDataValueExportForm();
+ }
+}
+
+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()
+{
+ var domainType = getListValue( "domainType" );
+ if ( domainType == "aggregate" )
+ {
+ selectAll( document.getElementById( "selectedDataSets" ) );
+ // Clear other selected dataset options
+ moveAllById( 'selectedPrograms', 'availablePrograms' );
+ moveAllById( 'selectedHrDataSets', 'availableHrDataSets' );
+
+ if ( validateDataValueExportForm() )
+ {
+ document.getElementById( "exportForm" ).submit();
+ }
+ }
+ else if ( domainType == "hr" )
+ {
+ selectAll( document.getElementById( "selectedHrDataSets" ) );
+ //Clear Other selected datasets options
+ moveAllById( 'selectedPrograms', 'availablePrograms' );
+ moveAllById( 'selectedDataSets', 'availableDataSets' );
+
+ if ( validateDataValueExportForm() )
+ {
+ document.getElementById( "exportForm" ).submit();
+ }
+ }
+ else if ( domainType == "patient" )
+ {
+ selectAll( document.getElementById( "selectedPrograms" ) );
+ // Clear Other selected datasets options
+ moveAllById( 'selectedDataSets', 'availableDataSets' );
+ moveAllById( 'selectedHrDataSets', 'availableHrDataSets' );
+
+ if ( validateDataValueExportForm() )
+ {
+ document.getElementById( "exportForm" ).submit();
+ }
+ }
+}
+
+
+function setDataType()
+{
+ var aggregatedData = getListValue( "aggregatedData" );
+
+ if ( aggregatedData == "true" )
+ {
+ showById( "aggregatedDataDiv" );
+ hideById( "regularDataDiv" );
+ }
+ else
+ {
+ hideById( "aggregatedDataDiv" );
+ showById( "regularDataDiv" );
+ }
+}
+function showRowById( id )
+{
+ jQuery("#" + id).show();
+ jQuery("#" + id).css('visibility', 'visible');
+}
+function hideRowById( id )
+{
+ jQuery("#" + id).hide();
+ jQuery("#" + id).css('visibility', 'collapse');
+}
+
+function setDatasetType()
+{
+ var domainType = getListValue( "domainType" );
+
+ if ( domainType == "aggregate" )
+ {
+ showRowById( "dataSetDiv1" );
+ showRowById( "dataSetDiv2" );
+ showRowById("startDateDiv1");
+ showRowById("startDateDiv2");
+ hideRowById( "hrDataSetDiv1" );
+ hideRowById( "hrDataSetDiv2" );
+ hideRowById( "programDiv1");
+ hideRowById( "programDiv2");
+ }
+ else if ( domainType == "hr")
+ {
+ showRowById( "hrDataSetDiv1" );
+ showRowById( "hrDataSetDiv2" );
+ hideRowById( "dataSetDiv1" );
+ hideRowById( "dataSetDiv2" );
+ hideRowById( "programDiv1" );
+ hideRowById( "programDiv2" );
+ hideRowById("startDateDiv1");
+ hideRowById("startDateDiv2");
+ }
+ else if ( domainType == "patient")
+ {
+ showRowById( "programDiv1" );
+ showRowById( "programDiv2" );
+ showRowById("startDateDiv1");
+ showRowById("startDateDiv2");
+ hideRowById("startDateDiv1");
+ hideRowById("startDateDiv2");
+ hideRowById( "dataSetDiv1" );
+ hideRowById( "dataSetDiv2" );
+ hideRowById( "hrDataSetDiv1");
+ hideRowById( "hrDataSetDiv2");
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// MetaDataExport
+// -----------------------------------------------------------------------------
+
+function submitMetaDataExportForm()
+{
+ if ( validateMetaDataExportForm() )
+ {
+ document.getElementById( "exportForm" ).submit();
+ }
+}
+
+function toggle( knob )
+{
+ var toggle = (knob == "all" ? true : false);
+
+ jQuery.each( jQuery("input[type=checkbox]"), function(i, item){
+ item.checked = toggle;
+ });
+}
+
+// -----------------------------------------------------------------------------
+// Validation
+// -----------------------------------------------------------------------------
+
+function validateMetaDataExportForm()
+{
+ if ( jQuery("input:checked").length == 0 )
+ {
+ setMessage( i18n_select_one_or_more_object_types );
+ return false;
+ }
+
+ hideMessage();
+ return true;
+}
+
+function validateDataValueExportForm()
+{
+ var domainType = getListValue( "domainType" );
+
+ if ( selectedOrganisationUnitIds == null || selectedOrganisationUnitIds.length == 0 )
+ {
+ setMessage( i18n_select_organisation_unit );
+ return false;
+ }
+ if ( !hasText( "startDate" ) )
+ {
+ setMessage( i18n_select_startdate );
+ return false;
+ }
+ if ( !hasText( "endDate" ) )
+ {
+ setMessage( i18n_select_enddate );
+ return false;
+ }
+ if ( domainType == "aggregate" )
+ {
+ if ( !hasElements( "selectedDataSets" ) )
+ {
+ setMessage( i18n_select_datasets );
+ return false;
+ }
+ }
+ else if ( domainType == "hr" )
+ {
+ if ( !hasElements( "selectedHrDataSets" ) )
+ {
+ setMessage( i18n_select_hr_datasets );
+ return false;
+ }
+ }
+ else if ( domainType == "patient" )
+ {
+ if ( !hasElements( "availablePrograms" ) )
+ {
+ setMessage( i18n_select_programs );
+ return false;
+ }
+ }
+
+ hideMessage();
+ return true;
+}
+
=== added file 'local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/import.js'
--- local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/import.js 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/import.js 2011-07-26 07:48:47 +0000
@@ -0,0 +1,515 @@
+
+// -------------------------------------------------------------------------
+// Import
+// -------------------------------------------------------------------------
+
+function submitImportForm()
+{
+ setWaitMessage( i18n_importing );
+ document.getElementById( "importForm" ).submit();
+}
+
+function showAdvancedOptions()
+{
+ var optionDiv = document.getElementById( "optionDiv" );
+
+ optionDiv.style.display = "block";
+
+ var optionButton = document.getElementById( "optionButton" );
+
+ optionButton.setAttribute( "onclick", "hideAdvancedOptions()" );
+ optionButton.value = i18n_hide_advanced_options;
+}
+
+function hideAdvancedOptions()
+{
+ var optionDiv = document.getElementById( "optionDiv" );
+
+ optionDiv.style.display = "none";
+
+ var optionButton = document.getElementById( "optionButton" );
+
+ optionButton.setAttribute( "onclick", "showAdvancedOptions()" );
+ optionButton.value = i18n_show_advanced_options;
+}
+
+// -------------------------------------------------------------------------
+// Preview
+// -------------------------------------------------------------------------
+
+function discardObjectAjax()
+{
+ var objects = document.getElementById( "objects" );
+
+ var params = "";
+
+ for ( var i = 0; i < objects.options.length; i++ )
+ {
+ if ( objects.options[ i ].selected )
+ {
+ params += "id=" + objects.options[ i ].value + "&";
+ }
+ }
+
+ var url = "discardObjectAjax.action";
+
+ var request = new Request();
+ request.sendAsPost( params );
+ request.setResponseTypeXML( 'message' );
+ request.setCallbackSuccess( discardObjectCallback );
+ request.send( url );
+}
+
+function discardObjectCallback( xmlElement )
+{
+ var type = xmlElement.getAttribute( "type" );
+ var discardedElements = xmlElement.firstChild.nodeValue;
+
+ var elementType = document.getElementById( "type" ).value;
+ var elementStatus = document.getElementById( "status" ).value;
+
+ if ( type == "success" )
+ {
+ if ( elementType == "DATAELEMENT" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newDataElementSpan", "newDataElementTd" );
+ }
+ else if ( elementType == "DATAELEMENT" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateDataElementSpan", "updateDataElementTd" );
+ }
+ else if ( elementType == "EXTENDEDDATAELEMENT" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newExtendedDataElementSpan", "newExtendedDataElementTd" );
+ }
+ else if ( elementType == "EXTENDEDDATAELEMENT" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateExtendedDataElementSpan", "updateExtendedDataElementTd" );
+ }
+ else if ( elementType == "DATAELEMENTGROUP" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newDataElementGroupSpan", "newDataElementGroupTd" );
+ }
+ else if ( elementType == "DATAELEMENTGROUP" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateDataElementGroupSpan", "updateDataElementGroupTd" );
+ }
+ else if ( elementType == "DATAELEMENTGROUPSET" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newDataElementGroupSetSpan", "newDataElementGroupSetTd" );
+ }
+ else if ( elementType == "DATAELEMENTGROUPSET" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateDataElementGroupSetSpan", "updateDataElementGroupSetTd" );
+ }
+ else if ( elementType == "INDICATORTYPE" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newIndicatorTypeSpan", "newIndicatorTypeTd" );
+ }
+ else if ( elementType == "INDICATORTYPE" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateIndicatorTypeSpan", "updateIndicatorTypeTd" );
+ }
+ else if ( elementType == "INDICATOR" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newIndicatorSpan", "newIndicatorTd" );
+ }
+ else if ( elementType == "INDICATOR" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateIndicatorSpan", "updateIndicatorTd" );
+ }
+ else if ( elementType == "INDICATORGROUP" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newIndicatorGroupSpan", "newIndicatorGroupTd" );
+ }
+ else if ( elementType == "INDICATORGROUP" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateIndicatorGroupSpan", "updateIndicatorGroupTd" );
+ }
+ else if ( elementType == "INDICATORGROUPSET" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newIndicatorGroupSetSpan", "newIndicatorGroupSetTd" );
+ }
+ else if ( elementType == "INDICATORGROUPSET" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateIndicatorGroupSetSpan", "updateIndicatorGroupSetTd" );
+ }
+ else if ( elementType == "DATASET" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newDataSetSpan", "newDataSetTd" );
+ }
+ else if ( elementType == "DATASET" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateDataSetSpan", "updateDataSetTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNIT" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newOrganisationUnitSpan", "newOrganisationUnitTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNIT" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateOrganisationUnitSpan", "updateOrganisationUnitTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNITGROUP" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newOrganisationUnitGroupSpan", "newOrganisationUnitGroupTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNITGROUP" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateOrganisationUnitGroupSpan", "updateOrganisationUnitGroupTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNITGROUPSET" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newOrganisationUnitGroupSetSpan", "newOrganisationUnitGroupSetTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNITGROUPSET" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateOrganisationUnitGroupSetSpan", "updateOrganisationUnitGroupSetTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNITLEVEL" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newOrganisationUnitLevelSpan", "newOrganisationUnitLevelTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNITLEVEL" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateOrganisationUnitLevelSpan", "updateOrganisationUnitLevelTd" );
+ }
+ else if ( elementType == "VALIDATIONRULE" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newValidationRuleSpan", "newValidationRuleTd" );
+ }
+ else if ( elementType == "VALIDATIONRULE" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateValidationRuleSpan", "updateValidationRuleTd" );
+ }
+ else if ( elementType == "REPORT" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newReportSpan", "newReportTd" );
+ }
+ else if ( elementType == "REPORT" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateReportTableSpan", "updateReportTableTd" );
+ }
+ else if ( elementType == "REPORTTABLE" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newReportTableSpan", "newReportTableTd" );
+ }
+ else if ( elementType == "REPORTTABLE" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateReportTableSpan", "updateReportTableTd" );
+ }
+ else if ( elementType == "CHART" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newChartSpan", "newChartTd" );
+ }
+ else if ( elementType == "CHART" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateChartSpan", "updateChartTd" );
+ }
+ else if ( elementType == "OLAPURL" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newOlapUrlSpan", "newOlapUrlTd" );
+ }
+ else if ( elementType == "OLAPURL" && elementStatus == "UPDATE" )
+ {
+ handleField( iscardedElements, "updateOlapUrlSpan", "updateOlapUrlTd" );
+ }
+ else if ( elementType == "DATAVALUE" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newDataValueSpan", "newDataValueTd" );
+ }
+ else if ( elementType == "DATAVALUE" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateDataValueSpan", "updateDataValueTd" );
+ }
+
+ // Remove selected options from list
+
+ removeSelectedOptions( document.getElementById( "objects" ) );
+ }
+}
+
+function discardObjectsOfTypeAjax()
+{
+ var type = document.getElementById( "type" ).value;
+
+ if ( type != null )
+ {
+ var url = "discardObjectsOfTypeAjax.action?type=" + type;
+
+ var request = new Request();
+ request.setResponseTypeXML( 'message' );
+ request.setCallbackSuccess( discardObjectsOfTypeCallback );
+ request.send( url );
+ }
+}
+
+function discardObjectsOfTypeCallback( xmlElement )
+{
+ var type = xmlElement.getAttribute( "type" );
+
+ var elementType = document.getElementById( "type" ).value;
+
+ if ( type == "success" )
+ {
+ // Set value count to none
+
+ if ( elementType == "DATAELEMENT" )
+ {
+ clearField( "newDataElementTd" );
+ clearField( "updateDataElementTd" );
+ clearField( "newIndicatorTd" );
+ clearField( "updateIndicatorTd" );
+ }
+ else if ( elementType == "EXTENDEDDATAELEMENT" )
+ {
+ clearField( "newExtendedDataElementTd" );
+ clearField( "updateExtendedDataElementTd" );
+ }
+ else if ( elementType == "DATAELEMENTGROUP" )
+ {
+ clearField( "newDataElementGroupTd" );
+ clearField( "updateDataElementGroupTd" );
+ }
+ else if ( elementType == "DATAELEMENTGROUPSET" )
+ {
+ clearField( "newDataElementGroupSetTd" );
+ clearField( "updateDataElementGroupSetTd" );
+ }
+ else if ( elementType == "INDICATORTYPE")
+ {
+ clearField( "newIndicatorTypeTd" );
+ clearField( "updateIndicatorTypeTd" );
+ clearField( "newIndicatorTd" );
+ clearField( "updateIndicatorTd" );
+ }
+ else if ( elementType == "INDICATOR" )
+ {
+ clearField( "newIndicatorTd" );
+ clearField( "updateIndicatorTd" );
+ }
+ else if ( elementType == "INDICATORGROUP" )
+ {
+ clearField( "newIndicatorGroupTd" );
+ clearField( "updateIndicatorGroupTd" );
+ }
+ else if ( elementType == "INDICATORGROUPSET" )
+ {
+ clearField( "newIndicatorGroupSetTd" );
+ clearField( "updateIndicatorGroupSetTd" );
+ }
+ else if ( elementType == "DATASET" )
+ {
+ clearField( "newDataSetTd" );
+ clearField( "updateDataSetTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNIT" )
+ {
+ clearField( "newOrganisationUnitTd" );
+ clearField( "updateOrganisationUnitTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNITGROUP" )
+ {
+ clearField( "newOrganisationUnitGroupTd" );
+ clearField( "updateOrganisationUnitGroupTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNITGROUPSET" )
+ {
+ clearField( "newOrganisationUnitGroupSetTd" );
+ clearField( "updateOrganisationUnitGroupSetTd" );
+ }
+ else if ( elementType == "ORGANISATIONUNITLEVEL" )
+ {
+ clearField( "newOrganisationUnitLevelTd" );
+ clearField( "updateOrganisationUnitLevelTd" );
+ }
+ else if ( elementType == "VALIDATIONRULE" )
+ {
+ clearField( "newValidationRuleTd" );
+ clearField( "updateValidationRuleTd" );
+ }
+ else if ( elementType == "REPORT" )
+ {
+ clearField( "newReportTd" );
+ clearFIeld( "updateReportTd" );
+ }
+ else if ( elementType == "REPORTTABLE" )
+ {
+ clearField( "newReportTableTd" );
+ clearFIeld( "updateReportTableTd" );
+ }
+ else if ( elementType == "CHART" )
+ {
+ clearField( "newChartTd" );
+ clearFIeld( "updateChartTd" );
+ }
+ else if ( elementType == "OLAPURL" )
+ {
+ clearField( "newOlapUrlTd" );
+ clearField( "updateOlapUrlTd" );
+ }
+ else if ( elementType == "DATAVALUE" )
+ {
+ clearField( "newDataValueTd" );
+ clearField( "updateDataValueTd" );
+ }
+
+ // Remove objects from list
+
+ document.getElementById( "objects" ).options.length = 0;
+ }
+}
+
+// -------------------------------------------------------------------------
+// Match / Compare
+// -------------------------------------------------------------------------
+
+function displayMatchForm()
+{
+ var list = document.getElementById( "objects" );
+
+ var id = list.options[ list.selectedIndex ].value;
+
+ var type = document.getElementById( "type" ).value;
+
+ window.location.href = "displayMatchForm.action?objectType=" + type + "&objectId=" + id;
+}
+
+function displayCompareForm()
+{
+ var list = document.getElementById( "objects" );
+
+ var id = list.options[ list.selectedIndex ].value;
+
+ var type = document.getElementById( "type" ).value;
+
+ window.location.href = "displayCompareForm.action?objectType=" + type + "&objectId=" + id;
+}
+
+function matchObject()
+{
+ var importObjectId = document.getElementById( "objectId" ).value;
+
+ var existingObjects = document.getElementById( "existingObjects" );
+
+ var existingObjectId = existingObjects.options[ existingObjects.selectedIndex ].value;
+
+ if ( importObjectId != null && existingObjectId != null )
+ {
+ window.location.href = "matchObject.action?importObjectId=" + importObjectId + "&existingObjectId=" + existingObjectId;
+ }
+}
+
+function matchUpdateObject()
+{
+ var importObjectId = document.getElementById( "objectId" ).value;
+
+ var existingObjectId = document.getElementById( "existingObjectId" ).value;
+
+ if ( importObjectId != null && existingObjectId != null )
+ {
+ window.location.href = "matchObject.action?importObjectId=" + importObjectId + "&existingObjectId=" + existingObjectId;
+ }
+}
+
+function discardObject()
+{
+ var objectId = document.getElementById( "objectId" ).value;
+
+ if ( objectId != null )
+ {
+ window.location.href = "discardObject.action?id=" + objectId;
+ }
+}
+
+function cancelObject()
+{
+ var type = document.getElementById( "objectType" ).value;
+
+ window.location.href = "displayPreviewForm.action?type=" + type;
+}
+
+function viewAllExistingObjects()
+{
+ var objectType = document.getElementById( "objectType" ).value;
+ var objectId = document.getElementById( "objectId" ).value;
+
+ window.location.href="displayMatchForm.action?objectType=" + objectType + "&objectId=" + objectId;
+}
+
+function filterExistingObjects()
+{
+ var existingList = document.getElementById( "existingObjects" );
+
+ var filteredList = document.getElementById( "filteredObjects" );
+
+ var filterText = document.getElementById( "filterField" ).value.toLowerCase();
+
+ // Move non-matching options to holding list
+
+ for ( var i = existingList.options.length-1; i >= 0; i-- )
+ {
+ var string = existingList.options[ i ].text.toLowerCase();
+
+ if ( string.indexOf( filterText ) == -1 )
+ {
+ option = existingList.options[ i ];
+ existingList.remove( i );
+ filteredList.add( option, null );
+ }
+ }
+
+ // Move matching options to main list
+
+ for ( var i = filteredList.options.length-1; i >= 0; i-- )
+ {
+ var string = filteredList.options[ i ].text.toLowerCase();
+
+ if ( string.indexOf( filterText ) != -1 )
+ {
+ option = filteredList.options[ i ];
+ filteredList.remove( i );
+ existingList.add( option, null );
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+// Supportive methods
+// -------------------------------------------------------------------------
+
+function handleField( discardedElements, spanName, tdName )
+{
+ var existingElements = document.getElementById( spanName ).innerHTML;
+
+ existingElements = existingElements - discardedElements;
+
+ if ( existingElements > 0 )
+ {
+ document.getElementById( spanName ).innerHTML = existingElements;
+ }
+ else
+ {
+ clearField( tdName );
+ }
+}
+
+function clearField( fieldName )
+{
+ if ( document.getElementById( fieldName ) != null )
+ {
+ document.getElementById( fieldName ).style.backgroundColor = "#FFFFFF";
+ document.getElementById( fieldName ).innerHTML = "None";
+ }
+}
+
+function removeSelectedOptions( list )
+{
+ for ( var i = list.options.length-1; i >= 0; i-- )
+ {
+ if ( list.options[ i ].selected )
+ {
+ list.remove( i );
+ }
+ }
+}
=== added file 'local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/process.js'
--- local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/process.js 1970-01-01 00:00:00 +0000
+++ local/tz/dhis-web-hrentry/src/main/webapp/dhis-web-hrentry/javascript/process.js 2011-07-26 07:48:47 +0000
@@ -0,0 +1,49 @@
+
+// -----------------------------------------------------------------------------
+// Import
+// -----------------------------------------------------------------------------
+
+function getImportStatus()
+{
+ var request = new Request();
+ request.setResponseTypeXML( "response" );
+ request.setCallbackSuccess( importStatusReceived );
+ request.send( "getImportStatus.action" );
+}
+
+function importStatusReceived( messageElement )
+{
+ var actionType = getElementValue( messageElement, "actionType" );
+
+ if ( actionType == "info" )
+ {
+ var statusMessage = getElementValue( messageElement, "statusMessage" );
+ var fileMessage = getElementValue( messageElement, "fileMessage" );
+ var running = getElementValue( messageElement, "running" );
+
+ setInfo( i18n_current_import_file + ": " + fileMessage );
+
+ if ( running == "true" )
+ {
+ setWaitMessage( statusMessage );
+ waitAndGetImportStatus( 2000 );
+ }
+ else
+ {
+ setMessage( statusMessage );
+ }
+ }
+ else if ( actionType == "preview" )
+ {
+ window.location.href = "displayPreviewForm.action";
+ }
+ else if ( actionType == "analysis" )
+ {
+ window.location.href = "getImportAnalysis.action";
+ }
+}
+
+function waitAndGetImportStatus( millis )
+{
+ setTimeout( "getImportStatus();", millis );
+}
=== modified file 'local/tz/pom.xml'
--- local/tz/pom.xml 2011-07-11 14:11:26 +0000
+++ local/tz/pom.xml 2011-07-26 07:48:47 +0000
@@ -12,10 +12,10 @@
<modules>
<module>dhis-api-hr</module>
<module>dhis-service-hr</module>
+ <module>dhis-service-importexport-hr</module>
+ <module>dhis-support-jdbc-hr</module>
<module>dhis-web-hrentry</module>
<module>dhis-web-maintenance-hr</module>
- <module>dhis-service-importexport-hr</module>
- <module>dhis-support-jdbc-hr</module>
</modules>
</project>