dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02004
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 664: Add new classes for the new functions
------------------------------------------------------------
revno: 664
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2009-09-10 17:56:49 +0700
message:
Add new classes for the new functions
added:
local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/statement/CreateCodeStatement.java
local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/CreateCodeAction.java
local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/responseCode.vm
local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/imports/action/ViewDataAction.java
local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseReportItemValues.vm
modified:
local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/imports.js
--
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.
=== added file 'local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/statement/CreateCodeStatement.java'
--- local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/statement/CreateCodeStatement.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/statement/CreateCodeStatement.java 2009-09-10 10:56:49 +0000
@@ -0,0 +1,53 @@
+package org.hisp.dhis.vn.chr.statement;
+
+import java.text.Format;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+
+import org.hisp.dhis.jdbc.StatementBuilder;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.vn.chr.Egroup;
+import org.hisp.dhis.vn.chr.Element;
+import org.hisp.dhis.vn.chr.Form;
+
+public class CreateCodeStatement extends FormStatement
+{
+
+ // -------------------------------------------------------------------------
+ // Constructor
+ // -------------------------------------------------------------------------
+
+ public CreateCodeStatement( Form form, StatementBuilder statementBuilder)
+ {
+ super( form, statementBuilder );
+ }
+
+ // -------------------------------------------------------------------------
+ // Override
+ // -------------------------------------------------------------------------
+
+ @Override
+ protected void init( Form form )
+ {
+
+ StringBuffer buffer = new StringBuffer();
+
+ // SELECT
+ buffer.append( "SELECT" + SPACE + "COUNT(*)" + SPACE);
+
+
+ // FROM <table_name> WHERE id = <id_column>
+ buffer.append( "FROM" + SPACE + form.getName().toLowerCase() + SPACE);
+ // WHERE
+ Date date = new Date();
+ Format formatter = new SimpleDateFormat( "yyyy-MM" );
+ String period = formatter.format(date);
+
+ buffer.append( "WHERE" + SPACE + "createddate>=" + period + "-" + "01" + SPACE );
+ buffer.append( "AND" + SPACE + "createddate<=" + period + "-" + "31" );
+
+ statement = buffer.toString();
+
+ }
+}
=== added file 'local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/CreateCodeAction.java'
--- local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/CreateCodeAction.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/CreateCodeAction.java 2009-09-10 10:56:49 +0000
@@ -0,0 +1,64 @@
+package org.hisp.dhis.vn.chr.object.action;
+
+import java.text.Format;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.hisp.dhis.system.util.CodecUtils;
+import org.hisp.dhis.vn.chr.Form;
+import org.hisp.dhis.vn.chr.FormService;
+import org.hisp.dhis.vn.chr.jdbc.FormManager;
+
+import com.opensymphony.xwork2.Action;
+
+public class CreateCodeAction
+ implements Action
+{
+
+ private FormManager formManager;
+
+ public void setFormManager( FormManager formManager )
+ {
+ this.formManager = formManager;
+ }
+
+ private FormService formService;
+
+ public void setFormService( FormService formService )
+ {
+ this.formService = formService;
+ }
+
+ private Integer formId;
+
+ public void setFormId( Integer formId )
+ {
+ this.formId = formId;
+ }
+
+ private String code;
+
+ public String getCode()
+ {
+ return code;
+ }
+
+
+ public String execute()
+ throws Exception
+ {
+ // create code : MCH<yyMM>
+ Date date = new Date();
+
+ Format formatter = new SimpleDateFormat( "yyMM" );
+
+ code = "MCH" + formatter.format( date );
+
+ Form form = formService.getForm( formId.intValue() );
+
+ // create code : xxxx
+ code += formManager.createCode( form );
+
+ return SUCCESS;
+ }
+}
=== added file 'local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/responseCode.vm'
--- local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/responseCode.vm 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/responseCode.vm 2009-09-10 10:56:49 +0000
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<createCode>
+ <code>$!code</code>
+</createCode>
+
+
=== added file 'local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/imports/action/ViewDataAction.java'
--- local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/imports/action/ViewDataAction.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/imports/action/ViewDataAction.java 2009-09-10 10:56:49 +0000
@@ -0,0 +1,111 @@
+package org.hisp.dhis.vn.imports.action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+
+import jxl.Sheet;
+import jxl.Workbook;
+import jxl.WorkbookSettings;
+
+import org.hisp.dhis.vn.imports.ReportItemValue;
+import org.hisp.dhis.vn.report.ReportExcelInterface;
+import org.hisp.dhis.vn.report.ReportExcelService;
+import org.hisp.dhis.vn.report.ReportItem;
+import org.hisp.dhis.vn.report.utils.ExcelUtils;
+
+import com.opensymphony.xwork2.Action;
+
+public class ViewDataAction
+ implements Action
+{
+ // --------------------------------------------------------------------
+ // Dependencies
+ // --------------------------------------------------------------------
+ private ReportExcelService reportExcelService;
+
+ public void setReportExcelService( ReportExcelService reportExcelService )
+ {
+ this.reportExcelService = reportExcelService;
+ }
+
+ // --------------------------------------------------------------------
+ // Input && Output
+ // --------------------------------------------------------------------
+
+ private Integer reportId;
+
+ public void setReportId( Integer reportId )
+ {
+ this.reportId = reportId;
+ }
+
+ private String uploadFileName;
+
+ public void setUploadFileName( String uploadFileName )
+ {
+ this.uploadFileName = uploadFileName;
+ }
+
+ private List<ReportItemValue> reportItemValues;
+
+ public List<ReportItemValue> getReportItemValues()
+ {
+ return reportItemValues;
+ }
+
+ // --------------------------------------------------------------------
+ // Action Implementation
+ // --------------------------------------------------------------------
+
+ public String execute()
+ {
+
+ try
+ {
+ // template report excel
+ ReportExcelInterface report = reportExcelService.getReport( reportId );
+ // file saves values
+ File upload = new File( uploadFileName );
+ WorkbookSettings ws = new WorkbookSettings();
+ ws.setLocale( new Locale( "en", "EN" ) );
+ Workbook templateWorkbook = Workbook.getWorkbook( upload, ws );
+
+ // get reportItems of the template report
+ Collection<ReportItem> reportItems = report.getReportItems();
+
+ Sheet sheet = templateWorkbook.getSheet( 0 );
+
+ // init parametter reportItermValues
+ reportItemValues = new ArrayList<ReportItemValue>();
+
+ for ( ReportItem reportItem : reportItems )
+ {
+ if ( reportItem.getItemType().equals( ReportItem.TYPE.DATAELEMENT ) )
+ {
+ String value = ExcelUtils.readValue( reportItem.getRow(), reportItem.getColumn(), sheet );
+
+ ReportItemValue reportItemvalue = new ReportItemValue( reportItem, value );
+
+ reportItemValues.add( reportItemvalue );
+
+ }// end if
+ }// end for
+
+ return SUCCESS;
+ }
+ catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ return ERROR;
+ }
+
+}
=== modified file 'local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/imports.js'
--- local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/imports.js 2009-09-10 10:50:06 +0000
+++ local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/imports.js 2009-09-10 10:56:49 +0000
@@ -120,11 +120,20 @@
var availableDiv = byId('showValue');
availableDiv.style.display = 'block';
- var str_values = "<br><br><table border='1' style='width:100% '> <tr><td>Report</td><td>Value</td></tr>";
+ //var str_values = "<br><br><table border='1' style='width:100% '> <tr><td>Report</td><td>Value</td></tr>";
var availableObjectList = xmlObject.getElementsByTagName('reportItemValue');
+ var myTable = document.getElementById('showReportItemValues');
+ var tBody = myTable.getElementsByTagName('tbody')[0];
+ var newTR = document.createElement('tr');
+ var newTD = document.createElement('td');
+ newTD.innerHTML = 'This is a new row';
+
+ newTR.appendChild (newTD);
+ tBody.appendChild(newTR);
+
for(var i=0;i<availableObjectList.length;i++){
str_values += "<tr>";
var reportItermValue = availableObjectList.item(i);
=== added file 'local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseReportItemValues.vm'
--- local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseReportItemValues.vm 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseReportItemValues.vm 2009-09-10 10:56:49 +0000
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<reportItemValues>
+#foreach($reportItemValue in $reportItemValues)
+ <reportItemValue>
+ <name>$encoder.xmlEncode($reportItemValue.reportItem.name)</name>
+ <value>$reportItemValue.value )</value>
+ </reportItemValue>
+#end
+</reportItemValues>
\ No newline at end of file