dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36605
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18730: Program indicator. Using assocation between program <> program indicators instead of service call
------------------------------------------------------------
revno: 18730
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-03-29 22:22:47 +0200
message:
Program indicator. Using assocation between program <> program indicators instead of service call
removed:
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorStoreTest.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramIndicatorDeletionHandler.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramIndicatorStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramIndicator.hbm.xml
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/AddProgramIndicatorAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/ShowAddProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programIndicatorForm.vm
--
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/program/ProgramIndicator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2015-03-24 10:52:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2015-03-29 20:22:47 +0000
@@ -74,6 +74,8 @@
public static final String VALID = "valid";
public static final String EXPRESSION_NOT_WELL_FORMED = "expression_not_well_formed";
+
+ private Program program;
private String valueType;
@@ -81,8 +83,6 @@
private String rootDate;
- private Program program;
-
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -92,11 +92,13 @@
setAutoFields();
}
- public ProgramIndicator( String name, String description, String valueType, String expression )
+ public ProgramIndicator( String name, String description, Program program, String valueType, String expression )
{
this();
this.name = name;
this.description = description;
+ this.program = program;
+ program.getProgramIndicators().add( this );
this.valueType = valueType;
this.expression = expression;
}
@@ -106,6 +108,20 @@
// -------------------------------------------------------------------------
@JsonProperty
+ @JsonSerialize( as = BaseIdentifiableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public Program getProgram()
+ {
+ return program;
+ }
+
+ public void setProgram( Program program )
+ {
+ this.program = program;
+ }
+
+ @JsonProperty
@JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getValueType()
@@ -144,20 +160,6 @@
this.rootDate = rootDate;
}
- @JsonProperty
- @JsonSerialize( as = BaseIdentifiableObject.class )
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public Program getProgram()
- {
- return program;
- }
-
- public void setProgram( Program program )
- {
- this.program = program;
- }
-
@Override
public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
{
@@ -169,17 +171,17 @@
if ( strategy.isReplace() )
{
+ program = programIndicator.getProgram();
valueType = programIndicator.getValueType();
expression = programIndicator.getExpression();
rootDate = programIndicator.getRootDate();
- program = programIndicator.getProgram();
}
else if ( strategy.isMerge() )
{
+ program = programIndicator.getProgram() == null ? program : programIndicator.getProgram();
valueType = programIndicator.getValueType() == null ? valueType : programIndicator.getValueType();
expression = programIndicator.getExpression() == null ? expression : programIndicator.getExpression();
rootDate = programIndicator.getRootDate() == null ? rootDate : programIndicator.getRootDate();
- program = programIndicator.getProgram() == null ? program : programIndicator.getProgram();
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java 2015-03-24 10:52:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java 2015-03-29 20:22:47 +0000
@@ -103,14 +103,6 @@
Collection<ProgramIndicator> getAllProgramIndicators();
/**
- * Get {@link ProgramIndicator} of a program
- *
- * @param program Program
- * @return ProgramIndicators belong to the program
- */
- Collection<ProgramIndicator> getProgramIndicators( Program program );
-
- /**
* Calculate an program indicator value based on program instance and an
* indicator defined for a TrackedEntityInstance
*
@@ -124,7 +116,7 @@
* Get indicator values of all program indicators defined for a TrackedEntityInstance
*
* @param programInstance ProgramInstance
- * @return Map<Indicator name, Indicator value>
+ * @return a mapping of indicator display name and indicator value.
*/
Map<String, String> getProgramIndicatorValues( ProgramInstance programInstance );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorStore.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorStore.java 2015-03-29 20:22:47 +0000
@@ -30,20 +30,10 @@
import org.hisp.dhis.common.GenericNameableObjectStore;
-import java.util.Collection;
-
/**
* @author Chau Thu Tran
- * @version $ ProgramIndicatorStore.java Apr 16, 2013 1:15:12 PM $
*/
public interface ProgramIndicatorStore
extends GenericNameableObjectStore<ProgramIndicator>
{
- /**
- * Get {@link ProgramIndicator} of a program
- *
- * @param program Program
- * @return ProgramIndicators belong to the program
- */
- Collection<ProgramIndicator> getByProgram( Program program );
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-03-27 04:16:43 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-03-29 20:22:47 +0000
@@ -180,12 +180,6 @@
}
@Override
- public Collection<ProgramIndicator> getProgramIndicators( Program program )
- {
- return i18n( i18nService, programIndicatorStore.getByProgram( program ) );
- }
-
- @Override
public String getProgramIndicatorValue( ProgramInstance programInstance, ProgramIndicator programIndicator )
{
Double value = getValue( programInstance, programIndicator );
@@ -221,7 +215,7 @@
{
Map<String, String> result = new HashMap<>();
- Collection<ProgramIndicator> programIndicators = programIndicatorStore.getByProgram( programInstance.getProgram() );
+ Collection<ProgramIndicator> programIndicators = new HashSet<>( programInstance.getProgram().getProgramIndicators() );
for ( ProgramIndicator programIndicator : programIndicators )
{
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramIndicatorDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramIndicatorDeletionHandler.java 2015-03-06 11:40:00 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramIndicatorDeletionHandler.java 2015-03-29 20:22:47 +0000
@@ -29,6 +29,7 @@
*/
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import org.hisp.dhis.system.deletion.DeletionHandler;
@@ -36,8 +37,6 @@
/**
* @author Chau Thu Tran
- *
- * @version $ ProgramIndicatorDeletionHandler.java Apr 4, 2014 10:45:58 PM $
*/
public class ProgramIndicatorDeletionHandler
extends DeletionHandler
@@ -62,7 +61,7 @@
@Override
public void deleteProgram( Program program )
{
- Collection<ProgramIndicator> indicators = programIndicatorService.getProgramIndicators( program );
+ Collection<ProgramIndicator> indicators = new HashSet<ProgramIndicator>( program.getProgramIndicators() );
Iterator<ProgramIndicator> iter = indicators.iterator();
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramIndicatorStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramIndicatorStore.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramIndicatorStore.java 2015-03-29 20:22:47 +0000
@@ -28,14 +28,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
-import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramIndicator;
import org.hisp.dhis.program.ProgramIndicatorStore;
-import java.util.Collection;
-
/**
* @author Chau Thu Tran
*/
@@ -43,14 +39,4 @@
extends HibernateIdentifiableObjectStore<ProgramIndicator>
implements ProgramIndicatorStore
{
- // -------------------------------------------------------------------------
- // Implemented methods
- // -------------------------------------------------------------------------
-
- @Override
- @SuppressWarnings( "unchecked" )
- public Collection<ProgramIndicator> getByProgram( Program program )
- {
- return getCriteria( Restrictions.eq( "program", program ) ).list();
- }
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramIndicator.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramIndicator.hbm.xml 2014-04-08 15:44:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramIndicator.hbm.xml 2015-03-29 20:22:47 +0000
@@ -20,7 +20,7 @@
<property name="description" />
<many-to-one name="program" class="org.hisp.dhis.program.Program"
- column="programid" foreign-key="fk_programindicator_program" />
+ column="programid" foreign-key="fk_programindicator_program" not-null="true" />
<property name="valueType" />
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-03-27 23:30:19 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-03-29 20:22:47 +0000
@@ -30,6 +30,7 @@
import static org.hisp.dhis.program.ProgramIndicator.KEY_ATTRIBUTE;
import static org.hisp.dhis.program.ProgramIndicator.KEY_DATAELEMENT;
+import static org.hisp.dhis.program.ProgramIndicator.KEY_CONSTANT;
import static org.hisp.dhis.program.ProgramIndicator.KEY_PROGRAM_VARIABLE;
import static org.hisp.dhis.program.ProgramIndicator.VALUE_TYPE_DATE;
import static org.hisp.dhis.program.ProgramIndicator.VALUE_TYPE_INT;
@@ -38,7 +39,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Map;
@@ -130,8 +130,8 @@
private TrackedEntityAttribute atC;
private TrackedEntityAttribute atD;
- private ProgramIndicator indicatorDate;
- private ProgramIndicator indicatorInt;
+ private ProgramIndicator indicatorA;
+ private ProgramIndicator indicatorB;
private ProgramIndicator indicatorC;
private ProgramIndicator indicatorD;
private ProgramIndicator indicatorE;
@@ -197,7 +197,7 @@
programStageDataElementService.addProgramStageDataElement( stageDataElementD );
// ---------------------------------------------------------------------
- // TrackedEntityInstance & Enrollement
+ // TrackedEntityInstance & Enrollment
// ---------------------------------------------------------------------
TrackedEntityInstance entityInstance = createTrackedEntityInstance( 'A', organisationUnit );
@@ -215,6 +215,8 @@
programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, programA, enrollmentDate, incidenDate,
organisationUnit );
+ //TODO enroll twice?
+
// ---------------------------------------------------------------------
// TrackedEntityAttribute
// ---------------------------------------------------------------------
@@ -250,14 +252,12 @@
Set<ProgramStageInstance> programStageInstances = new HashSet<>();
programStageInstances.add( stageInstanceA );
programStageInstances.add( stageInstanceB );
- programInstance.setProgramStageInstances( programStageInstances );
-
+ programInstance.setProgramStageInstances( programStageInstances );
TrackedEntityDataValue dataValueA = new TrackedEntityDataValue( stageInstanceA, deA, "3" );
TrackedEntityDataValue dataValueB = new TrackedEntityDataValue( stageInstanceA, deB, "2015-03-01" );
TrackedEntityDataValue dataValueC = new TrackedEntityDataValue( stageInstanceB, deA, "5" );
- TrackedEntityDataValue dataValueD = new TrackedEntityDataValue( stageInstanceB, deB, "2015-03-15" );
-
+ TrackedEntityDataValue dataValueD = new TrackedEntityDataValue( stageInstanceB, deB, "2015-03-15" );
dataValueService.saveTrackedEntityDataValue( dataValueA );
dataValueService.saveTrackedEntityDataValue( dataValueB );
@@ -275,65 +275,65 @@
// ProgramIndicator
// ---------------------------------------------------------------------
- indicatorInt = new ProgramIndicator( "IndicatorA", "IndicatorDesA", VALUE_TYPE_INT, "( " + KEY_PROGRAM_VARIABLE + "{"
+ indicatorA = new ProgramIndicator( "IndicatorA", "IndicatorDesA", programA, VALUE_TYPE_INT, "( " + KEY_PROGRAM_VARIABLE + "{"
+ ProgramIndicator.ENROLLMENT_DATE + "} - " + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.INCIDENT_DATE + "} ) / "
+ ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}" );
- indicatorInt.setUid( "UID-DATE" );
- indicatorInt.setShortName( "DATE" );
- indicatorInt.setProgram( programA );
-
- indicatorDate = new ProgramIndicator( "IndicatorB", "IndicatorDesB", ProgramIndicator.VALUE_TYPE_DATE, "70" );
- indicatorDate.setRootDate( ProgramIndicator.INCIDENT_DATE );
- indicatorDate.setUid( "UID-INT" );
- indicatorDate.setShortName( "INT" );
- indicatorDate.setProgram( programA );
-
- indicatorC = new ProgramIndicator( "IndicatorC", "IndicatorDesB", ProgramIndicator.VALUE_TYPE_INT, "0" );
+ indicatorA.setUid( "UID-DATE" );
+ indicatorA.setShortName( "DATE" );
+
+ indicatorB = new ProgramIndicator( "IndicatorB", "IndicatorDesB", programA, ProgramIndicator.VALUE_TYPE_DATE, "70" );
+ indicatorB.setRootDate( ProgramIndicator.INCIDENT_DATE );
+ indicatorB.setUid( "UID-INT" );
+ indicatorB.setShortName( "INT" );
+
+ indicatorC = new ProgramIndicator( "IndicatorC", "IndicatorDesB", programB, ProgramIndicator.VALUE_TYPE_INT, "0" );
indicatorC.setUid( "UID-C" );
indicatorC.setShortName( "C" );
- indicatorC.setProgram( programB );
- indicatorD = new ProgramIndicator( "IndicatorD", "IndicatorDesD", ProgramIndicator.VALUE_TYPE_INT, "0 + A + 4 + " + ProgramIndicator.KEY_PROGRAM_VARIABLE + "{"
+ indicatorD = new ProgramIndicator( "IndicatorD", "IndicatorDesD", programB, ProgramIndicator.VALUE_TYPE_INT, "0 + A + 4 + " + ProgramIndicator.KEY_PROGRAM_VARIABLE + "{"
+ ProgramIndicator.INCIDENT_DATE + "}" );
indicatorD.setUid( "UID-D" );
indicatorD.setShortName( "D" );
- indicatorD.setProgram( programB );
- indicatorE = new ProgramIndicator( "IndicatorE", "IndicatorDesE", VALUE_TYPE_INT,
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "} + " +
+ String expressionE = KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "} + " +
KEY_DATAELEMENT + "{" + psB.getUid() + "." + deA.getUid() + "} - " +
- KEY_ATTRIBUTE + "{" + atA.getUid() + "} + " + KEY_ATTRIBUTE + "{" + atB.getUid() + "}" );
-
- indicatorF = new ProgramIndicator( "IndicatorF", "IndicatorDesF", VALUE_TYPE_INT, "(" +
- KEY_DATAELEMENT + "{" + psB.getUid() + "." + deB.getUid() + "} - " +
+ KEY_ATTRIBUTE + "{" + atA.getUid() + "} + " + KEY_ATTRIBUTE + "{" + atB.getUid() + "}";
+
+ indicatorE = new ProgramIndicator( "IndicatorE", "IndicatorDesE", programB, VALUE_TYPE_INT, expressionE );
+
+ String expressionF = "(" + KEY_DATAELEMENT + "{" + psB.getUid() + "." + deB.getUid() + "} - " +
KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
- KEY_ATTRIBUTE + "{" + atA.getUid() + "} + " + KEY_ATTRIBUTE + "{" + atB.getUid() + "}" );
-
-
- indicatorG = new ProgramIndicator( "IndicatorG", "IndicatorDesG", VALUE_TYPE_INT, "(" +
- KEY_DATAELEMENT + "{" + psB.getUid() + "." + deB.getUid() + "} - " +
+ KEY_ATTRIBUTE + "{" + atA.getUid() + "} + " + KEY_ATTRIBUTE + "{" + atB.getUid() + "}";
+
+ indicatorF = new ProgramIndicator( "IndicatorF", "IndicatorDesF", programB, VALUE_TYPE_INT, expressionF );
+
+ String expressionG = "(" + KEY_DATAELEMENT + "{" + psB.getUid() + "." + deB.getUid() + "} - " +
KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
KEY_ATTRIBUTE + "{" + atA.getUid() + "} + " +
- KEY_ATTRIBUTE + "{" + atB.getUid() + "} * "
- + ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}" );
-
- indicatorH = new ProgramIndicator( "IndicatorH", "IndicatorDesH", VALUE_TYPE_INT, "(" +
- KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "}" );
-
-
- indicatorI = new ProgramIndicator( "IndicatorI", "IndicatorDesI", VALUE_TYPE_DATE, "(" +
- KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "}" );
+ KEY_ATTRIBUTE + "{" + atB.getUid() + "} * " +
+ KEY_CONSTANT + "{" + constantA.getUid() + "}";
+
+ indicatorG = new ProgramIndicator( "IndicatorG", "IndicatorDesG", programB, VALUE_TYPE_INT, expressionG );
+
+ String expressionH = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - " +
+ KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
+ KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "}";
+
+ indicatorH = new ProgramIndicator( "IndicatorH", "IndicatorDesH", programB, VALUE_TYPE_INT, expressionH );
+
+ String expressionI = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - " +
+ KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
+ KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "}";
+
+ indicatorI = new ProgramIndicator( "IndicatorI", "IndicatorDesI", programB, VALUE_TYPE_DATE, expressionI );
indicatorI.setRootDate( ProgramIndicator.INCIDENT_DATE );
- indicatorJ = new ProgramIndicator( "IndicatorJ", "IndicatorDesJ", VALUE_TYPE_DATE, "(" +
- KEY_ATTRIBUTE + "{" + atC.getUid() + "} - " +
+ String expressionJ = "(" + KEY_ATTRIBUTE + "{" + atC.getUid() + "} - " +
KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.ENROLLMENT_DATE + "} ) + " +
KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "} * " +
- ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}" );
+ ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}";
+
+ indicatorJ = new ProgramIndicator( "IndicatorJ", "IndicatorDesJ", programB, VALUE_TYPE_DATE, expressionJ );
indicatorJ.setRootDate( ProgramIndicator.INCIDENT_DATE );
}
@@ -344,8 +344,8 @@
@Test
public void testAddProgramIndicator()
{
- int idA = programIndicatorService.addProgramIndicator( indicatorDate );
- int idB = programIndicatorService.addProgramIndicator( indicatorInt );
+ int idA = programIndicatorService.addProgramIndicator( indicatorA );
+ int idB = programIndicatorService.addProgramIndicator( indicatorB );
assertNotNull( programIndicatorService.getProgramIndicator( idA ) );
assertNotNull( programIndicatorService.getProgramIndicator( idB ) );
@@ -354,18 +354,18 @@
@Test
public void testDeleteProgramIndicator()
{
- int idA = programIndicatorService.addProgramIndicator( indicatorDate );
- int idB = programIndicatorService.addProgramIndicator( indicatorInt );
+ int idA = programIndicatorService.addProgramIndicator( indicatorB );
+ int idB = programIndicatorService.addProgramIndicator( indicatorA );
assertNotNull( programIndicatorService.getProgramIndicator( idA ) );
assertNotNull( programIndicatorService.getProgramIndicator( idB ) );
- programIndicatorService.deleteProgramIndicator( indicatorDate );
+ programIndicatorService.deleteProgramIndicator( indicatorB );
assertNull( programIndicatorService.getProgramIndicator( idA ) );
assertNotNull( programIndicatorService.getProgramIndicator( idB ) );
- programIndicatorService.deleteProgramIndicator( indicatorInt );
+ programIndicatorService.deleteProgramIndicator( indicatorA );
assertNull( programIndicatorService.getProgramIndicator( idA ) );
assertNull( programIndicatorService.getProgramIndicator( idB ) );
@@ -374,12 +374,12 @@
@Test
public void testUpdateProgramIndicator()
{
- int idA = programIndicatorService.addProgramIndicator( indicatorDate );
+ int idA = programIndicatorService.addProgramIndicator( indicatorB );
assertNotNull( programIndicatorService.getProgramIndicator( idA ) );
- indicatorDate.setName( "B" );
- programIndicatorService.updateProgramIndicator( indicatorDate );
+ indicatorB.setName( "B" );
+ programIndicatorService.updateProgramIndicator( indicatorB );
assertEquals( "B", programIndicatorService.getProgramIndicator( idA ).getName() );
}
@@ -387,18 +387,18 @@
@Test
public void testGetProgramIndicatorById()
{
- int idA = programIndicatorService.addProgramIndicator( indicatorDate );
- int idB = programIndicatorService.addProgramIndicator( indicatorInt );
+ int idA = programIndicatorService.addProgramIndicator( indicatorB );
+ int idB = programIndicatorService.addProgramIndicator( indicatorA );
- assertEquals( indicatorDate, programIndicatorService.getProgramIndicator( idA ) );
- assertEquals( indicatorInt, programIndicatorService.getProgramIndicator( idB ) );
+ assertEquals( indicatorB, programIndicatorService.getProgramIndicator( idA ) );
+ assertEquals( indicatorA, programIndicatorService.getProgramIndicator( idB ) );
}
@Test
public void testGetProgramIndicatorByName()
{
- programIndicatorService.addProgramIndicator( indicatorDate );
- programIndicatorService.addProgramIndicator( indicatorInt );
+ programIndicatorService.addProgramIndicator( indicatorB );
+ programIndicatorService.addProgramIndicator( indicatorA );
assertEquals( "IndicatorA", programIndicatorService.getProgramIndicator( "IndicatorA" ).getName() );
assertEquals( "IndicatorB", programIndicatorService.getProgramIndicator( "IndicatorB" ).getName() );
@@ -407,17 +407,17 @@
@Test
public void testGetAllProgramIndicators()
{
- programIndicatorService.addProgramIndicator( indicatorDate );
- programIndicatorService.addProgramIndicator( indicatorInt );
+ programIndicatorService.addProgramIndicator( indicatorB );
+ programIndicatorService.addProgramIndicator( indicatorA );
- assertTrue( equals( programIndicatorService.getAllProgramIndicators(), indicatorDate, indicatorInt ) );
+ assertTrue( equals( programIndicatorService.getAllProgramIndicators(), indicatorB, indicatorA ) );
}
@Test
public void testGetProgramIndicatorByShortName()
{
- programIndicatorService.addProgramIndicator( indicatorDate );
- programIndicatorService.addProgramIndicator( indicatorInt );
+ programIndicatorService.addProgramIndicator( indicatorB );
+ programIndicatorService.addProgramIndicator( indicatorA );
assertEquals( "INT", programIndicatorService.getProgramIndicatorByShortName( "INT" ).getShortName() );
assertEquals( "DATE", programIndicatorService.getProgramIndicatorByShortName( "DATE" ).getShortName() );
@@ -426,31 +426,13 @@
@Test
public void testGetProgramIndicatorByUid()
{
- programIndicatorService.addProgramIndicator( indicatorDate );
- programIndicatorService.addProgramIndicator( indicatorInt );
+ programIndicatorService.addProgramIndicator( indicatorB );
+ programIndicatorService.addProgramIndicator( indicatorA );
assertEquals( "UID-INT", programIndicatorService.getProgramIndicatorByUid( "UID-INT" ).getUid() );
assertEquals( "UID-DATE", programIndicatorService.getProgramIndicatorByUid( "UID-DATE" ).getUid() );
}
- @Test
- public void testGetProgramIndicatorsByProgram()
- {
- programIndicatorService.addProgramIndicator( indicatorDate );
- programIndicatorService.addProgramIndicator( indicatorInt );
- programIndicatorService.addProgramIndicator( indicatorC );
-
- Collection<ProgramIndicator> indicators = programIndicatorService.getProgramIndicators( programA );
- assertEquals( 2, indicators.size() );
- assertTrue( indicators.contains( indicatorDate ) );
- assertTrue( indicators.contains( indicatorInt ) );
-
- indicators = programIndicatorService.getProgramIndicators( programB );
- assertEquals( 1, indicators.size() );
- assertTrue( indicators.contains( indicatorC ) );
-
- }
-
// -------------------------------------------------------------------------
// Logic tests
// -------------------------------------------------------------------------
@@ -479,8 +461,8 @@
@Test
public void testGetProgramIndicatorValue()
{
- programIndicatorService.addProgramIndicator( indicatorDate );
- programIndicatorService.addProgramIndicator( indicatorInt );
+ programIndicatorService.addProgramIndicator( indicatorB );
+ programIndicatorService.addProgramIndicator( indicatorA );
programIndicatorService.addProgramIndicator( indicatorE );
programIndicatorService.addProgramIndicator( indicatorF );
programIndicatorService.addProgramIndicator( indicatorG );
@@ -488,10 +470,10 @@
programIndicatorService.addProgramIndicator( indicatorI );
programIndicatorService.addProgramIndicator( indicatorJ );
- String valueINT = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorInt);
+ String valueINT = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorA);
assertEquals( "10.0", valueINT );
- String valueDATE = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorDate );
+ String valueDATE = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorB );
assertEquals( DateUtils.getMediumDateString( enrollmentDate ), valueDATE );
String valueE = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorE );
@@ -507,26 +489,25 @@
@Test
public void testGetProgramIndicatorValues()
{
- programIndicatorService.addProgramIndicator( indicatorDate );
- programIndicatorService.addProgramIndicator( indicatorInt );
+ programIndicatorService.addProgramIndicator( indicatorA );
+ programIndicatorService.addProgramIndicator( indicatorB );
Map<String, String> indicatorMap = programIndicatorService.getProgramIndicatorValues( programInstance );
assertEquals( 2, indicatorMap.keySet().size() );
assertEquals( "10.0", indicatorMap.get( "IndicatorA" ) );
assertEquals( DateUtils.getMediumDateString( enrollmentDate ), indicatorMap.get( "IndicatorB" ) );
-
}
@Test
public void testGetExpressionDescription()
{
- programIndicatorService.addProgramIndicator( indicatorDate );
- programIndicatorService.addProgramIndicator( indicatorInt );
+ programIndicatorService.addProgramIndicator( indicatorB );
+ programIndicatorService.addProgramIndicator( indicatorA );
- String description = programIndicatorService.getExpressionDescription( indicatorDate.getExpression() );
+ String description = programIndicatorService.getExpressionDescription( indicatorB.getExpression() );
assertEquals( "70", description);
- description = programIndicatorService.getExpressionDescription( indicatorInt.getExpression() );
+ description = programIndicatorService.getExpressionDescription( indicatorA.getExpression() );
assertEquals( "( Enrollment date - Incident date ) / ConstantA", description);
}
@@ -534,12 +515,12 @@
@Test
public void testExpressionIsValid()
{
- programIndicatorService.addProgramIndicator( indicatorDate );
- programIndicatorService.addProgramIndicator( indicatorInt );
+ programIndicatorService.addProgramIndicator( indicatorB );
+ programIndicatorService.addProgramIndicator( indicatorA );
programIndicatorService.addProgramIndicator( indicatorD );
- assertEquals( ProgramIndicator.VALID, programIndicatorService.expressionIsValid( indicatorDate.getExpression() ) );
- assertEquals( ProgramIndicator.VALID, programIndicatorService.expressionIsValid( indicatorInt.getExpression() ) );
+ assertEquals( ProgramIndicator.VALID, programIndicatorService.expressionIsValid( indicatorB.getExpression() ) );
+ assertEquals( ProgramIndicator.VALID, programIndicatorService.expressionIsValid( indicatorA.getExpression() ) );
assertEquals( ProgramIndicator.EXPRESSION_NOT_WELL_FORMED, programIndicatorService.expressionIsValid( indicatorD.getExpression() ) );
}
}
=== removed file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorStoreTest.java 2015-03-24 09:07:34 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorStoreTest.java 1970-01-01 00:00:00 +0000
@@ -1,147 +0,0 @@
-package org.hisp.dhis.program;
-
-/*
- * Copyright (c) 2004-2015, 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.
- */
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
-import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueService;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * @author Chau Thu Tran
- */
-public class ProgramIndicatorStoreTest
- extends DhisSpringTest
-{
- @Autowired
- private ProgramIndicatorStore programIndicatorStore;
-
- @Autowired
- private TrackedEntityInstanceService entityInstanceService;
-
- @Autowired
- private OrganisationUnitService organisationUnitService;
-
- @Autowired
- private ProgramService programService;
-
- @Autowired
- private ProgramStageService programStageService;
-
- @Autowired
- private ProgramInstanceService programInstanceService;
-
- @Autowired
- private TrackedEntityDataValueService dataValueService;
-
- private Program programA;
-
- private Program programB;
-
- private ProgramIndicator indicatorDate;
-
- private ProgramIndicator indicatorInt;
-
- private ProgramIndicator indicatorC;
-
- @Override
- public void setUpTest()
- {
- OrganisationUnit organisationUnit = createOrganisationUnit( 'A' );
- organisationUnitService.addOrganisationUnit( organisationUnit );
-
- programA = createProgram( 'A', new HashSet<ProgramStage>(), organisationUnit );
- programService.addProgram( programA );
-
- ProgramStage stageA = new ProgramStage( "StageA", programA );
- stageA.setSortOrder( 1 );
- programStageService.saveProgramStage( stageA );
-
- ProgramStage stageB = new ProgramStage( "StageB", programA );
- stageB.setSortOrder( 2 );
- programStageService.saveProgramStage( stageB );
-
- Set<ProgramStage> programStages = new HashSet<>();
- programStages.add( stageA );
- programStages.add( stageB );
- programA.setProgramStages( programStages );
- programService.updateProgram( programA );
-
- programB = createProgram( 'B', new HashSet<ProgramStage>(), organisationUnit );
- programService.addProgram( programB );
-
- indicatorDate = new ProgramIndicator( "IndicatorA", "IndicatorDesA", ProgramIndicator.VALUE_TYPE_INT, "( "
- + ProgramIndicator.INCIDENT_DATE + " - " + ProgramIndicator.ENROLLMENT_DATE + " ) / 7" );
- indicatorDate.setUid( "UID-DATE" );
- indicatorDate.setShortName( "DATE" );
- indicatorDate.setProgram( programA );
-
- indicatorInt = new ProgramIndicator( "IndicatorB", "IndicatorDesB", ProgramIndicator.VALUE_TYPE_DATE, "70" );
- indicatorInt.setRootDate( ProgramIndicator.INCIDENT_DATE );
- indicatorInt.setUid( "UID-INT" );
- indicatorInt.setShortName( "INT" );
- indicatorInt.setProgram( programA );
-
- indicatorC = new ProgramIndicator( "IndicatorC", "IndicatorDesB", ProgramIndicator.VALUE_TYPE_INT, "0" );
- indicatorC.setUid( "UID-C" );
- indicatorC.setShortName( "C" );
- indicatorC.setProgram( programB );
- }
-
- // -------------------------------------------------------------------------
- // Tests
- // -------------------------------------------------------------------------
-
- @Test
- public void testGetProgramIndicatorsByProgram()
- {
- programIndicatorStore.save( indicatorDate );
- programIndicatorStore.save( indicatorInt );
- programIndicatorStore.save( indicatorC );
-
- Collection<ProgramIndicator> indicators = programIndicatorStore.getByProgram( programA );
- assertEquals( 2, indicators.size() );
- assertTrue( indicators.contains( indicatorDate ) );
- assertTrue( indicators.contains( indicatorInt ) );
-
- indicators = programIndicatorStore.getByProgram( programB );
- assertEquals( 1, indicators.size() );
- assertTrue( indicators.contains( indicatorC ) );
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java 2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java 2015-03-29 20:22:47 +0000
@@ -42,7 +42,6 @@
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramIndicator;
-import org.hisp.dhis.program.ProgramIndicatorService;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.user.UserGroup;
import org.hisp.dhis.user.UserGroupService;
@@ -82,13 +81,6 @@
this.userGroupService = userGroupService;
}
- private List<PeriodType> periodTypes = new ArrayList<>();
-
- public List<PeriodType> getPeriodTypes()
- {
- return periodTypes;
- }
-
private PeriodService periodService;
public void setPeriodService( PeriodService periodService )
@@ -97,9 +89,6 @@
}
@Autowired
- private ProgramIndicatorService programIndicatorService;
-
- @Autowired
private ConstantService constantService;
// -------------------------------------------------------------------------
@@ -172,6 +161,13 @@
return constants;
}
+ private List<PeriodType> periodTypes = new ArrayList<>();
+
+ public List<PeriodType> getPeriodTypes()
+ {
+ return periodTypes;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -188,7 +184,7 @@
userGroups = new ArrayList<>( userGroupService.getAllUserGroups() );
- programIndicators = new ArrayList<>( programIndicatorService.getProgramIndicators( program ) );
+ programIndicators = new ArrayList<>( program.getProgramIndicators() );
Collections.sort( programIndicators, IdentifiableObjectNameComparator.INSTANCE );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/AddProgramIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/AddProgramIndicatorAction.java 2015-02-18 13:48:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/AddProgramIndicatorAction.java 2015-03-29 20:22:47 +0000
@@ -150,11 +150,10 @@
}
Program program = programService.getProgram( programId );
- ProgramIndicator programIndicator = new ProgramIndicator( name, description, valueType, expression );
+ ProgramIndicator programIndicator = new ProgramIndicator( name, description, program, valueType, expression );
programIndicator.setShortName( shortName );
programIndicator.setCode( code );
programIndicator.setRootDate( rootDate );
- programIndicator.setProgram( program );
programIndicatorService.addProgramIndicator( programIndicator );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorAction.java 2015-02-18 13:48:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorAction.java 2015-03-29 20:22:47 +0000
@@ -106,7 +106,7 @@
description = programIndicatorService.getExpressionDescription( programIndicator.getExpression() );
- constants = new ArrayList<>(constantService.getAllConstants());
+ constants = new ArrayList<>( constantService.getAllConstants() );
Collections.sort( constants, IdentifiableObjectNameComparator.INSTANCE );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorListAction.java 2015-02-18 13:48:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorListAction.java 2015-03-29 20:22:47 +0000
@@ -35,8 +35,8 @@
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramIndicator;
-import org.hisp.dhis.program.ProgramIndicatorService;
import org.hisp.dhis.program.ProgramService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -47,24 +47,9 @@
public class GetProgramIndicatorListAction
implements Action
{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private ProgramIndicatorService programIndicatorService;
-
- public void setProgramIndicatorService( ProgramIndicatorService programIndicatorService )
- {
- this.programIndicatorService = programIndicatorService;
- }
-
+ @Autowired
private ProgramService programService;
- public void setProgramService( ProgramService programService )
- {
- this.programService = programService;
- }
-
// -------------------------------------------------------------------------
// Setters
// -------------------------------------------------------------------------
@@ -100,11 +85,10 @@
{
program = programService.getProgram( programId );
- programIndicators = new ArrayList<>( programIndicatorService.getProgramIndicators( program ) );
+ programIndicators = new ArrayList<>( program.getProgramIndicators() );
Collections.sort( programIndicators, IdentifiableObjectNameComparator.INSTANCE );
return SUCCESS;
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java 2015-03-19 11:14:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java 2015-03-29 20:22:47 +0000
@@ -28,13 +28,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.program.ProgramIndicator;
-import org.hisp.dhis.program.ProgramIndicatorService;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageDataElement;
import org.hisp.dhis.program.ProgramStageService;
@@ -43,11 +47,7 @@
import org.hisp.dhis.user.UserGroupService;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.opensymphony.xwork2.Action;
/**
* @author Abyot Asalefew Gizaw
@@ -83,9 +83,6 @@
}
@Autowired
- private ProgramIndicatorService programIndicatorService;
-
- @Autowired
private AttributeService attributeService;
// -------------------------------------------------------------------------
@@ -179,7 +176,7 @@
userGroups = new ArrayList<>( userGroupService.getAllUserGroups() );
- programIndicators = new ArrayList<>( programIndicatorService.getProgramIndicators( programStage.getProgram() ) );
+ programIndicators = new ArrayList<>( programStage.getProgram().getProgramIndicators() );
programIndicators.removeAll( programStage.getProgramIndicators() );
attributeValues = AttributeUtils.getAttributeValueMap( programStage.getAttributeValues() );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/ShowAddProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/ShowAddProgramStageAction.java 2015-03-26 14:31:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/ShowAddProgramStageAction.java 2015-03-29 20:22:47 +0000
@@ -44,7 +44,6 @@
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramIndicator;
-import org.hisp.dhis.program.ProgramIndicatorService;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.user.UserGroup;
import org.hisp.dhis.user.UserGroupService;
@@ -75,9 +74,6 @@
private PeriodService periodService;
@Autowired
- private ProgramIndicatorService programIndicatorService;
-
- @Autowired
private ConstantService constantService;
@Autowired
@@ -183,7 +179,7 @@
userGroups = new ArrayList<>( userGroupService.getAllUserGroups() );
- programIndicators = new ArrayList<>( programIndicatorService.getProgramIndicators( program ) );
+ programIndicators = new ArrayList<>( program.getProgramIndicators() );
Collections.sort( programIndicators, IdentifiableObjectNameComparator.INSTANCE );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2015-03-19 11:14:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2015-03-29 20:22:47 +0000
@@ -1010,11 +1010,7 @@
<bean
id="org.hisp.dhis.trackedentity.action.programindicator.GetProgramIndicatorListAction"
class="org.hisp.dhis.trackedentity.action.programindicator.GetProgramIndicatorListAction"
- scope="prototype">
- <property name="programIndicatorService"
- ref="org.hisp.dhis.program.ProgramIndicatorService" />
- <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- </bean>
+ scope="prototype"/>
<bean
id="org.hisp.dhis.trackedentity.action.programindicator.UpdateProgramIndicatorAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programIndicatorForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programIndicatorForm.vm 2015-03-11 03:49:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programIndicatorForm.vm 2015-03-29 20:22:47 +0000
@@ -97,18 +97,6 @@
</div>
-<tr>
- <td>
- <br/>
- <a href="javascript:insertOperator( '(' )"><img src="../images/left_parent.png" title="$i18n.getString( 'left_brackets' )"/></a>
- <a href="javascript:insertOperator( ')' )"><img src="../images/right_parent.png" title="$i18n.getString( 'right_brackets' )"/></a>
- <a href="javascript:insertOperator( '*' )"><img src="../images/multiply.png" title="$i18n.getString( 'multiply' )"/></a>
- <a href="javascript:insertOperator( '/' )"><img src="../images/divide.png" title="$i18n.getString( 'divide' )"/></a>
- <a href="javascript:insertOperator( '+' )"><img src="../images/plus.png" title="$i18n.getString( 'plus' )"/></a>
- <a href="javascript:insertOperator( '-' )"><img src="../images/minus.png" title="$i18n.getString( 'minus' )"/></a>
- </td>
-</tr>
-
<p></p>
<table>
<tr>
@@ -120,6 +108,16 @@
</td>
</tr>
<tr>
+ <td>
+ <a href="javascript:insertOperator( '(' )"><img src="../images/left_parent.png" title="$i18n.getString( 'left_brackets' )"/></a>
+ <a href="javascript:insertOperator( ')' )"><img src="../images/right_parent.png" title="$i18n.getString( 'right_brackets' )"/></a>
+ <a href="javascript:insertOperator( '*' )"><img src="../images/multiply.png" title="$i18n.getString( 'multiply' )"/></a>
+ <a href="javascript:insertOperator( '/' )"><img src="../images/divide.png" title="$i18n.getString( 'divide' )"/></a>
+ <a href="javascript:insertOperator( '+' )"><img src="../images/plus.png" title="$i18n.getString( 'plus' )"/></a>
+ <a href="javascript:insertOperator( '-' )"><img src="../images/minus.png" title="$i18n.getString( 'minus' )"/></a><br><br>
+ </td>
+ </tr>
+ <tr>
<th>$i18n.getString( "description" )</th>
</tr>
<tr>