dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27101
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13442: Aggregation Query Builder
------------------------------------------------------------
revno: 13442
committer: Samta Bajpayee<samta-bajpayee@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-27 12:32:48 +0000
message:
Aggregation Query Builder
added:
local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/GetAggregationParameterAction.java
local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/csv/
local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/csv/action/
local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/csv/action/UploadCSVFileDataAction.java
local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationParam.vm
modified:
local/in/dhis-web-maintenance-ccem/pom.xml
local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/AddAggregationQueryFormAction.java
local/in/dhis-web-maintenance-ccem/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-maintenance-ccem/src/main/resources/struts.xml
local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationQuery.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 'local/in/dhis-web-maintenance-ccem/pom.xml'
--- local/in/dhis-web-maintenance-ccem/pom.xml 2013-12-24 12:32:37 +0000
+++ local/in/dhis-web-maintenance-ccem/pom.xml 2013-12-27 12:32:48 +0000
@@ -50,11 +50,11 @@
<artifactId>dhis-web-commons-resources</artifactId>
<type>war</type>
</dependency>
- <dependency>
+ <!--<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-aggregationengine-default</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>-->
<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-support-external</artifactId>
@@ -90,13 +90,13 @@
<artifactId>DynamicJasper</artifactId>
<version>4.0.0</version>
</dependency>
- <!--
+
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
- -->
+
<dependency>
<groupId>net.sourceforge.javacsv</groupId>
=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/AddAggregationQueryFormAction.java'
--- local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/AddAggregationQueryFormAction.java 2013-12-26 10:29:48 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/AddAggregationQueryFormAction.java 2013-12-27 12:32:48 +0000
@@ -53,7 +53,7 @@
throws Exception
{
lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.CCEI_AGG_TYPE ) );
-
+
dataElementList = new ArrayList<DataElement>( dataElementService.getAllActiveDataElements() );
return SUCCESS;
=== added file 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/GetAggregationParameterAction.java'
--- local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/GetAggregationParameterAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/GetAggregationParameterAction.java 2013-12-27 12:32:48 +0000
@@ -0,0 +1,114 @@
+package org.hisp.dhis.ccem.aggregation.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.coldchain.model.ModelAttributeValue;
+import org.hisp.dhis.coldchain.model.ModelAttributeValueService;
+import org.hisp.dhis.coldchain.model.ModelTypeAttribute;
+import org.hisp.dhis.coldchain.model.ModelTypeAttributeOption;
+import org.hisp.dhis.coldchain.model.ModelTypeAttributeService;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.lookup.Lookup;
+import org.hisp.dhis.lookup.LookupService;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetAggregationParameterAction implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+ private LookupService lookupService;
+
+ public void setLookupService(LookupService lookupService)
+ {
+ this.lookupService = lookupService;
+ }
+
+ private OptionService optionService;
+
+ public void setOptionService(OptionService optionService) {
+ this.optionService = optionService;
+ }
+ private ModelAttributeValueService modelAttributeValueService;
+
+ public void setModelAttributeValueService(
+ ModelAttributeValueService modelAttributeValueService) {
+ this.modelAttributeValueService = modelAttributeValueService;
+ }
+
+ private ModelTypeAttributeService modelTypeAttributeService;
+
+ public void setModelTypeAttributeService(
+ ModelTypeAttributeService modelTypeAttributeService) {
+ this.modelTypeAttributeService = modelTypeAttributeService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input/ Output
+ // -------------------------------------------------------------------------
+ private String aggTypeId;
+
+ public void setAggTypeId(String aggTypeId) {
+ this.aggTypeId = aggTypeId;
+ }
+
+ private Map<String,List<String>> lookUpParamMap;
+
+ public Map<String, List<String>> getLookUpParamMap() {
+ return lookUpParamMap;
+ }
+ List<Lookup> lookups;
+
+ public List<Lookup> getLookups()
+ {
+ return lookups;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+ public String execute()
+ throws Exception
+ {
+ Lookup lookup = lookupService.getLookup(Integer.parseInt(aggTypeId));
+ String lookupType = lookup.getName();
+
+ lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( lookupType ) );
+
+ lookUpParamMap = new HashMap<String,List<String>>();
+ for(Lookup lp : lookups)
+ {
+ if(lp.getName().equalsIgnoreCase("optionset"))
+ {
+ OptionSet os = optionService.getOptionSet(Integer.parseInt(lp.getValue()));
+
+ lookUpParamMap.put(lp.getName(), os.getOptions());
+ }
+ if(lp.getName().equalsIgnoreCase("modeltypeattribute"))
+ {
+ ModelTypeAttribute mtAttribute = modelTypeAttributeService.getModelTypeAttribute(Integer.parseInt(lp.getValue()));
+
+ List<ModelAttributeValue> modelAttValueList = new ArrayList<ModelAttributeValue>( modelAttributeValueService.getAllModelAttributeValuesByModelTypeAttribute(mtAttribute) );
+
+ List<String> modelNameList = new ArrayList<String>();
+
+ for(ModelAttributeValue maValue : modelAttValueList)
+ {
+ modelNameList.add(maValue.getValue());
+ }
+
+ lookUpParamMap.put(lp.getName(), modelNameList);
+ }
+ }
+
+ return SUCCESS;
+ }
+}
=== added directory 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/csv'
=== added directory 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/csv/action'
=== added file 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/csv/action/UploadCSVFileDataAction.java'
--- local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/csv/action/UploadCSVFileDataAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/csv/action/UploadCSVFileDataAction.java 2013-12-27 12:32:48 +0000
@@ -0,0 +1,68 @@
+package org.hisp.dhis.ccem.csv.action;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import au.com.bytecode.opencsv.CSVReader;
+
+import com.opensymphony.xwork2.Action;
+
+public class UploadCSVFileDataAction implements Action {
+
+ private File importData;
+
+ public void setImportData(File importData) {
+ this.importData = importData;
+ }
+
+ public String execute() {
+ try {
+
+ //System.out.println(importData);
+ InputStream in = new FileInputStream(importData);
+
+ CSVReader csvReader = new CSVReader(new FileReader(importData), ',');
+
+ //String[] header = csvReader.readNext();
+
+ List allRows = new ArrayList<String>();
+ String[] row = null;
+
+ //allRows = csvReader.readAll();
+ while ((row = csvReader.readNext()) != null)
+ {
+ allRows.add(row);
+ //System.out.println( row );
+ }
+ importCSVData(allRows);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ return SUCCESS;
+ }
+
+ public String importCSVData( List csvRows ) throws Exception
+ {
+ String nodeHeader = "NodeID";
+ int nodeId = -1;
+
+ for ( Object obj : csvRows)
+ {
+ String[] oneRow = (String[]) obj;
+ for(int i=0;i<=7;i++)
+ {
+ if(oneRow[i] != null && oneRow.length >= i && nodeHeader.equalsIgnoreCase(oneRow[i]))
+ {
+ nodeId = i;
+ }
+ }
+ System.out.println(oneRow[0]);
+ }
+ return null;
+ }
+}
=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-maintenance-ccem/src/main/resources/META-INF/dhis/beans.xml 2013-12-26 10:29:48 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/resources/META-INF/dhis/beans.xml 2013-12-27 12:32:48 +0000
@@ -745,6 +745,15 @@
scope="prototype">
<property name="lookupService" ref="org.hisp.dhis.lookup.LookupService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- </bean>
-
+ </bean>
+
+ <bean id="org.hisp.dhis.ccem.aggregation.action.GetAggregationParameterAction"
+ class="org.hisp.dhis.ccem.aggregation.action.GetAggregationParameterAction"
+ scope="prototype">
+ <property name="lookupService" ref="org.hisp.dhis.lookup.LookupService" />
+ <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
+ <property name="modelTypeAttributeService" ref="org.hisp.dhis.coldchain.model.ModelTypeAttributeService" />
+ <property name="modelAttributeValueService" ref="org.hisp.dhis.coldchain.model.ModelAttributeValueService" />
+ </bean>
+
</beans>
\ No newline at end of file
=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/resources/struts.xml'
--- local/in/dhis-web-maintenance-ccem/src/main/resources/struts.xml 2013-12-26 10:29:48 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/resources/struts.xml 2013-12-27 12:32:48 +0000
@@ -679,6 +679,10 @@
<param name="menu">/dhis-web-maintenance-ccem/menu.vm</param>
<param name="javascripts">javascript/aggregationEngine.js</param>
</action>
-
+
+ <action name="loadAggregationParam" class="org.hisp.dhis.ccem.aggregation.action.GetAggregationParameterAction">
+ <result name="success" type="velocity">/content.vm</result>
+ <param name="page">/dhis-web-maintenance-ccem/addAggregationParam.vm</param>
+ </action>
</package>
</struts>
\ No newline at end of file
=== added file 'local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationParam.vm'
--- local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationParam.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationParam.vm 2013-12-27 12:32:48 +0000
@@ -0,0 +1,15 @@
+<table style="width:100%" cellpadding="5" cellspacing="5">
+#foreach($lookup in $lookups)
+ <tr >
+ #set($parameterList = $lookUpParamMap.get($lookup.name))
+ <td style="width:40%">$lookup.name </td>
+ <td style="width:60%">
+ <select id="$lookup.name" style="width:100%" multiple>
+ #foreach($param in $parameterList)
+ <option value="$param">$param</option>
+ #end
+ </select>
+ </td>
+ </tr>
+#end
+</table>
\ No newline at end of file
=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationQuery.vm'
--- local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationQuery.vm 2013-12-26 10:29:48 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationQuery.vm 2013-12-27 12:32:48 +0000
@@ -1,6 +1,20 @@
+<script >
+function getParameters()
+{
+ if($("#aggType").val() != '-1')
+ {
+ $("#loadParameters").load("loadAggregationParam.action",
+ {
+ aggTypeId : $('#aggType').val()
+ }
+ , function( ){
+ });
+ }
+}
+</script>
<form id="addAggregationForm" action="addAggregationQuery.action" method="post" >
-<table>
+<table style="width:50%" cellpadding="5" cellspacing="5">
<thead>
<tr>
<th colspan="2">$i18n.getString( "aggregation_query_builder_detail" )</th>
@@ -9,13 +23,13 @@
<tbody>
<tr>
- <td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="name" name="name" class="{validate:{required:true,minlength:2}}"></td>
+ <td style="width:40%"><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td style="width:60%"><input type="text" id="name" name="name" class="{validate:{required:true,minlength:2}}" style='width:100%; margin-bottom:-5px;'></td>
</tr>
<tr>
- <td><label for="dataElement">$i18n.getString( "dataelement" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td>
- <select style='width:20px; margin-bottom:-5px;height:20px;' id="dataElementId" name="dataElementId" >
+ <td style="width:40%"><label for="dataElement">$i18n.getString( "dataelement" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td style="width:60%">
+ <select style='width:100%; margin-bottom:-5px;' id="dataElementId" name="dataElementId" >
#foreach( $dataElement in $dataElementList )
<option value="$dataElement.id">$dataElement.name</option>
#end
@@ -23,16 +37,21 @@
</td>
</tr>
<tr>
- <td><label for="operator">$i18n.getString( "type" )</label></td>
- <td>
- <select style='width:20px; margin-bottom:-5px;height:20px;' id="aggType" name="aggType" >
+ <td style="width:40%"><label for="operator">$i18n.getString( "type" )</label></td>
+ <td style="width:60%">
+ <select style='width:100%; margin-bottom:-5px;' id="aggType" name="aggType" onchange="getParameters()">
+ <option value="-1" >Please Select</option>
#foreach( $lookup in $lookups )
<option value="$lookup.id">$lookup.value</option>
#end
</select>
</td>
</tr>
-
+ <tr>
+ <td colspan="2">
+ <div id="loadParameters" style="width:100%"></div>
+ </td>
+ </tr>
</tbody>
</table>