=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-04-02 17:23:48 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-04-11 11:33:43 +0000 @@ -32,6 +32,8 @@ import static org.hisp.dhis.importexport.ImportStrategy.UPDATES; import static org.hisp.dhis.system.util.ConversionUtils.wrap; import static org.hisp.dhis.system.util.DateUtils.getDefaultDate; +import static org.hisp.dhis.system.notification.NotificationCategory.DATAVALUE_IMPORT; +import static org.hisp.dhis.system.notification.NotificationLevel.INFO; import java.io.InputStream; import java.io.OutputStream; @@ -61,6 +63,7 @@ import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; +import org.hisp.dhis.system.notification.Notifier; import org.hisp.dhis.system.util.DateUtils; import org.hisp.dhis.user.CurrentUserService; import org.springframework.beans.factory.annotation.Autowired; @@ -70,6 +73,11 @@ public class DefaultDataValueSetService implements DataValueSetService { + private static final String ERROR_INVALID_DATA_SET = "Invalid data set: "; + private static final String ERROR_INVALID_PERIOD = "Invalid period: "; + private static final String ERROR_INVALID_ORG_UNIT = "Invalid org unit: "; + private static final String ERROR_OBJECT_NEEDED_TO_COMPLETE = "Must be provided to complete data set"; + @Autowired private IdentifiableObjectManager identifiableObjectManager; @@ -97,6 +105,9 @@ @Autowired private DataValueSetStore dataValueSetStore; + @Autowired + private Notifier notifier; + //-------------------------------------------------------------------------- // DataValueSet implementation //-------------------------------------------------------------------------- @@ -109,17 +120,17 @@ if ( dataSet_ == null ) { - throw new IllegalArgumentException( "Invalid data set: " + dataSet ); + throw new IllegalArgumentException( ERROR_INVALID_DATA_SET + dataSet ); } if ( period_ == null ) { - throw new IllegalArgumentException( "Invalid period: " + period ); + throw new IllegalArgumentException( ERROR_INVALID_PERIOD + period ); } if ( orgUnit_ == null ) { - throw new IllegalArgumentException( "Invalid org unit: " + orgUnit ); + throw new IllegalArgumentException( ERROR_INVALID_ORG_UNIT + orgUnit ); } CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet_, period_, orgUnit_ ); @@ -138,6 +149,8 @@ public ImportSummary saveDataValueSet( InputStream in, IdentifiableProperty dataElementIdScheme, IdentifiableProperty orgUnitIdScheme, boolean dryRun, ImportStrategy strategy ) { + notifier.clear( DATAVALUE_IMPORT ).notify( DATAVALUE_IMPORT, "Process started" ); + ImportSummary summary = new ImportSummary(); DataValueSet dataValueSet = new StreamingDataValueSet( XMLFactory.getXMLReader( in ) ); @@ -172,6 +185,8 @@ int updateCount = 0; int totalCount = 0; + notifier.notify( DATAVALUE_IMPORT, "Importing data values" ); + while ( dataValueSet.hasNextDataValue() ) { org.hisp.dhis.dxf2.datavalue.DataValue dataValue = dataValueSet.getNextDataValue(); @@ -255,6 +270,8 @@ batchHandler.flush(); + notifier.notify( INFO, DATAVALUE_IMPORT, "Import done", true ).addTaskSummary( DATAVALUE_IMPORT, summary ); + return summary; } @@ -264,14 +281,18 @@ private void handleComplete( DataSet dataSet, Date completeDate, OrganisationUnit orgUnit, Period period, ImportSummary summary ) { + notifier.notify( DATAVALUE_IMPORT, "Completing data set" ); + if ( orgUnit == null ) { - throw new IllegalArgumentException( "Org unit id must be provided to complete data set" ); + summary.getConflicts().add( new ImportConflict( OrganisationUnit.class.getSimpleName(), ERROR_OBJECT_NEEDED_TO_COMPLETE ) ); + return; } if ( period == null ) { - throw new IllegalArgumentException( "Period id must be provided to complete data set" ); + summary.getConflicts().add( new ImportConflict( Period.class.getSimpleName(), ERROR_OBJECT_NEEDED_TO_COMPLETE ) ); + return; } CompleteDataSetRegistration completeAlready = registrationService.getCompleteDataSetRegistration( dataSet, period, orgUnit ); === modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java 2012-04-03 10:24:37 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java 2012-04-11 11:40:51 +0000 @@ -106,11 +106,9 @@ @Override public String toString() { - return "ImportCount{" + - "object='" + object + '\'' + + return "[object='" + object + "'" + ", imports=" + imports + ", updates=" + updates + - ", ignores=" + ignores + - '}'; + ", ignores=" + ignores + "]"; } } === modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/IndicatorImporter.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/IndicatorImporter.java 2012-04-07 12:36:39 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/IndicatorImporter.java 2012-04-11 11:33:43 +0000 @@ -29,7 +29,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hisp.dhis.constant.Constant; import org.hisp.dhis.indicator.Indicator; import org.springframework.stereotype.Component; === added directory 'dhis-2/dhis-dxf2/src/test/java/org' === added directory 'dhis-2/dhis-dxf2/src/test/java/org/hisp' === added directory 'dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis' === added directory 'dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2' === added directory 'dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset' === added file 'dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java' --- dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java 2012-04-11 11:40:51 +0000 @@ -0,0 +1,142 @@ +package org.hisp.dhis.dxf2.datavalueset; + +/* + * Copyright (c) 2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; + +import java.util.Collection; + +import org.hisp.dhis.DhisTest; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.dataset.CompleteDataSetRegistration; +import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.datavalue.DataValue; +import org.hisp.dhis.datavalue.DataValueService; +import org.hisp.dhis.dxf2.importsummary.ImportSummary; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.period.MonthlyPeriodType; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; + +public class DataValueSetServiceTest + extends DhisTest +{ + @Autowired + private DataElementService dataElementService; + + @Autowired + private DataElementCategoryService categoryService; + + @Autowired + private DataSetService dataSetService; + + @Autowired + private OrganisationUnitService organisationUnitService; + + @Autowired + private PeriodService periodService; + + @Autowired + private DataValueSetService dataValueSetService; + + @Autowired + private DataValueService dataValueService; + + @Autowired + private CompleteDataSetRegistrationService registrationService; + + private DataElement deA; + private DataElement deB; + private DataElement deC; + private DataSet dsA; + private OrganisationUnit ouA; + private Period peA; + private DataElementCategoryOptionCombo optionComboA; + + @Override + public void setUpTest() + { + deA = createDataElement( 'A' ); + deB = createDataElement( 'B' ); + deC = createDataElement( 'C' ); + dsA = createDataSet( 'A', new MonthlyPeriodType() ); + ouA = createOrganisationUnit( 'A' ); + peA = createPeriod( getDate( 2012, 1, 1 ), getDate( 2012, 1, 31 ) ); + optionComboA = categoryService.getDefaultDataElementCategoryOptionCombo(); + + deA.setUid( "f7n9E0hX8qk" ); + deB.setUid( "Ix2HsbDMLea" ); + deC.setUid( "eY5ehpbEsB7" ); + dsA.setUid( "pBOMPrpg1QX" ); + ouA.setUid( "DiszpKrYNg8" ); + + dataElementService.addDataElement( deA ); + dataElementService.addDataElement( deB ); + dataElementService.addDataElement( deC ); + dataSetService.addDataSet( dsA ); + organisationUnitService.addOrganisationUnit( ouA ); + periodService.addPeriod( peA ); + } + + @Test + public void testImport() + throws Exception + { + ImportSummary summary = dataValueSetService.saveDataValueSet( new ClassPathResource( "dataValueSetA.xml" ).getInputStream() ); + + assertNotNull( summary ); + assertEquals( 1, summary.getCounts().size() ); + + Collection dataValues = dataValueService.getAllDataValues(); + + assertNotNull( dataValues ); + assertEquals( 3, dataValues.size() ); + assertTrue( dataValues.contains( new DataValue( deA, peA, ouA, optionComboA ) ) ); + assertTrue( dataValues.contains( new DataValue( deB, peA, ouA, optionComboA ) ) ); + assertTrue( dataValues.contains( new DataValue( deC, peA, ouA, optionComboA ) ) ); + + CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dsA, peA, ouA ); + + assertNotNull( registration ); + assertEquals( dsA, registration.getDataSet() ); + assertEquals( peA, registration.getPeriod() ); + assertEquals( ouA, registration.getSource() ); + assertEquals( getDate( 2012, 1, 2 ), registration.getDate() ); + } +} === added directory 'dhis-2/dhis-dxf2/src/test/resources' === added file 'dhis-2/dhis-dxf2/src/test/resources/dataValueSetA.xml' --- dhis-2/dhis-dxf2/src/test/resources/dataValueSetA.xml 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-dxf2/src/test/resources/dataValueSetA.xml 2012-04-11 11:33:43 +0000 @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java 2012-04-10 20:15:18 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java 2012-04-11 14:33:18 +0000 @@ -29,25 +29,35 @@ import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import javax.annotation.PostConstruct; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * @author Lars Helge Overland */ public class InMemoryNotifier implements Notifier { + private static final Log log = LogFactory.getLog( InMemoryNotifier.class ); + private int MAX_SIZE = 1000; private List notifications; + private Map taskSummaries; + @PostConstruct public void init() { notifications = new ArrayList(); + taskSummaries = new HashMap(); } // ------------------------------------------------------------------------- @@ -72,6 +82,8 @@ notifications.remove( MAX_SIZE ); } + log.info( notification ); + return this; } @@ -132,13 +144,28 @@ while ( iter.hasNext() ) { - if ( category.equals( iter.next() ) ) + if ( category.equals( iter.next().getCategory() ) ) { iter.remove(); } } } - return this; + taskSummaries.remove( category ); + + return this; + } + + @Override + public Notifier addTaskSummary( NotificationCategory category, Object taskSummary ) + { + taskSummaries.put( category, taskSummary ); + return this; + } + + @Override + public Object getTaskSummary( NotificationCategory category ) + { + return taskSummaries.get( category ); } } === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/NotificationCategory.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/NotificationCategory.java 2012-02-12 20:32:14 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/NotificationCategory.java 2012-04-11 11:33:43 +0000 @@ -33,5 +33,6 @@ public enum NotificationCategory { DATAMART, - IMPORT + DATAVALUE_IMPORT, + METADATA_IMPORT } === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java 2012-04-10 20:15:18 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java 2012-04-11 11:33:43 +0000 @@ -43,4 +43,9 @@ List getNotifications( NotificationCategory category, String lastUid ); Notifier clear( NotificationCategory category ); + + Notifier addTaskSummary( NotificationCategory category, Object taskSummary ); + + Object getTaskSummary( NotificationCategory category ); + } === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm 2012-02-14 12:53:25 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm 2012-04-11 09:02:06 +0000 @@ -1,16 +1,3 @@ - - #if( $notifications.size() > 0 ) === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonNotifications.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonNotifications.vm 2012-04-10 20:15:18 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonNotifications.vm 2012-04-11 09:02:06 +0000 @@ -5,8 +5,8 @@ "uid": "${notification.uid}", "level": "${notification.level}", "category": "${notification.category}", - "time": "${format.formatDate( $notification.time )}", - "message": "${notification.message}", + "time": "${format.formatDateTime( $notification.time )}", + "message": "$!{encoder.jsonEncode( $notification.message )}", "completed": "${notification.completed}" }#if( $velocityCount < $size ),#end #end === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css 2012-03-09 13:21:38 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css 2012-04-11 09:02:06 +0000 @@ -338,6 +338,19 @@ border-radius: 3px; } +table.notificationTable +{ + background-color: #ffffbf; + border: 1px solid #cccc00; + padding: 6px; + border-radius: 3px; +} + +table.notificationTable td +{ + padding: 3px; +} + /*----------------------------------------------------------------------------*/ /* Sorting */ /*----------------------------------------------------------------------------*/ === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2012-03-05 10:43:47 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2012-04-11 14:33:18 +0000 @@ -4,8 +4,8 @@ // ----------------------------------------------------------------------------- var headerMessageTimeout = -1; -var _loading_bar_html = ""; -var _loading_circle_html = ""; +var _loading_bar_html = ""; +var _loading_circle_html = ""; /** * Go back using the document.referrer. @@ -1522,7 +1522,6 @@ // Paging // ----------------------------------------------------------------------------- - isAjax = false; function pagingList( currentPage, pageSize ) { @@ -1587,3 +1586,39 @@ pagingList( currentPage, pageSize ); } } + +// ----------------------------------------------------------------------------- +// Notifications +// ----------------------------------------------------------------------------- + +function pingNotifications( category, tableId ) +{ + var lastUid = $( '#' + tableId ).prop( 'lastUid' ); + + var param = lastUid ? '&lastUid=' + lastUid : ''; + + $.getJSON( '../dhis-web-commons-ajax-json/getNotifications.action?category=' + category + param, function( json ) + { + var html = ''; + var completedHtml = ''; + + $.each( json.notifications, function( i, notification ) + { + var first = i == 0; + var loaderHtml = ''; + + if ( first ) + { + $( '#' + tableId ).prop( 'lastUid', notification.uid ); + loaderHtml = _loading_bar_html; + $( '#loaderSpan' ).replaceWith ( '' ); // Hide previous loader bar + } + + html += ''; + } ); + + $( '#' + tableId ).prepend( html ); + } ); +} === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/NoAction.java' --- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/NoAction.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/NoAction.java 2012-04-11 13:49:03 +0000 @@ -36,6 +36,17 @@ public class NoAction implements Action { + private boolean running; + + public boolean isRunning() + { + return running; + } + public void setRunning( boolean running ) + { + this.running = running; + } + public String execute() { return SUCCESS; === added directory 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue' === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java 2012-04-11 13:49:03 +0000 @@ -0,0 +1,82 @@ +package org.hisp.dhis.importexport.action.datavalue; + +/* + * Copyright (c) 2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import org.hisp.dhis.dxf2.datavalueset.DataValueSetService; +import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.importexport.action.util.ImportDataValueTask; +import org.hisp.dhis.system.scheduling.Scheduler; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +public class ImportDataValueAction + implements Action +{ + @Autowired + private DataValueSetService dataValueSetService; + + @Autowired + private Scheduler scheduler; + + private File upload; + + public void setUpload( File upload ) + { + this.upload = upload; + } + + private boolean dryRun; + + public void setDryRun( boolean dryRun ) + { + this.dryRun = dryRun; + } + + private ImportStrategy strategy; + + public void setStrategy( String stgy ) + { + this.strategy = ImportStrategy.valueOf( stgy ); + } + + public String execute() + throws Exception + { + final InputStream in = new BufferedInputStream( new FileInputStream( upload ) ); + + scheduler.executeTask( new ImportDataValueTask( dataValueSetService, in, dryRun, strategy ) ); + + return SUCCESS; + } +} === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportDataValueTask.java 2012-04-11 13:49:03 +0000 @@ -0,0 +1,30 @@ +package org.hisp.dhis.importexport.action.util; + +import java.io.InputStream; + +import org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty; +import org.hisp.dhis.dxf2.datavalueset.DataValueSetService; +import org.hisp.dhis.importexport.ImportStrategy; + +public class ImportDataValueTask + implements Runnable +{ + private DataValueSetService dataValueSetService; + private InputStream in; + private boolean dryRun; + private ImportStrategy strategy; + + public ImportDataValueTask( DataValueSetService dataValueSetService, InputStream in, boolean dryRun, ImportStrategy strategy ) + { + this.dataValueSetService = dataValueSetService; + this.in = in; + this.dryRun = dryRun; + this.strategy = strategy; + } + + @Override + public void run() + { + dataValueSetService.saveDataValueSet( in, IdentifiableProperty.UID, IdentifiableProperty.UID, dryRun, strategy ); + } +} === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-01-05 20:39:23 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-04-11 13:49:03 +0000 @@ -3,9 +3,11 @@ xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> - - - + + + + + @@ -34,9 +36,7 @@ - - - + @@ -66,9 +66,7 @@ - - - + @@ -97,9 +95,7 @@ - - - + @@ -159,9 +155,7 @@ - - - + === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties 2012-02-23 11:12:25 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties 2012-04-11 14:33:18 +0000 @@ -262,6 +262,7 @@ intro_pdf_metadata_export=Portable Document Format (PDF) is a commonly used file format for document exchange. intro_xls_metadata_export=Excel Spreadsheet (XLS) is a commonly used spreadsheet file format from Microsoft. intro_import=This is the regular import function which imports data from the DHIS 2 exchange format called DXF. +intro_data_value_import=Import data values on the DXF format, which is used for data exchange by DHIS and other third-party software. intro_dhis14_import=Import data from DHIS 1.4 installations. DHIS 1.4 is the predecessor of DHIS 2. intro_data_export=Export data values. This is the regular export function which exports data to the DHIS 2 exchange format called DXF. intro_metadata_export=Export meta data to the DHIS 2 exchange format. Meta meta implies data elements and other objects describing the data. @@ -269,3 +270,8 @@ intro_export_to_other_systems=Export data and meta data to formats such as PDF, Excel and DHIS 1.4. intro_dhis14_file_configuration=Set the configuration for the DHIS 1.4 file import process, such as the location of the data file. no_item_to_match=Sorry, there is no any selected item to match +dry_run=Dry run +strategy=Strategy +new_only=New only +updates_only=Updates only +data_value_import=Data value import \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml 2011-06-23 14:44:17 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml 2012-04-11 13:49:03 +0000 @@ -14,9 +14,21 @@ /dhis-web-importexport/mainMenu.vm - - - + + + + /main.vm + /dhis-web-importexport/importDataValue.vm + /dhis-web-importexport/mainMenu.vm + javascript/importDataValue.js + + + + displayImportDataValueForm.action?running=true + + + + /main.vm @@ -30,9 +42,7 @@ /dhis-web-importexport/mainMenu.vm - - - + displayImportForm.action @@ -66,10 +76,8 @@ /dhis-web-importexport/importAnalysisForm.vm /dhis-web-importexport/mainMenu.vm - - - - + + /dhis-web-importexport/responseSuccess.vm @@ -83,9 +91,7 @@ plainTextError - - - + /main.vm @@ -129,10 +135,8 @@ /dhis-web-importexport/mainMenu.vm javascript/import.js - - - - + + /main.vm @@ -203,9 +207,7 @@ plainTextError - - - + /main.vm === added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm' --- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm 2012-04-11 14:33:18 +0000 @@ -0,0 +1,52 @@ + +

$i18n.getString( "data_value_import" )

+ +
+
+
' + notification.time + '' + notification.message + '  '; + html += notification.completed == "true" ? completedHtml : loaderHtml; + html += '
+++ + + + + + + + + + + + + + + + +
$i18n.getString( "file" )
$i18n.getString( "dry_run" )
$i18n.getString( "strategy" )
+ + + +#if( $running ) + +
+ +++
+
+ + + +#end \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm' --- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm 2012-03-04 13:26:24 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm 2012-04-11 14:33:18 +0000 @@ -9,6 +9,7 @@
    #introListImgItem( "setImportFormat.action?importFormat=DXF" "import" "import" ) + #introListImgItem( "displayImportDataValueForm.action" "data_value_import" "import" ) #introListImgItem( "displayExternalImportMenu.action" "dhis14_import" "import" ) #introListImgItem( "displayDataValueExportForm.action?exportFormat=DXF" "data_export" "export" ) === added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js' --- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js 2012-04-11 14:33:18 +0000 @@ -0,0 +1,17 @@ + +function importDataValue() +{ + if ( !$( "#upload" ).val() ) + { + setHeaderDelayMessage( "Please select a file to upload" ); + return false; + } + + $( "#importForm" ).submit(); +} + +function pingNotificationsTimeout() +{ + pingNotifications( 'DATAVALUE_IMPORT', 'notificationTable' ); + setTimeout( "pingNotificationsTimeout()", 2500 ); +} === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm' --- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm 2010-06-19 15:32:24 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm 2012-04-11 14:33:18 +0000 @@ -3,6 +3,7 @@ === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataMart.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataMart.js 2012-04-10 20:15:18 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataMart.js 2012-04-11 13:49:03 +0000 @@ -6,6 +6,8 @@ function startExport() { + $( '#notificationTable' ).show().prepend( '' + _loading_bar_html + '' ); + var startDate = $( '#startDate' ).val(); var endDate = $( '#endDate' ).val(); @@ -15,16 +17,11 @@ url += "&periodType=" + $( this ).val(); } ); - $.get( url, pingNotifications ); -} - -function pingNotifications() -{ - $( '#notificationDiv' ).load( '../dhis-web-commons-ajax-html/getNotifications.action?category=DATAMART&max=20' ); + $.get( url, pingNotificationsTimeout ); } function pingNotificationsTimeout() { - pingNotifications(); - setTimeout( "pingNotificationsTimeout()", 2000 ); + pingNotifications( 'DATAMART', 'notificationTable' ); + setTimeout( "pingNotificationsTimeout()", 2500 ); } === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm 2012-02-12 19:23:31 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm 2012-04-11 09:02:06 +0000 @@ -1,4 +1,3 @@ -

    $i18n.getString( "data_mart_management" )

    @@ -29,4 +28,9 @@
    -
    \ No newline at end of file +
    + +++ +
    \ No newline at end of file