← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19146: minor fixes to programRule* classes

 

------------------------------------------------------------
revno: 19146
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-05-13 09:28:26 +0700
message:
  minor fixes to programRule* classes
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRule.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleAction.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleVariable.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRule.hbm.xml
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleAction.hbm.xml
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleVariable.hbm.xml


--
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/programrule/ProgramRule.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRule.java	2015-04-28 16:02:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRule.java	2015-05-13 02:28:26 +0000
@@ -28,23 +28,24 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.HashSet;
-import java.util.Set;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
+import org.hisp.dhis.common.annotation.Scanned;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramStage;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * @author markusbekken
@@ -57,20 +58,21 @@
      * The description of the program rule
      */
     private String description;
-    
+
     /**
      * The program that the rule belongs to
      */
     private Program program;
-    
+
     /**
      * The programStage that the rule belongs to
      */
     private ProgramStage programStage;
-    
+
     /**
      * The collection of actions that will be triggered if the the rule is triggered.
      */
+    @Scanned
     private Set<ProgramRuleAction> programRuleActions;
 
     /**
@@ -93,7 +95,7 @@
         this.setAutoFields();
         this.programRuleActions = new HashSet<ProgramRuleAction>();
     }
-    
+
     public ProgramRule( String name, String description, Program program, ProgramStage programStage, Set<ProgramRuleAction> programRuleActions, String condition, Integer priority )
     {
         this();
@@ -105,7 +107,7 @@
         this.condition = condition;
         this.priority = priority;
     }
-    
+
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------
@@ -121,7 +123,7 @@
     {
         this.description = description;
     }
-    
+
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
@@ -147,10 +149,12 @@
     {
         this.programStage = programStage;
     }
-    
+
     @JsonProperty
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlElementWrapper( localName = "programRuleActions", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "programRuleAction", namespace = DxfNamespaces.DXF_2_0 )
     public Set<ProgramRuleAction> getProgramRuleActions()
     {
         return programRuleActions;
@@ -172,7 +176,7 @@
     {
         this.condition = condition;
     }
-    
+
     @JsonProperty
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Integer getPriority()

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleAction.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleAction.java	2015-05-08 13:46:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleAction.java	2015-05-13 02:28:26 +0000
@@ -28,6 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
@@ -38,12 +43,6 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.program.ProgramStageSection;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-
 /**
  * @author markusbekken
  */
@@ -55,43 +54,43 @@
      * The programRule that the action belongs to
      */
     private ProgramRule programRule;
-    
+
     /**
      * The type of action that is performed when the action is effectuated
-     * 
+     * <p/>
      * The actual action the ruleaction row is performing. Allowed values are:
-     *   displaytext
-     *       Shows a text in the rulebound widget with the matching location string.
-     *           location: the location code of the widget to display data in
-     *           content: A hardcoded string to display
-     *           data: a variable to be evaluated and displayed at the end of the string, can be null.
-     *   displaykeyvaluepair
-     *       Shows a key data box with a hardcoded name and a variable value.
-     *           location: the location code of the widget to display data in
-     *           content: A hardcoded string to display as title in the key data box
-     *           data: The variable to be evaluated and display in the lower half of the key data box.
-     *   hidefield
-     *       Hides a dataelement from the page, as long as the dataelement is not containing a value.
-     *           dataelement: the dataelement to hide.
-     *   assignvariable
-     *       Assigns/calculates a value that can be further used by other rules. Make sure the priorities is set so the rules that depend on the calculation is run after the assignvariable-rule.
-     *           content: the variable name to be assigned. “$severeanemia” for example.
-     *           data: the expression to be evaluated and assigned to the content field. Can contain a hardcoded value(f.ex. “true”) or an expression that is evaluated(for exampple “$hemoglobin < 7”). 
-     *   showwarning
-     *       Shows a validation warning connected to a designated dataelement
-     *           dataelement: the dataelement to show validationerror for
-     *           content: the validation error itself 
-     *   showerror
-     *       Shows a validation error connected to a designated dataelement
-     *           dataelement: the dataelement to show validationerror for
-     *           content: the validation error itself 
+     * displaytext
+     * Shows a text in the rulebound widget with the matching location string.
+     * location: the location code of the widget to display data in
+     * content: A hardcoded string to display
+     * data: a variable to be evaluated and displayed at the end of the string, can be null.
+     * displaykeyvaluepair
+     * Shows a key data box with a hardcoded name and a variable value.
+     * location: the location code of the widget to display data in
+     * content: A hardcoded string to display as title in the key data box
+     * data: The variable to be evaluated and display in the lower half of the key data box.
+     * hidefield
+     * Hides a dataelement from the page, as long as the dataelement is not containing a value.
+     * dataelement: the dataelement to hide.
+     * assignvariable
+     * Assigns/calculates a value that can be further used by other rules. Make sure the priorities is set so the rules that depend on the calculation is run after the assignvariable-rule.
+     * content: the variable name to be assigned. “$severeanemia” for example.
+     * data: the expression to be evaluated and assigned to the content field. Can contain a hardcoded value(f.ex. “true”) or an expression that is evaluated(for exampple “$hemoglobin < 7”).
+     * showwarning
+     * Shows a validation warning connected to a designated dataelement
+     * dataelement: the dataelement to show validationerror for
+     * content: the validation error itself
+     * showerror
+     * Shows a validation error connected to a designated dataelement
+     * dataelement: the dataelement to show validationerror for
+     * content: the validation error itself
      */
     private ProgramRuleActionType programRuleActionType;
