dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20669
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9572: [mobile] support j2me sms sending (WIP)
------------------------------------------------------------
revno: 9572
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Tue 2013-01-22 15:08:14 +0700
message:
[mobile] support j2me sms sending (WIP)
added:
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/SMSCode.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/SMSCommand.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/J2MEDataEntryParser.java
modified:
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Activity.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityPlan.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityValue.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Beneficiary.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Contact.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataElement.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataSet.java
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/DataStreamSerializable.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataValue.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileModel.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Model.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ModelList.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientIdentifier.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Program.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ProgramStage.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Section.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Task.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/Activity.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Activity.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Activity.java 2013-01-22 08:08:14 +0000
@@ -114,11 +114,18 @@
public void serialize( DataOutputStream dout )
throws IOException
{
- this.getTask().serialize( dout );
- this.getBeneficiary().serialize( dout );
- dout.writeBoolean( late );
- dout.writeLong( this.getDueDate().getTime() );
- dout.writeLong( this.getExpireDate().getTime() );
+ if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_EIGHT ) )
+ {
+ this.serializeVerssion2_8( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_NINE ) )
+ {
+ this.serializeVerssion2_9( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_TEN ) )
+ {
+ this.serializeVerssion2_10( dout );
+ }
}
@Override
@@ -140,7 +147,8 @@
public void serializeVerssion2_8( DataOutputStream dout )
throws IOException
{
- this.getTask().serializeVerssion2_8( dout );
+ this.task.setClientVersion( TWO_POINT_EIGHT );
+ this.getTask().serialize( dout );
this.getBeneficiary().serializeVerssion2_8( dout );
dout.writeBoolean( late );
dout.writeLong( this.getDueDate().getTime() );
@@ -151,12 +159,25 @@
public void serializeVerssion2_9( DataOutputStream dout )
throws IOException
{
- this.getTask().serializeVerssion2_9( dout );
- this.getBeneficiary().serializeVerssion2_9( dout );
- dout.writeBoolean( late );
- dout.writeLong( this.getDueDate().getTime() );
- dout.writeLong( this.getExpireDate().getTime() );
-
+ this.task.setClientVersion( TWO_POINT_NINE );
+ this.getTask().serialize( dout );
+ this.getBeneficiary().serializeVerssion2_9( dout );
+ dout.writeBoolean( late );
+ dout.writeLong( this.getDueDate().getTime() );
+ dout.writeLong( this.getExpireDate().getTime() );
+
+ }
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dout )
+ throws IOException
+ {
+ this.task.setClientVersion( TWO_POINT_TEN );
+ this.getTask().serialize( dout );
+ this.getBeneficiary().serializeVerssion2_9( dout );
+ dout.writeBoolean( late );
+ dout.writeLong( this.getDueDate().getTime() );
+ dout.writeLong( this.getExpireDate().getTime() );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityPlan.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityPlan.java 2012-07-23 04:34:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityPlan.java 2013-01-22 08:08:14 +0000
@@ -77,13 +77,17 @@
public void serialize( DataOutputStream dout )
throws IOException
{
- if ( this.clientVersion.equals( TWO_POINT_NINE ) )
- {
- serializeVerssion2_9( dout );
- }
- else
- {
- serializeVerssion2_8( dout );
+ if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_EIGHT ) )
+ {
+ this.serializeVerssion2_8( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_NINE ) )
+ {
+ this.serializeVerssion2_9( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_TEN ) )
+ {
+ this.serializeVerssion2_10( dout );
}
}
@@ -107,7 +111,9 @@
dout.writeInt( activitiesList.size() );
for ( int i = 0; i < activitiesList.size(); i++ )
{
- activitiesList.get( i ).serializeVerssion2_8( dout );
+ Activity activity = activitiesList.get( i );
+ activity.setClientVersion( TWO_POINT_EIGHT );
+ activity.serialize( dout );
}
}
}
@@ -125,7 +131,29 @@
dout.writeInt( activitiesList.size() );
for ( int i = 0; i < activitiesList.size(); i++ )
{
- activitiesList.get( i ).serializeVerssion2_9( dout );
+ Activity activity = activitiesList.get( i );
+ activity.setClientVersion( TWO_POINT_NINE );
+ activity.serialize( dout );
+ }
+ }
+ }
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dout )
+ throws IOException
+ {
+ if ( activitiesList == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( activitiesList.size() );
+ for ( int i = 0; i < activitiesList.size(); i++ )
+ {
+ Activity activity = activitiesList.get( i );
+ activity.setClientVersion( TWO_POINT_TEN );
+ activity.serialize( dout );
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityValue.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityValue.java 2012-06-22 02:59:28 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityValue.java 2013-01-22 08:08:14 +0000
@@ -119,4 +119,12 @@
}
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Beneficiary.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Beneficiary.java 2013-01-14 06:36:46 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Beneficiary.java 2013-01-22 08:08:14 +0000
@@ -505,4 +505,12 @@
each.serializeVerssion2_9( dout );
}
}
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Contact.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Contact.java 2013-01-14 16:10:34 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Contact.java 2013-01-22 08:08:14 +0000
@@ -86,5 +86,13 @@
{
this.listOfContacts = listOfContacts;
}
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataElement.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataElement.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataElement.java 2013-01-22 08:08:14 +0000
@@ -102,24 +102,17 @@
public void serialize( DataOutputStream dout )
throws IOException
{
- dout.writeInt( this.getId() );
- dout.writeUTF( this.getName() );
- dout.writeUTF( this.getType() );
- dout.writeBoolean( this.isCompulsory() );
-
- List<Model> cateOptCombos = this.getCategoryOptionCombos().getModels();
- if ( cateOptCombos == null || cateOptCombos.size() <= 0 )
- {
- dout.writeInt( 0 );
- }
- else
- {
- dout.writeInt( cateOptCombos.size() );
- for ( Model each : cateOptCombos )
- {
- dout.writeInt( each.getId() );
- dout.writeUTF( each.getName() );
- }
+ if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_EIGHT ) )
+ {
+ this.serializeVerssion2_8( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_NINE ) )
+ {
+ this.serializeVerssion2_9( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_TEN ) )
+ {
+ this.serializeVerssion2_10( dout );
}
}
@@ -142,7 +135,8 @@
dout.writeInt( cateOptCombos.size() );
for ( Model each : cateOptCombos )
{
- each.serializeVerssion2_8( dout );
+ each.setClientVersion( TWO_POINT_EIGHT );
+ each.serialize( dout );
}
}
}
@@ -166,19 +160,56 @@
dout.writeInt( cateOptCombos.size() );
for ( Model each : cateOptCombos )
{
- each.serializeVerssion2_9( dout );
- }
- }
-
- if ( optionSet == null || optionSet.getOptions().size() <= 0 )
- {
- dout.writeInt( 0 );
- }
- else
- {
- optionSet.serializeVerssion2_9( dout );
- }
-
+ each.setClientVersion( TWO_POINT_NINE );
+ each.serialize( dout );
+ }
+ }
+
+ if ( optionSet == null || optionSet.getOptions().size() <= 0 )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ optionSet.setClientVersion( TWO_POINT_NINE );
+ optionSet.serialize( dout );
+ }
+
+ }
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dout )
+ throws IOException
+ {
+ dout.writeInt( this.getId() );
+ dout.writeUTF( this.getName() );
+ dout.writeUTF( this.getType() );
+ dout.writeBoolean( this.isCompulsory() );
+
+ List<Model> cateOptCombos = this.getCategoryOptionCombos().getModels();
+ if ( cateOptCombos == null || cateOptCombos.size() <= 0 )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( cateOptCombos.size() );
+ for ( Model each : cateOptCombos )
+ {
+ each.setClientVersion( TWO_POINT_TEN );
+ each.serialize( dout );
+ }
+ }
+
+ if ( optionSet == null || optionSet.getOptions().size() <= 0 )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ optionSet.setClientVersion( TWO_POINT_TEN );
+ optionSet.serialize( dout );
+ }
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataSet.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataSet.java 2012-07-20 08:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataSet.java 2013-01-22 08:08:14 +0000
@@ -47,6 +47,8 @@
private int version;
+ private SMSCommand smsCommand;
+
public DataSet()
{
}
@@ -106,22 +108,17 @@
public void serialize( DataOutputStream dout )
throws IOException
{
- dout.writeInt( this.getId() );
- dout.writeUTF( this.getName() );
- dout.writeInt( this.getVersion() );
- dout.writeUTF( this.getPeriodType() );
-
- if ( this.sections == null )
- {
- dout.writeInt( 0 );
- }
- else
- {
- dout.writeInt( this.sections.size() );
- for ( Section section : this.sections )
- {
- section.serialize( dout );
- }
+ if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_EIGHT ) )
+ {
+ this.serializeVerssion2_8( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_NINE ) )
+ {
+ this.serializeVerssion2_9( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_TEN ) )
+ {
+ this.serializeVerssion2_10( dout );
}
}
@@ -143,11 +140,12 @@
dout.writeInt( this.sections.size() );
for ( Section section : this.sections )
{
- section.serializeVerssion2_8( dout );
+ section.setClientVersion( TWO_POINT_EIGHT );
+ section.serialize( dout );
}
}
}
-
+
@Override
public void serializeVerssion2_9( DataOutputStream dout )
throws IOException
@@ -166,7 +164,8 @@
dout.writeInt( this.sections.size() );
for ( Section section : this.sections )
{
- section.serializeVerssion2_9( dout );
+ section.setClientVersion( TWO_POINT_NINE );
+ section.serialize( dout );
}
}
}
@@ -191,6 +190,40 @@
}
@Override
+ public void serializeVerssion2_10( DataOutputStream dout )
+ throws IOException
+ {
+ dout.writeInt( this.getId() );
+ dout.writeUTF( this.getName() );
+ dout.writeInt( this.getVersion() );
+ dout.writeUTF( this.getPeriodType() );
+
+ if ( this.sections == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( this.sections.size() );
+ for ( Section section : this.sections )
+ {
+ section.setClientVersion( TWO_POINT_TEN );
+ section.serialize( dout );
+ }
+ }
+
+ if ( this.smsCommand != null )
+ {
+ dout.writeInt( 1 );
+ smsCommand.serialize( dout );
+ }
+ else
+ {
+ dout.writeInt( 0 );
+ }
+ }
+
+ @Override
public boolean equals( Object obj )
{
if ( ((DataSet) obj).getId() == this.getId() )
=== 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-08-09 09:43:27 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataSetList.java 2013-01-22 08:08:14 +0000
@@ -109,10 +109,14 @@
{
serializeVerssion2_8( dout );
}
- else
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_NINE ) )
{
serializeVerssion2_9( dout );
}
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_TEN ) )
+ {
+ serializeVerssion2_10( dout );
+ }
}
@Override
@@ -224,6 +228,61 @@
}
@Override
+ public void serializeVerssion2_10( DataOutputStream dout )
+ throws IOException
+ {
+
+ if ( addedDataSets != null )
+ {
+ dout.writeInt( addedDataSets.size() );
+ for ( DataSet dataSet : addedDataSets )
+ {
+ dataSet.serializeVerssion2_10( dout );
+ }
+ }
+ else
+ {
+ dout.writeInt( 0 );
+ }
+ if ( deletedDataSets != null )
+ {
+ dout.writeInt( deletedDataSets.size() );
+ for ( DataSet dataSet : deletedDataSets )
+ {
+ dataSet.serializeVerssion2_10( dout );
+ }
+ }
+ else
+ {
+ dout.writeInt( 0 );
+ }
+ if ( modifiedDataSets != null )
+ {
+ dout.writeInt( modifiedDataSets.size() );
+ for ( DataSet dataSet : modifiedDataSets )
+ {
+ dataSet.serializeVerssion2_10( dout );
+ }
+ }
+ else
+ {
+ dout.writeInt( 0 );
+ }
+ if ( currentDataSets != null )
+ {
+ dout.writeInt( currentDataSets.size() );
+ for ( DataSet dataSet : currentDataSets )
+ {
+ dataSet.serializeVerssion2_10( dout );
+ }
+ }
+ else
+ {
+ dout.writeInt( 0 );
+ }
+ }
+
+ @Override
public void deSerialize( DataInputStream dataInputStream )
throws IOException
{
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataStreamSerializable.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataStreamSerializable.java 2012-07-02 06:43:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataStreamSerializable.java 2013-01-22 08:08:14 +0000
@@ -42,6 +42,8 @@
public static final String TWO_POINT_EIGHT = "2.8";
public static final String TWO_POINT_NINE = "2.9";
+
+ public static final String TWO_POINT_TEN = "2.10";
public void serialize( DataOutputStream dataOutputStream )
throws IOException;
@@ -54,5 +56,8 @@
public void serializeVerssion2_9( DataOutputStream dataOutputStream )
throws IOException;
+
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException;
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataValue.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataValue.java 2012-06-22 02:59:28 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataValue.java 2013-01-22 08:08:14 +0000
@@ -120,4 +120,12 @@
// TODO Auto-generated method stub
}
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileModel.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileModel.java 2012-07-23 04:34:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileModel.java 2013-01-22 08:08:14 +0000
@@ -52,6 +52,8 @@
private Collection<String> locales;
+ private List<SMSCommand> smsCommands;
+
public ActivityPlan getActivityPlan()
{
return activityPlan;
@@ -111,6 +113,16 @@
{
this.clientVersion = clientVersion;
}
+
+ public List<SMSCommand> getSmsCommands()
+ {
+ return smsCommands;
+ }
+
+ public void setSmsCommands( List<SMSCommand> smsCommands )
+ {
+ this.smsCommands = smsCommands;
+ }
@Override
public void serialize( DataOutputStream dout )
@@ -120,10 +132,14 @@
{
this.serializeVerssion2_8( dout );
}
- else
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_NINE ) )
{
this.serializeVerssion2_9( dout );
}
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_TEN ) )
+ {
+ this.serializeVerssion2_10( dout );
+ }
}
@Override
@@ -147,7 +163,8 @@
for ( Program prog : programs )
{
- prog.serializeVerssion2_8( dout );
+ prog.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
+ prog.serialize( dout );
}
}
@@ -158,7 +175,8 @@
}
else
{
- this.activityPlan.serializeVerssion2_8( dout );
+ activityPlan.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
+ this.activityPlan.serialize( dout );
}
// Write current server's date
@@ -174,7 +192,8 @@
dout.writeInt( datasets.size() );
for ( DataSet ds : datasets )
{
- ds.serializeVerssion2_8( dout );
+ ds.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
+ ds.serialize( dout );
}
}
@@ -207,49 +226,130 @@
for ( Program prog : programs )
{
- prog.serializeVerssion2_9( dout );
- }
- }
-
- // Write ActivityPlans
- if ( this.activityPlan == null )
- {
- dout.writeInt( 0 );
- }
- else
- {
- this.activityPlan.serializeVerssion2_9( dout );
- }
-
- // Write current server's date
- dout.writeLong( serverCurrentDate.getTime() );
-
- // Write DataSets
- if ( datasets == null )
- {
- dout.writeInt( 0 );
- }
- else
- {
- dout.writeInt( datasets.size() );
- for ( DataSet ds : datasets )
- {
- ds.serializeVerssion2_9( dout );
- }
- }
-
- // Write Locales
- if ( locales == null )
- {
- dout.writeInt( 0 );
- }
- else
- {
- dout.writeInt( locales.size() );
- for ( String locale : locales )
- {
- dout.writeUTF( locale );
- }
+ prog.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
+ prog.serialize( dout );
+ }
+ }
+
+ // Write ActivityPlans
+ if ( this.activityPlan == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ this.activityPlan.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
+ this.activityPlan.serialize( dout );
+ }
+
+ // Write current server's date
+ dout.writeLong( serverCurrentDate.getTime() );
+
+ // Write DataSets
+ if ( datasets == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( datasets.size() );
+ for ( DataSet ds : datasets )
+ {
+ ds.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
+ ds.serialize( dout );
+ }
+ }
+
+ // Write Locales
+ if ( locales == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( locales.size() );
+ for ( String locale : locales )
+ {
+ dout.writeUTF( locale );
+ }
+ }
+ }
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dout )
+ throws IOException
+ {
+ if ( programs == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( programs.size() );
+
+ for ( Program prog : programs )
+ {
+ prog.setClientVersion( DataStreamSerializable.TWO_POINT_TEN );
+ prog.serialize( dout );
+ }
+ }
+
+ // Write ActivityPlans
+ if ( this.activityPlan == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ this.activityPlan.setClientVersion( DataStreamSerializable.TWO_POINT_TEN );
+ this.activityPlan.serialize( dout );
+ }
+
+ // Write current server's date
+ dout.writeLong( serverCurrentDate.getTime() );
+
+ // Write DataSets
+ if ( datasets == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( datasets.size() );
+ for ( DataSet ds : datasets )
+ {
+ ds.setClientVersion( DataStreamSerializable.TWO_POINT_TEN );
+ ds.serialize( dout );
+ }
+ }
+
+ // Write Locales
+ if ( locales == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( locales.size() );
+ for ( String locale : locales )
+ {
+ dout.writeUTF( locale );
+ }
+ }
+
+ // Write SMS Command
+
+ if ( smsCommands != null )
+ {
+ dout.writeInt( smsCommands.size() );
+ for (SMSCommand smsCommand : smsCommands) {
+ smsCommand.setClientVersion( getClientVersion() );
+ smsCommand.serialize( dout );
+ }
+ }
+ else
+ {
+ dout.writeInt( 0 );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java 2013-01-14 06:36:46 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java 2013-01-22 08:08:14 +0000
@@ -266,4 +266,12 @@
dataOutputStream.writeUTF( this.findPatientUrl );
}
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Model.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Model.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Model.java 2013-01-22 08:08:14 +0000
@@ -106,4 +106,12 @@
dout.writeUTF( this.name );
}
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // No change from 2.9 to 2.10
+ this.serializeVerssion2_9( dataOutputStream );
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ModelList.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ModelList.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ModelList.java 2013-01-22 08:08:14 +0000
@@ -131,4 +131,12 @@
}
}
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java 2012-08-22 13:33:18 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java 2013-01-22 08:08:14 +0000
@@ -135,4 +135,12 @@
}
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java 2012-10-02 06:59:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java 2013-01-22 08:08:14 +0000
@@ -124,4 +124,12 @@
}
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientIdentifier.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientIdentifier.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientIdentifier.java 2013-01-22 08:08:14 +0000
@@ -116,4 +116,12 @@
dataOutputStream.writeUTF( identifier );
}
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Program.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Program.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Program.java 2013-01-22 08:08:14 +0000
@@ -36,7 +36,7 @@
extends Model
{
private String clientVersion;
-
+
private int version;
public int getVersion()
@@ -60,7 +60,7 @@
{
this.programStages = programStages;
}
-
+
public String getClientVersion()
{
return clientVersion;
@@ -75,17 +75,29 @@
public void serialize( DataOutputStream dout )
throws IOException
{
- dout.writeInt( this.getId() );
- dout.writeUTF( this.getName() );
- dout.writeInt( this.getVersion() );
- dout.writeInt( programStages.size() );
- for ( int i = 0; i < programStages.size(); i++ )
- {
- ProgramStage programStage = (ProgramStage) programStages.get( i );
- programStage.serialize( dout );
- }
+ if ( this.clientVersion.equalsIgnoreCase( DataStreamSerializable.TWO_POINT_EIGHT ) )
+ {
+ this.serializeVerssion2_8( dout );
+ }
+ else if ( this.clientVersion.equalsIgnoreCase( DataStreamSerializable.TWO_POINT_NINE ) )
+ {
+ this.serializeVerssion2_9( dout );
+ }
+ else if ( this.clientVersion.equalsIgnoreCase( DataStreamSerializable.TWO_POINT_TEN ) )
+ {
+ this.serializeVerssion2_10( dout );
+ }
+ // dout.writeInt( this.getId() );
+ // dout.writeUTF( this.getName() );
+ // dout.writeInt( this.getVersion() );
+ // dout.writeInt( programStages.size() );
+ // for ( int i = 0; i < programStages.size(); i++ )
+ // {
+ // ProgramStage programStage = (ProgramStage) programStages.get( i );
+ // programStage.serialize( dout );
+ // }
}
-
+
@Override
public void serializeVerssion2_8( DataOutputStream dout )
throws IOException
@@ -97,10 +109,11 @@
for ( int i = 0; i < programStages.size(); i++ )
{
ProgramStage programStage = (ProgramStage) programStages.get( i );
- programStage.serializeVerssion2_8( dout );
+ programStage.setClientVersion( TWO_POINT_EIGHT );
+ programStage.serialize( dout );
}
}
-
+
@Override
public void serializeVerssion2_9( DataOutputStream dout )
throws IOException
@@ -112,7 +125,24 @@
for ( int i = 0; i < programStages.size(); i++ )
{
ProgramStage programStage = (ProgramStage) programStages.get( i );
- programStage.serializeVerssion2_9( dout );
+ programStage.setClientVersion( TWO_POINT_NINE );
+ programStage.serialize( dout );
+ }
+ }
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dout )
+ throws IOException
+ {
+ dout.writeInt( this.getId() );
+ dout.writeUTF( this.getName() );
+ dout.writeInt( this.getVersion() );
+ dout.writeInt( programStages.size() );
+ for ( int i = 0; i < programStages.size(); i++ )
+ {
+ ProgramStage programStage = (ProgramStage) programStages.get( i );
+ programStage.setClientVersion( TWO_POINT_TEN );
+ programStage.serialize( dout );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ProgramStage.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ProgramStage.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ProgramStage.java 2013-01-22 08:08:14 +0000
@@ -63,15 +63,17 @@
public void serialize( DataOutputStream dout )
throws IOException
{
- dout.writeInt( this.getId() );
- dout.writeUTF( this.getName() );
-
- dout.writeInt( dataElements.size() );
-
- for ( int i = 0; i < dataElements.size(); i++ )
- {
- DataElement de = (DataElement) dataElements.get( i );
- de.serialize( dout );
+ if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_EIGHT ) )
+ {
+ this.serializeVerssion2_8( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_NINE ) )
+ {
+ this.serializeVerssion2_9( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_TEN ) )
+ {
+ this.serializeVerssion2_10( dout );
}
}
@@ -87,7 +89,8 @@
for ( int i = 0; i < dataElements.size(); i++ )
{
DataElement de = (DataElement) dataElements.get( i );
- de.serializeVerssion2_8( dout );
+ de.setClientVersion( TWO_POINT_EIGHT );
+ de.serialize( dout );
}
}
@@ -103,7 +106,25 @@
for ( int i = 0; i < dataElements.size(); i++ )
{
DataElement de = (DataElement) dataElements.get( i );
- de.serializeVerssion2_9( dout );
+ de.setClientVersion( TWO_POINT_NINE );
+ de.serialize( dout );
+ }
+ }
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dout )
+ throws IOException
+ {
+ dout.writeInt( this.getId() );
+ dout.writeUTF( this.getName() );
+
+ dout.writeInt( dataElements.size() );
+
+ for ( int i = 0; i < dataElements.size(); i++ )
+ {
+ DataElement de = (DataElement) dataElements.get( i );
+ de.setClientVersion( TWO_POINT_TEN );
+ de.serialize( dout );
}
}
=== added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/SMSCode.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/SMSCode.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/SMSCode.java 2013-01-22 08:08:14 +0000
@@ -0,0 +1,99 @@
+package org.hisp.dhis.api.mobile.model;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+public class SMSCode
+ implements DataStreamSerializable
+{
+ private String code;
+
+ private int dataElementId;
+
+ private int optionId;
+
+ private String clientVersion;
+
+ @Override
+ public void serialize( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ this.serializeVerssion2_10( dataOutputStream );
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ this.setCode( dataInputStream.readUTF() );
+ this.setDataElementId( dataInputStream.readInt() );
+ this.setOptionId( dataInputStream.readInt() );
+
+ }
+
+ @Override
+ public void serializeVerssion2_8( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // does not exist in version 2.8
+ }
+
+ @Override
+ public void serializeVerssion2_9( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // does not exist in version 2.9
+
+ }
+
+ public String getCode()
+ {
+ return code;
+ }
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
+
+ public int getDataElementId()
+ {
+ return dataElementId;
+ }
+
+ public void setDataElementId( int dataElementId )
+ {
+ this.dataElementId = dataElementId;
+ }
+
+ public int getOptionId()
+ {
+ return optionId;
+ }
+
+ public void setOptionId( int optionId )
+ {
+ this.optionId = optionId;
+ }
+
+ public String getClientVersion()
+ {
+ return clientVersion;
+ }
+
+ public void setClientVersion( String clientVersion )
+ {
+ this.clientVersion = clientVersion;
+ }
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ dataOutputStream.writeUTF( this.code );
+ dataOutputStream.writeInt( this.dataElementId );
+ dataOutputStream.writeInt( this.optionId );
+ }
+
+}
=== added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/SMSCommand.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/SMSCommand.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/SMSCommand.java 2013-01-22 08:08:14 +0000
@@ -0,0 +1,135 @@
+package org.hisp.dhis.api.mobile.model;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+public class SMSCommand
+ implements DataStreamSerializable
+{
+ private String parserType;
+
+ private String separator;
+
+ private String codeSeparator;
+
+ private List<SMSCode> smsCodes;
+
+ private String clientVersion;
+
+ private int dataSetId;
+
+ @Override
+ public void serialize( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ this.serializeVerssion2_10( dataOutputStream );
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ // no need for deserialize
+ }
+
+ @Override
+ public void serializeVerssion2_8( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // does not exist in version 2.8
+ }
+
+ @Override
+ public void serializeVerssion2_9( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // does not exist in version 2.9
+ }
+
+ public String getParserType()
+ {
+ return parserType;
+ }
+
+ public void setParserType( String parserType )
+ {
+ this.parserType = parserType;
+ }
+
+ public String getSeparator()
+ {
+ return separator;
+ }
+
+ public void setSeparator( String separator )
+ {
+ this.separator = separator;
+ }
+
+ public String getCodeSeparator()
+ {
+ return codeSeparator;
+ }
+
+ public void setCodeSeparator( String codeSeparator )
+ {
+ this.codeSeparator = codeSeparator;
+ }
+
+ public List<SMSCode> getSmsCodes()
+ {
+ return smsCodes;
+ }
+
+ public void setSmsCodes( List<SMSCode> smsCodes )
+ {
+ this.smsCodes = smsCodes;
+ }
+
+ public String getClientVersion()
+ {
+ return clientVersion;
+ }
+
+ public void setClientVersion( String clientVersion )
+ {
+ this.clientVersion = clientVersion;
+ }
+
+ public int getDataSetId()
+ {
+ return dataSetId;
+ }
+
+ public void setDataSetId( int dataSetId )
+ {
+ this.dataSetId = dataSetId;
+ }
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ dataOutputStream.writeUTF( this.parserType );
+ dataOutputStream.writeUTF( this.separator );
+ dataOutputStream.writeUTF( this.codeSeparator );
+ dataOutputStream.writeInt( this.dataSetId );
+
+ if ( this.smsCodes == null )
+ {
+ dataOutputStream.writeInt( 0 );
+ }
+ else
+ {
+ dataOutputStream.writeInt( smsCodes.size() );
+ }
+
+ for ( SMSCode smsCode : smsCodes )
+ {
+ smsCode.serialize( dataOutputStream );
+ }
+ }
+
+}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Section.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Section.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Section.java 2013-01-22 08:08:14 +0000
@@ -65,21 +65,17 @@
public void serialize( DataOutputStream dout )
throws IOException
{
- dout.writeInt( this.getId() );
- dout.writeUTF( getName() );
-
- if ( dataElements == null )
- {
- dout.writeInt( 0 );
- }
- else
- {
- dout.writeInt( dataElements.size() );
- for ( int i = 0; i < dataElements.size(); i++ )
- {
- DataElement de = (DataElement) dataElements.get( i );
- de.serialize( dout );
- }
+ if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_EIGHT ) )
+ {
+ this.serializeVerssion2_8( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_NINE ) )
+ {
+ this.serializeVerssion2_9( dout );
+ }
+ else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_TEN ) )
+ {
+ this.serializeVerssion2_10( dout );
}
}
@@ -100,11 +96,12 @@
for ( int i = 0; i < dataElements.size(); i++ )
{
DataElement de = (DataElement) dataElements.get( i );
- de.serializeVerssion2_8( dout );
+ de.setClientVersion( TWO_POINT_EIGHT );
+ de.serialize( dout );
}
}
}
-
+
@Override
public void serializeVerssion2_9( DataOutputStream dout )
throws IOException
@@ -122,7 +119,31 @@
for ( int i = 0; i < dataElements.size(); i++ )
{
DataElement de = (DataElement) dataElements.get( i );
- de.serializeVerssion2_9( dout );
+ de.setClientVersion( TWO_POINT_NINE);
+ de.serialize( dout );
+ }
+ }
+ }
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dout )
+ throws IOException
+ {
+ dout.writeInt( this.getId() );
+ dout.writeUTF( getName() );
+
+ if ( dataElements == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( dataElements.size() );
+ for ( int i = 0; i < dataElements.size(); i++ )
+ {
+ DataElement de = (DataElement) dataElements.get( i );
+ de.setClientVersion( TWO_POINT_TEN);
+ de.serialize( dout );
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Task.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Task.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Task.java 2013-01-22 08:08:14 +0000
@@ -132,4 +132,12 @@
dout.writeBoolean( this.isCompleted() );
}
+
+ @Override
+ public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
}
=== added file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/J2MEDataEntryParser.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/J2MEDataEntryParser.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/J2MEDataEntryParser.java 2013-01-22 08:08:14 +0000
@@ -0,0 +1,24 @@
+package org.hisp.dhis.sms.parse;
+
+import java.util.Map;
+
+public class J2MEDataEntryParser
+ implements IParser
+{
+
+ @Override
+ public Map<String, String> parse( String sms )
+ {
+ String keyValueSection = sms.split( "" )[1];
+
+ return null;
+ }
+
+ @Override
+ public void setSeparator( String separator )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
=== 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 2013-01-17 09:23:01 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2013-01-22 08:08:14 +0000
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import java.util.List;
import java.util.Locale;
import org.hisp.dhis.api.mobile.ActivityReportingService;
import org.hisp.dhis.api.mobile.FacilityReportingService;
@@ -17,10 +18,13 @@
import org.hisp.dhis.api.mobile.model.DataStreamSerializable;
import org.hisp.dhis.api.mobile.model.MobileModel;
import org.hisp.dhis.api.mobile.model.ModelList;
+import org.hisp.dhis.api.mobile.model.SMSCode;
+import org.hisp.dhis.api.mobile.model.SMSCommand;
import org.hisp.dhis.i18n.I18nService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.smscommand.SMSCommandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
@@ -57,12 +61,13 @@
@Autowired
private PatientService patientService;
+ @Autowired
+ private SMSCommandService smsCommandService;
+
// For client version 2.8 and lower
@RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/all" )
@ResponseBody
- public MobileModel getAllDataForOrgUnit2_8( @PathVariable
- int id, @RequestHeader( "accept-language" )
- String locale )
+ public MobileModel getAllDataForOrgUnit2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
{
MobileModel mobileModel = new MobileModel();
mobileModel.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
@@ -77,10 +82,8 @@
@RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/updateDataSets" )
@ResponseBody
- public DataSetList checkUpdatedDataSet2_8( @PathVariable
- int id, @RequestBody
- DataSetList dataSetList, @RequestHeader( "accept-language" )
- String locale )
+ public DataSetList checkUpdatedDataSet2_8( @PathVariable int id, @RequestBody DataSetList dataSetList,
+ @RequestHeader( "accept-language" ) String locale )
{
DataSetList returnList = facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale );
returnList.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
@@ -95,9 +98,7 @@
*/
@RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/dataSets" )
@ResponseBody
- public String saveDataSetValues2_8( @PathVariable
- int id, @RequestBody
- DataSetValue dataSetValue )
+ public String saveDataSetValues2_8( @PathVariable int id, @RequestBody DataSetValue dataSetValue )
throws NotAllowedException
{
facilityReportingService.saveDataSetValues( getUnit( id ), dataSetValue );
@@ -113,9 +114,7 @@
*/
@RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/activities" )
@ResponseBody
- public String saveActivityReport2_8( @PathVariable
- int id, @RequestBody
- ActivityValue activityValue )
+ public String saveActivityReport2_8( @PathVariable int id, @RequestBody ActivityValue activityValue )
throws NotAllowedException
{
// FIXME set the last argument to 0 to fix compilation error
@@ -125,10 +124,8 @@
@RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/activitiyplan" )
@ResponseBody
- public MobileModel updatePrograms2_8( @PathVariable
- int id, @RequestHeader( "accept-language" )
- String locale, @RequestBody
- ModelList programsFromClient )
+ public MobileModel updatePrograms2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale,
+ @RequestBody ModelList programsFromClient )
{
MobileModel model = new MobileModel();
model.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
@@ -140,9 +137,7 @@
@RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/search" )
@ResponseBody
- public ActivityPlan search2_8( @PathVariable
- int id, @RequestHeader( "identifier" )
- String identifier )
+ public ActivityPlan search2_8( @PathVariable int id, @RequestHeader( "identifier" ) String identifier )
throws NotAllowedException
{
ActivityPlan activityPlan = activityReportingService.getActivitiesByIdentifier( identifier );
@@ -153,9 +148,7 @@
@RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/changeLanguageDataSet" )
@ResponseBody
- public DataSetList changeLanguageDataSet2_8( @PathVariable
- int id, @RequestHeader( "accept-language" )
- String locale )
+ public DataSetList changeLanguageDataSet2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
{
return facilityReportingService.getDataSetsForLocale( getUnit( id ), locale );
}
@@ -164,33 +157,28 @@
@RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/all" )
@ResponseBody
- public MobileModel getAllDataForOrgUnit( @PathVariable
- String clientVersion, @PathVariable
- int id, @RequestHeader( "accept-language" )
- String locale )
+ public MobileModel getAllDataForOrgUnit( @PathVariable String clientVersion, @PathVariable int id,
+ @RequestHeader( "accept-language" ) String locale )
{
MobileModel mobileModel = new MobileModel();
- mobileModel.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
+ mobileModel.setClientVersion( clientVersion );
OrganisationUnit unit = getUnit( id );
mobileModel.setActivityPlan( activityReportingService.getCurrentActivityPlan( unit, locale ) );
mobileModel.setPrograms( programService.getPrograms( unit, locale ) );
mobileModel.setDatasets( facilityReportingService.getMobileDataSetsForUnit( unit, locale ) );
mobileModel.setServerCurrentDate( new Date() );
mobileModel.setLocales( getLocalStrings( i18nService.getAvailableLocales() ) );
-
+ mobileModel.setSmsCommands( this.getMobileSMSCommands( smsCommandService.getSMSCommands() ) );
return mobileModel;
}
@RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/updateDataSets" )
@ResponseBody
- public DataSetList checkUpdatedDataSet( @PathVariable
- String clientVersion, @PathVariable
- int id, @RequestBody
- DataSetList dataSetList, @RequestHeader( "accept-language" )
- String locale )
+ public DataSetList checkUpdatedDataSet( @PathVariable String clientVersion, @PathVariable int id,
+ @RequestBody DataSetList dataSetList, @RequestHeader( "accept-language" ) String locale )
{
DataSetList returnList = facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale );
- returnList.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
+ returnList.setClientVersion( clientVersion );
return returnList;
}
@@ -203,33 +191,56 @@
@RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/dataSets" )
@ResponseBody
- public String saveDataSetValues( @PathVariable
- int id, @RequestBody
- DataSetValue dataSetValue )
+ public String saveDataSetValues( @PathVariable int id, @RequestBody DataSetValue dataSetValue )
throws NotAllowedException
{
- System.out.println("access METHOD");
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.setClientVersion( clientVersion );
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;
}
+ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/search" )
+ @ResponseBody
+ public ActivityPlan search( @PathVariable String clientVersion, @PathVariable int id,
+ @RequestHeader( "identifier" ) String identifier )
+ throws NotAllowedException
+ {
+ ActivityPlan activityPlan = activityReportingService.getActivitiesByIdentifier( identifier );
+ activityPlan.setClientVersion( clientVersion );
+ return activityPlan;
+ }
+
+ /**
+ * 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 )
+ // throws NotAllowedException
+ // {
+ // facilityReportingService.saveDataSetValues( getUnit( id ), dataSetValue
+ // );
+ // return DATASET_REPORT_UPLOADED;
+ // }
+
/**
* Save activity report for unit
*
@@ -239,9 +250,7 @@
*/
@RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/activities" )
@ResponseBody
- public String saveActivityReport( @PathVariable
- int id, @RequestBody
- ActivityValue activityValue )
+ public String saveActivityReport( @PathVariable int id, @RequestBody ActivityValue activityValue )
throws NotAllowedException
{
// FIXME set the last argument to 0 to fix compilation error
@@ -249,24 +258,9 @@
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.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 )
+ public DataSetList changeLanguageDataSet( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
{
return facilityReportingService.getDataSetsForLocale( getUnit( id ), locale );
}
@@ -277,11 +271,11 @@
{
return facilityReportingService.updateContactForMobile();
}
-
+
@RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/findPatient" )
@ResponseBody
- public Beneficiary findPatientByName( @PathVariable int id, @RequestHeader( "name" ) String fullName)
- throws NotAllowedException
+ public Beneficiary findPatientByName( @PathVariable int id, @RequestHeader( "name" ) String fullName )
+ throws NotAllowedException
{
return activityReportingService.findPatient( fullName );
}
@@ -303,9 +297,32 @@
return localeStrings;
}
+ private List<SMSCommand> getMobileSMSCommands( Collection<org.hisp.dhis.smscommand.SMSCommand> normalSMSCommands )
+ {
+ List<SMSCommand> smsCommands = new ArrayList<SMSCommand>();
+ for ( org.hisp.dhis.smscommand.SMSCommand normalSMSCommand : normalSMSCommands )
+ {
+ SMSCommand mobileSMSCommand = new SMSCommand();
+ List<SMSCode> smsCodes = new ArrayList<SMSCode>();
+ mobileSMSCommand.setCodeSeparator( normalSMSCommand.getSeparator() );
+ mobileSMSCommand.setDataSetId( normalSMSCommand.getDataset().getId() );
+ mobileSMSCommand.setCodeSeparator( normalSMSCommand.getCodeSeparator() );
+ for ( org.hisp.dhis.smscommand.SMSCode normalSMSCode : normalSMSCommand.getCodes() )
+ {
+ SMSCode smsCode = new SMSCode();
+ smsCode.setCode( normalSMSCode.getCode() );
+ smsCode.setDataElementId( normalSMSCode.getDataElement().getId() );
+ smsCode.setOptionId( normalSMSCode.getId() );
+ smsCodes.add( smsCode );
+ }
+ mobileSMSCommand.setSmsCodes( smsCodes );
+ smsCommands.add( mobileSMSCommand );
+ }
+ return smsCommands;
+ }
+
private OrganisationUnit getUnit( int id )
{
return organisationUnitService.getOrganisationUnit( id );
}
-
}