dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37739
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19275: Program indicator, including only attributes which can be aggregated for expression
------------------------------------------------------------
revno: 19275
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-06-03 15:37:55 +0200
message:
Program indicator, including only attributes which can be aggregated for expression
added:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableDataElementFilter.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/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/common/ValueType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java 2015-05-11 14:01:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java 2015-06-03 13:37:55 +0000
@@ -37,7 +37,7 @@
* @author Lars Helge Overland
*/
public enum ValueType
-{
+{
TEXT( String.class ),
LONG_TEXT( String.class ),
LETTER( String.class ),
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableDataElementFilter.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableDataElementFilter.java 2015-05-28 18:21:56 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableDataElementFilter.java 2015-06-03 13:37:55 +0000
@@ -29,12 +29,13 @@
*/
-import java.util.HashSet;
import java.util.Set;
+import org.hisp.dhis.commons.filter.Filter;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementDomain;
-import org.hisp.dhis.commons.filter.Filter;
+
+import com.google.common.collect.Sets;
/**
* @author Lars Helge Overland
@@ -42,19 +43,13 @@
public class AggregatableDataElementFilter
implements Filter<DataElement>
{
- private static Set<String> types;
-
- static
- {
- types = new HashSet<>();
- types.add( DataElement.VALUE_TYPE_BOOL );
- types.add( DataElement.VALUE_TYPE_INT );
- types.add( DataElement.VALUE_TYPE_STRING );
- }
-
+ public static final AggregatableDataElementFilter INSTANCE = new AggregatableDataElementFilter();
+
+ private static Set<String> TYPES = Sets.newHashSet( DataElement.VALUE_TYPE_BOOL, DataElement.VALUE_TYPE_INT, DataElement.VALUE_TYPE_STRING );
+
@Override
public boolean retain( DataElement object )
{
- return object != null && types.contains( object.getType() ) && DataElementDomain.AGGREGATE.equals( object.getDomainType() );
+ return object != null && TYPES.contains( object.getType() ) && DataElementDomain.AGGREGATE.equals( object.getDomainType() );
}
}
=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java 2015-06-03 13:37:55 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.system.filter;
+
+/*
+ * 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 java.util.Set;
+
+import org.hisp.dhis.commons.filter.Filter;
+import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
+
+import com.google.common.collect.Sets;
+
+public class AggregatableTrackedEntityAttributeValueFilter
+ implements Filter<TrackedEntityAttribute>
+{
+ public static final AggregatableTrackedEntityAttributeValueFilter INSTANCE = new AggregatableTrackedEntityAttributeValueFilter();
+
+ private static final Set<String> TYPES = Sets.newHashSet( TrackedEntityAttribute.TYPE_NUMBER, TrackedEntityAttribute.TYPE_BOOL );
+
+ @Override
+ public boolean retain( TrackedEntityAttribute object )
+ {
+ return object != null && TYPES.contains( object.getValueType() );
+ }
+}
=== 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-06-02 18:23:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programindicator/GetProgramIndicatorAction.java 2015-06-03 13:37:55 +0000
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
@@ -37,6 +38,9 @@
import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.program.ProgramIndicator;
import org.hisp.dhis.program.ProgramIndicatorService;
+import org.hisp.dhis.system.filter.AggregatableTrackedEntityAttributeValueFilter;
+import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
+import org.hisp.dhis.util.FilterUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -94,7 +98,14 @@
return filter;
}
- private List<Constant> constants;
+ private List<TrackedEntityAttribute> attributes = new ArrayList<>();
+
+ public List<TrackedEntityAttribute> getAttributes()
+ {
+ return attributes;
+ }
+
+ private List<Constant> constants = new ArrayList<>();
public List<Constant> getConstants()
{
@@ -115,6 +126,10 @@
filter = programIndicatorService.getExpressionDescription( programIndicator.getFilter() );
+ attributes = new ArrayList<>( programIndicator.getProgram().getTrackedEntityAttributes() );
+
+ FilterUtils.filter( attributes, AggregatableTrackedEntityAttributeValueFilter.INSTANCE );
+
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/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-06-03 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programIndicatorForm.vm 2015-06-03 13:37:55 +0000
@@ -27,7 +27,7 @@
<select id="expression-program-stage" onChange="getTrackedEntityDataElements('expression');" style="width:35%;margin-right:20px;">
<option value=''>[ $i18n.getString('select_program_stage') ]</option>
#foreach( $programStage in $program.programStages )
- <option value='$programStage.uid'>$programStage.displayName</option>
+ <option value='$programStage.uid'>$programStage.displayName</option>
#end
</select>
<input type='text' id='expression-de-search' onKeyUp="filterExpressionSelect(event, this.value, 'expression-data-elements');" placeholder="$i18n.getString('filter')" />
@@ -56,10 +56,8 @@
<tr>
<td>
<select multiple id="expression-attributes" name="expression-attributes" size="7" style="width:100%" ondblclick="insertAttribute(this,'A');">
- #foreach( $programAttribute in $program.programAttributes )
- #if( $programAttribute.attribute.valueType=='number' )
- <option value='$programAttribute.attribute.uid'>$encoder.htmlEncode($programAttribute.attribute.displayName)</option>
- #end
+ #foreach( $programAttribute in $attributes )
+ <option value='$programAttribute.attribute.uid'>$encoder.htmlEncode($programAttribute.attribute.displayName)</option>
#end
</select>
</td>
@@ -173,7 +171,7 @@
<select id="filter-program-stage" onChange="getTrackedEntityDataElements('filter');" style="width:35%;margin-right:20px;">
<option value=''>[ $i18n.getString('select_program_stage') ]</option>
#foreach( $programStage in $program.programStages )
- <option value='$programStage.uid'>$programStage.displayName</option>
+ <option value='$programStage.uid'>$programStage.displayName</option>
#end
</select>
<input type='text' id='filter-de-search' onKeyUp="filterExpressionSelect(event, this.value, 'filter-data-elements');" placeholder="$i18n.getString('filter')" />
@@ -202,9 +200,7 @@
<td>
<select multiple id="filter-attributes" name="filter-attributes" size="7" style="width:100%" ondblclick="insertAttribute('filter');">
#foreach( $programAttribute in $program.programAttributes )
- #if( $programAttribute.attribute.valueType=='number' )
- <option value='$programAttribute.attribute.uid'>$encoder.htmlEncode($programAttribute.attribute.displayName)</option>
- #end
+ <option value='$programAttribute.attribute.uid'>$encoder.htmlEncode($programAttribute.attribute.displayName)</option>
#end
</select>
</td>