=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2011-05-05 21:14:56 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2011-10-05 10:06:16 +0000 @@ -34,9 +34,9 @@ import org.hisp.dhis.common.AbstractIdentifiableObject; /** - * DataElementGroupSet is a set of DataElementGroups. It is by default exclusive, - * in the sense that a DataElement can only be a member of one or zero of the - * DataElementGroups in a DataElementGroupSet. + * DataElementGroupSet is a set of DataElementGroups. It is by default + * exclusive, in the sense that a DataElement can only be a member of one or + * zero of the DataElementGroups in a DataElementGroupSet. * * @author Lars Helge Overland */ @@ -48,6 +48,10 @@ */ private static final long serialVersionUID = -2118690320625221749L; + private String description; + + private Boolean compulsory = false; + private List members = new ArrayList(); // ------------------------------------------------------------------------- @@ -55,12 +59,26 @@ // ------------------------------------------------------------------------- public DataElementGroupSet() - { + { } - + public DataElementGroupSet( String name ) { this.name = name; + this.compulsory = false; + } + + public DataElementGroupSet( String name, Boolean compulsory ) + { + this.name = name; + this.compulsory = compulsory; + } + + public DataElementGroupSet( String name, String description, Boolean compulsory ) + { + this.name = name; + this.description = description; + this.compulsory = compulsory; } // ------------------------------------------------------------------------- @@ -70,15 +88,15 @@ public Collection getDataElements() { List dataElements = new ArrayList(); - + for ( DataElementGroup group : members ) { dataElements.addAll( group.getMembers() ); } - + return dataElements; } - + public DataElementGroup getGroup( DataElement dataElement ) { for ( DataElementGroup group : members ) @@ -88,10 +106,28 @@ return group; } } - + return null; } - + + public Boolean isMemberOfDataElementGroups( DataElement dataElement ) + { + for ( DataElementGroup group : members ) + { + if ( group.getMembers().contains( dataElement ) ) + { + return true; + } + } + + return false; + } + + public Boolean hasDataElementGroups() + { + return members != null && members.size() > 0; + } + // ------------------------------------------------------------------------- // equals and hashCode // ------------------------------------------------------------------------- @@ -115,7 +151,7 @@ return false; } - if ( !( o instanceof DataElementGroupSet ) ) + if ( !(o instanceof DataElementGroupSet) ) { return false; } @@ -135,6 +171,26 @@ // Getters and setters // ------------------------------------------------------------------------- + public String getDescription() + { + return description; + } + + public void setDescription( String description ) + { + this.description = description; + } + + public Boolean isCompulsory() + { + return compulsory; + } + + public void setCompulsory( Boolean compulsory ) + { + this.compulsory = compulsory; + } + public List getMembers() { return members; @@ -143,5 +199,5 @@ public void setMembers( List members ) { this.members = members; - } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2011-09-10 08:40:27 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2011-10-05 10:06:16 +0000 @@ -93,7 +93,7 @@ /** * Returns the DataElement with the given code. - * + * * @param code the code. * @return the DataElement with the given code, or null if no match. */ @@ -115,14 +115,16 @@ * match. */ DataElement getDataElementByAlternativeName( String alternativeName ); - + /** * Returns List of DataElements with a given key. * * @param key the name of the DataElement to return. - * @return List of DataElements with a given key, or all dataelements if no match. + * @return List of DataElements with a given key, or all dataelements if no + * match. */ Collection searchDataElementsByName( String key ); + /** * Returns a DataElement with a given short name. * @@ -199,7 +201,7 @@ * @return a Collection of DataElements. */ Collection getDataElementsByPeriodType( PeriodType periodType ); - + /** * Returns all DataElements with the given category combo. * @@ -243,7 +245,7 @@ * @return all DataElements which are not member of any DataElementGroups. */ Collection getDataElementsWithoutGroups(); - + /** * Returns all DataElements which are not assigned to any DataSets. * @@ -257,7 +259,7 @@ * @return all DataElements which are assigned to at least one DataSet. */ Collection getDataElementsWithDataSets(); - + /** * Checks whether a DataElement with the given identifier exists. * @@ -267,7 +269,8 @@ boolean dataElementExists( int id ); /** - * Checks whether a DataElementCategoryOptionCombo with the given identifier exists. + * Checks whether a DataElementCategoryOptionCombo with the given identifier + * exists. * * @param id the DataElementCategoryOptionCombo identifier. * @return true or false. @@ -275,17 +278,17 @@ boolean dataElementCategoryOptionComboExists( int id ); Collection getDataElementsByDataSets( Collection dataSets ); - + Collection getDataElementsLikeName( String name ); - + Collection getDataElementsBetween( int first, int max ); - + Collection getDataElementsBetweenByName( String name, int first, int max ); - + int getDataElementCount(); - + int getDataElementCountByName( String name ); - + // ------------------------------------------------------------------------- // DataElementGroup // ------------------------------------------------------------------------- @@ -362,7 +365,6 @@ */ Collection getGroupsContainingDataElement( DataElement dataElement ); - /** * Returns data elements with identifier in the given id. * @@ -372,10 +374,11 @@ Collection getDataElementsByGroupId( int groupId ); /** - * Defines the given data elements as zero is significant. All other data elements - * are defined as zero is in-significant. + * Defines the given data elements as zero is significant. All other data + * elements are defined as zero is in-significant. * - * @param dataElementIds identifiers of data elements where zero is significant. + * @param dataElementIds identifiers of data elements where zero is + * significant. */ void setZeroIsSignificantForDataElements( Collection dataElementIds ); @@ -394,16 +397,17 @@ * @param dataElementGroup is group contain data elements * @return a collection of all DataElement */ - Collection getDataElementsByZeroIsSignificantAndGroup( boolean zeroIsSignificant, DataElementGroup dataElementGroup ); + Collection getDataElementsByZeroIsSignificantAndGroup( boolean zeroIsSignificant, + DataElementGroup dataElementGroup ); Collection getDataElementGroupsBetween( int first, int max ); - + Collection getDataElementGroupsBetweenByName( String name, int first, int max ); - + int getDataElementGroupCount(); - + int getDataElementGroupCountByName( String name ); - + // ------------------------------------------------------------------------- // DataElementGroupSet // ------------------------------------------------------------------------- @@ -418,16 +422,22 @@ DataElementGroupSet getDataElementGroupSetByName( String name ); + Collection getCompulsoryDataElementGroupSets(); + + Collection getCompulsoryDataElementGroupSetsWithMembers(); + + Collection getCompulsoryDataElementGroupSetsNotAssignedTo( DataElement dataElement ); + Collection getAllDataElementGroupSets(); Collection getDataElementGroupSets( Collection identifiers ); - + Collection getDataElementGroupSetsBetween( int first, int max ); - + Collection getDataElementGroupSetsBetweenByName( String name, int first, int max ); - + int getDataElementGroupSetCount(); - + int getDataElementGroupSetCountByName( String name ); // ------------------------------------------------------------------------- @@ -443,12 +453,13 @@ Collection getAllGeneratedOperands(); /** - * Returns all generated permutations of Operands for the given collection of - * DataElements. Requires the categoryoptioncomboname resource table to be populated. + * Returns all generated permutations of Operands for the given collection + * of DataElements. Requires the categoryoptioncomboname resource table to + * be populated. * * @param dataElements the DataElements. * @return a collection of all Operands. */ Collection getAllGeneratedOperands( Collection dataElements ); - + } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java 2011-05-05 21:14:56 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java 2011-10-05 10:06:16 +0000 @@ -36,7 +36,7 @@ /** * An IndicatorGroupSet is a set of IndicatorGroups. It is by default exclusive, * in the sense that an Indicator can only be a member of one or zero of the - * IndicatorGroups in a IndicatorGroupSet. + * IndicatorGroups in a IndicatorGroupSet. * * @author Lars Helge Overland */ @@ -48,6 +48,10 @@ */ private static final long serialVersionUID = 3051446168246358150L; + private String description; + + private Boolean compulsory = false; + private List members = new ArrayList(); // ------------------------------------------------------------------------- @@ -55,12 +59,26 @@ // ------------------------------------------------------------------------- public IndicatorGroupSet() - { + { } public IndicatorGroupSet( String name ) { this.name = name; + this.compulsory = false; + } + + public IndicatorGroupSet( String name, Boolean compulsory ) + { + this.name = name; + this.compulsory = compulsory; + } + + public IndicatorGroupSet( String name, String description, Boolean compulsory ) + { + this.name = name; + this.description = description; + this.compulsory = compulsory; } // ------------------------------------------------------------------------- @@ -70,15 +88,15 @@ public Collection getIndicators() { List indicators = new ArrayList(); - + for ( IndicatorGroup group : members ) { indicators.addAll( group.getMembers() ); } - + return indicators; } - + public IndicatorGroup getGroup( Indicator indicator ) { for ( IndicatorGroup group : members ) @@ -88,10 +106,28 @@ return group; } } - + return null; } - + + public Boolean isMemberOfIndicatorGroups( Indicator indicator ) + { + for ( IndicatorGroup group : members ) + { + if ( group.getMembers().contains( indicator ) ) + { + return true; + } + } + + return false; + } + + public Boolean hasIndicatorGroups() + { + return members != null && members.size() > 0; + } + // ------------------------------------------------------------------------- // equals and hashCode // ------------------------------------------------------------------------- @@ -115,7 +151,7 @@ return false; } - if ( !( o instanceof IndicatorGroupSet ) ) + if ( !(o instanceof IndicatorGroupSet) ) { return false; } @@ -135,6 +171,26 @@ // Getters and setters // ------------------------------------------------------------------------- + public String getDescription() + { + return description; + } + + public void setDescription( String description ) + { + this.description = description; + } + + public Boolean isCompulsory() + { + return compulsory; + } + + public void setCompulsory( Boolean compulsory ) + { + this.compulsory = compulsory; + } + public List getMembers() { return members; @@ -143,5 +199,5 @@ public void setMembers( List members ) { this.members = members; - } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2011-10-03 15:14:41 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2011-10-05 10:06:16 +0000 @@ -36,7 +36,7 @@ public interface IndicatorService { String ID = IndicatorService.class.getName(); - + // ------------------------------------------------------------------------- // Indicator // ------------------------------------------------------------------------- @@ -48,37 +48,37 @@ void deleteIndicator( Indicator indicator ); Indicator getIndicator( int id ); - + Indicator getIndicator( String uuid ); - + Collection getAllIndicators(); - + Collection getIndicators( Collection identifiers ); - + Indicator getIndicatorByName( String name ); Indicator getIndicatorByShortName( String shortName ); Indicator getIndicatorByAlternativeName( String alternativeName ); - + Indicator getIndicatorByCode( String code ); Collection getIndicatorsWithGroupSets(); - + Collection getIndicatorsWithoutGroups(); - + Collection getIndicatorsWithDataSets(); int getIndicatorCountByName( String name ); - + Collection getIndicatorsLikeName( String name ); - + Collection getIndicatorsBetweenByName( String name, int first, int max ); - + int getIndicatorCount(); - - Collection getIndicatorsBetween(int first, int max ); - + + Collection getIndicatorsBetween( int first, int max ); + // ------------------------------------------------------------------------- // IndicatorType // ------------------------------------------------------------------------- @@ -90,7 +90,7 @@ void deleteIndicatorType( IndicatorType indicatorType ); IndicatorType getIndicatorType( int id ); - + Collection getIndicatorTypes( Collection identifiers ); Collection getAllIndicatorTypes(); @@ -98,11 +98,11 @@ IndicatorType getIndicatorTypeByName( String name ); Collection getIndicatorTypesBetween( int first, int max ); - + Collection getIndicatorTypesBetweenByName( String name, int first, int max ); - + int getIndicatorTypeCount(); - + int getIndicatorTypeCountByName( String name ); // ------------------------------------------------------------------------- @@ -116,23 +116,23 @@ void deleteIndicatorGroup( IndicatorGroup indicatorGroup ); IndicatorGroup getIndicatorGroup( int id ); - + Collection getIndicatorGroups( Collection identifiers ); - + IndicatorGroup getIndicatorGroup( String uuid ); Collection getAllIndicatorGroups(); IndicatorGroup getIndicatorGroupByName( String name ); - + Collection getGroupsContainingIndicator( Indicator indicator ); Collection getIndicatorGroupsBetween( int first, int max ); - + Collection getIndicatorGroupsBetweenByName( String name, int first, int max ); - + int getIndicatorGroupCount(); - + int getIndicatorGroupCountByName( String name ); // ------------------------------------------------------------------------- @@ -140,24 +140,30 @@ // ------------------------------------------------------------------------- int addIndicatorGroupSet( IndicatorGroupSet groupSet ); - + void updateIndicatorGroupSet( IndicatorGroupSet groupSet ); - + void deleteIndicatorGroupSet( IndicatorGroupSet groupSet ); - + IndicatorGroupSet getIndicatorGroupSet( int id ); - + IndicatorGroupSet getIndicatorGroupSetByName( String name ); - + + Collection getCompulsoryIndicatorGroupSets(); + + Collection getCompulsoryIndicatorGroupSetsWithMembers(); + + Collection getCompulsoryIndicatorGroupSetsNotAssignedTo( Indicator indicator ); + Collection getAllIndicatorGroupSets(); - + Collection getIndicatorGroupSets( Collection identifiers ); - + Collection getIndicatorGroupSetsBetween( int first, int max ); - + Collection getIndicatorGroupSetsBetweenByName( String name, int first, int max ); - + int getIndicatorGroupSetCount(); - + int getIndicatorGroupSetCountByName( String name ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2011-09-26 15:24:25 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2011-10-05 10:06:16 +0000 @@ -206,9 +206,10 @@ { return i18n( i18nService, dataElementStore.getDataElementByName( name ) ); } - - public Collection searchDataElementsByName( String key ){ - return i18n( i18nService, dataElementStore.searchDataElementsByName( key ) ); + + public Collection searchDataElementsByName( String key ) + { + return i18n( i18nService, dataElementStore.searchDataElementsByName( key ) ); } public DataElement getDataElementByAlternativeName( String alternativeName ) @@ -307,7 +308,7 @@ { return i18n( i18nService, dataElementStore.getDataElementsWithoutDataSets() ); } - + public Collection getDataElementsWithDataSets() { return i18n( i18nService, dataElementStore.getDataElementsWithDataSets() ); @@ -322,7 +323,7 @@ { return dataElementStore.dataElementCategoryOptionComboExists( id ); } - + public Collection getDataElementsLikeName( String name ) { return dataElementStore.getDataElementsLikeName( name ); @@ -332,7 +333,7 @@ { return dataElementStore.getDataElementsBetween( first, max ); } - + public Collection getDataElementsBetweenByName( String name, int first, int max ) { return dataElementStore.getDataElementsBetweenByName( name, first, max ); @@ -342,17 +343,17 @@ { return dataElementStore.getDataElementCount(); } - + public int getDataElementCountByName( String name ) { return dataElementStore.getDataElementCountByName( name ); } - + public Collection getDataElementsByDataSets( Collection dataSets ) { return i18n( i18nService, dataElementStore.getDataElementsByDataSets( dataSets ) ); } - + // ------------------------------------------------------------------------- // DataElementGroup // ------------------------------------------------------------------------- @@ -444,7 +445,7 @@ { return dataElementGroupStore.getBetween( first, max ); } - + public Collection getDataElementGroupsBetweenByName( String name, int first, int max ) { return dataElementGroupStore.getBetweenByName( name, first, max ); @@ -454,12 +455,12 @@ { return dataElementGroupStore.getCount(); } - + public int getDataElementGroupCountByName( String name ) { return dataElementGroupStore.getCountByName( name ); } - + // ------------------------------------------------------------------------- // DataElementGroupSet // ------------------------------------------------------------------------- @@ -497,6 +498,50 @@ return i18n( i18nService, dataElementGroupSetStore.getByName( name ) ); } + @Override + public Collection getCompulsoryDataElementGroupSets() + { + Collection groupSets = new ArrayList(); + + for ( DataElementGroupSet groupSet : getAllDataElementGroupSets() ) + { + if ( groupSet.isCompulsory() ) + { + groupSets.add( groupSet ); + } + } + + return groupSets; + } + + @Override + public Collection getCompulsoryDataElementGroupSetsWithMembers() + { + return FilterUtils.filter( getAllDataElementGroupSets(), new Filter() + { + public boolean retain( DataElementGroupSet object ) + { + return object.isCompulsory() && object.hasDataElementGroups(); + } + } ); + } + + @Override + public Collection getCompulsoryDataElementGroupSetsNotAssignedTo( DataElement dataElement ) + { + Collection groupSets = new ArrayList(); + + for ( DataElementGroupSet groupSet : getCompulsoryDataElementGroupSets() ) + { + if ( !groupSet.isMemberOfDataElementGroups( dataElement ) && groupSet.hasDataElementGroups() ) + { + groupSets.add( groupSet ); + } + } + + return groupSets; + } + public Collection getAllDataElementGroupSets() { return i18n( i18nService, dataElementGroupSetStore.getAll() ); @@ -534,6 +579,7 @@ { return dataElementGroupSetStore.getBetweenByName( name, first, max ); } + // ------------------------------------------------------------------------- // DataElementOperand // ------------------------------------------------------------------------- @@ -548,5 +594,4 @@ return dataElementStore.getAllGeneratedOperands( dataElements ); } - } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2011-10-03 15:14:41 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2011-10-05 10:06:16 +0000 @@ -29,6 +29,7 @@ import static org.hisp.dhis.i18n.I18nUtils.i18n; +import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.Iterator; @@ -51,16 +52,16 @@ // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- - + private IndicatorStore indicatorStore; public void setIndicatorStore( IndicatorStore indicatorStore ) { this.indicatorStore = indicatorStore; } - + private GenericIdentifiableObjectStore indicatorTypeStore; - + public void setIndicatorTypeStore( GenericIdentifiableObjectStore indicatorTypeStore ) { this.indicatorTypeStore = indicatorTypeStore; @@ -90,77 +91,77 @@ // ------------------------------------------------------------------------- // Indicator // ------------------------------------------------------------------------- - + public int addIndicator( Indicator indicator ) { if ( indicator.getUuid() == null ) { - indicator.setUuid( UUIdUtils.getUUId() ); + indicator.setUuid( UUIdUtils.getUUId() ); } - + indicator.setLastUpdated( new Date() ); - + int id = indicatorStore.addIndicator( indicator ); - + i18nService.addObject( indicator ); - + return id; } public void updateIndicator( Indicator indicator ) { indicator.setLastUpdated( new Date() ); - + indicatorStore.updateIndicator( indicator ); - + i18nService.verify( indicator ); } - + public void deleteIndicator( Indicator indicator ) { i18nService.removeObject( indicator ); - - indicatorStore.deleteIndicator( indicator ); + + indicatorStore.deleteIndicator( indicator ); } - + public Indicator getIndicator( int id ) { return i18n( i18nService, indicatorStore.getIndicator( id ) ); } - + public Indicator getIndicator( String uuid ) { return i18n( i18nService, indicatorStore.getIndicator( uuid ) ); } - + public Collection getAllIndicators() { return i18n( i18nService, indicatorStore.getAllIndicators() ); } - + public Collection getIndicators( final Collection identifiers ) { Collection indicators = getAllIndicators(); - + return identifiers == null ? indicators : FilterUtils.filter( indicators, new Filter() + { + public boolean retain( Indicator object ) { - public boolean retain( Indicator object ) - { - return identifiers.contains( object.getId() ); - } - } ); + return identifiers.contains( object.getId() ); + } + } ); } - + public Indicator getIndicatorByName( String name ) { return i18n( i18nService, indicatorStore.getIndicatorByName( name ) ); } - + public Indicator getIndicatorByShortName( String shortName ) { return i18n( i18nService, indicatorStore.getIndicatorByShortName( shortName ) ); } - + public Indicator getIndicatorByAlternativeName( String alternativeName ) { return i18n( i18nService, indicatorStore.getIndicatorByAlternativeName( alternativeName ) ); @@ -170,17 +171,17 @@ { return i18n( i18nService, indicatorStore.getIndicatorByCode( code ) ); } - + public Collection getIndicatorsWithGroupSets() { return i18n( i18nService, indicatorStore.getIndicatorsWithGroupSets() ); } - + public Collection getIndicatorsWithoutGroups() { return i18n( i18nService, indicatorStore.getIndicatorsWithoutGroups() ); } - + public Collection getIndicatorsWithDataSets() { return i18n( i18nService, indicatorStore.getIndicatorsWithDataSets() ); @@ -200,7 +201,7 @@ { return i18n( i18nService, indicatorStore.getIndicatorsLikeName( name ) ); } - + public Collection getIndicatorsBetween( int first, int max ) { return i18n( i18nService, indicatorStore.getIndicatorsBetween( first, max ) ); @@ -210,7 +211,7 @@ { return i18n( i18nService, indicatorStore.getIndicatorsBetweenByName( name, first, max ) ); } - + // ------------------------------------------------------------------------- // IndicatorType // ------------------------------------------------------------------------- @@ -218,23 +219,23 @@ public int addIndicatorType( IndicatorType indicatorType ) { int id = indicatorTypeStore.save( indicatorType ); - + i18nService.addObject( indicatorType ); - + return id; } - + public void updateIndicatorType( IndicatorType indicatorType ) { indicatorTypeStore.update( indicatorType ); - + i18nService.verify( indicatorType ); } public void deleteIndicatorType( IndicatorType indicatorType ) { i18nService.removeObject( indicatorType ); - + indicatorTypeStore.delete( indicatorType ); } @@ -242,29 +243,29 @@ { return i18n( i18nService, indicatorTypeStore.get( id ) ); } - + public Collection getIndicatorTypes( final Collection identifiers ) { Collection types = getAllIndicatorTypes(); - + return identifiers == null ? types : FilterUtils.filter( types, new Filter() + { + public boolean retain( IndicatorType object ) { - public boolean retain( IndicatorType object ) - { - return identifiers.contains( object.getId() ); - } - } ); + return identifiers.contains( object.getId() ); + } + } ); } - + public Collection getAllIndicatorTypes() { return i18n( i18nService, indicatorTypeStore.getAll() ); } - + public IndicatorType getIndicatorTypeByName( String name ) { return i18n( i18nService, indicatorTypeStore.getByName( name ) ); - } + } public int getIndicatorTypeCount() { @@ -296,56 +297,56 @@ { indicatorGroup.setUuid( UUIdUtils.getUUId() ); } - + int id = indicatorGroupStore.save( indicatorGroup ); - + i18nService.addObject( indicatorGroup ); - + return id; } - + public void updateIndicatorGroup( IndicatorGroup indicatorGroup ) { indicatorGroupStore.update( indicatorGroup ); - + i18nService.verify( indicatorGroup ); } - + public void deleteIndicatorGroup( IndicatorGroup indicatorGroup ) { i18nService.removeObject( indicatorGroup ); - + indicatorGroupStore.delete( indicatorGroup ); } - + public IndicatorGroup getIndicatorGroup( int id ) { return i18n( i18nService, indicatorGroupStore.get( id ) ); } - + public Collection getIndicatorGroups( final Collection identifiers ) { Collection groups = getAllIndicatorGroups(); - + return identifiers == null ? groups : FilterUtils.filter( groups, new Filter() + { + public boolean retain( IndicatorGroup object ) { - public boolean retain( IndicatorGroup object ) - { - return identifiers.contains( object.getId() ); - } - } ); + return identifiers.contains( object.getId() ); + } + } ); } - + public IndicatorGroup getIndicatorGroup( String uuid ) { return i18n( i18nService, indicatorGroupStore.getByUuid( uuid ) ); } - + public Collection getAllIndicatorGroups() { return i18n( i18nService, indicatorGroupStore.getAll() ); } - + public IndicatorGroup getIndicatorGroupByName( String name ) { return i18n( i18nService, indicatorGroupStore.getByName( name ) ); @@ -354,20 +355,20 @@ public Collection getGroupsContainingIndicator( Indicator indicator ) { Collection groups = getAllIndicatorGroups(); - + Iterator iterator = groups.iterator(); - + while ( iterator.hasNext() ) { IndicatorGroup group = iterator.next(); - + if ( !group.getMembers().contains( indicator ) ) { iterator.remove(); } } - - return groups; + + return groups; } public int getIndicatorGroupCount() @@ -397,26 +398,26 @@ public int addIndicatorGroupSet( IndicatorGroupSet groupSet ) { int id = indicatorGroupSetStore.save( groupSet ); - + i18nService.addObject( groupSet ); - + return id; } - + public void updateIndicatorGroupSet( IndicatorGroupSet groupSet ) { indicatorGroupSetStore.update( groupSet ); - + i18nService.verify( groupSet ); } - + public void deleteIndicatorGroupSet( IndicatorGroupSet groupSet ) { i18nService.removeObject( groupSet ); - + indicatorGroupSetStore.delete( groupSet ); } - + public IndicatorGroupSet getIndicatorGroupSet( int id ) { return i18n( i18nService, indicatorGroupSetStore.get( id ) ); @@ -426,23 +427,67 @@ { return i18n( i18nService, indicatorGroupSetStore.getByName( name ) ); } - + + @Override + public Collection getCompulsoryIndicatorGroupSets() + { + Collection groupSets = new ArrayList(); + + for ( IndicatorGroupSet groupSet : getAllIndicatorGroupSets() ) + { + if ( groupSet.isCompulsory() ) + { + groupSets.add( groupSet ); + } + } + + return groupSets; + } + + @Override + public Collection getCompulsoryIndicatorGroupSetsWithMembers() + { + return FilterUtils.filter( getAllIndicatorGroupSets(), new Filter() + { + public boolean retain( IndicatorGroupSet object ) + { + return object.isCompulsory() && object.hasIndicatorGroups(); + } + } ); + } + + @Override + public Collection getCompulsoryIndicatorGroupSetsNotAssignedTo( Indicator indicator ) + { + Collection groupSets = new ArrayList(); + + for ( IndicatorGroupSet groupSet : getCompulsoryIndicatorGroupSets() ) + { + if ( !groupSet.isMemberOfIndicatorGroups( indicator ) && groupSet.hasIndicatorGroups() ) + { + groupSets.add( groupSet ); + } + } + + return groupSets; + } + public Collection getAllIndicatorGroupSets() { return i18n( i18nService, indicatorGroupSetStore.getAll() ); } - + public Collection getIndicatorGroupSets( final Collection identifiers ) { Collection groupSets = getAllIndicatorGroupSets(); - + return identifiers == null ? groupSets : FilterUtils.filter( groupSets, new Filter() + { + public boolean retain( IndicatorGroupSet object ) { - public boolean retain( IndicatorGroupSet object ) - { - return identifiers.contains( object.getId() ); - } - } ); + return identifiers.contains( object.getId() ); + } + } ); } public int getIndicatorGroupSetCountByName( String name ) === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml 2011-05-28 21:25:46 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml 2011-10-05 10:06:16 +0000 @@ -20,9 +20,13 @@ + + + + - + === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/IndicatorGroupSet.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/IndicatorGroupSet.hbm.xml 2011-05-28 21:25:46 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/IndicatorGroupSet.hbm.xml 2011-10-05 10:06:16 +0000 @@ -20,6 +20,10 @@ + + + + === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-10-05 07:03:07 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-10-05 10:06:16 +0000 @@ -256,6 +256,10 @@ "name" : { "required" : true, "rangelength" : [ 2, 230 ] + }, + "description" : { + "required" : true, + "rangelength" : [ 2, 255 ] } }, "dataDictionary" : { @@ -323,6 +327,10 @@ "name" : { "required" : true, "rangelength" : [ 2, 230 ] + }, + "description" : { + "required" : true, + "rangelength" : [ 2, 255 ] } }, "indicatorType" : { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/AddDataElementGroupSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/AddDataElementGroupSetAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/AddDataElementGroupSetAction.java 2011-10-05 10:06:16 +0000 @@ -67,6 +67,20 @@ this.name = name; } + private String description; + + public void setDescription( String description ) + { + this.description = description; + } + + private boolean compulsory; + + public void setCompulsory( boolean compulsory ) + { + this.compulsory = compulsory; + } + private List groupMembers = new ArrayList(); public void setGroupMembers( List groupMembers ) @@ -81,8 +95,8 @@ public String execute() throws Exception { - DataElementGroupSet dataElementGroupSet = new DataElementGroupSet( name ); - + DataElementGroupSet dataElementGroupSet = new DataElementGroupSet( name, description, compulsory ); + dataElementGroupSet.setUuid( UUIdUtils.getUUId() ); List dataElementGroups = new ArrayList(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/UpdateDataElementGroupSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/UpdateDataElementGroupSetAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/UpdateDataElementGroupSetAction.java 2011-10-05 10:06:16 +0000 @@ -72,6 +72,20 @@ this.name = name; } + private String description; + + public void setDescription( String description ) + { + this.description = description; + } + + private boolean compulsory; + + public void setCompulsory( boolean compulsory ) + { + this.compulsory = compulsory; + } + private List groupMembers = new ArrayList(); public void setGroupMembers( List groupMembers ) @@ -89,12 +103,14 @@ DataElementGroupSet dataElementGroupSet = dataElementService.getDataElementGroupSet( id ); dataElementGroupSet.setName( name ); + dataElementGroupSet.setDescription( description ); + dataElementGroupSet.setCompulsory( compulsory ); dataElementGroupSet.getMembers().clear(); for ( String id : groupMembers ) { - DataElementGroup dataElementGroup = dataElementService.getDataElementGroup( Integer.parseInt( id ) ); + DataElementGroup dataElementGroup = dataElementService.getDataElementGroup( Integer.parseInt( id ) ); dataElementGroupSet.getMembers().add( dataElementGroup ); } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroupset/AddIndicatorGroupSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroupset/AddIndicatorGroupSetAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroupset/AddIndicatorGroupSetAction.java 2011-10-05 10:06:16 +0000 @@ -66,6 +66,20 @@ this.name = name; } + private String description; + + public void setDescription( String description ) + { + this.description = description; + } + + private boolean compulsory; + + public void setCompulsory( boolean compulsory ) + { + this.compulsory = compulsory; + } + private List groupMembers = new ArrayList(); public void setGroupMembers( List groupMembers ) @@ -79,7 +93,7 @@ public String execute() { - IndicatorGroupSet indicatorGroupSet = new IndicatorGroupSet( name ); + IndicatorGroupSet indicatorGroupSet = new IndicatorGroupSet( name, description, compulsory ); indicatorGroupSet.setUuid( UUIdUtils.getUUId() ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroupset/UpdateIndicatorGroupSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroupset/UpdateIndicatorGroupSetAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroupset/UpdateIndicatorGroupSetAction.java 2011-10-05 10:06:16 +0000 @@ -73,6 +73,20 @@ this.name = name; } + private String description; + + public void setDescription( String description ) + { + this.description = description; + } + + private boolean compulsory; + + public void setCompulsory( boolean compulsory ) + { + this.compulsory = compulsory; + } + private List groupMembers = new ArrayList(); public void setGroupMembers( List groupMembers ) @@ -91,7 +105,9 @@ IndicatorGroupSet indicatorGroupSet = indicatorService.getIndicatorGroupSet( id ); indicatorGroupSet.setName( name.trim() ); - + indicatorGroupSet.setDescription( description ); + indicatorGroupSet.setCompulsory( compulsory ); + indicatorGroupSet.getMembers().clear(); for ( String id : groupMembers ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties 2011-09-27 17:05:48 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties 2011-10-05 10:06:16 +0000 @@ -352,4 +352,5 @@ view_1 = View 1 view_2 = View 2 store_zero_data_values = Store Zero Data Value -form_name = Form name \ No newline at end of file +form_name = Form name +compulsory = Compulsory === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm 2011-06-10 11:09:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm 2011-10-05 10:06:16 +0000 @@ -29,8 +29,24 @@ - - + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorGroupSet.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorGroupSet.vm 2011-06-10 11:09:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorGroupSet.vm 2011-10-05 10:06:16 +0000 @@ -29,8 +29,24 @@ - - + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm 2011-06-10 11:09:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm 2011-10-05 10:06:16 +0000 @@ -31,8 +31,24 @@ - - + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorGroupSet.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorGroupSet.vm 2011-06-10 11:09:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorGroupSet.vm 2011-10-05 10:06:16 +0000 @@ -31,8 +31,24 @@ - - + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitGroupSetForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitGroupSetForm.vm 2011-08-18 15:12:34 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitGroupSetForm.vm 2011-10-05 10:06:16 +0000 @@ -30,18 +30,18 @@ - + - + - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupSetForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupSetForm.vm 2011-08-18 15:12:34 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupSetForm.vm 2011-10-05 10:06:16 +0000 @@ -38,18 +38,18 @@ - + - + -