← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14551: Implementation: J2ME Tracker 2.15 (Add TrackedEntity)

 

------------------------------------------------------------
revno: 14551
committer: sherylyn.marie
branch nick: trunk
timestamp: Mon 2014-03-31 15:36:28 +0800
message:
  Implementation: J2ME Tracker 2.15 (Add TrackedEntity)
  https://blueprints.launchpad.net/dhis-mobile/+spec/j2me-tracker-2.15
modified:
  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/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.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/PatientAttribute.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java	2014-03-31 07:36:28 +0000
@@ -48,22 +48,22 @@
     private String type;
 
     private boolean isMandatory;
-    
+
     private boolean isDisplayedInList = false;
 
-    private List<String> predefinedValues = new ArrayList<String>();
+    private OptionSet optionSet;
 
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
 
-    public PatientAttribute( String name, String value, String type, boolean isMandatory, List<String> predefinedValues )
+    public PatientAttribute( String name, String value, String type, boolean isMandatory, OptionSet optionSet )
     {
         this.name = name;
         this.value = value;
         this.type = type;
         this.isMandatory = isMandatory;
-        this.predefinedValues = predefinedValues;
+        this.optionSet = optionSet;
     }
 
     public PatientAttribute()
@@ -116,14 +116,14 @@
         this.type = type;
     }
 
-    public List<String> getPredefinedValues()
+    public OptionSet getOptionSet()
     {
-        return predefinedValues;
+        return optionSet;
     }
 
-    public void setPredefinedValues( List<String> predefinedValues )
+    public void setOptionSet( OptionSet optionSet )
     {
-        this.predefinedValues = predefinedValues;
+        this.optionSet = optionSet;
     }
 
     public boolean isMandatory()
@@ -135,7 +135,7 @@
     {
         this.isMandatory = isMandatory;
     }
-    
+
     public boolean isDisplayedInList()
     {
         return isDisplayedInList;
@@ -155,15 +155,14 @@
         dout.writeUTF( this.type );
         dout.writeBoolean( this.isMandatory );
         dout.writeBoolean( this.isDisplayedInList );
+        
+        int optionSize = (this.optionSet == null || this.optionSet.getOptions() == null) ? 0 : this.optionSet
+            .getOptions().size();
+        dout.writeInt( optionSize );
 
-        int valueSize = this.predefinedValues.size();
-        dout.writeInt( valueSize );
-        if ( valueSize > 0 )
+        if ( optionSize > 0 )
         {
-            for ( String option : predefinedValues )
-            {
-                dout.writeUTF( option );
-            }
+            optionSet.serialize( dout );
         }
 
     }
@@ -178,15 +177,14 @@
         isMandatory = dataInputStream.readBoolean();
         isDisplayedInList = dataInputStream.readBoolean();
 
-        List<String> optionList = new ArrayList<String>();
-
-        int size = dataInputStream.readInt();
-
-        for ( int i = 0; i < size; i++ )
+        int optionSize = dataInputStream.readInt();
+
+        if ( optionSize > 0 )
         {
-            optionList.add( dataInputStream.readUTF() );
+            optionSet = new OptionSet();
+            optionSet.deSerialize( dataInputStream );
         }
-        predefinedValues = optionList;
+
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-03-26 19:40:22 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-03-31 07:36:28 +0000
@@ -52,6 +52,7 @@
 import org.hisp.dhis.api.mobile.model.ActivityValue;
 import org.hisp.dhis.api.mobile.model.Beneficiary;
 import org.hisp.dhis.api.mobile.model.DataValue;
+import org.hisp.dhis.api.mobile.model.OptionSet;
 import org.hisp.dhis.api.mobile.model.PatientAttribute;
 import org.hisp.dhis.api.mobile.model.Task;
 import org.hisp.dhis.api.mobile.model.LWUITmodel.LostEvent;
@@ -760,7 +761,7 @@
             {
                 org.hisp.dhis.api.mobile.model.PatientAttribute patientAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute(
                     value.getAttribute().getName(), value.getValue(), value.getAttribute().getValueType(), false,
-                    new ArrayList<String>() );
+                    new OptionSet() );
                 
                 patientAtts.add( patientAttribute );
             }
@@ -1387,7 +1388,7 @@
 
         for ( TrackedEntityAttribute patientAtt : getPatientAtts( null ) )
         {
-            list.add( new PatientAttribute( patientAtt.getName(), null, patientAtt.getValueType(), false, new ArrayList<String>() ) );
+            list.add( new PatientAttribute( patientAtt.getName(), null, patientAtt.getValueType(), false, new OptionSet() ) );
         }
 
         return list;

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java	2014-03-20 15:05:57 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java	2014-03-31 07:36:28 +0000
@@ -38,6 +38,7 @@
 import org.hisp.dhis.api.mobile.model.DataElement;
 import org.hisp.dhis.api.mobile.model.Model;
 import org.hisp.dhis.api.mobile.model.ModelList;
+import org.hisp.dhis.api.mobile.model.OptionSet;
 import org.hisp.dhis.api.mobile.model.Program;
 import org.hisp.dhis.api.mobile.model.ProgramStage;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -296,6 +297,7 @@
         mobileAttribute.setName( pa.getName() );
         mobileAttribute.setType( pa.getValueType() );
         mobileAttribute.setValue( "" );
+
         if ( ppa.isDisplayInList() )
         {
             mobileAttribute.setDisplayedInList( true );
@@ -304,6 +306,21 @@
         {
             mobileAttribute.setDisplayedInList( false );
         }
+
+        if ( pa.getValueType().equals( TrackedEntityAttribute.TYPE_COMBO ) )
+        {
+            OptionSet optionSet = new OptionSet();
+
+            if ( pa.getOptionSet() != null )
+            {
+                optionSet.setId( pa.getOptionSet().getId() );
+                optionSet.setName( pa.getOptionSet().getName() );
+                optionSet.setOptions( pa.getOptionSet().getOptions() );
+
+                mobileAttribute.setOptionSet( optionSet );
+            }
+        }
+
         return mobileAttribute;
     }