dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29190
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14712: Add reference from DataApproval to DataApprovalLevel
------------------------------------------------------------
revno: 14712
committer: Jim Grace <jimgrace@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-07 00:27:17 -0400
message:
Add reference from DataApproval to DataApprovalLevel
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApproval.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApproval.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalStoreTest.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataApprovalController.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/DataApproval.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApproval.java 2014-03-28 01:53:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApproval.java 2014-04-07 04:27:17 +0000
@@ -58,6 +58,11 @@
private int id;
/**
+ * The approval level for which this approval is defined.
+ */
+ private DataApprovalLevel dataApprovalLevel;
+
+ /**
* The DataSet for the values being approved (required).
*/
private DataSet dataSet;
@@ -102,10 +107,12 @@
{
}
- public DataApproval( DataSet dataSet, Period period, OrganisationUnit organisationUnit,
+ public DataApproval( DataApprovalLevel dataApprovalLevel, DataSet dataSet,
+ Period period, OrganisationUnit organisationUnit,
CategoryOptionGroup categoryOptionGroup, boolean accepted,
Date created, User creator )
{
+ this.dataApprovalLevel = dataApprovalLevel;
this.dataSet = dataSet;
this.period = period;
this.organisationUnit = organisationUnit;
@@ -129,6 +136,16 @@
this.id = id;
}
+ public DataApprovalLevel getDataApprovalLevel()
+ {
+ return dataApprovalLevel;
+ }
+
+ public void setDataApprovalLevel( DataApprovalLevel dataApprovalLevel )
+ {
+ this.dataApprovalLevel = dataApprovalLevel;
+ }
+
public DataSet getDataSet()
{
return dataSet;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApproval.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApproval.hbm.xml 2014-03-28 01:53:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApproval.hbm.xml 2014-04-07 04:27:17 +0000
@@ -11,6 +11,8 @@
<generator class="native" />
</id>
+ <many-to-one name="dataApprovalLevel" class="org.hisp.dhis.dataapproval.DataApprovalLevel" column="dataapprovallevelid" not-null="true" foreign-key="fk_dataapproval_dataapprovallevel" />
+
<properties name="dataapproval_dataset_period_orgunit_catoptiongroup_unique_key" unique="true">
<many-to-one name="dataSet" class="org.hisp.dhis.dataset.DataSet" column="datasetid" not-null="true" foreign-key="fk_dataapproval_datasetid" />
<many-to-one name="period" class="org.hisp.dhis.period.Period" column="periodid" not-null="true" foreign-key="fk_dataapproval_periodid" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java 2014-04-04 16:47:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java 2014-04-07 04:27:17 +0000
@@ -127,29 +127,29 @@
private OrganisationUnit organisationUnitF;
- private DataApprovalLevel dataApprovalLevel1;
-
- private DataApprovalLevel dataApprovalLevel2;
-
- private DataApprovalLevel dataApprovalLevel3;
-
- private DataApprovalLevel dataApprovalLevel4;
-
- private DataApprovalLevel dataApprovalLevel1A;
-
- private DataApprovalLevel dataApprovalLevel2A;
-
- private DataApprovalLevel dataApprovalLevel3A;
-
- private DataApprovalLevel dataApprovalLevel4A;
-
- private DataApprovalLevel dataApprovalLevel1B;
-
- private DataApprovalLevel dataApprovalLevel2B;
-
- private DataApprovalLevel dataApprovalLevel3B;
-
- private DataApprovalLevel dataApprovalLevel4B;
+ private DataApprovalLevel level1;
+
+ private DataApprovalLevel level2;
+
+ private DataApprovalLevel level3;
+
+ private DataApprovalLevel level4;
+
+ private DataApprovalLevel level1A;
+
+ private DataApprovalLevel level2A;
+
+ private DataApprovalLevel level3A;
+
+ private DataApprovalLevel level4A;
+
+ private DataApprovalLevel level1B;
+
+ private DataApprovalLevel level2B;
+
+ private DataApprovalLevel level3B;
+
+ private DataApprovalLevel level4B;
private User userA;
@@ -286,10 +286,10 @@
organisationUnitService.addOrganisationUnit( organisationUnitE );
organisationUnitService.addOrganisationUnit( organisationUnitF );
- dataApprovalLevel1 = new DataApprovalLevel( "1", 1, null );
- dataApprovalLevel2 = new DataApprovalLevel( "2", 2, null );
- dataApprovalLevel3 = new DataApprovalLevel( "3", 3, null );
- dataApprovalLevel4 = new DataApprovalLevel( "4", 4, null );
+ level1 = new DataApprovalLevel( "1", 1, null );
+ level2 = new DataApprovalLevel( "2", 2, null );
+ level3 = new DataApprovalLevel( "3", 3, null );
+ level4 = new DataApprovalLevel( "4", 4, null );
userA = createUser( 'A' );
userB = createUser( 'B' );
@@ -389,14 +389,14 @@
groupSetB.addCategoryOptionGroup( groupC );
groupSetB.addCategoryOptionGroup( groupD );
- dataApprovalLevel1A = new DataApprovalLevel( "1A", 1, groupSetA );
- dataApprovalLevel1B = new DataApprovalLevel( "1B",1, groupSetB );
- dataApprovalLevel2A = new DataApprovalLevel( "2A", 2, groupSetA );
- dataApprovalLevel2B = new DataApprovalLevel( "2B", 2, groupSetB );
- dataApprovalLevel3A = new DataApprovalLevel( "3A", 3, groupSetA );
- dataApprovalLevel3B = new DataApprovalLevel( "3B", 3, groupSetB );
- dataApprovalLevel4A = new DataApprovalLevel( "4A", 4, groupSetA );
- dataApprovalLevel4B = new DataApprovalLevel( "4B", 4, groupSetB );
+ level1A = new DataApprovalLevel( "1A", 1, groupSetA );
+ level1B = new DataApprovalLevel( "1B",1, groupSetB );
+ level2A = new DataApprovalLevel( "2A", 2, groupSetA );
+ level2B = new DataApprovalLevel( "2B", 2, groupSetB );
+ level3A = new DataApprovalLevel( "3A", 3, groupSetA );
+ level3B = new DataApprovalLevel( "3B", 3, groupSetB );
+ level4A = new DataApprovalLevel( "4A", 4, groupSetA );
+ level4B = new DataApprovalLevel( "4B", 4, groupSetB );
}
// -------------------------------------------------------------------------
@@ -406,20 +406,20 @@
@Test
public void testAddAndGetDataApproval() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
Set<OrganisationUnit> units = new HashSet<OrganisationUnit>();
units.add( organisationUnitA );
createUserAndInjectSecurityContext( units, false, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalC = new DataApproval( dataSetA, periodB, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalD = new DataApproval( dataSetB, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalC = new DataApproval( level1, dataSetA, periodB, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalD = new DataApproval( level1, dataSetB, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalService.addDataApproval( dataApprovalA );
dataApprovalService.addDataApproval( dataApprovalB );
@@ -444,7 +444,7 @@
assertEquals( userA.getId(), da.getCreator().getId() );
level = status.getDataApprovalLevel();
assertNotNull( level );
- assertEquals( dataApprovalLevel1, level );
+ assertEquals( level1, level );
status = dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS );
assertEquals( DataApprovalState.APPROVED_ELSEWHERE, status.getDataApprovalState() );
@@ -457,7 +457,7 @@
assertEquals( userA.getId(), da.getCreator().getId() );
level = status.getDataApprovalLevel();
assertNotNull( level );
- assertEquals( dataApprovalLevel1, level );
+ assertEquals( level1, level );
status = dataApprovalService.getDataApprovalStatus( dataSetA, periodB, organisationUnitA, NO_GROUPS, NO_OPTIONS );
assertEquals( DataApprovalState.APPROVED_HERE, status.getDataApprovalState() );
@@ -470,7 +470,7 @@
assertEquals( userA.getId(), da.getCreator().getId() );
level = status.getDataApprovalLevel();
assertNotNull( level );
- assertEquals( dataApprovalLevel1, level );
+ assertEquals( level1, level );
status = dataApprovalService.getDataApprovalStatus( dataSetB, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS );
assertEquals( DataApprovalState.APPROVED_HERE, status.getDataApprovalState() );
@@ -483,7 +483,7 @@
assertEquals( userA.getId(), da.getCreator().getId() );
level = status.getDataApprovalLevel();
assertNotNull( level );
- assertEquals( dataApprovalLevel1, level );
+ assertEquals( level1, level );
status = dataApprovalService.getDataApprovalStatus( dataSetB, periodB, organisationUnitB, NO_GROUPS, NO_OPTIONS );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, status.getDataApprovalState() );
@@ -494,18 +494,18 @@
@Test
public void testAddDuplicateDataApproval() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
Set<OrganisationUnit> units = new HashSet<OrganisationUnit>();
units.add( organisationUnitA );
createUserAndInjectSecurityContext( units, false, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level1, dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalService.addDataApproval( dataApprovalA );
@@ -523,18 +523,18 @@
@Test
public void testDeleteDataApproval() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
Set<OrganisationUnit> units = new HashSet<OrganisationUnit>();
units.add( organisationUnitA );
createUserAndInjectSecurityContext( units, false, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userB );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userB );
DataApproval testA;
DataApproval testB;
@@ -570,10 +570,10 @@
@Test
public void testGetDataApprovalState() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
Set<OrganisationUnit> units = new HashSet<OrganisationUnit>();
units.add( organisationUnitA );
@@ -610,7 +610,7 @@
Date date = new Date();
// Approved for sourceD
- DataApproval dataApprovalD = new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalD = new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalService.addDataApproval( dataApprovalD );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
@@ -620,7 +620,7 @@
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
// Also approved for sourceC
- DataApproval dataApprovalC = new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalC = new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalService.addDataApproval( dataApprovalC );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
@@ -630,7 +630,7 @@
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
// Also approved for sourceF
- DataApproval dataApprovalF = new DataApproval( dataSetA, periodA, organisationUnitF, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalF = new DataApproval( level4, dataSetA, periodA, organisationUnitF, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalService.addDataApproval( dataApprovalF );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
@@ -640,7 +640,7 @@
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
// Also approved also for sourceE
- DataApproval dataApprovalE = new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalE = new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalService.addDataApproval( dataApprovalE );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
@@ -660,10 +660,10 @@
@Test
public void testGetDataApprovalStateWithMultipleChildren() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
Set<OrganisationUnit> units = new HashSet<OrganisationUnit>();
units.add( organisationUnitA );
@@ -682,7 +682,7 @@
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitF, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level4, dataSetA, periodA, organisationUnitF, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
@@ -690,7 +690,7 @@
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
@@ -698,7 +698,7 @@
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
@@ -706,7 +706,7 @@
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.APPROVED_ELSEWHERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, NO_GROUPS, NO_OPTIONS ).getDataApprovalState() );
@@ -718,10 +718,10 @@
@Test
public void testGetDataApprovalStateOtherPeriodTypes() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
Set<OrganisationUnit> units = new HashSet<OrganisationUnit>();
units.add( organisationUnitA );
@@ -743,10 +743,10 @@
@Test
public void testMayApprove() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
dataSetA.setApproveData( true );
@@ -763,24 +763,24 @@
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitD, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalStore.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalStore.addDataApproval( new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitC, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalStore.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
- dataApprovalStore.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalStore.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalStore.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( true, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalStore.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalStore.addDataApproval( new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).isMayApprove());
}
@Test
public void testMayApproveLowerLevels() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
dataSetA.setApproveData( true );
@@ -797,24 +797,24 @@
assertEquals( true, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitD, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( true, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitC, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).isMayApprove());
}
@Test
public void testMayApproveSameAndLowerLevels() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
dataSetA.setApproveData( true );
@@ -831,24 +831,24 @@
assertEquals( true, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitD, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( true, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitC, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( true, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).isMayApprove());
}
@Test
public void testMayApproveNoAuthority() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
dataSetA.setApproveData( true );
@@ -865,24 +865,24 @@
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitD, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitC, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitB, NO_GROUPS, NO_OPTIONS ).isMayApprove());
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA ) );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).isMayApprove());
}
@Test
public void testMayUnapprove() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
dataSetA.setApproveData( true );
@@ -892,11 +892,11 @@
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalC = new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalD = new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalE = new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalC = new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalD = new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalE = new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalStore.addDataApproval( dataApprovalD );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).isMayUnapprove());
@@ -927,10 +927,10 @@
@Test
public void testMayUnapproveLowerLevels() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
dataSetA.setApproveData( true );
@@ -940,11 +940,11 @@
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalC = new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalD = new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalE = new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalC = new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalD = new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalE = new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalStore.addDataApproval( dataApprovalD );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).isMayUnapprove());
@@ -975,10 +975,10 @@
@Test
public void testMayUnapproveSameAndLowerLevels() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
dataSetA.setApproveData( true );
@@ -988,11 +988,11 @@
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalC = new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalD = new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalE = new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalC = new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalD = new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalE = new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalStore.addDataApproval( dataApprovalD );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).isMayUnapprove());
@@ -1023,10 +1023,10 @@
@Test
public void testMayUnapproveNoAuthority() throws Exception
{
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel1 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel3 );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel4 );
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+ dataApprovalLevelService.addDataApprovalLevel( level3 );
+ dataApprovalLevelService.addDataApprovalLevel( level4 );
dataSetA.setApproveData( true );
@@ -1036,11 +1036,11 @@
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalC = new DataApproval( dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalD = new DataApproval( dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
- DataApproval dataApprovalE = new DataApproval( dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, organisationUnitA, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level2, dataSetA, periodA, organisationUnitB, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalC = new DataApproval( level3, dataSetA, periodA, organisationUnitC, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalD = new DataApproval( level4, dataSetA, periodA, organisationUnitD, NO_GROUP, NOT_ACCEPTED, date, userA );
+ DataApproval dataApprovalE = new DataApproval( level3, dataSetA, periodA, organisationUnitE, NO_GROUP, NOT_ACCEPTED, date, userA );
dataApprovalStore.addDataApproval( dataApprovalD );
assertEquals( false, dataApprovalService.getDataApprovalPermissions( dataSetA, periodA, organisationUnitA, NO_GROUPS, NO_OPTIONS ).isMayUnapprove());
@@ -1124,7 +1124,7 @@
assertEquals( DataApprovalState.UNAPPROVABLE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, optionComboA ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVABLE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, optionComboA ).getDataApprovalState() );
- dataApprovalLevelService.addDataApprovalLevel( dataApprovalLevel2A );
+ dataApprovalLevelService.addDataApprovalLevel( level2A );
assertEquals( DataApprovalState.UNAPPROVABLE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, groupASet, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, groupASet, NO_OPTIONS ).getDataApprovalState() );
@@ -1138,7 +1138,7 @@
assertEquals( DataApprovalState.UNAPPROVED_ELSEWHERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, optionComboJ ).getDataApprovalState() );
assertEquals( DataApprovalState.UNAPPROVED_ELSEWHERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, optionComboK ).getDataApprovalState() );
- dataApprovalService.addDataApproval( new DataApproval( dataSetA, periodA, organisationUnitB, groupA, NOT_ACCEPTED, date, userA ) );
+ dataApprovalService.addDataApproval( new DataApproval( level2A, dataSetA, periodA, organisationUnitB, groupA, NOT_ACCEPTED, date, userA ) );
assertEquals( DataApprovalState.UNAPPROVABLE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, groupASet, NO_OPTIONS ).getDataApprovalState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, groupASet, NO_OPTIONS ).getDataApprovalState() );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalStoreTest.java 2014-03-28 01:53:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalStoreTest.java 2014-04-07 04:27:17 +0000
@@ -61,6 +61,9 @@
private DataApprovalStore dataApprovalStore;
@Autowired
+ private DataApprovalLevelService dataApprovalLevelService;
+
+ @Autowired
private PeriodService periodService;
@Autowired
@@ -79,6 +82,14 @@
// Supporting data
// -------------------------------------------------------------------------
+ private DataApprovalLevel level1;
+
+ private DataApprovalLevel level2;
+
+ private DataApprovalLevel level3;
+
+ private DataApprovalLevel level4;
+
private DataSet dataSetA;
private DataSet dataSetB;
@@ -112,6 +123,11 @@
// Add supporting data
// ---------------------------------------------------------------------
+ level1 = new DataApprovalLevel( "1", 1, null );
+ level2 = new DataApprovalLevel( "2", 2, null );
+ level3 = new DataApprovalLevel( "3", 3, null );
+ level4 = new DataApprovalLevel( "4", 4, null );
+
PeriodType periodType = PeriodType.getPeriodTypeByName( "Monthly" );
dataSetA = createDataSet( 'A', periodType );
@@ -152,11 +168,14 @@
@Test
public void testAddAndGetDataApproval() throws Exception
{
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, sourceA, categoryOptionGroup, false, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetA, periodA, sourceB, categoryOptionGroup, false, date, userA );
- DataApproval dataApprovalC = new DataApproval( dataSetA, periodB, sourceA, categoryOptionGroup, false, date, userA );
- DataApproval dataApprovalD = new DataApproval( dataSetB, periodA, sourceA, categoryOptionGroup, false, date, userA );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, sourceA, categoryOptionGroup, false, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level2, dataSetA, periodA, sourceB, categoryOptionGroup, false, date, userA );
+ DataApproval dataApprovalC = new DataApproval( level1, dataSetA, periodB, sourceA, categoryOptionGroup, false, date, userA );
+ DataApproval dataApprovalD = new DataApproval( level1, dataSetB, periodA, sourceA, categoryOptionGroup, false, date, userA );
DataApproval dataApprovalE;
dataApprovalStore.addDataApproval( dataApprovalA );
@@ -166,6 +185,7 @@
dataApprovalA = dataApprovalStore.getDataApproval( dataSetA, periodA, sourceA, categoryOptionGroup );
assertNotNull( dataApprovalA );
+ assertEquals( level1.getId(), dataApprovalA.getDataApprovalLevel().getId() );
assertEquals( dataSetA.getId(), dataApprovalA.getDataSet().getId() );
assertEquals( periodA, dataApprovalA.getPeriod() );
assertEquals( sourceA.getId(), dataApprovalA.getOrganisationUnit().getId() );
@@ -174,6 +194,7 @@
dataApprovalB = dataApprovalStore.getDataApproval( dataSetA, periodA, sourceB, categoryOptionGroup );
assertNotNull( dataApprovalB );
+ assertEquals( level2.getId(), dataApprovalB.getDataApprovalLevel().getId() );
assertEquals( dataSetA.getId(), dataApprovalB.getDataSet().getId() );
assertEquals( periodA, dataApprovalB.getPeriod() );
assertEquals( sourceB.getId(), dataApprovalB.getOrganisationUnit().getId() );
@@ -182,6 +203,7 @@
dataApprovalC = dataApprovalStore.getDataApproval( dataSetA, periodB, sourceA, categoryOptionGroup );
assertNotNull( dataApprovalC );
+ assertEquals( level1.getId(), dataApprovalC.getDataApprovalLevel().getId() );
assertEquals( dataSetA.getId(), dataApprovalC.getDataSet().getId() );
assertEquals( periodB, dataApprovalC.getPeriod() );
assertEquals( sourceA.getId(), dataApprovalC.getOrganisationUnit().getId() );
@@ -190,6 +212,7 @@
dataApprovalD = dataApprovalStore.getDataApproval( dataSetB, periodA, sourceA, categoryOptionGroup );
assertNotNull( dataApprovalD );
+ assertEquals( level1.getId(), dataApprovalD.getDataApprovalLevel().getId() );
assertEquals( dataSetB.getId(), dataApprovalD.getDataSet().getId() );
assertEquals( periodA, dataApprovalD.getPeriod() );
assertEquals( sourceA.getId(), dataApprovalD.getOrganisationUnit().getId() );
@@ -203,9 +226,11 @@
@Test
public void testAddDuplicateDataApproval() throws Exception
{
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, sourceA, categoryOptionGroup, false, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetA, periodA, sourceA, categoryOptionGroup, false, date, userA );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, sourceA, categoryOptionGroup, false, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level1, dataSetA, periodA, sourceA, categoryOptionGroup, false, date, userA );
dataApprovalStore.addDataApproval( dataApprovalA );
@@ -223,9 +248,12 @@
@Test
public void testDeleteDataApproval() throws Exception
{
+ dataApprovalLevelService.addDataApprovalLevel( level1 );
+ dataApprovalLevelService.addDataApprovalLevel( level2 );
+
Date date = new Date();
- DataApproval dataApprovalA = new DataApproval( dataSetA, periodA, sourceA, categoryOptionGroup, false, date, userA );
- DataApproval dataApprovalB = new DataApproval( dataSetB, periodB, sourceB, categoryOptionGroup, false, date, userB );
+ DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, sourceA, categoryOptionGroup, false, date, userA );
+ DataApproval dataApprovalB = new DataApproval( level2, dataSetB, periodB, sourceB, categoryOptionGroup, false, date, userB );
dataApprovalStore.addDataApproval( dataApprovalA );
dataApprovalStore.addDataApproval( dataApprovalB );
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2014-04-04 16:59:23 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2014-04-07 04:27:17 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.concept.Concept;
import org.hisp.dhis.constant.Constant;
import org.hisp.dhis.dashboard.DashboardItem;
+import org.hisp.dhis.dataapproval.DataApprovalLevel;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
@@ -153,6 +154,15 @@
return null;
}
+ public void deleteDataApprovalLevel( DataApprovalLevel dataApprovalLevel )
+ {
+ }
+
+ public String allowDeleteDataApprovalLevel( DataApprovalLevel dataApprovalLevel )
+ {
+ return null;
+ }
+
public void deleteDataDictionary( DataDictionary dataDictionary )
{
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataApprovalController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataApprovalController.java 2014-04-01 19:50:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataApprovalController.java 2014-04-07 04:27:17 +0000
@@ -217,7 +217,8 @@
CategoryOptionGroup categoryOptionGroup = categoryOptionGroups == null ? null : (CategoryOptionGroup) categoryOptionGroups.toArray() [0];
- DataApproval approval = new DataApproval( dataSet, period, organisationUnit, categoryOptionGroup, false, new Date(), user );
+ DataApproval approval = new DataApproval( permissions.getDataApprovalStatus().getDataApprovalLevel(),
+ dataSet, period, organisationUnit, categoryOptionGroup, false, new Date(), user );
dataApprovalService.addDataApproval( approval );
}