-    
+
     /**
-     * The data element that is affected by the rule action. 
+     * The data element that is affected by the rule action.
      * Used for:
-     * 
+     * <p/>
      * <ul>
      * <li>hidefield</li>
      * <li>showwarning</li>
@@ -99,15 +98,15 @@
      * </ul>
      */
     private DataElement dataElement;
-    
+
     /**
      * The program stage section that is affected by the rule action.
      */
     private ProgramStageSection programStageSection;
-    
+
     /**
      * Used to determine which widget to display data for the two action types:
-     * 
+     * <p/>
      * <ul>
      * <li>displaytext</li>
      * <li>displaykeydata</li>
@@ -119,7 +118,7 @@
      * Used by all the different actions. See “actions”
      */
     private String content;
-    
+
     /**
      * Used by all the different actions. See “actions”. The data field will be evaluated, so it can contain a rich expression.
      */
@@ -133,7 +132,7 @@
     {
         setAutoFields();
     }
-    
+
     public ProgramRuleAction( String name, ProgramRule programRule, ProgramRuleActionType programRuleActionType, DataElement dataElement, String location, String content, String data )
     {
         this();
@@ -145,11 +144,11 @@
         this.content = content;
         this.data = data;
     }
-    
+
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------
-    
+
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
@@ -237,7 +236,7 @@
     {
         this.data = data;
     }
-    
+
     @Override
     public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
     {
@@ -265,7 +264,7 @@
                 programStageSection = programRuleAction.getProgramStageSection() == null ? programStageSection : programRuleAction.getProgramStageSection();
                 location = programRuleAction.getLocation() == null ? location : programRuleAction.getLocation();
                 content = programRuleAction.getContent() == null ? content : programRuleAction.getContent();
-                data = programRuleAction.getData() == null ? data : programRuleAction.getData();            
+                data = programRuleAction.getData() == null ? data : programRuleAction.getData();
             }
         }
     }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleVariable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleVariable.java	2015-05-08 13:46:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleVariable.java	2015-05-13 02:28:26 +0000
@@ -28,6 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
@@ -40,12 +45,6 @@
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-
 /**
  * @author markusbekken
  */
