← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20406: minor, remove usage of i18nformat in TEIService

 

------------------------------------------------------------
revno: 20406
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-09-30 12:00:31 +0700
message:
  minor, remove usage of i18nformat in TEIService
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.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-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2015-09-30 04:01:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2015-09-30 05:00:31 +0000
@@ -32,7 +32,6 @@
 import org.hisp.dhis.common.IllegalQueryException;
 import org.hisp.dhis.common.OrganisationUnitSelectionMode;
 import org.hisp.dhis.event.EventStatus;
-import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramStatus;
 import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
@@ -65,7 +64,7 @@
  * <p>Attributes specified in the query follows on the next column indexes.
  * Example usage for retrieving TEIs with two attributes using one attribute as
  * filter:</p>
- * <p/>
+ * <p>
  * <pre>
  * <code>
  * TrackedEntityInstanceQueryParams params = new TrackedEntityInstanceQueryParams();
@@ -242,12 +241,11 @@
      * @param program        Program which person needs to enroll. If this parameter is
      *                       null, the system check unique attribute values of the
      *                       entityInstance
-     * @param format         I18nFormat
      * @return Error code 0 : Validation is OK 1_<duplicate-value> : The
      * attribute value is duplicated 2_<validation-criteria-id> :
      * Violate validation criteria of the program
      */
-    String validateTrackedEntityInstance( TrackedEntityInstance entityInstance, Program program, I18nFormat format );
+    String validateTrackedEntityInstance( TrackedEntityInstance entityInstance, Program program );
 
     /**
      * Validate tracked entity instance enrollment
@@ -255,8 +253,7 @@
      * @param entityInstance TrackedEntityInstance object
      * @param program        Program which person needs to enroll. If this parameter is
      *                       null, the system check identifiers of the tracked entity instance
-     * @param format         I18nFormat
      * @return ValidationCriteria object which is violated
      */
-    ValidationCriteria validateEnrollment( TrackedEntityInstance entityInstance, Program program, I18nFormat format );
+    ValidationCriteria validateEnrollment( TrackedEntityInstance entityInstance, Program program );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2015-09-30 04:06:58 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2015-09-30 05:00:31 +0000
@@ -28,26 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.common.OrganisationUnitSelectionMode.ACCESSIBLE;
-import static org.hisp.dhis.common.OrganisationUnitSelectionMode.ALL;
-import static org.hisp.dhis.common.OrganisationUnitSelectionMode.CHILDREN;
-import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.CREATED_ID;
-import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.INACTIVE_ID;
-import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.LAST_UPDATED_ID;
-import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.META_DATA_NAMES_KEY;
-import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.ORG_UNIT_ID;
-import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.PAGER_META_KEY;
-import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.TRACKED_ENTITY_ID;
-import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.TRACKED_ENTITY_INSTANCE_ID;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.DimensionalObject;
@@ -61,7 +41,6 @@
 import org.hisp.dhis.common.QueryOperator;
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.event.EventStatus;
-import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.program.Program;
@@ -72,6 +51,7 @@
 import org.hisp.dhis.relationship.RelationshipType;
 import org.hisp.dhis.relationship.RelationshipTypeService;
 import org.hisp.dhis.system.grid.ListGrid;
+import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
 import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService;
 import org.hisp.dhis.user.CurrentUserService;
@@ -80,6 +60,17 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.hisp.dhis.common.OrganisationUnitSelectionMode.*;
+import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.*;
+
 /**
  * @author Abyot Asalefew Gizaw
  */
@@ -651,11 +642,11 @@
     }
 
     @Override
-    public String validateTrackedEntityInstance( TrackedEntityInstance instance, Program program, I18nFormat format )
+    public String validateTrackedEntityInstance( TrackedEntityInstance instance, Program program )
     {
         if ( program != null )
         {
-            ValidationCriteria validationCriteria = validateEnrollment( instance, program, format );
+            ValidationCriteria validationCriteria = validateEnrollment( instance, program );
 
             if ( validationCriteria != null )
             {
@@ -681,7 +672,7 @@
     }
 
     @Override
-    public ValidationCriteria validateEnrollment( TrackedEntityInstance instance, Program program, I18nFormat format )
+    public ValidationCriteria validateEnrollment( TrackedEntityInstance instance, Program program )
     {
         for ( ValidationCriteria criteria : program.getValidationCriteria() )
         {
@@ -706,8 +697,9 @@
                     }
                     else if ( valueType.isDate() )
                     {
-                        Date value1 = format.parseDate( value );
-                        Date value2 = format.parseDate( criteria.getValue() );
+                        Date value1 = DateUtils.parseDate( value );
+                        Date value2 = DateUtils.parseDate( criteria.getValue() );
+
                         int i = value1.compareTo( value2 );
 
                         if ( i != criteria.getOperator() )

=== 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	2015-09-24 08:32:10 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2015-09-30 05:00:31 +0000
@@ -1513,8 +1513,7 @@
             }
 
             Program program = programService.getProgram( Integer.parseInt( programIdText ) );
-            String[] errorCode = entityInstanceService.validateTrackedEntityInstance( newTrackedEntityInstance,
-                program, format ).split( "_" );
+            String[] errorCode = entityInstanceService.validateTrackedEntityInstance( newTrackedEntityInstance, program ).split( "_" );
             int code = Integer.parseInt( errorCode[0] );
 
             if ( code >= 1 )
@@ -1604,8 +1603,7 @@
         }
 
         // validate
-        String[] errorCode = entityInstanceService.validateTrackedEntityInstance( tempTEI, program, format )
-            .split( "_" );
+        String[] errorCode = entityInstanceService.validateTrackedEntityInstance( tempTEI, program ).split( "_" );
         int code = Integer.parseInt( errorCode[0] );
 
         if ( code >= 1 )
@@ -2539,16 +2537,15 @@
             {
                 throw new NotAllowedException( "relative does not exist" );
             }
+
             patientId = entityInstanceService.createTrackedEntityInstance( patientWeb, relative.getUid(),
                 patient.getRelTypeIdToAdd(), patientAttributeValues );
         }
         else
         {
-            patientId = entityInstanceService.createTrackedEntityInstance( patientWeb, null, null,
-                patientAttributeValues );
+            patientId = entityInstanceService.createTrackedEntityInstance( patientWeb, null, null, patientAttributeValues );
         }
-        TrackedEntityInstance newTrackedEntityInstance = entityInstanceService
-            .getTrackedEntityInstance( this.patientId );
+        TrackedEntityInstance newTrackedEntityInstance = entityInstanceService.getTrackedEntityInstance( this.patientId );
 
         String errorMsg = null;
 
@@ -2563,8 +2560,7 @@
             }
 
             Program program = programService.getProgram( Integer.parseInt( programId ) );
-            String[] errorCode = entityInstanceService.validateTrackedEntityInstance( newTrackedEntityInstance,
-                program, format ).split( "_" );
+            String[] errorCode = entityInstanceService.validateTrackedEntityInstance( newTrackedEntityInstance, program ).split( "_" );
             int code = Integer.parseInt( errorCode[0] );
 
             if ( code >= 1 )