=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2015-08-19 11:58:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2015-09-22 09:35:56 +0000 @@ -545,50 +545,6 @@ */ DataElementCategoryOptionCombo getDataElementCategoryOptionComboAcl( IdentifiableProperty property, String id ); - /** - * Populates all transient properties on each Operand in the given - * collection. - * - * @param operands the collection of Operands. - * @return a set of Operands. - */ - List populateOperands( List operands ); - - /** - * Gets the Operands for the given Collection of DataElements. - * - * @param dataElements the Collection of DataElements. - * @return the Operands for the given Collection of DataElements. - */ - List getOperands( Collection dataElements ); - - /** - * Gets the Operands for the given Collection of DataElements. - * - * @param dataElements the Collection of DataElements. - * @param includeTotals whether to include DataElement totals in the - * Collection of Operands. - * @return the Operands for the given Collection of DataElements. - */ - List getOperands( Collection dataElements, boolean includeTotals ); - - /** - * Gets the Operands for the DataElements with names like the given name. - * - * @param name the name. - * @return the Operands for the DataElements with names like the given name. - */ - List getOperandsLikeName( String name ); - - /** - * Gets the Operands for the given Collection of DataElements. Operands will - * contain DataElement and CategoryOptionCombo object - * - * @param dataElements the Collection of DataElements. - * @return the Operands for the given Collection of DataElements. - */ - List getFullOperands( Collection dataElements ); - List getDataElementCategoriesBetween( int first, int max ); List getDataElementCategoriesBetweenByName( String name, int first, int max ); @@ -624,6 +580,54 @@ List getDataElementCategoryCombosBetweenByName( String name, int first, int max ); // ------------------------------------------------------------------------- + // DataElementOperand + // ------------------------------------------------------------------------- + + /** + * Populates all transient properties on each Operand in the given + * collection. + * + * @param operands the collection of Operands. + * @return a set of Operands. + */ + List populateOperands( List operands ); + + /** + * Gets the Operands for the given Collection of DataElements. + * + * @param dataElements the Collection of DataElements. + * @return the Operands for the given Collection of DataElements. + */ + List getOperands( Collection dataElements ); + + /** + * Gets the Operands for the DataElements with names like the given name. + * + * @param name the name. + * @return the Operands for the DataElements with names like the given name. + */ + List getOperandsLikeName( String name ); + + /** + * Gets the Operands for the given Collection of DataElements. + * + * @param dataElements the Collection of DataElements. + * @param includeTotals whether to include DataElement totals in the + * Collection of Operands. + * @return the Operands for the given Collection of DataElements. + */ + List getOperands( Collection dataElements, boolean includeTotals ); + + /** + * Gets the Operands for the given Collection of DataElements. Operands will + * contain DataElement and CategoryOptionCombo object + * + * @param dataElements the Collection of DataElements. + * @return the Operands for the given Collection of DataElements. + */ + List getFullOperands( Collection dataElements ); + + // ------------------------------------------------------------------------- // CategoryOptionGroup // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2015-09-17 13:53:08 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2015-09-22 09:35:56 +0000 @@ -717,87 +717,6 @@ } @Override - public List populateOperands( List operands ) - { - for ( DataElementOperand operand : operands ) - { - DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() ); - DataElementCategoryOptionCombo categoryOptionCombo = getDataElementCategoryOptionCombo( operand - .getOptionComboId() ); - - operand.updateProperties( dataElement, categoryOptionCombo ); - } - - return operands; - } - - @Override - public List getOperands( Collection dataElements ) - { - return getOperands( dataElements, false ); - } - - @Override - public List getOperands( Collection dataElements, boolean includeTotals ) - { - List operands = new ArrayList<>(); - - for ( DataElement dataElement : dataElements ) - { - if ( dataElement != null && dataElement.getCategoryCombo() != null ) - { - if ( !dataElement.getCategoryCombo().isDefault() && includeTotals ) - { - DataElementOperand operand = new DataElementOperand(); - operand.updateProperties( dataElement ); - - operands.add( operand ); - } - - for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() ) - { - DataElementOperand operand = new DataElementOperand(); - operand.updateProperties( dataElement, categoryOptionCombo ); - - operands.add( operand ); - } - } - } - - return operands; - } - - @Override - public List getOperandsLikeName( String name ) - { - List dataElements = dataElementService.getDataElementsLikeName( name ); - - return getOperands( dataElements ); - } - - @Override - public List getFullOperands( Collection dataElements ) - { - List operands = new ArrayList<>(); - - for ( DataElement dataElement : dataElements ) - { - if ( dataElement != null && dataElement.getCategoryCombo() != null ) - { - for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getOptionCombos() ) - { - DataElementOperand dataElementOperand = new DataElementOperand( dataElement, categoryOptionCombo ); - dataElementOperand.updateProperties( dataElement, categoryOptionCombo ); - - operands.add( dataElementOperand ); - } - } - } - - return operands; - } - - @Override public void generateOptionCombos( DataElementCategoryCombo categoryCombo ) { categoryCombo.generateOptionCombos(); @@ -906,7 +825,92 @@ return options.size() == categoryOptionCombo.getCategoryOptions().size(); } - + + // ------------------------------------------------------------------------- + // DataElementOperand + // ------------------------------------------------------------------------- + + @Override + public List populateOperands( List operands ) + { + for ( DataElementOperand operand : operands ) + { + DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() ); + DataElementCategoryOptionCombo categoryOptionCombo = getDataElementCategoryOptionCombo( operand + .getOptionComboId() ); + + operand.updateProperties( dataElement, categoryOptionCombo ); + } + + return operands; + } + + @Override + public List getOperands( Collection dataElements ) + { + return getOperands( dataElements, false ); + } + + @Override + public List getOperandsLikeName( String name ) + { + List dataElements = dataElementService.getDataElementsLikeName( name ); + + return getOperands( dataElements ); + } + + @Override + public List getOperands( Collection dataElements, boolean includeTotals ) + { + List operands = new ArrayList<>(); + + for ( DataElement dataElement : dataElements ) + { + if ( dataElement != null && dataElement.getCategoryCombo() != null ) + { + if ( !dataElement.getCategoryCombo().isDefault() && includeTotals ) + { + DataElementOperand operand = new DataElementOperand(); + operand.updateProperties( dataElement ); + + operands.add( operand ); + } + + for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() ) + { + DataElementOperand operand = new DataElementOperand(); + operand.updateProperties( dataElement, categoryOptionCombo ); + + operands.add( operand ); + } + } + } + + return operands; + } + + @Override + public List getFullOperands( Collection dataElements ) + { + List operands = new ArrayList<>(); + + for ( DataElement dataElement : dataElements ) + { + if ( dataElement != null && dataElement.getCategoryCombo() != null ) + { + for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getOptionCombos() ) + { + DataElementOperand dataElementOperand = new DataElementOperand( dataElement, categoryOptionCombo ); + dataElementOperand.updateProperties( dataElement, categoryOptionCombo ); + + operands.add( dataElementOperand ); + } + } + } + + return operands; + } + // ------------------------------------------------------------------------- // CategoryOptionGroup // -------------------------------------------------------------------------