dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41082
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20906: Some renaming and a new action type - WIP
------------------------------------------------------------
revno: 20906
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-10-30 16:13:52 +0100
message:
Some renaming and a new action type - WIP
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleAction.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleActionType.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleAction.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionStoreTest.java
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js
--
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/ProgramRuleAction.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleAction.java 2015-10-13 10:07:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleAction.java 2015-10-30 15:13:52 +0000
@@ -43,6 +43,7 @@
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.program.ProgramIndicator;
+import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageSection;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
@@ -127,6 +128,11 @@
* The program stage section that is affected by the rule action.
*/
private ProgramStageSection programStageSection;
+
+ /**
+ * The program stage that is affected by the rule action.
+ */
+ private ProgramStage programStage;
/**
* Used to determine which widget to display data for the two action types:
@@ -158,13 +164,17 @@
}
public ProgramRuleAction( String name, ProgramRule programRule, ProgramRuleActionType programRuleActionType,
- DataElement dataElement, TrackedEntityAttribute attribute, ProgramIndicator programIndicator, String location, String content, String data )
+ DataElement dataElement, TrackedEntityAttribute attribute,
+ ProgramStageSection programStageSection, ProgramStage programStage,
+ ProgramIndicator programIndicator, String location, String content, String data )
{
this.name = name;
this.programRule = programRule;
this.programRuleActionType = programRuleActionType;
this.dataElement = dataElement;
this.attribute = attribute;
+ this.programStageSection = programStageSection;
+ this.programStage = programStage;
this.programIndicator = programIndicator;
this.location = location;
this.content = content;
@@ -248,6 +258,19 @@
return programStageSection;
}
+ public void setProgramStage( ProgramStage programStage )
+ {
+ this.programStage = programStage;
+ }
+
+ @JsonProperty
+ @JsonSerialize( as = BaseIdentifiableObject.class )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public ProgramStage getProgramStage()
+ {
+ return programStage;
+ }
+
public void setProgramStageSection( ProgramStageSection programStageSection )
{
this.programStageSection = programStageSection;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleActionType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleActionType.java 2015-05-08 13:46:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programrule/ProgramRuleActionType.java 2015-10-30 15:13:52 +0000
@@ -36,9 +36,10 @@
DISPLAYKEYVALUEPAIR( "displaykeyvaluepair" ),
HIDEFIELD( "hidefield" ),
HIDESECTION( "hidesection" ),
- ASSIGNVARIABLE( "assignvariable" ),
+ ASSIGN( "assign" ),
SHOWWARNING( "showwarning" ),
- SHOWERROR( "showerror" );
+ SHOWERROR( "showerror" ),
+ CREATEEVENT("createevent");
final String value;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleAction.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleAction.hbm.xml 2015-10-13 10:07:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleAction.hbm.xml 2015-10-30 15:13:52 +0000
@@ -37,6 +37,9 @@
<many-to-one name="programStageSection" class="org.hisp.dhis.program.ProgramStageSection"
column="programstagesectionid" foreign-key="fk_programruleaction_programstagesection" />
+ <many-to-one name="programStage" class="org.hisp.dhis.program.ProgramStage"
+ column="programstageid" foreign-key="fk_programruleaction_programstage" />
+
<property name="location" />
<property name="content" type="text" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionServiceTest.java 2015-10-13 10:07:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionServiceTest.java 2015-10-30 15:13:52 +0000
@@ -34,13 +34,17 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageService;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
import org.junit.Test;
@@ -55,6 +59,7 @@
private TrackedEntityAttribute attributeA;
private DataElement dataElementA;
private Program programA;
+ private ProgramStage programStageA;
@Autowired
private ProgramRuleService programRuleService;
@@ -71,10 +76,17 @@
@Autowired
private ProgramService programService;
+ @Autowired
+ private ProgramStageService programStageService;
+
@Override
public void setUpTest()
{
- programA = createProgram( 'A', null, null );
+
+ programStageA = createProgramStage( 'A', 0 );
+ Set<ProgramStage> programStages = new HashSet<>();
+ programStages.add( programStageA );
+ programA = createProgram( 'A', programStages, null );
programRuleA = createProgramRule( 'A', programA );
programRuleB = createProgramRule( 'B', programA );
programRuleC = createProgramRule( 'C', programA );
@@ -82,6 +94,7 @@
attributeA = createTrackedEntityAttribute('a');
programService.addProgram( programA );
+ programStageService.saveProgramStage(programStageA);
programRuleService.addProgramRule( programRuleA );
programRuleService.addProgramRule( programRuleB );
programRuleService.addProgramRule( programRuleC );
@@ -92,30 +105,33 @@
@Test
public void testAddGet()
{
- ProgramRuleAction actionA = new ProgramRuleAction( "ActionA", programRuleA, ProgramRuleActionType.ASSIGNVARIABLE, null, null, null, null, "$myvar", "true");
- ProgramRuleAction actionB = new ProgramRuleAction( "ActionB", programRuleA, ProgramRuleActionType.DISPLAYTEXT, null, null, null, "con","Hello", "$placeofliving");
- ProgramRuleAction actionC = new ProgramRuleAction( "ActionC", programRuleA, ProgramRuleActionType.HIDEFIELD, dataElementA, null, null, null, null, null);
- ProgramRuleAction actionD = new ProgramRuleAction( "ActionC", programRuleA, ProgramRuleActionType.HIDEFIELD, null, attributeA, null, null, null, null);
+ ProgramRuleAction actionA = new ProgramRuleAction( "ActionA", programRuleA, ProgramRuleActionType.ASSIGN, null, null, null, null, null, null, "$myvar", "true");
+ ProgramRuleAction actionB = new ProgramRuleAction( "ActionB", programRuleA, ProgramRuleActionType.DISPLAYTEXT, null, null, null, null, null, "con","Hello", "$placeofliving");
+ ProgramRuleAction actionC = new ProgramRuleAction( "ActionC", programRuleA, ProgramRuleActionType.HIDEFIELD, dataElementA, null, null, null, null, null, null, null);
+ ProgramRuleAction actionD = new ProgramRuleAction( "ActionD", programRuleA, ProgramRuleActionType.HIDEFIELD, null, attributeA, null, null, null, null, null, null);
+ ProgramRuleAction actionE = new ProgramRuleAction( "ActionE", programRuleA, ProgramRuleActionType.CREATEEVENT, null, null, null, programStageA, null, null, null, "{wqpUVEeJR3D:30,mrVkW9h2Rdp:'live'}");
int idA = actionService.addProgramRuleAction( actionA );
int idB = actionService.addProgramRuleAction( actionB );
int idC = actionService.addProgramRuleAction( actionC );
int idD = actionService.addProgramRuleAction( actionD );
+ int idE = actionService.addProgramRuleAction( actionE );
assertEquals( actionA, actionService.getProgramRuleAction( idA ) );
assertEquals( actionB, actionService.getProgramRuleAction( idB ) );
assertEquals( actionC, actionService.getProgramRuleAction( idC ) );
assertEquals( actionD, actionService.getProgramRuleAction( idD ) );
+ assertEquals( actionE, actionService.getProgramRuleAction( idE ) );
}
@Test
public void testGetByProgram()
{
- ProgramRuleAction actionD = new ProgramRuleAction( "ActionD", programRuleB, ProgramRuleActionType.ASSIGNVARIABLE, null, null, null, null, "$myvar", "true");
- ProgramRuleAction actionE = new ProgramRuleAction( "ActionE", programRuleB, ProgramRuleActionType.DISPLAYTEXT, null, null, null, "con","Hello", "$placeofliving");
- ProgramRuleAction actionF = new ProgramRuleAction( "ActionF", programRuleB, ProgramRuleActionType.HIDEFIELD, dataElementA, null, null, null, null, null);
+ ProgramRuleAction actionD = new ProgramRuleAction( "ActionD", programRuleB, ProgramRuleActionType.ASSIGN, null, null, null, null, null, null, "$myvar", "true");
+ ProgramRuleAction actionE = new ProgramRuleAction( "ActionE", programRuleB, ProgramRuleActionType.DISPLAYTEXT, null, null, null, null, null, "con","Hello", "$placeofliving");
+ ProgramRuleAction actionF = new ProgramRuleAction( "ActionF", programRuleB, ProgramRuleActionType.HIDEFIELD, dataElementA, null, null, null, null, null, null, null);
//Add an action that is not part of programRuleB....
- ProgramRuleAction actionG = new ProgramRuleAction( "ActionG", programRuleC, ProgramRuleActionType.HIDEFIELD, dataElementA, null, null, null, null, null);
+ ProgramRuleAction actionG = new ProgramRuleAction( "ActionG", programRuleC, ProgramRuleActionType.HIDEFIELD, dataElementA, null, null, null, null, null, null, null);
actionService.addProgramRuleAction( actionD );
actionService.addProgramRuleAction( actionE );
@@ -136,7 +152,7 @@
@Test
public void testUpdate()
{
- ProgramRuleAction actionH = new ProgramRuleAction( "ActionH", programRuleB, ProgramRuleActionType.ASSIGNVARIABLE, null, null, null, null, "$myvar", "true");
+ ProgramRuleAction actionH = new ProgramRuleAction( "ActionH", programRuleB, ProgramRuleActionType.ASSIGN, null, null, null, null, null, null, "$myvar", "true");
int idH = actionService.addProgramRuleAction( actionH );
@@ -155,8 +171,8 @@
@Test
public void testDeleteProgramRuleVariable()
{
- ProgramRuleAction actionI = new ProgramRuleAction( "ActionI", programRuleA, ProgramRuleActionType.ASSIGNVARIABLE, null, null, null, null, "$myvar", "true");
- ProgramRuleAction actionJ = new ProgramRuleAction( "ActionJ", programRuleA, ProgramRuleActionType.DISPLAYTEXT, null, null, null, "con","Hello", "$placeofliving");
+ ProgramRuleAction actionI = new ProgramRuleAction( "ActionI", programRuleA, ProgramRuleActionType.ASSIGN, null, null, null, null, null, null, "$myvar", "true");
+ ProgramRuleAction actionJ = new ProgramRuleAction( "ActionJ", programRuleA, ProgramRuleActionType.DISPLAYTEXT, null, null, null, null, null, "con","Hello", "$placeofliving");
int idI = actionService.addProgramRuleAction( actionI );
int idJ = actionService.addProgramRuleAction( actionJ );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionStoreTest.java 2015-10-13 10:07:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionStoreTest.java 2015-10-30 15:13:52 +0000
@@ -75,9 +75,9 @@
@Test
public void testGetByProgram()
{
- ProgramRuleAction actionA = new ProgramRuleAction( "ActionA", programRuleA, ProgramRuleActionType.ASSIGNVARIABLE, null, null, null, null, "$myvar", "true");
- ProgramRuleAction actionB = new ProgramRuleAction( "ActionB", programRuleA, ProgramRuleActionType.DISPLAYTEXT, null, null, null, "con","Hello", "$placeofliving");
- ProgramRuleAction actionC = new ProgramRuleAction( "ActionC", programRuleA, ProgramRuleActionType.HIDEFIELD, dataElementA, null, null, null, null, null);
+ ProgramRuleAction actionA = new ProgramRuleAction( "ActionA", programRuleA, ProgramRuleActionType.ASSIGN, null, null, null, null, null, null, "$myvar", "true");
+ ProgramRuleAction actionB = new ProgramRuleAction( "ActionB", programRuleA, ProgramRuleActionType.DISPLAYTEXT, null, null, null, null, null, "con","Hello", "$placeofliving");
+ ProgramRuleAction actionC = new ProgramRuleAction( "ActionC", programRuleA, ProgramRuleActionType.HIDEFIELD, dataElementA, null, null, null, null, null, null, null);
actionStore.save( actionA );
actionStore.save( actionB );
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2015-10-20 09:25:25 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2015-10-30 15:13:52 +0000
@@ -478,7 +478,7 @@
function getProgramRules( programRules )
{
- return checkAndGetD2Objects( programRules, 'programRules', '../api/programRules', 'fields=id,name,condition,description,program[id],programStage[id],priority,programRuleActions[id,content,location,data,programRuleActionType,programStageSection[id],dataElement[id],trackedEntityAttribute[id]]');
+ return checkAndGetD2Objects( programRules, 'programRules', '../api/programRules', 'fields=id,name,condition,description,program[id],programStage[id],priority,programRuleActions[id,content,location,data,programRuleActionType,programStageSection[id],dataElement[id],trackedEntityAttribute[id],programIndicator[id],programStage[id]]');
}
function getMetaProgramRuleVariables( programs )
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2015-10-22 11:47:52 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2015-10-30 15:13:52 +0000
@@ -573,7 +573,7 @@
function getProgramRules( programRules )
{
- return checkAndGetD2Objects( programRules, 'programRules', '../api/programRules', 'fields=id,name,condition,description,program[id],programStage[id],priority,programRuleActions[id,content,location,data,programRuleActionType,programStageSection[id],dataElement[id],trackedEntityAttribute[id]]');
+ return checkAndGetD2Objects( programRules, 'programRules', '../api/programRules', 'fields=id,name,condition,description,program[id],programStage[id],priority,programRuleActions[id,content,location,data,programRuleActionType,programStageSection[id],dataElement[id],trackedEntityAttribute[id],programIndicator[id],programStage[id]]');
}
function getMetaProgramRuleVariables( programs )
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-10-26 09:10:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-10-30 15:13:52 +0000
@@ -1542,6 +1542,8 @@
action:action.programRuleActionType,
dataElement:action.dataElement,
trackedEntityAttribute:action.trackedEntityAttribute,
+ programStage: action.programStage,
+ programIndicator: action.programIndicator,
programStageSection: action.programStageSection && action.programStageSection.id ? action.programStageSection.id : null,
content:action.content,
data:action.data,