dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18582
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7881: [mobile] fix update dataset bug
------------------------------------------------------------
revno: 7881
committer: Long <thanhlongngo1988@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-08-09 16:43:27 +0700
message:
[mobile] fix update dataset bug
modified:
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataSetList.java
dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.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
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataSetList.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataSetList.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataSetList.java 2012-08-09 09:43:27 +0000
@@ -105,53 +105,13 @@
public void serialize( DataOutputStream dout )
throws IOException
{
- if ( addedDataSets != null )
- {
- dout.writeInt( addedDataSets.size() );
- for ( DataSet dataSet : addedDataSets )
- {
- dataSet.serialize( dout );
- }
- }
- else
- {
- dout.writeInt( 0 );
- }
- if ( deletedDataSets != null )
- {
- dout.writeInt( deletedDataSets.size() );
- for ( DataSet dataSet : deletedDataSets )
- {
- dataSet.serialize( dout );
- }
- }
- else
- {
- dout.writeInt( 0 );
- }
- if ( modifiedDataSets != null )
- {
- dout.writeInt( modifiedDataSets.size() );
- for ( DataSet dataSet : modifiedDataSets )
- {
- dataSet.serialize( dout );
- }
- }
- else
- {
- dout.writeInt( 0 );
- }
- if ( currentDataSets != null )
- {
- dout.writeInt( currentDataSets.size() );
- for ( DataSet dataSet : currentDataSets )
- {
- dataSet.serialize( dout );
- }
- }
- else
- {
- dout.writeInt( 0 );
+ if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_EIGHT ) )
+ {
+ serializeVerssion2_8( dout );
+ }
+ else
+ {
+ serializeVerssion2_9( dout );
}
}
@@ -164,7 +124,7 @@
dout.writeInt( addedDataSets.size() );
for ( DataSet dataSet : addedDataSets )
{
- dataSet.serialize( dout );
+ dataSet.serializeVerssion2_8( dout );
}
}
else
@@ -176,7 +136,7 @@
dout.writeInt( deletedDataSets.size() );
for ( DataSet dataSet : deletedDataSets )
{
- dataSet.serialize( dout );
+ dataSet.serializeVerssion2_8( dout );
}
}
else
@@ -188,7 +148,7 @@
dout.writeInt( modifiedDataSets.size() );
for ( DataSet dataSet : modifiedDataSets )
{
- dataSet.serialize( dout );
+ dataSet.serializeVerssion2_8( dout );
}
}
else
@@ -200,7 +160,7 @@
dout.writeInt( currentDataSets.size() );
for ( DataSet dataSet : currentDataSets )
{
- dataSet.serialize( dout );
+ dataSet.serializeVerssion2_8( dout );
}
}
else
@@ -218,7 +178,7 @@
dout.writeInt( addedDataSets.size() );
for ( DataSet dataSet : addedDataSets )
{
- dataSet.serialize( dout );
+ dataSet.serializeVerssion2_9( dout );
}
}
else
@@ -230,7 +190,7 @@
dout.writeInt( deletedDataSets.size() );
for ( DataSet dataSet : deletedDataSets )
{
- dataSet.serialize( dout );
+ dataSet.serializeVerssion2_9( dout );
}
}
else
@@ -242,7 +202,7 @@
dout.writeInt( modifiedDataSets.size() );
for ( DataSet dataSet : modifiedDataSets )
{
- dataSet.serialize( dout );
+ dataSet.serializeVerssion2_9( dout );
}
}
else
@@ -254,7 +214,7 @@
dout.writeInt( currentDataSets.size() );
for ( DataSet dataSet : currentDataSets )
{
- dataSet.serialize( dout );
+ dataSet.serializeVerssion2_9( dout );
}
}
else
=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2012-08-03 03:30:42 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2012-08-09 09:43:27 +0000
@@ -72,7 +72,9 @@
public DataSetList checkUpdatedDataSet2_8( @PathVariable int id, @RequestBody DataSetList dataSetList,
@RequestHeader( "accept-language" ) String locale )
{
- return facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale );
+ DataSetList returnList = facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale );
+ returnList.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
+ return returnList;
}
/**
@@ -89,7 +91,7 @@
facilityReportingService.saveDataSetValues( getUnit( id ), dataSetValue );
return DATASET_REPORT_UPLOADED;
}
-
+
/**
* Save activity report for unit
*
@@ -112,22 +114,24 @@
@RequestBody ModelList programsFromClient )
{
MobileModel model = new MobileModel();
+ model.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
model.setPrograms( programService.updateProgram( programsFromClient, locale, getUnit( id ) ) );
model.setActivityPlan( activityReportingService.getCurrentActivityPlan( getUnit( id ), locale ) );
model.setServerCurrentDate( new Date() );
return model;
}
-
+
@RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/search" )
@ResponseBody
public ActivityPlan search2_8( @PathVariable int id, @RequestHeader( "identifier" ) String identifier )
throws NotAllowedException
{
- ActivityPlan activityPlan = activityReportingService.getActivitiesByIdentifier( identifier );;
+ ActivityPlan activityPlan = activityReportingService.getActivitiesByIdentifier( identifier );
+ ;
activityPlan.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
return activityPlan;
}
-
+
@RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/changeLanguageDataSet" )
@ResponseBody
public DataSetList changeLanguageDataSet2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
@@ -136,7 +140,7 @@
}
// For client version 2.9 and higher
-
+
@RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/all" )
@ResponseBody
public MobileModel getAllDataForOrgUnit( @PathVariable String clientVersion, @PathVariable int id,
@@ -159,16 +163,18 @@
public DataSetList checkUpdatedDataSet( @PathVariable String clientVersion, @PathVariable int id,
@RequestBody DataSetList dataSetList, @RequestHeader( "accept-language" ) String locale )
{
- return facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale );
+ DataSetList returnList = facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale );
+ returnList.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
+ return returnList;
}
-
+
/**
* Save a facility report for unit
*
* @param dataSetValue - the report to save
* @throws NotAllowedException if the {@link DataSetValue} is invalid
*/
-
+
@RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/dataSets" )
@ResponseBody
public String saveDataSetValues( @PathVariable int id, @RequestBody DataSetValue dataSetValue )
@@ -177,20 +183,21 @@
facilityReportingService.saveDataSetValues( getUnit( id ), dataSetValue );
return DATASET_REPORT_UPLOADED;
}
-
+
@RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/activitiyplan" )
@ResponseBody
- public MobileModel updatePrograms(@PathVariable String clientVersion, @PathVariable int id, @RequestHeader( "accept-language" ) String locale,
- @RequestBody ModelList programsFromClient )
+ public MobileModel updatePrograms( @PathVariable String clientVersion, @PathVariable int id,
+ @RequestHeader( "accept-language" ) String locale, @RequestBody ModelList programsFromClient )
{
MobileModel model = new MobileModel();
+ model.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
model.setPrograms( programService.updateProgram( programsFromClient, locale, getUnit( id ) ) );
model.setActivityPlan( activityReportingService.getCurrentActivityPlan( getUnit( id ), locale ) );
model.setServerCurrentDate( new Date() );
model.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
return model;
}
-
+
/**
* Save activity report for unit
*
@@ -206,25 +213,26 @@
activityReportingService.saveActivityReport( getUnit( id ), activityValue );
return ACTIVITY_REPORT_UPLOADED;
}
-
+
@RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/search" )
@ResponseBody
public ActivityPlan search( @PathVariable int id, @RequestHeader( "identifier" ) String identifier )
throws NotAllowedException
{
- ActivityPlan activityPlan = activityReportingService.getActivitiesByIdentifier( identifier );;
+ ActivityPlan activityPlan = activityReportingService.getActivitiesByIdentifier( identifier );
+ ;
activityPlan.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
return activityPlan;
}
-
+
@RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/changeLanguageDataSet" )
@ResponseBody
public DataSetList changeLanguageDataSet( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
{
return facilityReportingService.getDataSetsForLocale( getUnit( id ), locale );
}
-
- //Supportive methods
+
+ // Supportive methods
private Collection<String> getLocalStrings( Collection<Locale> locales )
{