← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3982: Fix bug: Exception occurs in designing data entry form when data element is not exist.

 

------------------------------------------------------------
revno: 3982
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-06-22 15:30:49 +0700
message:
  Fix bug: Exception occurs in designing data entry form when data element is not exist.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.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-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2011-05-30 04:34:47 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2011-06-22 08:30:49 +0000
@@ -27,7 +27,6 @@
 
 package org.hisp.dhis.program;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
@@ -190,10 +189,6 @@
                 // Get data element ID of data element
                 // -------------------------------------------------------------
 
-                int programStageId = Integer.parseInt( identifierMatcher.group( 1 ) );
-                ProgramStage programStage = programStageService.getProgramStage( programStageId );
-                Collection<DataElement> dataElements = new ArrayList<DataElement>( programStageDataElementService.getListDataElement( programStage ) );
-
                 int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
                 DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
@@ -201,7 +196,7 @@
                 DataElementCategoryOptionCombo optionCombo = categoryService
                     .getDataElementCategoryOptionCombo( optionComboId );
 
-                if ( !dataElements.contains( dataElement ) || optionCombo == null )
+                if ( dataElement == null || optionCombo == null )
                 {
                     inputMatcher.appendReplacement( sb, DATA_ELEMENT_DOES_NOT_EXIST );
                 }
@@ -251,14 +246,11 @@
                 // -------------------------------------------------------------
                 // Get data element ID of data element
                 // -------------------------------------------------------------
-                int programStageId = Integer.parseInt( identifierMatcher.group( 1 ) );
-                ProgramStage programStage = programStageService.getProgramStage( programStageId );
-                Collection<DataElement> dataElements = new ArrayList<DataElement>( programStageDataElementService.getListDataElement( programStage ) );
-
+              
                 int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
                 DataElement dataElement = dataElementService.getDataElement( dataElementId );
                 
-                if ( !dataElements.contains( dataElement ) )
+                if ( dataElement == null )
                 {
                     inputMatcher.appendReplacement( sb, DATA_ELEMENT_DOES_NOT_EXIST );
                 } 
@@ -307,14 +299,11 @@
                 // -------------------------------------------------------------
                 // Get data element ID of data element
                 // -------------------------------------------------------------
-                int programStageId = Integer.parseInt( identifierMatcher.group( 1 ) );
-                ProgramStage programStage = programStageService.getProgramStage( programStageId );
-                Collection<DataElement> dataElements = new ArrayList<DataElement>( programStageDataElementService.getListDataElement( programStage ) );
-
+                
                 int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
                 DataElement dataElement = dataElementService.getDataElement( dataElementId );
                 
-                if ( !dataElements.contains( dataElement ) )
+                if ( dataElement == null )
                 {
                     inputMatcher.appendReplacement( sb, DATA_ELEMENT_DOES_NOT_EXIST );
                 } 
@@ -363,15 +352,11 @@
                 // -------------------------------------------------------------
                 // Get data element ID of data element
                 // -------------------------------------------------------------
-               
-                int programStageId = Integer.parseInt( identifierMatcher.group( 1 ) );
-                ProgramStage programStage = programStageService.getProgramStage( programStageId );
-                Collection<DataElement> dataElements = new ArrayList<DataElement>( programStageDataElementService.getListDataElement( programStage ) );
-
+                
                 int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
                 DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
-                if ( !dataElements.contains( dataElement ) )
+                if ( dataElement == null )
                 {
                     inputMatcher.appendReplacement( sb, DATA_ELEMENT_DOES_NOT_EXIST );
                 } else