dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41339
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21054: Added program indicator > legend set association
------------------------------------------------------------
revno: 21054
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-11-14 20:06:53 +0100
message:
Added program indicator > legend set association
modified:
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramIndicator.hbm.xml
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/UpdateProgramIndicatorAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramIndicator.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramIndicator.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-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramIndicator.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramIndicator.hbm.xml 2015-10-11 21:39:47 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramIndicator.hbm.xml 2015-11-14 19:06:53 +0000
@@ -34,9 +34,12 @@
<param name="type">12</param>
</type>
</property>
-
+
<property name="decimals" />
+ <many-to-one name="legendSet" class="org.hisp.dhis.legend.LegendSet" column="legendsetid"
+ foreign-key="fk_programindicator_legendset" />
+
<property name="displayInForm" />
<!-- Access properties -->
=== 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-10-04 20:41:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/AddProgramIndicatorAction.java 2015-11-14 19:06:53 +0000
@@ -30,10 +30,13 @@
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.analytics.AggregationType;
+import org.hisp.dhis.legend.LegendService;
+import org.hisp.dhis.legend.LegendSet;
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;
@@ -61,6 +64,9 @@
{
this.programIndicatorService = programIndicatorService;
}
+
+ @Autowired
+ private LegendService legendService;
// -------------------------------------------------------------------------
// Setters
@@ -134,6 +140,13 @@
this.decimals = decimals;
}
+ private Integer legendSetId;
+
+ public void setLegendSetId( Integer legendSetId )
+ {
+ this.legendSetId = legendSetId;
+ }
+
private Boolean displayInForm;
public void setDisplayInForm( Boolean displayInForm )
@@ -151,6 +164,8 @@
{
Program program = programService.getProgram( programId );
+ LegendSet legendSet = legendService.getLegendSet( legendSetId );
+
ProgramIndicator indicator = new ProgramIndicator();
indicator.setName( StringUtils.trimToNull( name ) );
indicator.setShortName( StringUtils.trimToNull( shortName ) );
@@ -161,6 +176,7 @@
indicator.setFilter( StringUtils.trimToNull( filter ) );
indicator.setAggregationType( AggregationType.valueOf( aggregationType ) );
indicator.setDecimals( decimals );
+ indicator.setLegendSet( legendSet );
indicator.setDisplayInForm( displayInForm );
programIndicatorService.addProgramIndicator( indicator );
=== 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-10-19 14:29:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorAction.java 2015-11-14 19:06:53 +0000
@@ -35,6 +35,8 @@
import org.hisp.dhis.constant.Constant;
import org.hisp.dhis.constant.ConstantService;
+import org.hisp.dhis.legend.LegendService;
+import org.hisp.dhis.legend.LegendSet;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramIndicator;
import org.hisp.dhis.program.ProgramIndicatorService;
@@ -67,6 +69,9 @@
@Autowired
private ProgramService programService;
+
+ @Autowired
+ private LegendService legendService;
// -------------------------------------------------------------------------
// Setters
@@ -134,6 +139,13 @@
{
return constants;
}
+
+ private List<LegendSet> legendSets = new ArrayList<>();
+
+ public List<LegendSet> getLegendSets()
+ {
+ return legendSets;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -157,13 +169,15 @@
}
expressionAttributes = new ArrayList<>( program.getTrackedEntityAttributes() );
- constants = new ArrayList<>( constantService.getAllConstants() );
+ constants = constantService.getAllConstants();
+ legendSets = legendService.getAllLegendSets();
expressionAttributes = expressionAttributes.stream().filter( ArithmeticValueTypeTrackedEntityAttributeFilter.INSTANCE ).collect( Collectors.toList() );
Collections.sort( expressionAttributes );
Collections.sort( constants );
-
+ Collections.sort( legendSets );
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/UpdateProgramIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/UpdateProgramIndicatorAction.java 2015-10-04 20:41:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/UpdateProgramIndicatorAction.java 2015-11-14 19:06:53 +0000
@@ -30,8 +30,11 @@
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.analytics.AggregationType;
+import org.hisp.dhis.legend.LegendService;
+import org.hisp.dhis.legend.LegendSet;
import org.hisp.dhis.program.ProgramIndicator;
import org.hisp.dhis.program.ProgramIndicatorService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -53,6 +56,9 @@
this.programIndicatorService = programIndicatorService;
}
+ @Autowired
+ private LegendService legendService;
+
// -------------------------------------------------------------------------
// Setters
// -------------------------------------------------------------------------
@@ -120,6 +126,13 @@
this.decimals = decimals;
}
+ private Integer legendSetId;
+
+ public void setLegendSetId( Integer legendSetId )
+ {
+ this.legendSetId = legendSetId;
+ }
+
private Boolean displayInForm;
public void setDisplayInForm( Boolean displayInForm )
@@ -144,6 +157,8 @@
{
ProgramIndicator indicator = programIndicatorService.getProgramIndicator( id );
+ LegendSet legendSet = legendService.getLegendSet( legendSetId );
+
indicator.setName( StringUtils.trimToNull( name ) );
indicator.setShortName( StringUtils.trimToNull( shortName ) );
indicator.setCode( StringUtils.trimToNull( code ) );
@@ -152,6 +167,7 @@
indicator.setFilter( StringUtils.trimToNull( filter ) );
indicator.setAggregationType( AggregationType.valueOf( aggregationType ) );
indicator.setDecimals( decimals );
+ indicator.setLegendSet( legendSet );
indicator.setDisplayInForm( displayInForm );
programIndicatorService.updateProgramIndicator( indicator );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramIndicator.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramIndicator.vm 2015-10-04 20:41:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramIndicator.vm 2015-11-14 19:06:53 +0000
@@ -78,6 +78,17 @@
</td>
<td></td>
</tr>
+ <tr>
+ <td><label>$i18n.getString( 'legend_set' )</label></td>
+ <td>
+ <select id="legendSetId" name="legendSetId">
+ <option value="0">[$i18n.getString('please_select')]</option>
+ #foreach ( $legendSet in $legendSets )
+ <option value="$legendSet.id">$!encoder.htmlEncode( $legendSet.displayName )</option>
+ #end
+ </select>
+ </td>
+ </tr>
<tr>
<td><label for="displayInForm">$i18n.getString( "display_in_form" )</label></td>
<td><input type="checkbox" id="displayInForm" name="displayInForm" value="true"></td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramIndicator.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramIndicator.vm 2015-10-04 20:41:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramIndicator.vm 2015-11-14 19:06:53 +0000
@@ -77,6 +77,17 @@
</select>
</td>
</tr>
+ <tr>
+ <td><label>$i18n.getString( 'legend_set' )</label></td>
+ <td>
+ <select id="legendSetId" name="legendSetId">
+ <option value="0">[$i18n.getString('please_select')]</option>
+ #foreach ( $legendSet in $legendSets )
+ <option value="$legendSet.id"#if( $legendSet.id == $programIndicator.legendSet.id ) selected="selected"#end>$!encoder.htmlEncode( $legendSet.displayName )</option>
+ #end
+ </select>
+ </td>
+ </tr>
<tr>
<td><label for="displayInForm">$i18n.getString( "display_in_form" )</label></td>
<td><input type="checkbox" id="displayInForm" name="displayInForm" value="true"#if( $programIndicator.displayInForm ) checked="checked"#end></td>