dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29125
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14654: dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java
------------------------------------------------------------
revno: 14654
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-04-04 13:54:42 +0200
message:
dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.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/common/QueryItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java 2014-03-26 16:33:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java 2014-04-04 11:54:42 +0000
@@ -30,34 +30,19 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
+ * Class which encapsulates a query parameter and value. Operator and filter
+ * are inherited from QueryFilter.
+ *
* @author Lars Helge Overland
*/
public class QueryItem
+ extends QueryFilter
{
- public static final String OPTION_SEP = ";";
-
- public static final Map<String, String> OPERATOR_MAP = new HashMap<String, String>() { {
- put( "eq", "=" );
- put( "gt", ">" );
- put( "ge", ">=" );
- put( "lt", "<" );
- put( "le", "<=" );
- put( "ne", "!=" );
- put( "like", "like" );
- put( "in", "in" );
- } };
-
private IdentifiableObject item;
- private String operator;
-
- private String filter;
-
private boolean numeric;
// -------------------------------------------------------------------------
@@ -80,49 +65,6 @@
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
-
- public boolean hasFilter()
- {
- return operator != null && !operator.isEmpty() && filter != null && !filter.isEmpty();
- }
-
- public String getSqlOperator()
- {
- if ( operator == null )
- {
- return null;
- }
-
- return OPERATOR_MAP.get( operator.toLowerCase() );
- }
-
- public String getSqlFilter( String encodedFilter )
- {
- if ( operator == null || encodedFilter == null )
- {
- return null;
- }
-
- if ( operator.equalsIgnoreCase( "like" ) )
- {
- return "'%" + encodedFilter + "%'";
- }
- else if ( operator.equalsIgnoreCase( "in" ) )
- {
- String[] split = encodedFilter.split( OPTION_SEP );
-
- final StringBuffer buffer = new StringBuffer( "(" );
-
- for ( String el : split )
- {
- buffer.append( "'" ).append( el ).append( "'," );
- }
-
- return buffer.deleteCharAt( buffer.length() - 1 ).append( ")" ).toString();
- }
-
- return "'" + encodedFilter + "'";
- }
public String getItemId()
{
@@ -170,26 +112,6 @@
this.item = item;
}
- public String getOperator()
- {
- return operator;
- }
-
- public void setOperator( String operator )
- {
- this.operator = operator;
- }
-
- public String getFilter()
- {
- return filter;
- }
-
- public void setFilter( String filter )
- {
- this.filter = filter;
- }
-
public boolean isNumeric()
{
return numeric;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java 2014-04-03 16:03:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java 2014-04-04 11:54:42 +0000
@@ -45,9 +45,11 @@
{
Schema schema = new Schema( DataApprovalLevel.class, "dataApprovalLevel", "dataApprovalLevels" );
- schema.setShareable( false );
+ schema.setShareable( true );
- schema.getAuthorities().add( new Authority( AuthorityType.CREATE, Lists.newArrayList( "F_SYSTEM_SETTING" ) ) );
+ schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DATAAPPROVALLEVEL_PUBLIC_ADD" ) ) );
+ schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PRIVATE, Lists.newArrayList( "F_DATAAPPROVALLEVEL_PRIVATE_ADD" ) ) );
+ schema.getAuthorities().add( new Authority( AuthorityType.DELETE, Lists.newArrayList( "F_DATAAPPROVALLEVEL_DELETE" ) ) );
return schema;
}
=== 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-04 03:49:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2014-04-04 11:54:42 +0000
@@ -133,8 +133,6 @@
orgUnit.getLevel() : organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getUid() );
userOrgUnitLevels.add( orgUnitLevel );
-
- System.out.println("User assigned to org unit level " + orgUnitLevel );
}
boolean assignedAtLevel = false;
@@ -168,8 +166,6 @@
approvableAtLevel = canReadThisLevel && ( ( mayApprove && assignedAtLevel ) || approvableAtAllLowerLevels );
- System.out.println( approvalLevel.getName() + " read " + canReadThisLevel + " assigned " + assignedAtLevel + " approvable " + approvableAtLevel );
-
//
// Test using assignedAtLevel and approvableAtLevel values from the current level:
//
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java 2014-04-04 03:49:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java 2014-04-04 11:54:42 +0000
@@ -443,7 +443,6 @@
List<DataApprovalLevel> levels;
- System.out.println("\n--- NoAuthorities" );
levels = dataApprovalLevelService.getUserDataApprovalLevels();
assertEquals( 0, levels.size() );
@@ -486,12 +485,8 @@
dataApprovalLevelService.addDataApprovalLevel( level1A );
dataApprovalLevelService.addDataApprovalLevel( level1 );
- System.out.println("\n--- ApproveHere" );
levels = dataApprovalLevelService.getUserDataApprovalLevels();
- for ( DataApprovalLevel level : levels )
- {
- System.out.println("Here " + level.getName() );
- }
+
assertEquals( 4, levels.size() );
assertEquals( "2", levels.get( 0 ).getName() );
assertEquals( "2 - Set A", levels.get( 1 ).getName() );
@@ -521,12 +516,8 @@
dataApprovalLevelService.addDataApprovalLevel( level1A );
dataApprovalLevelService.addDataApprovalLevel( level1 );
- System.out.println("\n--- ApproveLower" );
levels = dataApprovalLevelService.getUserDataApprovalLevels();
- for ( DataApprovalLevel level : levels )
- {
- System.out.println("Lower " + level.getName() );
- }
+
assertEquals( 8, levels.size() );
assertEquals( "2 - Set A", levels.get( 0 ).getName() );
assertEquals( "2 - Set B", levels.get( 1 ).getName() );
@@ -560,12 +551,8 @@
dataApprovalLevelService.addDataApprovalLevel( level1A );
dataApprovalLevelService.addDataApprovalLevel( level1 );
- System.out.println("\n--- HereAndLower" );
levels = dataApprovalLevelService.getUserDataApprovalLevels();
- for ( DataApprovalLevel level : levels )
- {
- System.out.println("HereAndLower " + level.getName() );
- }
+
assertEquals( 9, levels.size() );
assertEquals( "2", levels.get( 0 ).getName() );
assertEquals( "2 - Set A", levels.get( 1 ).getName() );
@@ -600,12 +587,8 @@
dataApprovalLevelService.addDataApprovalLevel( level1A );
dataApprovalLevelService.addDataApprovalLevel( level1 );
- System.out.println("\n--- AcceptLower" );
levels = dataApprovalLevelService.getUserDataApprovalLevels();
- for ( DataApprovalLevel level : levels )
- {
- System.out.println("AcceptLower " + level.getName() );
- }
+
assertEquals( 3, levels.size() );
assertEquals( "2 - Set A", levels.get( 0 ).getName() );
assertEquals( "2 - Set B", levels.get( 1 ).getName() );