dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37225
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19049: Program rule, action, variable, setting name and program fields to not-null
------------------------------------------------------------
revno: 19049
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-04-28 18:43:41 +0200
message:
Program rule, action, variable, setting name and program fields to not-null
modified:
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
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionStoreTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleStoreTest.java
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.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-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-21 15:12:13 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRule.hbm.xml 2015-04-28 16:43:41 +0000
@@ -16,12 +16,12 @@
&identifiableProperties;
- <property name="name" column="name" length="230" />
+ <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" />
+ 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" />
=== 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-04-21 15:12:13 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/programrule/hibernate/ProgramRuleAction.hbm.xml 2015-04-28 16:43:41 +0000
@@ -16,12 +16,12 @@
&identifiableProperties;
- <property name="name" column="name" length="230" />
+ <property name="name" column="name" not-null="true" length="230" />
<many-to-one name="programRule" class="org.hisp.dhis.programrule.ProgramRule"
column="programruleid" foreign-key="fk_programruleaction_programrule" />
- <property name="programRuleActionType" column="actiontype">
+ <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>
=== 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-21 15:12:13 +0000
+++ 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
@@ -16,12 +16,12 @@
&identifiableProperties;
- <property name="name" column="name" length="230" />
+ <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" />
+ column="programid" foreign-key="fk_programrulevariable_program" not-null="true" />
- <property name="sourceType" column="sourcetype">
+ <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>
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionServiceTest.java 2015-03-13 08:24:36 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionServiceTest.java 2015-04-28 16:43:41 +0000
@@ -33,6 +33,8 @@
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.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -45,6 +47,7 @@
private ProgramRule programRuleB;
private ProgramRule programRuleC;
private DataElement dataElementA;
+ private Program programA;
@Autowired
private ProgramRuleService programRuleService;
@@ -54,15 +57,20 @@
@Autowired
private ProgramRuleActionService actionService;
+
+ @Autowired
+ private ProgramService programService;
@Override
public void setUpTest()
{
- programRuleA = createProgramRule( 'A' );
- programRuleB = createProgramRule( 'B' );
- programRuleC = createProgramRule( 'C' );
+ programA = createProgram( 'A', null, null );
+ programRuleA = createProgramRule( 'A', programA );
+ programRuleB = createProgramRule( 'B', programA );
+ programRuleC = createProgramRule( 'C', programA );
dataElementA = createDataElement( 'A' );
+ programService.addProgram( programA );
programRuleService.addProgramRule( programRuleA );
programRuleService.addProgramRule( programRuleB );
programRuleService.addProgramRule( programRuleC );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionStoreTest.java 2015-03-13 08:24:36 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionStoreTest.java 2015-04-28 16:43:41 +0000
@@ -27,42 +27,49 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
-import org.junit.Test;
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementStore;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class ProgramRuleActionStoreTest
extends DhisSpringTest
{
- public ProgramRule programRuleA;
-
- public DataElement dataElementA;
-
+ private ProgramRule programRuleA;
+ private DataElement dataElementA;
+ private Program programA;
@Autowired
public ProgramRuleStore programRuleStore;
@Autowired
- public DataElementStore dataElementStore;
+ public DataElementService dataElementService;
@Autowired
public ProgramRuleActionStore actionStore;
+
+ @Autowired
+ private ProgramService programService;
@Override
public void setUpTest()
{
- programRuleA = createProgramRule( 'A' );
+ programA = createProgram( 'A', null, null );
+ programRuleA = createProgramRule( 'A', programA );
dataElementA = createDataElement( 'A' );
+ programService.addProgram( programA );
programRuleStore.save( programRuleA );
- dataElementStore.save( dataElementA );
+ dataElementService.addDataElement( dataElementA );
}
@Test
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleServiceTest.java 2015-03-13 08:24:36 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleServiceTest.java 2015-04-28 16:43:41 +0000
@@ -56,7 +56,6 @@
private ProgramRuleVariable programRuleVariableA;
private ProgramRuleVariable programRuleVariableB;
-
@Autowired
private ProgramService programService;
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleStoreTest.java 2015-03-13 08:24:36 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleStoreTest.java 2015-04-28 16:43:41 +0000
@@ -27,6 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -43,9 +44,8 @@
public class ProgramRuleStoreTest
extends DhisSpringTest
{
- public Program programA;
-
- public ProgramStage programStageA;
+ private Program programA;
+ private ProgramStage programStageA;
@Autowired
public ProgramStore programStore;
@@ -59,7 +59,7 @@
@Override
public void setUpTest()
{
- programA = createProgram('A', null, null);
+ programA = createProgram('A', null, null );
programStageA = createProgramStage( 'A', 0 );
programStore.save( programA );
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-04-15 20:26:30 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-04-28 16:43:41 +0000
@@ -89,7 +89,9 @@
import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
import org.hisp.dhis.programrule.ProgramRule;
import org.hisp.dhis.programrule.ProgramRuleAction;
+import org.hisp.dhis.programrule.ProgramRuleActionType;
import org.hisp.dhis.programrule.ProgramRuleVariable;
+import org.hisp.dhis.programrule.ProgramRuleVariableSourceType;
import org.hisp.dhis.relationship.RelationshipType;
import org.hisp.dhis.sqlview.SqlView;
import org.hisp.dhis.sqlview.SqlViewType;
@@ -1125,7 +1127,11 @@
OrganisationUnit unit )
{
Set<OrganisationUnit> units = new HashSet<>();
- units.add( unit );
+
+ if ( unit != null )
+ {
+ units.add( unit );
+ }
return createProgram( uniqueCharacter, programStages, null, units );
}
@@ -1168,18 +1174,11 @@
return program;
}
-
- public static ProgramRule createProgramRule ( char uniqueCharacter )
+
+ public static ProgramRule createProgramRule ( char uniqueCharacter, Program parentProgram )
{
ProgramRule programRule = new ProgramRule();
programRule.setName( "ProgramRule" + uniqueCharacter );
-
- return programRule;
- }
-
- public static ProgramRule createProgramRule ( char uniqueCharacter, Program parentProgram )
- {
- ProgramRule programRule = createProgramRule( uniqueCharacter );
programRule.setProgram( parentProgram );
return programRule;
@@ -1189,6 +1188,7 @@
{
ProgramRuleAction programRuleAction = new ProgramRuleAction();
programRuleAction.setName( "ProgramRuleAction" + uniqueCharacter );
+ programRuleAction.setProgramRuleActionType( ProgramRuleActionType.HIDEFIELD );
return programRuleAction;
}
@@ -1201,18 +1201,12 @@
return programRuleAction;
}
- public static ProgramRuleVariable createProgramRuleVariable ( char uniqueCharacter )
+ public static ProgramRuleVariable createProgramRuleVariable ( char uniqueCharacter, Program parentProgram )
{
ProgramRuleVariable programRuleVariable = new ProgramRuleVariable();
programRuleVariable.setName( "ProgramRuleVariable" + uniqueCharacter );
-
- return programRuleVariable;
- }
-
- public static ProgramRuleVariable createProgramRuleVariable ( char uniqueCharacter, Program parentProgram )
- {
- ProgramRuleVariable programRuleVariable = createProgramRuleVariable( uniqueCharacter );
programRuleVariable.setProgram( parentProgram );
+ programRuleVariable.setSourceType( ProgramRuleVariableSourceType.DATAELEMENT_CURRENT_EVENT );
return programRuleVariable;
}