dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15670
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5740: (mobile) dataentry: added support for dataset locking, made completion a one-way street, added ne...
------------------------------------------------------------
revno: 5740
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-01-17 00:00:37 +0530
message:
(mobile) dataentry: added support for dataset locking, made completion a one-way street, added new icons, made saveSection check for locking..
removed:
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/check.jpg
added:
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/checkmark.jpg
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/lock.jpg
modified:
dhis-2/dhis-web/dhis-web-light/pom.xml
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java
dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntryOverview.vm
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-light/pom.xml'
--- dhis-2/dhis-web/dhis-web-light/pom.xml 2011-12-26 09:25:32 +0000
+++ dhis-2/dhis-web/dhis-web-light/pom.xml 2012-01-16 18:30:37 +0000
@@ -44,6 +44,10 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-administration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-mobile</artifactId>
</dependency>
<dependency>
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java 2012-01-04 12:55:23 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java 2012-01-16 18:30:37 +0000
@@ -26,14 +26,10 @@
*/
package org.hisp.dhis.light.dataentry.action;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.opensymphony.xwork2.Action;
import org.apache.commons.lang.Validate;
+import org.hisp.dhis.datalock.DataSetLock;
+import org.hisp.dhis.datalock.DataSetLockService;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
import org.hisp.dhis.dataset.DataSet;
@@ -46,7 +42,7 @@
import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
import org.hisp.dhis.system.util.FilterUtils;
-import com.opensymphony.xwork2.Action;
+import java.util.*;
/**
* @author mortenoh
@@ -74,6 +70,13 @@
this.dataSetService = dataSetService;
}
+ private DataSetLockService dataSetLockService;
+
+ public void setDataSetLockService( DataSetLockService dataSetLockService )
+ {
+ this.dataSetLockService = dataSetLockService;
+ }
+
private CompleteDataSetRegistrationService registrationService;
public void setRegistrationService( CompleteDataSetRegistrationService registrationService )
@@ -142,6 +145,13 @@
return periods;
}
+ private List<Period> lockedPeriods = new ArrayList<Period>();
+
+ public List<Period> getLockedPeriods()
+ {
+ return lockedPeriods;
+ }
+
private Boolean complete = false;
public void setComplete( Boolean complete )
@@ -190,6 +200,8 @@
periods = periods.subList( 0, MAX_PERIODS );
}
+ markLockedDataSets( organisationUnit, dataSet, periods );
+
for ( Period period : periods )
{
period.setName( format.formatPeriod( period ) );
@@ -202,4 +214,30 @@
return SUCCESS;
}
+
+ private void markLockedDataSets( OrganisationUnit organisationUnit, DataSet dataSet, List<Period> periods )
+ {
+ for ( Period period : periods )
+ {
+ boolean locked = dataSetLocked( organisationUnit, dataSet, period );
+
+ if ( locked )
+ {
+ lockedPeriods.add( period );
+ }
+ }
+ }
+
+ private boolean dataSetLocked( OrganisationUnit organisationUnit, DataSet dataSet, Period period )
+ {
+ // HACK workaround since get dataSetLock by unit/dataSet/period fails
+ DataSetLock dataSetLock = dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period );
+
+ if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
+ {
+ return true;
+ }
+
+ return false;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java 2012-01-12 09:16:32 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java 2012-01-16 18:30:37 +0000
@@ -37,6 +37,8 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.datalock.DataSetLock;
+import org.hisp.dhis.datalock.DataSetLockService;
import org.hisp.dhis.dataset.*;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
@@ -105,6 +107,13 @@
this.dataSetService = dataSetService;
}
+ private DataSetLockService dataSetLockService;
+
+ public void setDataSetLockService( DataSetLockService dataSetLockService )
+ {
+ this.dataSetLockService = dataSetLockService;
+ }
+
private CompleteDataSetRegistrationService registrationService;
public void setRegistrationService( CompleteDataSetRegistrationService registrationService )
@@ -275,6 +284,9 @@
dataSet = dataSetService.getDataSet( dataSetId );
+ // this should never happen, but validate that that dataset is not locked
+ Validate.isTrue( !dataSetLocked( organisationUnit, dataSet, period ) );
+
String storedBy = currentUserService.getCurrentUsername();
if ( StringUtils.isBlank( storedBy ) )
@@ -463,4 +475,17 @@
return SUCCESS;
}
+
+ private boolean dataSetLocked( OrganisationUnit organisationUnit, DataSet dataSet, Period period )
+ {
+ // HACK workaround since get dataSetLock by unit/dataSet/period fails
+ DataSetLock dataSetLock = dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period );
+
+ if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
+ {
+ return true;
+ }
+
+ return false;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-01-12 08:43:22 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-01-16 18:30:37 +0000
@@ -38,6 +38,7 @@
scope="prototype">
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
<property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
</bean>
@@ -70,6 +71,7 @@
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
<property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
<property name="formUtils" ref="org.hisp.dhis.light.dataentry.utils.FormUtils" />
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2012-01-13 10:16:31 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2012-01-16 18:30:37 +0000
@@ -44,3 +44,4 @@
reply=Reply
write_feedback=Write feedback
form_complete=Form complete
+successfully_saved_section=Successfully Saved
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntryOverview.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntryOverview.vm 2012-01-13 10:16:31 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntryOverview.vm 2012-01-16 18:30:37 +0000
@@ -32,6 +32,7 @@
#end
*#
+#if( $complete != true)
<p>
<ul>
#if( $dataSet.sections.size() > 0 )
@@ -45,6 +46,9 @@
#end
</ul>
</p>
+#else
+<br />
+#end
<form method="GET" action="dataEntry.action">
=== removed file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/check.jpg'
Binary files dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/check.jpg 2011-10-14 07:44:17 +0000 and dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/check.jpg 1970-01-01 00:00:00 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/checkmark.jpg'
Binary files dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/checkmark.jpg 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/checkmark.jpg 2012-01-16 18:30:37 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/lock.jpg'
Binary files dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/lock.jpg 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/images/lock.jpg 2012-01-16 18:30:37 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm 2011-11-01 18:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm 2012-01-16 18:30:37 +0000
@@ -1,25 +1,18 @@
<h2>$i18n.getString( "available_periods" )</h2>
-#if( $validated )
-<div class="header-box">
- <h3 style="text-align: left;">Successfully Saved</h3>
- <p style="text-align: left;">
- #if( $complete )
- DataSet $dataSet.name was saved and completed <br />
- #else
- DataSet $dataSet.name was saved<br />
- #end
- </p>
-</div>
-#end
-
<p>
<ul>
#foreach( $period in $periods )
<li>
- <a href="dataEntry.action?organisationUnitId=$organisationUnitId&dataSetId=$dataSetId&periodId=$period.getExternalId()">$!encoder.htmlEncode( ${period.name} )</a>
- #if( $periodCompletedMap.get($period) )<img src="../dhis-web-light/images/check.jpg" />#end
+ #if( ! $lockedPeriods.contains( $period ) && ! $periodCompletedMap.get($period) )
+ <a href="dataEntry.action?organisationUnitId=$organisationUnitId&dataSetId=$dataSetId&periodId=$period.getExternalId()">$!encoder.htmlEncode( ${period.name} )</a>
+ #else
+ $!encoder.htmlEncode( ${period.name} )
+ #end
+
+ #if( $periodCompletedMap.get($period) )<img src="../dhis-web-light/images/checkmark.jpg" />#end
+ #if( $lockedPeriods.contains( $period ) )<img src="../dhis-web-light/images/lock.jpg" />#end
</li>
#end
</ul>