dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26962
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13358: Data entry, making data set category combo availabl in meta data
------------------------------------------------------------
revno: 13358
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-20 22:52:58 +0100
message:
Data entry, making data set category combo availabl in meta data
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionDeletionHandler.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.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/java/org/hisp/dhis/dataelement/DataElementCategoryOptionDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionDeletionHandler.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionDeletionHandler.java 2013-12-20 21:52:58 +0000
@@ -28,8 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Iterator;
-
import org.hisp.dhis.system.deletion.DeletionHandler;
/**
@@ -63,13 +61,10 @@
@Override
public void deleteDataElementCategory( DataElementCategory category )
{
- Iterator<DataElementCategoryOption> iterator = category.getCategoryOptions().iterator();
-
- while ( iterator.hasNext() )
+ for ( DataElementCategoryOption categoryOption : category.getCategoryOptions() )
{
- DataElementCategoryOption categoryOption = iterator.next();
- iterator.remove();
- categoryService.deleteDataElementCategoryOption( categoryOption );
+ categoryOption.getCategories().remove( category );
+ categoryService.updateDataElementCategoryOption( categoryOption );
}
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java 2013-12-20 19:48:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java 2013-12-20 21:52:58 +0000
@@ -30,11 +30,16 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategory;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -98,7 +103,7 @@
{
this.currentUserService = currentUserService;
}
-
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -131,9 +136,9 @@
return indicators;
}
- private Collection<DataSet> dataSets;
+ private List<DataSet> dataSets;
- public Collection<DataSet> getDataSets()
+ public List<DataSet> getDataSets()
{
return dataSets;
}
@@ -158,6 +163,20 @@
{
return emptyOrganisationUnits;
}
+
+ private List<DataElementCategoryCombo> categoryCombos;
+
+ public List<DataElementCategoryCombo> getCategoryCombos()
+ {
+ return categoryCombos;
+ }
+
+ private List<DataElementCategory> categories;
+
+ public List<DataElementCategory> getCategories()
+ {
+ return categories;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -194,8 +213,28 @@
organisationUnitAssociationSetMap = organisationUnitSet.getOrganisationUnitAssociationSetMap();
- dataSets = dataSetService.getDataSetsByUid( organisationUnitSet.getDistinctDataSets() );
+ dataSets = new ArrayList<DataSet>( dataSetService.getDataSetsByUid( organisationUnitSet.getDistinctDataSets() ) );
+ Set<DataElementCategoryCombo> categoryComboSet = new HashSet<DataElementCategoryCombo>();
+ Set<DataElementCategory> categorySet = new HashSet<DataElementCategory>();
+
+ for ( DataSet dataSet : dataSets )
+ {
+ categoryComboSet.add( dataSet.getCategoryCombo() );
+ }
+
+ for ( DataElementCategoryCombo categoryCombo : categoryComboSet )
+ {
+ categorySet.addAll( categoryCombo.getCategories() );
+ }
+
+ categoryCombos = new ArrayList<DataElementCategoryCombo>( categoryComboSet );
+ categories = new ArrayList<DataElementCategory>( categorySet );
+
+ Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );
+ Collections.sort( categoryCombos, IdentifiableObjectNameComparator.INSTANCE );
+ Collections.sort( categories, IdentifiableObjectNameComparator.INSTANCE );
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm 2013-12-09 21:32:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm 2013-12-20 21:52:58 +0000
@@ -13,8 +13,7 @@
"dataElements": {
#set( $size = $dataElements.size() )
#foreach( $dataElement in $dataElements )
-"${dataElement.uid}":"$encoder.jsonEncode( ${dataElement.getDetailedNumberType()} )"
-#if( $velocityCount < $size ),#end
+"${dataElement.uid}":"$encoder.jsonEncode( ${dataElement.getDetailedNumberType()} )"#if( $velocityCount < $size ),#end
#end },
"optionSets": {
@@ -31,15 +30,14 @@
"indicatorFormulas": {
#set( $size = $indicators.size() )
#foreach( $indicator in $indicators )
-"${indicator.uid}":"($!{indicator.explodedNumerator})/($!{indicator.explodedDenominator})*($!{indicator.indicatorType.factor})"
-#if( $velocityCount < $size ),#end
+"${indicator.uid}":"($!{indicator.explodedNumerator})/($!{indicator.explodedDenominator})*($!{indicator.indicatorType.factor})"#if( $velocityCount < $size ),#end
#end },
"dataSets": {
#set( $size = $dataSets.size() )
#foreach( $dataSet in $dataSets )
"${dataSet.uid}":{"name":"$encoder.jsonEncode( ${dataSet.displayName} )","periodType":"$encoder.jsonEncode( ${dataSet.periodType.name} )",
-"version":"${dataSet.version}","type":"${dataSet.getDataSetType()}","expiryDays":"${dataSet.expiryDays}",
+"categoryCombo":"${dataSet.categoryCombo.uid}","version":"${dataSet.version}","type":"${dataSet.getDataSetType()}","expiryDays":"${dataSet.expiryDays}",
"allowFuturePeriods":${dataSet.allowFuturePeriods},"fieldCombinationRequired":${dataSet.fieldCombinationRequired},"validCompleteOnly":${dataSet.validCompleteOnly},
"skipOffline":${dataSet.skipOffline}, "renderAsTabs":${dataSet.renderAsTabs}, "renderHorizontally":${dataSet.renderHorizontally}
}#if( $velocityCount < $size ),#end
@@ -62,4 +60,28 @@
#foreach( $orgUnit in $organisationUnitAssociationSetMap.keySet() )
"${orgUnit}":"$organisationUnitAssociationSetMap.get( ${orgUnit} )"#if( $velocityCount < $size ),#end
#end }
+},
+
+"categoryCombos": {
+#set( $size1 = $categoryCombos.size() )
+#foreach( $categoryCombo in $categoryCombos )
+"${categoryCombo.uid}":{"name":"$encoder.jsonEncode( ${categoryCombo.displayName} )","categories":[
+#set( $size2 = $categoryCombo.categories.size() )
+#foreach( $category in $categoryCombo.categories )
+"${category.uid}"#if( $velocityCount < $size2 ),#end
+#end
+] }#if( $velocityCount < $size1 ),#end
+#end
+},
+
+"categories": {
+#set( $size1 = $categories.size() )
+#foreach( $category in $categories )
+"${category.uid}":{"name":"$encoder.jsonEncode( ${category.displayName} )","options":[
+#set( $size2 = $category.categoryOptions.size() )
+#foreach( $option in $category.categoryOptions )
+{"id":"${option.uid}","name":"$encoder.jsonEncode( ${option.displayName} )"}#if( $velocityCount < $size2 ),#end
+#end
+] }#if( $velocityCount < $size1 ),#end
+#end
} }