=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java 2014-08-07 11:46:01 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java 2014-08-08 08:54:26 +0000 @@ -96,17 +96,17 @@ return null; } - + protected static boolean stringAsBoolean( String str, boolean defaultValue ) { return str != null ? Boolean.parseBoolean( str ) : defaultValue; } - + protected static boolean stringIsTrue( String str ) { return stringAsBoolean( str, false ); } - + protected static int stringAsInt( String str ) { return stringAsInt( str, 0 ); @@ -155,18 +155,18 @@ //-------------------------------------------------------------------------- /** - * Indicates whether the given object type is enabled. Takes the assumeTrue + * Indicates whether the given object type is enabled. Takes the assumeTrue * parameter into account. */ public boolean isEnabled( String type ) { String enabled = options.get( type ); - return stringIsTrue( enabled ) || ( enabled == null && assumeTrue ); + return stringIsTrue( enabled ) || (enabled == null && assumeTrue); } /** - * Indicates whether the given object type is disabled. Takes the assumeTrue + * Indicates whether the given object type is disabled. Takes the assumeTrue * parameter into account. */ public boolean isDisabled( String type ) @@ -178,7 +178,7 @@ { return stringAsDate( options.get( key ) ); } - + /** * Indicates whether the options contains the given parameter key. */ @@ -188,14 +188,14 @@ } /** - * Indicates whether the options contains a non-null option value for the given + * Indicates whether the options contains a non-null option value for the given * parameter key. */ public boolean containsValue( String key ) { return options.get( key ) != null; } - + /** * Returns the option value for the given parameter key. */ @@ -209,15 +209,15 @@ */ public Integer getInt( String key ) { - return options.get( key ) != null ? Integer.parseInt( options.get( key ) ) : null; + return options.containsKey( key ) ? Integer.parseInt( options.get( key ) ) : null; } - + /** * Indicates whether the option value for the parameter key is true. */ public boolean isTrue( String key ) { - return options.get( key ) != null && Boolean.parseBoolean( options.get( key ) ); + return options.containsKey( key ) && Boolean.parseBoolean( options.get( key ) ); } //-------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java 2014-08-05 04:47:34 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java 2014-08-08 08:54:26 +0000 @@ -28,6 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import com.google.common.collect.Lists; import org.hisp.dhis.common.Pager; import org.hisp.dhis.common.PagerUtils; import org.hisp.dhis.dataelement.DataElement; @@ -56,16 +57,25 @@ protected List getEntityList( WebMetaData metaData, WebOptions options ) { - List dataElements = new ArrayList<>( manager.getAllSorted( DataElement.class ) ); - List entityList = new ArrayList<>( categoryService.getFullOperands( dataElements ) ); + List dataElementOperands; + + if ( options.isTrue( "persisted" ) ) + { + dataElementOperands = Lists.newArrayList( manager.getAll( DataElementOperand.class ) ); + } + else + { + List dataElements = new ArrayList<>( manager.getAllSorted( DataElement.class ) ); + dataElementOperands = new ArrayList<>( categoryService.getFullOperands( dataElements ) ); + } if ( options.hasPaging() ) { - Pager pager = new Pager( options.getPage(), entityList.size(), options.getPageSize() ); + Pager pager = new Pager( options.getPage(), dataElementOperands.size(), options.getPageSize() ); metaData.setPager( pager ); - entityList = PagerUtils.pageCollection( entityList, pager ); + dataElementOperands = PagerUtils.pageCollection( dataElementOperands, pager ); } - return entityList; + return dataElementOperands; } }