dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20381
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9274: Add option for program-stage to turn off the create-new-event pop-up after clicking complete even...
------------------------------------------------------------
revno: 9274
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-12-12 11:43:25 +0700
message:
Add option for program-stage to turn off the create-new-event pop-up after clicking complete event button.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramStage.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java
--
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/program/ProgramStage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2012-12-12 04:43:25 +0000
@@ -86,6 +86,8 @@
private Boolean validCompleteOnly = false;
+ private Boolean displayGenerateEventBox = true;
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -264,6 +266,16 @@
this.validCompleteOnly = validCompleteOnly;
}
+ public Boolean getDisplayGenerateEventBox()
+ {
+ return displayGenerateEventBox;
+ }
+
+ public void setDisplayGenerateEventBox( Boolean displayGenerateEventBox )
+ {
+ this.displayGenerateEventBox = displayGenerateEventBox;
+ }
+
public String getDataEntryType()
{
if ( dataEntryForm != null )
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2012-12-12 04:43:25 +0000
@@ -153,6 +153,9 @@
executeSql( "ALTER TABLE programvalidation DROP COLUMN dateType" );
executeSql( "UPDATE programstage SET validCompleteOnly=false WHERE validCompleteOnly is null" );
+ executeSql( "UPDATE program SET ignoreOverdueEvents=false WHERE ignoreOverdueEvents is null" );
+ executeSql( "UPDATE program SET displayGenerateEventBox=true WHERE displayGenerateEventBox is null" );
+
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2012-12-12 04:43:25 +0000
@@ -48,5 +48,7 @@
<property name="validCompleteOnly"/>
+ <property name="displayGenerateEventBox"/>
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-12-07 13:55:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-12-12 04:43:25 +0000
@@ -21,6 +21,7 @@
<input type='hidden' name='programStageInstanceId' id='programStageInstanceId' value='$!programStageInstance.id'>
<input type='hidden' name='programInstanceId' id='programInstanceId' value='$!programStageInstance.programInstance.id'>
<input type='hidden' name='irregular' id='irregular' value='$!programStageInstance.programStage.irregular'>
+<input type='hidden' name='displayGenerateEventBox' id='displayGenerateEventBox' value='$!programStageInstance.programStage.displayGenerateEventBox'>
<input type='hidden' name='completed' id='completed' value='$!programStageInstance.completed'>
<input type='hidden' name='programStageId' id='programStageId' value='$!programStageInstance.programStage.id'>
<input type='hidden' name='programId' id='programId' value='$!programStageInstance.programInstance.program.id'>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-12-07 13:55:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-12-12 04:43:25 +0000
@@ -512,8 +512,9 @@
disableCompletedButton(true);
var irregular = jQuery('#entryFormContainer [name=irregular]').val();
+ var displayGenerateEventBox = jQuery('#entryFormContainer [name=displayGenerateEventBox]').val();
var programInstanceId = jQuery('#entryFormContainer [id=programInstanceId]').val();
- if( irregular == 'true' )
+ if( irregular == 'true' && displayGenerateEventBox=="true" )
{
var programStageId = jQuery(".stage-object-selected").attr('psid');
showCreateNewEvent( programInstanceId, programStageId );
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramStage.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramStage.vm 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramStage.vm 2012-12-12 04:43:25 +0000
@@ -18,6 +18,7 @@
"irregular": "$!programStage.irregular",
"autoGenerateEvent": "$!programStage.autoGenerateEvent",
"validCompleteOnly": "$!programStage.validCompleteOnly",
+ "displayGenerateEventBox": "$!programStage.displayGenerateEventBox",
#set( $size = ${programStageDataElements.size()} )
"dataElement": [
#foreach($d in $programStageDataElements)
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java 2012-12-12 04:43:25 +0000
@@ -198,6 +198,13 @@
this.validCompleteOnly = validCompleteOnly;
}
+ private Boolean displayGenerateEventBox;
+
+ public void setDisplayGenerateEventBox( Boolean displayGenerateEventBox )
+ {
+ this.displayGenerateEventBox = displayGenerateEventBox;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -209,7 +216,8 @@
irregular = (irregular == null) ? false : irregular;
autoGenerateEvent = (autoGenerateEvent == null) ? false : autoGenerateEvent;
validCompleteOnly = (validCompleteOnly == null) ? false : validCompleteOnly;
-
+ displayGenerateEventBox = (displayGenerateEventBox == null) ? false : displayGenerateEventBox;
+
ProgramStage programStage = new ProgramStage();
Program program = programService.getProgram( id );
@@ -220,8 +228,10 @@
programStage.setReportDateDescription( reportDateDescription );
programStage.setIrregular( irregular );
programStage.setMinDaysFromStart( minDaysFromStart );
+ programStage.setDisplayGenerateEventBox( displayGenerateEventBox );
+
+ programStage.setValidCompleteOnly( validCompleteOnly );
programStage.setAutoGenerateEvent( autoGenerateEvent );
- programStage.setValidCompleteOnly( validCompleteOnly );
Set<PatientReminder> patientReminders = new HashSet<PatientReminder>();
for ( int i = 0; i < daysAllowedSendMessages.size(); i++ )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java 2012-12-12 04:43:25 +0000
@@ -191,6 +191,13 @@
this.validCompleteOnly = validCompleteOnly;
}
+ private Boolean displayGenerateEventBox;
+
+ public void setDisplayGenerateEventBox( Boolean displayGenerateEventBox )
+ {
+ this.displayGenerateEventBox = displayGenerateEventBox;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -202,6 +209,7 @@
irregular = (irregular == null) ? false : irregular;
autoGenerateEvent = (autoGenerateEvent == null) ? false : autoGenerateEvent;
validCompleteOnly = (validCompleteOnly == null) ? false : validCompleteOnly;
+ displayGenerateEventBox = (displayGenerateEventBox == null) ? false : displayGenerateEventBox;
ProgramStage programStage = programStageService.getProgramStage( id );
@@ -211,6 +219,9 @@
programStage.setReportDateDescription( reportDateDescription );
programStage.setMinDaysFromStart( minDaysFromStart );
programStage.setIrregular( irregular );
+ programStage.setMinDaysFromStart( minDaysFromStart );
+ programStage.setDisplayGenerateEventBox( displayGenerateEventBox );
+
programStage.setAutoGenerateEvent( autoGenerateEvent );
programStage.setValidCompleteOnly( validCompleteOnly );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2012-12-10 04:03:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2012-12-12 04:43:25 +0000
@@ -322,4 +322,5 @@
description_not_null = Description is not null
expression_not_null = Expression is not null
complete_allowed_only_if_validation_passes = Complete allowed only if validation passes
-ignore_overdue_events = Ignore overdue events
\ No newline at end of file
+ignore_overdue_events = Ignore overdue events
+display_generate_event_box_after_completed = Display generate event box after completed
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2012-12-12 04:43:25 +0000
@@ -41,8 +41,13 @@
</tr>
<tr>
+ <td><label>$i18n.getString( "display_generate_event_box_after_completed" )</label></td>
+ <td><input type="checkbox" id="displayGenerateEventBox" name="displayGenerateEventBox" value='true' checked disabled /></td>
+ </tr>
+
+ <tr>
<td><label>$i18n.getString( "standard_interval_days" )</label></td>
- <td><input type="text" id="standardInterval" name="standardInterval" class="{validate:{required:true,number:true}}" disabled /></td>
+ <td><input type="text" id="standardInterval" name="standardInterval" class="{validate:{number:true}}" disabled /></td>
</tr>
<tr><th colspan="2">$i18n.getString( "form_details" )</th></tr>
@@ -53,7 +58,7 @@
</tr>
<tr>
- <td><label>$i18n.getString( "report_date_description" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><label>$i18n.getString( "report_date_description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><input type="text" id="reportDateDescription" name="reportDateDescription" class="{validate:{required:true}}" /></td>
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2012-12-12 04:43:25 +0000
@@ -62,6 +62,9 @@
var autoGenerateEvent = (json.programStage.autoGenerateEvent=='true') ? i18n_yes : i18n_no;
setInnerHTML( 'autoGenerateEventField', autoGenerateEvent );
+ var displayGenerateEventBox = (json.programStage.displayGenerateEventBox=='true') ? i18n_yes : i18n_no;
+ setInnerHTML( 'displayGenerateEventBoxField', displayGenerateEventBox );
+
var validCompleteOnly = (json.programStage.validCompleteOnly=='true') ? i18n_yes : i18n_no;
setInnerHTML( 'validCompleteOnlyField', validCompleteOnly );
@@ -233,11 +236,12 @@
if( checked )
{
enable('standardInterval');
+ enable('displayGenerateEventBox');
}
else
{
disable('standardInterval');
- setFieldValue('standardInterval', '0');
+ disable('displayGenerateEventBox');
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm 2012-12-12 04:43:25 +0000
@@ -46,6 +46,7 @@
<p><label class="bold">$i18n.getString( "scheduled_days_from_start" ):</label><br><span id="scheduledDaysFromStartField"></span></p>
<p><label class="bold">$i18n.getString( "auto_generate_event" ):</label><br><span id="autoGenerateEventField"></span></p>
<p><label class="bold">$i18n.getString( "irregular" ):</label><br><span id="irregularField"></span></p>
+ <p><label class="bold">$i18n.getString( "display_generate_event_box_after_completed" ):</label><br><span id="displayGenerateEventBoxField"></span></p>
<p><label class="bold">$i18n.getString( "standard_interval_days" ):</label><br><span id="standardIntervalField"></span></p>
<p><label class="bold">$i18n.getString( "complete_allowed_only_if_validation_passes" ):</label><br><span id="validCompleteOnlyField"></span></p>
<p><label class="bold">$i18n.getString( "report_date_description" ):</label><br><span id="reportDateDescriptionField"></span></p>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2012-12-12 04:43:25 +0000
@@ -43,8 +43,13 @@
</tr>
<tr>
+ <td><label>$i18n.getString( "display_generate_event_box_after_completed" )</label></td>
+ <td><input type="checkbox" id="displayGenerateEventBox" name="displayGenerateEventBox" value='true' #if( $programStage.displayGenerateEventBox && $programStage.displayGenerateEventBox=='true' ) checked #end #if($programStage.irregular!='true' ) disabled checked #end /></td>
+ </tr>
+
+ <tr>
<td><label>$i18n.getString( "standard_interval_days" )</label></td>
- <td><input type="text" id="standardInterval" name="standardInterval" value='$!programStage.standardInterval' class="{validate:{required:true,number:true}}" #if($programStage.irregular!='true' ) disabled #end /></td>
+ <td><input type="text" id="standardInterval" name="standardInterval" value='$!programStage.standardInterval'class="{validate:{number:true}}" #if($programStage.irregular!='true' ) disabled #end /></td>
</tr>
#end
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java 2012-12-11 20:24:41 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java 2012-12-12 04:43:25 +0000
@@ -27,53 +27,35 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.io.FilenameUtils.getExtension;
-import static org.apache.commons.io.FilenameUtils.getName;
-import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM;
-import static org.hisp.dhis.dataelement.DataElement.DOMAIN_TYPE_AGGREGATE;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_INT;
-import static org.hisp.dhis.reportsheet.ExportItem.PERIODTYPE.SELECTED_MONTH;
-import static org.hisp.dhis.reportsheet.ExportItem.TYPE.DATAELEMENT;
-import static org.hisp.dhis.reportsheet.utils.ExcelUtils.convertAlignmentString;
-import static org.hisp.dhis.reportsheet.utils.ExcelUtils.readValueByPOI;
+import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Comment;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.FormulaEvaluator;
-import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.dataentryform.DataEntryFormService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.reportsheet.ExportItem;
import org.hisp.dhis.reportsheet.ExportReport;
import org.hisp.dhis.reportsheet.ExportReportNormal;
import org.hisp.dhis.reportsheet.ExportReportService;
-import org.hisp.dhis.reportsheet.state.SelectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -87,39 +69,8 @@
* @version $Id$
*/
-public class AutoGenerateFormByTemplate
- implements Action
+public class AutoGenerateFormByTemplate implements Action
{
- private static final String REPORT_EXCEL_GROUP = "BAO CAO THONG KE";
-
- private static final String WORKBOOK_OPENTAG = "<workbook>";
-
- private static final String WORKBOOK_CLOSETAG = "</workbook>";
-
- private static final String MERGEDCELL_OPENTAG = "<MergedCells>";
-
- private static final String MERGEDCELL_CLOSETAG = "</MergedCells>";
-
- private String excelFileName = "";
-
- private String commonName = "";
-
- /**
- * The workbook we are reading from a given file
- */
- private Workbook WORKBOOK;
-
- private FormulaEvaluator evaluatorFormula;
-
- /**
- * The encoding to write
- */
- private StringBuffer xml = new StringBuffer( 200000 );
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
@Autowired
private DataElementService dataElementService;
@@ -127,7 +78,7 @@
private DataElementCategoryService categoryService;
@Autowired
- private DataEntryFormService dataEntryFormService;
+ private DataEntryFormService dataEntryFormService;
@Autowired
private DataSetService dataSetService;
@@ -135,12 +86,10 @@
@Autowired
private ExportReportService exportReportService;
- @Autowired
- protected SelectionManager selectionManager;
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
+ /**
+ * The workbook we are reading from a given file
+ */
+ private Workbook WORKBOOK;
public String execute()
{
@@ -149,7 +98,7 @@
try
{
- autoGenerateFormByTemplate( selectionManager.getUploadFilePath(), collectSheets );
+ autoGenerateFormByTemplate( "d:\\template_file.xls", collectSheets );
}
catch ( Exception e )
{
@@ -158,12 +107,12 @@
return SUCCESS;
}
-
- // -------------------------------------------------------------------------
- // Sub-methods
- // -------------------------------------------------------------------------
-
- private void cleanUp()
+
+ // -------------------------------------------------------------------------
+ // Get & Set methods
+ // -------------------------------------------------------------------------
+
+ private void cleanUpForResponse()
{
System.gc();
}
@@ -179,14 +128,15 @@
* @exception java.io.IOException
*/
+ private String excelFileName = "";
+
private void autoGenerateFormByTemplate( String pathFileName, Set<Integer> collectSheets )
throws Exception
{
- this.cleanUp();
+ this.cleanUpForResponse();
InputStream inputSteam = new FileInputStream( pathFileName );
- excelFileName = getName( pathFileName );
- commonName = getBaseName( pathFileName );
+ excelFileName = new File( pathFileName ).getName();
if ( getExtension( pathFileName ).equals( "xls" ) )
{
@@ -211,135 +161,100 @@
private void writeFormattedXML( Collection<Integer> collectSheets )
throws Exception
{
- this.writeXMLMergedDescription( collectSheets );
-
- xml.append( WORKBOOK_OPENTAG );
-
- PeriodType periodType = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME );
-
- DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
-
- // Create new DataSet
- DataSet dataSet = new DataSet( commonName, commonName, periodType );
- dataSetService.addDataSet( dataSet );
-
- // Create new ExportReport
- ExportReport exportReport = new ExportReportNormal( commonName, REPORT_EXCEL_GROUP, excelFileName, null );
- exportReportService.addExportReport( exportReport );
-
+ for ( Integer sheet : collectSheets )
+ {
+ createFormByComment( sheet );
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Sub-methods
+ // -------------------------------------------------------------------------
+
+ private void createFormByComment( int sheetNo )
+ {
+ DataElementCategoryCombo catagoryCombo = categoryService.getDefaultDataElementCategoryOptionCombo()
+ .getCategoryCombo();
+ int catagoryOptionComboId = categoryService.getDefaultDataElementCategoryOptionCombo().getId();
+ PeriodType periodType = PeriodType.getPeriodTypeByName( "Monthly" );
StringBuffer htmlCode = new StringBuffer();
-
- for ( Integer sheet : collectSheets )
- {
- createFormByComment( sheet, optionCombo, periodType, htmlCode, dataSet, exportReport );
- }
-
- // Update DataSet
- DataEntryForm dataEntryForm = new DataEntryForm( commonName, htmlCode.toString() );
- dataEntryFormService.addDataEntryForm( dataEntryForm );
-
- dataSet.setDataEntryForm( dataEntryForm );
- dataSetService.updateDataSet( dataSet );
-
- // Update ExportReport
- Set<DataSet> dataSets = new HashSet<DataSet>();
- dataSets.add( dataSet );
-
- exportReport.setDataSets( dataSets );
- exportReportService.updateExportReport( exportReport );
-
- xml.append( WORKBOOK_CLOSETAG );
- }
-
- private void createFormByComment( int sheetNo, DataElementCategoryOptionCombo optionCombo, PeriodType periodType,
- StringBuffer htmlCode, DataSet dataSet, ExportReport exportReport )
- {
Sheet s = WORKBOOK.getSheetAt( sheetNo - 1 );
- xml.append( "<sheet id='" + (sheetNo) + "'>" );
- xml.append( "<name><![CDATA[" + s.getSheetName() + "]]></name>" );
+ DataSet dataSet = new DataSet( excelFileName, excelFileName, periodType );
+
+ // Generate report
+ ExportReport exportReport = new ExportReportNormal();
+ exportReport.setName( WORKBOOK.getSheetName( sheetNo - 1 ) );
+ exportReport.setExcelTemplateFile( excelFileName );
+ exportReport.setGroup( excelFileName );
+ exportReport.setCreatedBy( "DHIS-System" );
+ int reportId = exportReportService.addExportReport( exportReport );
try
{
for ( Row row : s )
- {
- xml.append( "<row index='" + row.getRowNum() + "'>" );
-
- Map<Integer, Integer> idxMap = new HashMap<Integer, Integer>();
-
+ {
for ( Cell cell : row )
{
Comment cmt = cell.getCellComment();
-
- if ( cmt != null )
+ if ( cell.getCellComment() != null )
{
String deName = cell.getStringCellValue();
- String[] indexes = cmt.getString().getString().split( "," );
-
+ String[] indexes = cmt.getString().toString().split( "," );
int rowIndex = cell.getRowIndex();
for ( String index : indexes )
{
- String name = deName + " (" + index + ")";
- int idx = Integer.parseInt( index );
-
- // Generate DataElement
+ String name = deName + "(" + index + ")";
+ int idx = Integer.parseInt( index ) - 1;
+
+ // Generate dataElement
DataElement dataElement = new DataElement( name );
- /** TAKE CARE OF SHORT_NAME IS TOO LONG */
dataElement.setShortName( name );
dataElement.setActive( true );
+ dataElement.setDomainType( "aggregate" );
+ dataElement.setType( DataElement.VALUE_TYPE_INT );
+ dataElement.setNumberType( DataElement.VALUE_TYPE_INT );
+ dataElement.setCategoryCombo( catagoryCombo );
+ dataElement.setAggregationOperator( "sum" );
dataElement.setZeroIsSignificant( false );
- dataElement.setDomainType( DOMAIN_TYPE_AGGREGATE );
- dataElement.setType( VALUE_TYPE_INT );
- dataElement.setNumberType( VALUE_TYPE_INT );
- dataElement.setAggregationOperator( AGGREGATION_OPERATOR_SUM );
- dataElement.setCategoryCombo( optionCombo.getCategoryCombo() );
-
int deId = dataElementService.addDataElement( dataElement );
- idxMap.put( idx - 1, deId );
-
- // Add the dataElement into the dataSet
+ // Add the dataelement into the dataset
dataSet.addDataElement( dataElement );
- // Generate Report Item
+ // Put text field into the cell(rowIndex,idx)
+ // htmlCode.append( str );
+
+ // Generate report item
ExportItem exportItem = new ExportItem();
exportItem.setName( name );
- exportItem.setItemType( DATAELEMENT );
- exportItem.setRow( rowIndex + 1 );
+ exportItem.setItemType( "dataelement" );
+ exportItem.setRow( rowIndex );
exportItem.setColumn( idx );
- exportItem.setExpression( "[" + deId + "." + optionCombo.getId() + "]" );
- exportItem.setPeriodType( SELECTED_MONTH );
- exportItem.setSheetNo( sheetNo );
- exportItem.setExportReport( exportReport );
-
+ exportItem.setExpression( "[" + deId + "." + catagoryOptionComboId + "]" );
+ exportItem.setPeriodType( "selected_month" );
+ exportItem.setSheetNo( (sheetNo) );
+ exportItem.setExportReport( exportReportService.getExportReport( reportId ) );
exportReportService.addExportItem( exportItem );
+
}
}
-
- xml.append( "<col no='" + cell.getColumnIndex() + "'>" );
-
- if ( idxMap.containsKey( cell.getColumnIndex() ) )
- {
- xml.append( "<data><![CDATA[" + "<input id=\"" + idxMap.get( cell.getColumnIndex() ) + "-"
- + optionCombo.getId()
- + "-val\" style=\"width:7em;text-align:right\" title=\"\" value=\"\">" + "]]></data>" );
- }
- else if ( (cell.getCellStyle() != null || cell.getCellType() != Cell.CELL_TYPE_BLANK)
- && !s.isColumnHidden( cell.getColumnIndex() ) )
- {
- xml.append( "<data><![CDATA["
- + readValueByPOI( row.getRowNum() + 1, cell.getColumnIndex() + 1, s, evaluatorFormula )
- + "]]></data>" );
-
- this.readingDetailsFormattedCell( s, cell );
-
- }
- xml.append( "</col>" );
}
- xml.append( "</row>" );
}
- xml.append( "</sheet>" );
+
+ DataEntryForm dataEntryForm = new DataEntryForm( "DataEntry form", htmlCode.toString() );
+ dataEntryFormService.addDataEntryForm( dataEntryForm );
+
+ dataSet.setDataEntryForm( dataEntryForm );
+ dataSetService.addDataSet( dataSet );
+
+ Set<DataSet> dataSets = new HashSet<DataSet>();
+ dataSets.add( dataSet );
+
+ exportReport.setDataSets( dataSets );
+ exportReportService.updateExportReport( exportReport );
+
}
catch ( Exception e )
{
@@ -347,92 +262,4 @@
System.err.println( "Error: " + e.getMessage() );
}
}
-
- // -------------------------------------------------------------------------
- // Get the merged cell's information
- // -------------------------------------------------------------------------
-
- private void readingDetailsFormattedCell( Sheet sheet, Cell objCell )
- {
- // The format information
- CellStyle format = objCell.getCellStyle();
-
- if ( format != null )
- {
- xml.append( "<format a='" + convertAlignmentString( format.getAlignment() ) + "'" );
- xml.append( " b='"
- + (format.getBorderBottom() + format.getBorderLeft() + format.getBorderRight() + format.getBorderTop())
- + "'" );
-
- Font font = WORKBOOK.getFontAt( format.getFontIndex() );
-
- if ( font != null )
- {
- xml.append( "><font s='" + font.getFontHeightInPoints() + "'" );
- xml.append( " b='" + (font.getBoldweight() == Font.BOLDWEIGHT_BOLD ? "1" : "0") + "'" );
- xml.append( " i='" + font.getItalic() + "'" );
- xml.append( " c='" + getSimilarColor( font.getColor() ) + "'" );
- xml.append( "/>" );
-
- xml.append( "</format>" );
- }
- else
- {
- xml.append( "/>" );
- }
- }
- }
-
- private void writeXMLMergedDescription( Collection<Integer> collectSheets )
- throws IOException
- {
- // Open the main Tag //
- xml.append( MERGEDCELL_OPENTAG );
-
- for ( Integer sheet : collectSheets )
- {
- writeMergedInfoBySheetNo( sheet );
- }
-
- // Close the main Tag //
- xml.append( MERGEDCELL_CLOSETAG );
- }
-
- private void writeMergedInfoBySheetNo( int sheetNo )
- {
- Sheet sheet = WORKBOOK.getSheetAt( sheetNo - 1 );
- CellRangeAddress cellRangeAddress = null;
-
- for ( int i = 0; i < sheet.getNumMergedRegions(); i++ )
- {
- cellRangeAddress = sheet.getMergedRegion( i );
-
- if ( cellRangeAddress.getFirstColumn() != cellRangeAddress.getLastColumn() )
- {
- xml.append( "<cell " + "iKey='" + (sheetNo) + "#" + cellRangeAddress.getFirstRow() + "#"
- + cellRangeAddress.getFirstColumn() + "'>"
- + (cellRangeAddress.getLastColumn() - cellRangeAddress.getFirstColumn() + 1) + "</cell>" );
- }
- }
- }
-
- private String getSimilarColor( short index )
- {
- if ( IndexedColors.BLUE.getIndex() == index )
- {
- return "blue";
- }
-
- if ( IndexedColors.DARK_BLUE.getIndex() == index )
- {
- return "darkblue";
- }
-
- if ( IndexedColors.BROWN.getIndex() == index )
- {
- return "brown";
- }
-
- return "";
- }
}
\ No newline at end of file