dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40323
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20430: Input utils. Fixed compilation error. Removed code duplication.
------------------------------------------------------------
revno: 20430
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-10-01 13:42:39 +0200
message:
Input utils. Fixed compilation error. Removed code duplication.
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/InputUtils.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-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/InputUtils.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/InputUtils.java 2015-10-01 11:35:44 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/InputUtils.java 2015-10-01 11:42:39 +0000
@@ -56,8 +56,8 @@
* code along with a textual message will be set on the response in case of
* invalid input.
*
- * @param cc the category combo identifier.
- * @param cp the category and option query string.
+ * @param cc the category combo identifier.
+ * @param cp the category and option query string.
* @return the attribute option combo identified from the given input, or null
* if the input was invalid.
*/
@@ -81,55 +81,16 @@
throw new IllegalQueryException( "Illegal category combo identifier: " + cc );
}
- // ---------------------------------------------------------------------
- // Attribute category options validation
- // ---------------------------------------------------------------------
-
- DataElementCategoryOptionCombo attributeOptionCombo = null;
-
- if ( opts != null )
- {
- Set<DataElementCategoryOption> categoryOptions = new HashSet<>();
-
- for ( String uid : opts )
- {
- DataElementCategoryOption categoryOption = idObjectManager.get( DataElementCategoryOption.class, uid );
-
- if ( categoryOption == null )
- {
- throw new IllegalQueryException( "Illegal category option identifier: " + uid ) ;
- }
-
- categoryOptions.add( categoryOption );
- }
-
- attributeOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryCombo, categoryOptions );
-
- if ( attributeOptionCombo == null )
- {
- throw new IllegalQueryException( "Attribute option combo does not exist for given category combo and category options" );
- }
- }
-
- if ( attributeOptionCombo == null )
- {
- attributeOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
- }
-
- if ( attributeOptionCombo == null )
- {
- throw new IllegalQueryException( "Default attribute option combo does not exist" );
- }
-
- return attributeOptionCombo;
+ return getAttributeOptionCombo( categoryCombo, cp );
}
+
/**
* Validates and retrieves the attribute option combo. 409 conflict as status
* code along with a textual message will be set on the response in case of
* invalid input.
*
- * @param cc the category combo.
- * @param cp the category option query string.
+ * @param categoryCombo the category combo.
+ * @param cp the category option query string.
* @return the attribute option combo identified from the given input, or null
* if the input was invalid.
*/
@@ -183,6 +144,5 @@
}
return attributeOptionCombo;
- }
-
+ }
}