------------------------------------------------------------
revno: 15048
committer: Lars Helge Overland <[email protected]>
branch nick: dhis2
timestamp: Mon 2014-04-28 11:34:22 +0200
message:
Data approval level, encapsulating test for level equality in method and
replacing == comparison with equals() between group sets
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.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-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java 2014-04-14 06:52:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java 2014-04-28 09:34:22 +0000
@@ -122,6 +122,31 @@
return categoryOptionGroupSet != null;
}
+ /**
+ * Indicates whether the given approval level represents the same level as this.
+ */
+ public boolean levelEquals( DataApprovalLevel other )
+ {
+ if ( other == null )
+ {
+ return false;
+ }
+
+ if ( level != other.getLevel() )
+ {
+ return false;
+ }
+
+ if ( categoryOptionGroupSet != null ?
+ !categoryOptionGroupSet.equals( other.getCategoryOptionGroupSet() ) :
+ other.getCategoryOptionGroupSet() != null )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
// -------------------------------------------------------------------------
// Getters and Setters
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2014-04-28 08:53:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2014-04-28 09:34:22 +0000
@@ -248,8 +248,7 @@
for ( DataApprovalLevel dataApprovalLevel : dataApprovalLevels )
{
- if ( level.getOrgUnitLevel() == dataApprovalLevel.getOrgUnitLevel()
- && level.getCategoryOptionGroupSet() == dataApprovalLevel.getCategoryOptionGroupSet() )
+ if ( level.levelEquals( dataApprovalLevel ) )
{
return true;
}
@@ -417,7 +416,7 @@
if ( orgLevelDifference == 0 )
{
- if ( newLevel.getCategoryOptionGroupSet() == test.getCategoryOptionGroupSet() )
+ if ( newLevel.levelEquals( test ) )
{
return -1;
}
_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to : [email protected]
Unsubscribe : https://launchpad.net/~dhis2-devs
More help : https://help.launchpad.net/ListHelp