← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4028: Fixed issue, showing informative message when trying to load custom data entry screen with refere...

 

------------------------------------------------------------
revno: 4028
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-06-27 12:55:31 +0200
message:
  Fixed issue, showing informative message when trying to load custom data entry screen with reference to non-existing data element/category option combo/indicator
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.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-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2011-06-16 09:27:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2011-06-27 10:55:31 +0000
@@ -184,20 +184,29 @@
                 int dataElementId = Integer.parseInt( identifierMatcher.group( 1 ) );
                 DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
+                if ( dataElement == null )
+                {
+                    return "Data element with id : " + dataElementId + " does not exist";
+                }
+                
                 int optionComboId = Integer.parseInt( identifierMatcher.group( 2 ) );
-                DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
-                String optionComboName = optionCombo != null ? optionCombo.getName() : "";
+                DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
 
+                if ( categoryOptionCombo == null )
+                {
+                    return "Category option combo with id: " + optionComboId + " does not exist";
+                }
+                
                 // -------------------------------------------------------------
                 // Insert name of data element operand as value and title
                 // -------------------------------------------------------------
 
                 StringBuilder title = new StringBuilder( "title=\"" ).append( dataElement.getId() ).append( " - " ).
                     append( dataElement.getName() ).append( " - " ).append( optionComboId ).append( " - " ).
-                    append( optionComboName ).append( " - " ).append( dataElement.getType() ).append( "\"" );
+                    append( categoryOptionCombo.getName() ).append( " - " ).append( dataElement.getType() ).append( "\"" );
                 
-                String displayValue = dataElement != null ? "value=\"[ " + dataElement.getName() + " " + optionComboName + " ]\"" : "[ Data element does not exist ]";
-                String displayTitle = dataElement != null ? title.toString() : "[ Data element does not exist ]";
+                String displayValue = "value=\"[ " + dataElement.getName() + " " + categoryOptionCombo.getName() + " ]\"";
+                String displayTitle = title.toString();
                 
                 inputHtml = inputHtml.contains( EMPTY_VALUE_TAG ) ? inputHtml.replace( EMPTY_VALUE_TAG, displayValue ) : inputHtml + " " + displayValue;                    
                 inputHtml = inputHtml.contains( EMPTY_TITLE_TAG ) ? inputHtml.replace( EMPTY_TITLE_TAG, displayTitle ) : " " + displayTitle;
@@ -209,6 +218,11 @@
                 int indicatorId = Integer.parseInt( indicatorMatcher.group( 1 ) );
                 Indicator indicator = indicatorService.getIndicator( indicatorId );
 
+                if ( indicator == null )
+                {
+                    return "Indicator with id: " + indicatorId + " does not exist";
+                }
+                
                 // -------------------------------------------------------------
                 // Insert name of indicator as value and title
                 // -------------------------------------------------------------