← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14634: Added DataApprovalBaseState

 

------------------------------------------------------------
revno: 14634
committer: Jim Grace <jimgrace@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-04-03 09:11:26 -0400
message:
  Added DataApprovalBaseState
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalBaseState.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalState.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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalBaseState.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalBaseState.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalBaseState.java	2014-04-03 13:11:26 +0000
@@ -0,0 +1,63 @@
+package org.hisp.dhis.dataapproval;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * "Base", or simplified, state of data approval for a given data selection.
+ *
+ * @author Jim Grace
+ */
+public enum DataApprovalBaseState
+{
+    /**
+     * Data approval does not apply to this selection. (Data is neither
+     * "approved" nor "unapproved".)
+     */
+    UNAPPROVABLE,
+
+    /**
+     * Data is unapproved, and is not ready to be approved for this selection.
+     */
+    UNAPPROVED_NOT_READY,
+
+    /**
+     * Data is unapproved, and is ready to be approved for this selection.
+     */
+    UNAPPROVED_READY,
+
+    /**
+     * Data is approved (either here or elsewhere).
+     */
+    APPROVED,
+
+    /**
+     * Data is approved and accepted (either here or elsewhere).
+     */
+    ACCEPTED;
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalState.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalState.java	2014-03-28 10:13:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalState.java	2014-04-03 13:11:26 +0000
@@ -29,7 +29,7 @@
  */
 
 /**
- * Current status of data approval for a selected combination of data set, period,
+ * Current state of data approval for a selected combination of data set, period,
  * organisation unit, and category options or category group options.
  *
  * @author Jim Grace
@@ -40,28 +40,28 @@
      * Data approval does not apply to this selection. (Data is neither
      * "approved" nor "unapproved".)
      */
-    UNAPPROVABLE ( false, false, false, false, false ),
-
-    /**
-     * Data is unapproved, and is ready to be approved for this selection.
-     */
-    UNAPPROVED_READY ( false, true, true, false, true ),
+    UNAPPROVABLE ( DataApprovalBaseState.UNAPPROVABLE, false, false, false, false, false ),
 
     /**
      * Data is unapproved, and is waiting for some lower-level approval.
      */
-    UNAPPROVED_WAITING ( false, true, true, false, false ),
+    UNAPPROVED_WAITING ( DataApprovalBaseState.UNAPPROVED_NOT_READY, false, true, true, false, false ),
 
     /**
      * Data is unapproved, and is waiting for approval somewhere else
      * (not approvable here.)
      */
-    UNAPPROVED_ELSEWHERE ( false, true, false, false, false ),
+    UNAPPROVED_ELSEWHERE ( DataApprovalBaseState.UNAPPROVED_NOT_READY, false, true, false, false, false ),
+
+    /**
+     * Data is unapproved, and is ready to be approved for this selection.
+     */
+    UNAPPROVED_READY ( DataApprovalBaseState.UNAPPROVED_READY, false, true, true, false, true ),
 
     /**
      * Data is approved, and was approved here (so could be unapproved here.)
      */
-    APPROVED_HERE ( true, false, true, false, false ),
+    APPROVED_HERE ( DataApprovalBaseState.APPROVED, true, false, true, false, false ),
 
     /**
      * Data is approved, but was not approved here (so cannot be unapproved here.)
@@ -74,17 +74,22 @@
      * In the first two cases, there is a single data approval object
      * that covers the selection. In the third case there is not.
      */
-    APPROVED_ELSEWHERE( true, false, false, false, false ),
+    APPROVED_ELSEWHERE( DataApprovalBaseState.APPROVED, true, false, false, false, false ),
 
     /**
      * Data is approved and accepted here (so could be unapproved here.)
      */
-    ACCEPTED_HERE ( true, false, true, true, false ),
+    ACCEPTED_HERE ( DataApprovalBaseState.ACCEPTED, true, false, true, true, false ),
 
     /**
      * Data is approved and accepted, but elsewhere.
      */
-    ACCEPTED_ELSEWHERE ( true, false, false, true, false );
+    ACCEPTED_ELSEWHERE ( DataApprovalBaseState.ACCEPTED, true, false, false, true, false );
+
+    /**
+     * "Base", or simplified, state of data approval.
+     */
+    private DataApprovalBaseState baseState;
 
     /**
      * Is this data approved (and therefore locked)?
@@ -115,8 +120,10 @@
     // Constructor
     // -------------------------------------------------------------------------
 
-    DataApprovalState( boolean approved, boolean unapproved, boolean approvable, boolean accepted, boolean ready )
+    DataApprovalState( DataApprovalBaseState baseState, boolean approved, boolean unapproved,
+                       boolean approvable, boolean accepted, boolean ready )
     {
+        this.baseState = baseState;
         this.approved = approved;
         this.unapproved = unapproved;
         this.approvable = approvable;
@@ -128,6 +135,11 @@
     // Getters
     // -------------------------------------------------------------------------
 
+    public DataApprovalBaseState getBaseState()
+    {
+        return baseState;
+    }
+
     public boolean isApproved()
     {
         return approved;