@@ -86,7 +85,7 @@
     /**
      * The data element that is linked to the variable. Must be defined if the
      * sourceType is one of the following:
-     * 
+     * <p/>
      * <ul>
      * <li>dataelement_newest_event_program_stage</li>
      * <li>dataelement_newest_event_program</li>
@@ -110,12 +109,12 @@
         setAutoFields();
     }
 
-    public ProgramRuleVariable( String name, 
-        Program program, 
+    public ProgramRuleVariable( String name,
+        Program program,
         ProgramRuleVariableSourceType sourceType,
         TrackedEntityAttribute attribute,
         DataElement dataElement,
-        ProgramStage programStage)
+        ProgramStage programStage )
     {
         this();
         this.name = name;
@@ -169,9 +168,9 @@
         this.dataElement = dataElement;
     }
 
-    @JsonProperty
+    @JsonProperty( "trackedEntityAttribute" )
     @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "trackedEntityAttribute", namespace = DxfNamespaces.DXF_2_0 )
     public TrackedEntityAttribute getAttribute()
     {
         return attribute;
@@ -182,9 +181,9 @@
         this.attribute = attribute;
     }
 
-    @JsonProperty
+    @JsonProperty( "programRuleVariableSourceType" )
     @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "programRuleVariableSourceType", namespace = DxfNamespaces.DXF_2_0 )
     public ProgramRuleVariableSourceType getSourceType()
     {
         return sourceType;
@@ -194,7 +193,7 @@
     {
         this.sourceType = sourceType;
     }
-    
+
     @Override
     public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRule.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRule.hbm.xml	2015-04-28 20:52:00 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRule.hbm.xml	2015-05-13 02:28:26 +0000
@@ -13,27 +13,26 @@
     <id name="id" column="programruleid">
       <generator class="native" />
     </id>
-
     &identifiableProperties;
 
     <property name="name" column="name" not-null="true" length="230" />
-    
+
     <property name="description" />
 
-    <many-to-one name="program" class="org.hisp.dhis.program.Program" 
-       	column="programid" foreign-key="fk_programrule_program" not-null="true" />
-    
-	<many-to-one name="programStage" class="org.hisp.dhis.program.ProgramStage" 
-		column="programstageid" foreign-key="fk_programrule_programstage" />
+    <many-to-one name="program" class="org.hisp.dhis.program.Program"
+      column="programid" foreign-key="fk_programrule_program" not-null="true" />
+
+    <many-to-one name="programStage" class="org.hisp.dhis.program.ProgramStage"
+      column="programstageid" foreign-key="fk_programrule_programstage" />
 
     <set name="programRuleActions" cascade="all">
-		<key column="programruleid" />
-		<one-to-many class="org.hisp.dhis.programrule.ProgramRuleAction" />
-	</set>
+      <key column="programruleid" />
+      <one-to-many class="org.hisp.dhis.programrule.ProgramRuleAction" />
+    </set>
 
     <property name="condition" type="text" not-null="true" />
-   
+
     <property name="priority" />
-   
+
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleAction.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleAction.hbm.xml	2015-05-08 13:46:50 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleAction.hbm.xml	2015-05-13 02:28:26 +0000
@@ -13,29 +13,28 @@
     <id name="id" column="programruleactionid">
       <generator class="native" />
     </id>
-
     &identifiableProperties;
 
-	<many-to-one name="programRule" class="org.hisp.dhis.programrule.ProgramRule" 
-		column="programruleid" foreign-key="fk_programruleaction_programrule" />
+    <many-to-one name="programRule" class="org.hisp.dhis.programrule.ProgramRule"
+      column="programruleid" foreign-key="fk_programruleaction_programrule" />
 
     <property name="programRuleActionType" column="actiontype" not-null="true">
-        <type name="org.hibernate.type.EnumType">
-            <param name="enumClass">org.hisp.dhis.programrule.ProgramRuleActionType</param>
-            <param name="type">12</param>
-        </type>
+      <type name="org.hibernate.type.EnumType">
+        <param name="enumClass">org.hisp.dhis.programrule.ProgramRuleActionType</param>
+        <param name="type">12</param>
+      </type>
     </property>
 
-    <many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" 
-        column="dataelementid" foreign-key="fk_programruleaction_dataelement" />
+    <many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement"
+      column="dataelementid" foreign-key="fk_programruleaction_dataelement" />
 
-	<many-to-one name="programStageSection" class="org.hisp.dhis.program.ProgramStageSection"
-		column="programstagesectionid" foreign-key="fk_programruleaction_programstagesection" />
+    <many-to-one name="programStageSection" class="org.hisp.dhis.program.ProgramStageSection"
+      column="programstagesectionid" foreign-key="fk_programruleaction_programstagesection" />
 
     <property name="location" />
-   
+
     <property name="content" type="text" />
-    
+
     <property name="data" type="text" />
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleVariable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleVariable.hbm.xml	2015-04-28 16:43:41 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleVariable.hbm.xml	2015-05-13 02:28:26 +0000
@@ -13,29 +13,28 @@
     <id name="id" column="programrulevariableid">
       <generator class="native" />
     </id>
-
     &identifiableProperties;
 
     <property name="name" column="name" not-null="true" length="230" />
 
-    <many-to-one name="program" class="org.hisp.dhis.program.Program" 
-       	column="programid" foreign-key="fk_programrulevariable_program" not-null="true" />
-    
+    <many-to-one name="program" class="org.hisp.dhis.program.Program"
+      column="programid" foreign-key="fk_programrulevariable_program" not-null="true" />
+
     <property name="sourceType" column="sourcetype" not-null="true">
-        <type name="org.hibernate.type.EnumType">
-            <param name="enumClass">org.hisp.dhis.programrule.ProgramRuleVariableSourceType</param>
-            <param name="type">12</param>
-        </type>
+      <type name="org.hibernate.type.EnumType">
+        <param name="enumClass">org.hisp.dhis.programrule.ProgramRuleVariableSourceType</param>
+        <param name="type">12</param>
+      </type>
     </property>
-    
-    <many-to-one name="attribute" class="org.hisp.dhis.trackedentity.TrackedEntityAttribute" 
-        column="trackedentityattributeid" foreign-key="fk_programrulevariable_trackedentityattribute" />
-    
-    <many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" 
-        column="dataelementid" foreign-key="fk_programrulevariable_dataelement" />
-     
-    <many-to-one name="programStage" class="org.hisp.dhis.program.ProgramStage" 
-        column="programstageid" foreign-key="fk_programrulevariable_programstage" />
-        
+
+    <many-to-one name="attribute" class="org.hisp.dhis.trackedentity.TrackedEntityAttribute"
+      column="trackedentityattributeid" foreign-key="fk_programrulevariable_trackedentityattribute" />
+
+    <many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement"
+      column="dataelementid" foreign-key="fk_programrulevariable_dataelement" />
+
+    <many-to-one name="programStage" class="org.hisp.dhis.program.ProgramStage"
+      column="programstageid" foreign-key="fk_programrulevariable_programstage" />
+
   </class>
 </hibernate-mapping>