← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14492: Fixed bug - Age field is displayed -1 in Update TEI form

 

------------------------------------------------------------
revno: 14492
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-03-27 21:36:12 +0700
message:
  Fixed bug - Age field is displayed -1 in Update TEI form
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddTrackedEntityInstanceAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetTrackedEntityInstanceAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/TrackedEntityInstanceDashboardAction.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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddTrackedEntityInstanceAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddTrackedEntityInstanceAction.java	2014-03-19 06:44:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddTrackedEntityInstanceAction.java	2014-03-27 14:36:12 +0000
@@ -161,12 +161,13 @@
                     attributeValue = new TrackedEntityAttributeValue();
                     attributeValue.setEntityInstance( entityInstance );
                     attributeValue.setAttribute( attribute );
-                    attributeValue.setValue( value.trim() );
 
                     if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_AGE ) )
                     {
                         value = format.formatDate( TrackedEntityAttribute.getDateFromAge( Integer.parseInt( value ) ) );
                     }
+
+                    attributeValue.setValue( value.trim() );
                     attributeValues.add( attributeValue );
                 }
                 else if ( attribute.getInherit() && relationship != null )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetTrackedEntityInstanceAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetTrackedEntityInstanceAction.java	2014-03-20 22:27:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetTrackedEntityInstanceAction.java	2014-03-27 14:36:12 +0000
@@ -247,16 +247,17 @@
                         }
                     }
                 }
-                
 
-                for( TrackedEntityAttribute attribute : attributes){
+                for ( TrackedEntityAttribute attribute : attributes )
+                {
                     mandatoryMap.put( attribute.getId(), false );
                 }
             }
             else
             {
                 attributes = program.getTrackedEntityAttributes();
-                for( ProgramTrackedEntityAttribute programAttribute : program.getAttributes() ){
+                for ( ProgramTrackedEntityAttribute programAttribute : program.getAttributes() )
+                {
                     mandatoryMap.put( programAttribute.getAttribute().getId(), programAttribute.isMandatory() );
                 }
             }
@@ -290,8 +291,7 @@
         {
             String value = attributeValue.getValue();
 
-            if ( attributeValue.getAttribute().getValueType().equals( TrackedEntityAttribute.TYPE_AGE )
-                && value != null )
+            if ( attributeValue.getAttribute().getValueType().equals( TrackedEntityAttribute.TYPE_AGE ) )
             {
                 Date date = format.parseDate( value );
                 value = TrackedEntityAttribute.getAgeFromDate( date ) + "";

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/TrackedEntityInstanceDashboardAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/TrackedEntityInstanceDashboardAction.java	2014-03-18 14:54:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/TrackedEntityInstanceDashboardAction.java	2014-03-27 14:36:12 +0000
@@ -35,6 +35,7 @@
 import java.util.HashSet;
 import java.util.Map;
 
+import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramIndicatorService;
@@ -101,10 +102,17 @@
 
     private Map<String, String> programIndicatorsMap = new HashMap<String, String>();
 
+    private I18nFormat format;
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
     public Map<String, String> getProgramIndicatorsMap()
     {
         return programIndicatorsMap;
@@ -203,7 +211,7 @@
         // Get relationship
         // ---------------------------------------------------------------------
 
-        relationships = relationshipService.getRelationshipsForTrackedEntityInstance(  entityInstance );
+        relationships = relationshipService.getRelationshipsForTrackedEntityInstance( entityInstance );
 
         Collection<ProgramInstance> programInstances = entityInstance.getProgramInstances();
 
@@ -222,6 +230,13 @@
             {
                 if ( atttributes.contains( attributeValue.getAttribute() ) )
                 {
+                    String value = attributeValue.getValue();
+                    if ( attributeValue.getAttribute().getValueType().equals( TrackedEntityAttribute.TYPE_AGE ) )
+                    {
+                        value = format.formatDate( TrackedEntityAttribute.getDateFromAge( Integer.parseInt( value ) ) );
+                    }
+
+                    attributeValue.setValue( value );
                     attributeValues.add( attributeValue );
                 }
             }
@@ -262,11 +277,12 @@
         PeriodType.clearTimeOfDay( today );
         Date date = today.getTime();
         String visitor = currentUserService.getCurrentUsername();
-        TrackedEntityAudit entityInstanceAudit = auditService.getTrackedEntityAudit( entityInstance.getId(), visitor, date,
-            TrackedEntityAudit.MODULE_ENTITY_INSTANCE_DASHBOARD );
+        TrackedEntityAudit entityInstanceAudit = auditService.getTrackedEntityAudit( entityInstance.getId(), visitor,
+            date, TrackedEntityAudit.MODULE_ENTITY_INSTANCE_DASHBOARD );
         if ( entityInstanceAudit == null )
         {
-            entityInstanceAudit = new TrackedEntityAudit( entityInstance, visitor, date, TrackedEntityAudit.MODULE_ENTITY_INSTANCE_DASHBOARD );
+            entityInstanceAudit = new TrackedEntityAudit( entityInstance, visitor, date,
+                TrackedEntityAudit.MODULE_ENTITY_INSTANCE_DASHBOARD );
             auditService.saveTrackedEntityAudit( entityInstanceAudit );
         }