← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1927: Added "late" flag to activity

 

------------------------------------------------------------
revno: 1927
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: cbhis-mobile
timestamp: Wed 2010-10-20 17:24:08 +0530
message:
  Added "late" flag to activity
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.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-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java	2010-10-20 11:54:08 +0000
@@ -14,6 +14,8 @@
 
     private Beneficiary beneficiary;
 
+    private boolean late = false;
+
     private Task task;
 
     private Date dueDate;   
@@ -48,6 +50,16 @@
         this.dueDate = dueDate;
     }
 
+    
+    
+	public boolean isLate() {
+		return late;
+	}
+
+	public void setLate(boolean late) {
+		this.late = late;
+	}
+
 	@Override
 	public byte[] serialize() throws IOException {
 		// TODO Auto-generated method stub
@@ -70,6 +82,7 @@
         DataOutputStream dout = new DataOutputStream(bout);
         
         this.getBeneficiary().serialize(dout);
+        dout.writeBoolean(late);
         this.getTask().serialize(dout);        
         dout.writeLong(this.getDueDate().getTime());       
         
@@ -82,5 +95,6 @@
 	public void deSerialize(byte[] data) throws IOException {
 		// TODO Auto-generated method stub
 		
-	}	
+	}
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java	2010-10-19 09:32:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java	2010-10-20 11:54:08 +0000
@@ -63,6 +63,7 @@
         	dout.writeUTF(b.getFirstName()); 
         	dout.writeUTF(b.getMiddleName()); 
         	dout.writeUTF(b.getLastName());
+        	dout.writeBoolean(activity.isLate());
         	Set<String> atts = b.getPatientAttValues();
                 dout.writeInt( atts.size() );
                 for(String att : atts){

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java	2010-10-19 09:32:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java	2010-10-20 11:54:08 +0000
@@ -66,58 +66,46 @@
 
         Collection<Activity> allActivities = activityPlanService.getActivitiesByProvider( unit );
         Collection<Activity> activities = new ArrayList<Activity>();
+
+        ActivityPlan plan = new ActivityPlan();
+
+        if ( activities == null || activities.isEmpty() )
+        {
+            return plan;
+        }
+
+        List<org.hisp.dhis.web.api.model.Activity> items = new ArrayList<org.hisp.dhis.web.api.model.Activity>();
+        plan.setActivitiesList( items );
+        int i = 0;
+
+        
         for ( Activity activity : allActivities )
         {
-            long dueTime = activity.getDueDate().getTime();
+            //there are error on db with patientattributeid 14, so I limit the patient to be downloaded
+            if(i++>10){
+            	break;
+            }
+
+        	long dueTime = activity.getDueDate().getTime();
             if ( to.isBefore( dueTime ) )
             {
                 continue;
             }
             
-            if (from.isBefore( dueTime ) || !activity.getTask().isCompleted()) {
-                activities.add( activity );
+            if (from.isBefore( dueTime )) {
+                items.add( getActivityModel( activity) );
+            } else if (!activity.getTask().isCompleted()) {
+            	org.hisp.dhis.web.api.model.Activity a = getActivityModel( activity);
+            	items.add( a );
+            	a.setLate(true);
             }
         }
 
-//        ActivityPlan plan = new ActivitiesMapper().getModel( activities );
-        ActivityPlan plan = getActivityPlanModel(activities);
-        
-
         return plan;
 	}
 	
-	
-	
-	
-	//method replace the Mappers
-        private org.hisp.dhis.web.api.model.ActivityPlan getActivityPlanModel( Collection<org.hisp.dhis.activityplan.Activity> activities )
-            {
-                ActivityPlan plan = new ActivityPlan();
-
-                if ( activities == null || activities.isEmpty() )
-                {
-                    return plan;
-                }
-
-                List<org.hisp.dhis.web.api.model.Activity> items = new ArrayList<org.hisp.dhis.web.api.model.Activity>();
-                plan.setActivitiesList( items );
-                int i = 0;
-                for ( org.hisp.dhis.activityplan.Activity activity : activities )
-                {
-                    //there are error on db with patientattributeid 14, so I limit the patient to be downloaded
-                    if(i<=10){
-                        org.hisp.dhis.web.api.model.Activity temp = getActivityModel( activity);
-                        if(temp != null){
-                            items.add(temp);
-                        }
-                        i++;
-                    }
-                }
-                return plan;
-            }
-        
-        
-        private org.hisp.dhis.web.api.model.Activity getActivityModel( org.hisp.dhis.activityplan.Activity activity )
+
+		private org.hisp.dhis.web.api.model.Activity getActivityModel( org.hisp.dhis.activityplan.Activity activity )
         {
             if ( activity == null )
             {