← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14780: Code style

 

------------------------------------------------------------
revno: 14780
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-04-10 23:20:39 +0200
message:
  Code style
modified:
  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/DefaultDataApprovalService.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-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-10 01:28:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java	2014-04-10 21:20:39 +0000
@@ -92,20 +92,11 @@
 
         for ( DataApprovalLevel dataApprovalLevel : dataApprovalLevels)
         {
-            String ouLevelName;
-
             int ouLevelNumber = dataApprovalLevel.getOrgUnitLevel();
 
             OrganisationUnitLevel ouLevel = organisationUnitService.getOrganisationUnitLevelByLevel( ouLevelNumber );
 
-            if ( ouLevel != null )
-            {
-                ouLevelName = ouLevel.getName();
-            }
-            else
-            {
-                ouLevelName = "Organization unit level " + ouLevelNumber;
-            }
+            String ouLevelName = ouLevel != null ? ouLevel.getName() : "Organisation unit level " + ouLevelNumber;
 
             dataApprovalLevel.setOrgUnitLevelName( ouLevelName );
         }
@@ -199,15 +190,8 @@
         DataApprovalLevel test = dataApprovalLevels.get( index );
         DataApprovalLevel next = dataApprovalLevels.get( index + 1 );
 
-        if ( test.getOrgUnitLevel() == next.getOrgUnitLevel()
-            && test.getCategoryOptionGroupSet() != null )
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
+        return test.getOrgUnitLevel() == next.getOrgUnitLevel()
+            && test.getCategoryOptionGroupSet() != null;
     }
 
     public boolean canDataApprovalLevelMoveUp( int level )
@@ -224,15 +208,8 @@
         DataApprovalLevel test = dataApprovalLevels.get( index );
         DataApprovalLevel previous = dataApprovalLevels.get( index - 1 );
 
-        if ( test.getOrgUnitLevel() == previous.getOrgUnitLevel()
-            && previous.getCategoryOptionGroupSet() != null )
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
+        return test.getOrgUnitLevel() == previous.getOrgUnitLevel()
+            && previous.getCategoryOptionGroupSet() != null;
     }
 
     public void moveDataApprovalLevelDown( int level )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java	2014-04-04 16:47:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java	2014-04-10 21:20:39 +0000
@@ -116,7 +116,7 @@
     public void addDataApproval( DataApproval dataApproval )
     {
         if ( ( dataApproval.getCategoryOptionGroup() == null || securityService.canRead( dataApproval.getCategoryOptionGroup() ) )
-                && mayApprove( dataApproval.getOrganisationUnit() ) )
+            && mayApprove( dataApproval.getOrganisationUnit() ) )
         {
             dataApprovalStore.addDataApproval( dataApproval );
         }
@@ -129,7 +129,7 @@
     public void deleteDataApproval( DataApproval dataApproval )
     {
         if ( ( dataApproval.getCategoryOptionGroup() == null || securityService.canRead( dataApproval.getCategoryOptionGroup() ) )
-                && mayUnapprove( dataApproval.getOrganisationUnit(), dataApproval.isAccepted() ))
+            && mayUnapprove( dataApproval.getOrganisationUnit(), dataApproval.isAccepted() ))
         {
             dataApprovalStore.deleteDataApproval( dataApproval );
 
@@ -152,8 +152,8 @@
     public DataApprovalStatus getDataApprovalStatus( DataSet dataSet, Period period, OrganisationUnit organisationUnit, DataElementCategoryOptionCombo attributeOptionCombo )
     {
         return getDataApprovalStatus( dataSet, period, organisationUnit, null,
-                ( attributeOptionCombo == null || attributeOptionCombo.getId() == categoryService.getDefaultDataElementCategoryOptionCombo().getId() )
-                        ? null : attributeOptionCombo.getCategoryOptions() );
+            ( attributeOptionCombo == null || attributeOptionCombo.getId() == categoryService.getDefaultDataElementCategoryOptionCombo().getId() )
+                ? null : attributeOptionCombo.getCategoryOptions() );
     }
 
     public DataApprovalStatus getDataApprovalStatus( DataSet dataSet, Period period, OrganisationUnit organisationUnit,
@@ -171,15 +171,15 @@
         OrganisationUnit organisationUnit, DataElementCategoryOptionCombo attributeOptionCombo )
     {
         return getDataApprovalPermissions( dataSet, period, organisationUnit, null,
-                ( attributeOptionCombo == null || attributeOptionCombo.getId() == categoryService.getDefaultDataElementCategoryOptionCombo().getId() )
-                ? null : attributeOptionCombo.getCategoryOptions() );
+            ( attributeOptionCombo == null || attributeOptionCombo.getId() == categoryService.getDefaultDataElementCategoryOptionCombo().getId() )
+            ? null : attributeOptionCombo.getCategoryOptions() );
     }
 
     public DataApprovalPermissions getDataApprovalPermissions( DataSet dataSet, Period period,
         OrganisationUnit organisationUnit, Set<CategoryOptionGroup> categoryOptionGroups, Set<DataElementCategoryOption> dataElementCategoryOptions )
     {
         DataApprovalStatus status = getDataApprovalStatus( dataSet, period,
-                organisationUnit, categoryOptionGroups, dataElementCategoryOptions );
+            organisationUnit, categoryOptionGroups, dataElementCategoryOptions );
 
         DataApprovalPermissions permissions = new DataApprovalPermissions();
 
@@ -222,7 +222,7 @@
     public void accept( DataApproval dataApproval )
     {
         if ( ( dataApproval.getCategoryOptionGroup() == null || securityService.canRead( dataApproval.getCategoryOptionGroup() ) )
-                && mayAcceptOrUnaccept( dataApproval.getOrganisationUnit() ) )
+            && mayAcceptOrUnaccept( dataApproval.getOrganisationUnit() ) )
         {
             if ( !dataApproval.isAccepted() )
             {
@@ -240,7 +240,7 @@
     public void unaccept( DataApproval dataApproval )
     {
         if ( ( dataApproval.getCategoryOptionGroup() == null || securityService.canRead( dataApproval.getCategoryOptionGroup() ) )
-                && mayAcceptOrUnaccept( dataApproval.getOrganisationUnit() ) )
+            && mayAcceptOrUnaccept( dataApproval.getOrganisationUnit() ) )
         {
             if ( dataApproval.isAccepted() )
             {
@@ -307,7 +307,7 @@
             boolean mayApproveAtLowerLevels = user.getUserCredentials().isAuthorized( DataApproval.AUTH_APPROVE_LOWER_LEVELS );
 
             if ( mayApproveAtLowerLevels && CollectionUtils.containsAny( user.getOrganisationUnits(),
-                    organisationUnit.getAncestors() ) )
+                organisationUnit.getAncestors() ) )
             {
                 log.info( "mayApprove = true because organisation unit " + organisationUnit.getName()
                         + " is under user and user may approve at lower levels." );
@@ -373,7 +373,7 @@
             boolean mayAcceptAtLowerLevels = user.getUserCredentials().isAuthorized( DataApproval.AUTH_ACCEPT_LOWER_LEVELS );
 
             if ( mayAcceptAtLowerLevels && CollectionUtils.containsAny( user.getOrganisationUnits(),
-                    organisationUnit.getAncestors() ) )
+                organisationUnit.getAncestors() ) )
             {
                 log.info( "User may accept or unaccept for organisation unit " + organisationUnit.getName() );