dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41084
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20908: Moved ImportDataValueTask to service layer
------------------------------------------------------------
revno: 20908
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-10-30 23:58:41 -0400
message:
Moved ImportDataValueTask to service layer
removed:
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportDataValueTask.java
added:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/tasks/
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/tasks/ImportDataValueTask.java
modified:
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java
--
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 directory 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/tasks'
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/tasks/ImportDataValueTask.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/tasks/ImportDataValueTask.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/tasks/ImportDataValueTask.java 2015-10-31 03:58:41 +0000
@@ -0,0 +1,88 @@
+package org.hisp.dhis.dxf2.datavalueset.tasks;
+
+/*
+ * Copyright (c) 2004-2015, 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.security.SecurityContextRunnable;
+import org.hisp.dhis.dxf2.common.ImportOptions;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
+import org.hisp.dhis.scheduling.TaskId;
+
+import java.io.InputStream;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class ImportDataValueTask
+ extends SecurityContextRunnable
+{
+ public static final String FORMAT_XML = "xml";
+ public static final String FORMAT_JSON = "json";
+ public static final String FORMAT_CSV = "csv";
+ public static final String FORMAT_PDF = "pdf";
+
+ private DataValueSetService dataValueSetService;
+
+ private InputStream inputStream;
+
+ private final ImportOptions options;
+
+ private final TaskId taskId;
+
+ private final String format;
+
+ public ImportDataValueTask( DataValueSetService dataValueSetService, InputStream inputStream, ImportOptions options, TaskId taskId, String format )
+ {
+ this.dataValueSetService = dataValueSetService;
+ this.inputStream = inputStream;
+ this.options = options;
+ this.taskId = taskId;
+ this.format = format;
+ }
+
+ @Override
+ public void call()
+ {
+ if ( FORMAT_JSON.equals( format ) )
+ {
+ dataValueSetService.saveDataValueSetJson( inputStream, options, taskId );
+ }
+ else if ( FORMAT_CSV.equals( format ) )
+ {
+ dataValueSetService.saveDataValueSetCsv( inputStream, options, taskId );
+ }
+ else if ( FORMAT_PDF.equals( format ) )
+ {
+ dataValueSetService.saveDataValueSetPdf( inputStream, options, taskId );
+ }
+ else // FORMAT_XML
+ {
+ dataValueSetService.saveDataValueSet( inputStream, options, taskId );
+ }
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java 2015-08-30 17:07:42 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java 2015-10-31 03:58:41 +0000
@@ -38,8 +38,8 @@
import org.hisp.dhis.commons.util.StreamUtils;
import org.hisp.dhis.dxf2.common.ImportOptions;
import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
+import org.hisp.dhis.dxf2.datavalueset.tasks.ImportDataValueTask;
import org.hisp.dhis.importexport.ImportStrategy;
-import org.hisp.dhis.importexport.action.util.ImportDataValueTask;
import org.hisp.dhis.scheduling.TaskCategory;
import org.hisp.dhis.scheduling.TaskId;
import org.hisp.dhis.system.notification.Notifier;
=== removed file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportDataValueTask.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportDataValueTask.java 2015-09-10 10:22:46 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportDataValueTask.java 1970-01-01 00:00:00 +0000
@@ -1,88 +0,0 @@
-package org.hisp.dhis.importexport.action.util;
-
-/*
- * Copyright (c) 2004-2015, 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.security.SecurityContextRunnable;
-import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
-import org.hisp.dhis.scheduling.TaskId;
-
-import java.io.InputStream;
-
-/**
- * @author Lars Helge Overland
- */
-public class ImportDataValueTask
- extends SecurityContextRunnable
-{
- public static final String FORMAT_XML = "xml";
- public static final String FORMAT_JSON = "json";
- public static final String FORMAT_CSV = "csv";
- public static final String FORMAT_PDF = "pdf";
-
- private DataValueSetService dataValueSetService;
-
- private InputStream inputStream;
-
- private final ImportOptions options;
-
- private final TaskId taskId;
-
- private final String format;
-
- public ImportDataValueTask( DataValueSetService dataValueSetService, InputStream inputStream, ImportOptions options, TaskId taskId, String format )
- {
- this.dataValueSetService = dataValueSetService;
- this.inputStream = inputStream;
- this.options = options;
- this.taskId = taskId;
- this.format = format;
- }
-
- @Override
- public void call()
- {
- if ( FORMAT_JSON.equals( format ) )
- {
- dataValueSetService.saveDataValueSetJson( inputStream, options, taskId );
- }
- else if ( FORMAT_CSV.equals( format ) )
- {
- dataValueSetService.saveDataValueSetCsv( inputStream, options, taskId );
- }
- else if ( FORMAT_PDF.equals( format ) )
- {
- dataValueSetService.saveDataValueSetPdf( inputStream, options, taskId );
- }
- else // FORMAT_XML
- {
- dataValueSetService.saveDataValueSet( inputStream, options, taskId );
- }
- }
-}