dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #06884
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1925: Added DataLock Check for Excel Importing
------------------------------------------------------------
revno: 1925
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-08-17 14:05:20 +0530
message:
Added DataLock Check for Excel Importing
added:
local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/responseStatus.vm
modified:
local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/ExcelImportResultAction.java
local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetReportsAction.java
local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/api/Report.java
local/in/dhis-web-excelimport/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-excelimport/src/main/resources/struts.xml
local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/excelImportForm.vm
local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/javascript/reports.js
local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/responseImportReport.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-excelimport/src/main/java/org/hisp/dhis/excelimport/action/ExcelImportResultAction.java'
--- local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/ExcelImportResultAction.java 2010-06-15 11:26:37 +0000
+++ local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/ExcelImportResultAction.java 2010-08-17 08:35:20 +0000
@@ -36,6 +36,8 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.datalock.DataSetLock;
+import org.hisp.dhis.datalock.DataSetLockService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.datavalue.DataValue;
@@ -125,9 +127,9 @@
private DataElementCategoryService dataElementCategoryService;
- public DataElementCategoryService getDataElementCategoryService()
+ public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
{
- return dataElementCategoryService;
+ this.dataElementCategoryService = dataElementCategoryService;
}
private CurrentUserService currentUserService;
@@ -137,6 +139,13 @@
this.currentUserService = currentUserService;
}
+ private DataSetLockService dataSetLockService;
+
+ public void setDataSetLockService( DataSetLockService dataSetLockService )
+ {
+ this.dataSetLockService = dataSetLockService;
+ }
+
private SessionFactory sessionFactory;
public void setSessionFactory( SessionFactory sessionFactory )
@@ -213,13 +222,6 @@
return mathTool;
}
- // private OrganisationUnit selectedOrgUnit;
-
- // public OrganisationUnit getSelectedOrgUnit()
- // {
- // return selectedOrgUnit;
- // }
-
private List<OrganisationUnit> orgUnitList;
public List<OrganisationUnit> getOrgUnitList()
@@ -493,17 +495,26 @@
{
return columnEnd;
}
+
+ private Integer dataSetId;
+
+ public void setDataSetId( Integer dataSetId )
+ {
+ this.dataSetId = dataSetId;
+ }
+
+ OrganisationUnit orgUnit;
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
public String execute()
throws Exception
{
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
+ // Initialization
statementManager.initialise();
- // Initialization
raFolderName = reportService.getRAFolderName();
InputStream inputStream = null;
@@ -538,10 +549,6 @@
inputStream = new BufferedInputStream( new FileInputStream( file ) );
- // path = newpath + File.separator + raFolderName + File.separator +
- // excelImportFolderName
- // + File.separator + fileName;
-
String excelTemplatePath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator
+ excelImportFolderName + File.separator + "template" + File.separator + reportFileNameTB;
@@ -552,12 +559,6 @@
file.renameTo( new File( excelFilePath ) );
- // if ( file.renameTo( new File( excelFilePath ) ) )
- // {
- // System.out.println( "FILE PATH : \t" + file.getAbsolutePath() + "\t
- // name " + file.getName() );
- // }
-
moveFile( file, new File( excelFilePath ) );
WorkbookSettings ws = new WorkbookSettings();
@@ -588,17 +589,28 @@
if ( reportModelTB.equalsIgnoreCase( "STATIC" ) )
{
orgUnitList = new ArrayList<OrganisationUnit>();
- OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
+ orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
orgUnitList.add( orgUnit );
}
+ DataSet dataSet = dataSetService.getDataSet( dataSetId );
+
selectedPeriod = periodService.getPeriod( availablePeriods );
sDate = format.parseDate( String.valueOf( selectedPeriod.getStartDate() ) );
eDate = format.parseDate( String.valueOf( selectedPeriod.getEndDate() ) );
+ DataSetLock dataSetLock = dataSetLockService.getDataSetLockByDataSetPeriodAndSource( dataSet, selectedPeriod, orgUnit );
+
+ if( dataSetLock != null )
+ {
+ message = "Unable to Import : Corresponding Dataset ( "+dataSet.getName()+" ) for the selected Excel Template is locked.";
+
+ return SUCCESS;
+ }
+
// Getting DataValues
dataValueList = new ArrayList<String>();
List<String> deCodesList = new ArrayList<String>();
@@ -608,17 +620,15 @@
if ( deCodesList.isEmpty() )
deCodesList = getDECodes( deCodesImportXMLFileName );
- Iterator it = orgUnitList.iterator();
+ Iterator<OrganisationUnit> it = orgUnitList.iterator();
OrganisationUnit currentOrgUnit = new OrganisationUnit();
while ( it.hasNext() )
-
{
-
currentOrgUnit = (OrganisationUnit) it.next();
- Iterator it1 = deCodesList.iterator();
+ Iterator<String> it1 = deCodesList.iterator();
int count1 = 0;
while ( it1.hasNext() )
{
@@ -689,35 +699,26 @@
{
dataValueService.addDataValue( dataValue );
}
-
catch ( Exception ex )
{
throw new RuntimeException( "Cannot add datavalue", ex );
-
}
-
}
else if ( oldValue != null && (!riRadio.equalsIgnoreCase( "reject" )) )
{
-
try
{
-
oldValue.setValue( value );
oldValue.setTimestamp( new Date() );
oldValue.setStoredBy( storedBy );
dataValueService.updateDataValue( oldValue );
}
-
catch ( Exception ex )
{
throw new RuntimeException( "Cannot add datavalue", ex );
-
}
-
}
-
else
{
count1++;
@@ -725,8 +726,6 @@
continue;
}
- // }
-
count1++;
}// inner while loop end
@@ -743,7 +742,6 @@
public List<Calendar> getStartingEndingPeriods( String deType, Calendar tempStartDate, Calendar tempEndDate )
{
-
List<Calendar> calendarList = new ArrayList<Calendar>();
Period previousPeriod = new Period();
=== modified file 'local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetReportsAction.java'
--- local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetReportsAction.java 2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetReportsAction.java 2010-08-17 08:35:20 +0000
@@ -7,6 +7,8 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.excelimport.api.Report;
import org.hisp.dhis.excelimport.util.ReportService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -42,6 +44,13 @@
this.reportService = reportService;
}
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
// -------------------------------------------------------------------------
// Input & output
// -------------------------------------------------------------------------
@@ -91,6 +100,8 @@
private String orgUnitLevel;
private String raFolderName;
+
+ OrganisationUnit orgUnit;
// -------------------------------------------------------------------------
// Action implementation
@@ -105,7 +116,7 @@
{
try
{
- OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( ouId ) );
+ orgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( ouId ) );
int ouLevel = organisationUnitService.getLevelOfOrganisationUnit( orgUnit );
@@ -160,7 +171,7 @@
String reportId = "";
String reportName = "";
String reportType = "";
- String reportLevel = "";
+ String dataSetId = "";
String reportModel = "";
String reportFileName = "";
// String checkerFileName = "";
@@ -207,18 +218,17 @@
NodeList textreportFileNameList = reportFileNameElement.getChildNodes();
reportFileName = ((Node) textreportFileNameList.item( 0 )).getNodeValue().trim();
- // NodeList reportCheckerList =
- // reportElement.getElementsByTagName( "checkerFileName" );
- // Element reportCheckerElement = (Element)
- // reportCheckerList.item( 0 );
- // NodeList textreportCheckerList =
- // reportCheckerElement.getChildNodes();
- // checkerFileName = ((Node) textreportCheckerList.item( 0
- // )).getNodeValue().trim();
-
- if ( reportType.equals( periodType ) )
+
+ NodeList reportDatasetList = reportElement.getElementsByTagName( "dataset" );
+ Element reportDatasetElement = (Element) reportDatasetList.item( 0 );
+ NodeList textreportDatasetList = reportDatasetElement.getChildNodes();
+ dataSetId = ((Node) textreportDatasetList.item( 0 )).getNodeValue().trim();
+
+ DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) );
+
+ if ( reportType.equals( periodType ) && dataSet.getSources().contains( orgUnit ) )
{
- Report reportObj = new Report( reportId, reportName, reportType, reportModel, reportFileName );
+ Report reportObj = new Report( reportId, reportName, reportType, reportModel, reportFileName, dataSetId );
reportList.add( count, reportObj );
count++;
System.out.println( reportName + " : " + reportId );
@@ -243,8 +253,4 @@
}// getReportList end
- /**
- * @param autogenrep the autogenrep to set
- */
-
}
=== modified file 'local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/api/Report.java'
--- local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/api/Report.java 2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/api/Report.java 2010-08-17 08:35:20 +0000
@@ -37,6 +37,11 @@
*/
private String chckerFileName;
+ /**
+ * dataset id
+ */
+ private String datasetId;
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -46,7 +51,7 @@
}
- public Report( String id, String name, String type, String model, String fileName )
+ public Report( String id, String name, String type, String model, String fileName, String datasetId )
{
this.id = id;
this.name = name;
@@ -54,8 +59,9 @@
this.model = model;
this.fileName = fileName;
//this.chckerFileName = checkerFileName;
+ this.datasetId = datasetId;
}
-
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -120,4 +126,13 @@
this.chckerFileName = chckerFileName;
}
+ public String getDatasetId()
+ {
+ return datasetId;
+ }
+
+ public void setDatasetId( String datasetId )
+ {
+ this.datasetId = datasetId;
+ }
}
=== modified file 'local/in/dhis-web-excelimport/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-excelimport/src/main/resources/META-INF/dhis/beans.xml 2010-06-17 07:51:57 +0000
+++ local/in/dhis-web-excelimport/src/main/resources/META-INF/dhis/beans.xml 2010-08-17 08:35:20 +0000
@@ -26,8 +26,8 @@
class="org.hisp.dhis.excelimport.action.ExcelImportResultAction"
scope="prototype">
<property name="statementManager" ref="statementManager"/>
- <property name="dataElementCategoryOptionComboService">
- <ref bean="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/>
+ <property name="dataElementCategoryService">
+ <ref bean="org.hisp.dhis.dataelement.DataElementCategoryService"/>
</property>
<property name="periodService">
<ref bean="org.hisp.dhis.period.PeriodService"/>
@@ -47,6 +47,9 @@
<property name="reportService">
<ref bean="org.hisp.dhis.excelimport.util.ReportService"/>
</property>
+ <property name="dataSetLockService">
+ <ref bean="org.hisp.dhis.datalock.DataSetLockService"/>
+ </property>
<property name="currentUserService">
<ref bean="org.hisp.dhis.user.CurrentUserService"/>
</property>
@@ -104,6 +107,9 @@
<property name="organisationUnitService">
<ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
</property>
+ <property name="dataSetService">
+ <ref bean="org.hisp.dhis.dataset.DataSetService"/>
+ </property>
</bean>
<!-- Report Service -->
=== modified file 'local/in/dhis-web-excelimport/src/main/resources/struts.xml'
--- local/in/dhis-web-excelimport/src/main/resources/struts.xml 2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-excelimport/src/main/resources/struts.xml 2010-08-17 08:35:20 +0000
@@ -24,25 +24,14 @@
,../dhis-web-commons/util/validate/additional-methods.js,../dhis-web-commons/util/validate/messages_locale.js</param>
<param name="stylesheets">css/StylesForTags.css</param>
<interceptor-ref name="organisationUnitTreeStack"/>
- <!--<interceptor-ref name="fileUploadStack"/>-->
</action>
- <!--
- <action name="excelResultForm"
- class="org.hisp.dhis.excelimport.action.ExcelImportResultAction">
- <result name="success" type="velocity">/main.vm</result>
- <result name="notvalid" type="redirect">reject.action</result>
- <param name="javascripts">
- ../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/lists/lists.js,javascript/reports.js,javascript/reports.js,javascript/hashtable.js</param>
- <param name="stylesheets">css/StylesForTags.css</param>
- <interceptor-ref name="fileUploadStack"/>
- </action>
- -->
-
- <action name="excelResultForm" class="org.hisp.dhis.excelimport.action.ExcelImportResultAction">
- <result name="success" type="chain">excelImportForm</result>
- <interceptor-ref name="fileUploadStack"/>
- </action>
+ <action name="excelResultForm" class="org.hisp.dhis.excelimport.action.ExcelImportResultAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-excelimport/responseStatus.vm</param>
+ <param name="menu">/dhis-web-excelimport/menu.vm</param>
+ <interceptor-ref name="fileUploadStack"/>
+ </action>
<action name="rejectImport"
class="org.hisp.dhis.excelimport.action.RejectAction">
@@ -56,13 +45,11 @@
<interceptor-ref name="fileUploadStack"/>
</action>
-
- <!-- AJAX Requests -->
+ <!-- AJAX Requests -->
<action name="getDataElements"
class="org.hisp.dhis.excelimport.action.GetDataElementsAction">
<result name="success" type="velocity">
/dhis-web-excelimport/responseDataElement.vm</result>
- <!--<interceptor-ref name="transactionStack"/>-->
<param name="onExceptionReturn">plainTextError</param>
</action>
@@ -70,7 +57,6 @@
class="org.hisp.dhis.excelimport.action.GetPeriodsAction">
<result name="success" type="velocity">
/dhis-web-excelimport/responsePeriod.vm</result>
- <!--<interceptor-ref name="transactionStack"/>-->
<param name="onExceptionReturn">plainTextError</param>
</action>
@@ -80,7 +66,6 @@
/dhis-web-excelimport/responseImportReport.vm</result>
<param name="javascripts">
../dhis-web-commons/ouwt/ouwt.js,javascript/reports.js,../dhis-web-commons/lists/lists.js,javascript/hashtable.js</param>
- <!--<interceptor-ref name="transactionStack"/>-->
<param name="onExceptionReturn">plainTextError</param>
</action>
@@ -88,7 +73,6 @@
class="org.hisp.dhis.excelimport.action.GetOrgUnitsAction">
<result name="success" type="velocity">
/dhis-web-excelimport/responseOrgUnit.vm</result>
- <!--<interceptor-ref name="transactionStack"/>-->
<param name="onExceptionReturn">plainTextError</param>
</action>
=== modified file 'local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/excelImportForm.vm'
--- local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/excelImportForm.vm 2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/excelImportForm.vm 2010-08-17 08:35:20 +0000
@@ -1,192 +1,150 @@
-<html>
- <head>
- <title>Excel Import Form</title>
- <script>
- //Global Variables
- var selriRadioButton = "overWrite";
- var reportModels = new HashTable();
- var reportFileNames = new HashTable();
- var checkerFileNames = new HashTable();
- // OrganisationUnit ids and its Names
- ##var orgUnits = new HashTable();
- ##foreach($orgUnit in $organisationUnits)
- ## var orgUnitId = ""+$orgUnit.getId();
- ## orgUnits.put(orgUnitId,"$orgUnit.getShortName()");
- ##end
- // OrganisationUnit ids and its Level
- ##var orgUnitLevels = new HashTable();
- ##foreach($orgUnit in $organisationUnits)
- ## var orgUnitId = ""+$orgUnit.getId();
- ## orgUnitLevels.put(orgUnitId,"$organisationUnitService.getLevelOfOrganisationUnit( $orgUnit )");
- ##end
-
- function formValidations()
- {
- var reportListIndex = document.reportForm.reportList.selectedIndex;
- var periodIndex = document.reportForm.availablePeriods.selectedIndex;
- var periodIDIndex = document.reportForm.periodTypeId.selectedIndex;
- //alert("periodIDIndex = "+periodIDIndex+ " periodIndex = " +periodIndex + " period value = " +document.reportForm.availablePeriods.options[periodIndex].text);
- var orgunitIdValue = document.reportForm.ouIDTB.value;
- if(reportListIndex < 0 || document.reportForm.reportList.options[reportListIndex].text == null) {alert("Please Select Report"); return false;}
- else if(document.reportForm.availablePeriods.options[periodIndex].text == null || document.reportForm.availablePeriods.options[periodIndex].text== "") {alert("Please Select Period"); return false;}
- else if(document.reportForm.periodTypeId.options[periodIDIndex].value == "NA") {alert("Please Select Period Type"); return false;}
- else if(orgunitIdValue == null || orgunitIdValue=="" || orgunitIdValue==" ") {alert("Please Select OrganisationUnit"); return false;}
-
- document.reportForm.reportModelTB.value = reportModels.get(document.reportForm.reportList.options[reportListIndex].value);
- document.reportForm.reportFileNameTB.value = reportFileNames.get(document.reportForm.reportList.options[reportListIndex].value);
- document.reportForm.checkerFileNameTB.value = checkerFileNames.get(document.reportForm.reportList.options[reportListIndex].value);
-
- /*
- var k=0;
- if(selriRadioButton == "dataElementsRadio")
- {
- document.ChartGenerationForm.overWrite.selected = true;
- }
- else
- {
- document.ChartGenerationForm.reject.selected = true;
- }
- */
- return true;
- }
-
-//-----------------------------------------------------------------------
-//init jQuery validation for reportForm
-//-----------------------------------------------------------------------
- jQuery(document).ready(
- function()
- {
- jQuery("#reportForm").validate({
- meta:"validate"
- ,errorElement:"td"
- ,submitHandler: function(form)
- {
- submitImportForm();
- }
- });
- jQuery.validator.loadLocaled( jQuery("#curLocaleCode").val() );
- jQuery("#name").focus();
- }
- );
-
-</script>
-</head>
-<body>
- <h1>Excel Import Form</h1>
- <hr />
- <br />
- <form id="reportForm" name="reportForm" method="post" enctype="multipart/form-data" action="excelResultForm.action">
- <input type="hidden" id="curLocaleCode" value="$locale.getLanguage()_$locale.getCountry()"/>
- ##<form id="reportForm" name="reportForm" method="post" enctype="multipart/form-data" action="excelResultForm.action" onsubmit="submitForm(); return validateExcelImport()">
- <table align="center" style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" width="730" border=0>
- <tr>
- <td class="NormalB">
- PeriodType : <br />
- <select id="periodTypeId" name="periodTypeId" style="width:200px" onchange="getPeriods()">
- <option value="NA">[ Select PeriodType ]</option>
- #foreach ( $type in $periodTypes )
- <option value="$type.name">$type.name</option>
- #end
- </select>
- </td>
- <td class="NormalB">
- OrganisationUnit : <br />
- <input type="text" name="ouNameTB" id="ouNameTB" size="20" class="{validate:{required:true}}" disabled >
-</td>
-</tr>
-<tr>
- <td> </td>
- <td> </td>
-</tr>
-<tr>
- <td> </td>
- <td> </td>
-</tr>
-<tr>
- <td class="NormalB">
- Periods : <br />
- <select id="availablePeriods" name="availablePeriods" style="width:200px" class="{validate:{required:true}}">
- <option value="EMPTY_PLACEHOLDER_VALUE"></option>
- </select>
- <select multiple id="selectedPeriods" name="selectedPeriods" style="display:none; width:200px; height:0px">
- <option value="EMPTY_PLACEHOLDER_VALUE"></option>
- </select>
- </td>
- <td class="NormalB">
- Reports :<br />
- <select id="reportList" name="reportList" style="width:200px" class="{validate:{required:true}}">
- #foreach ( $report in $reportList )
- <option value="$!report.name">$!report.name</option>
- #end
- </select>
- </td>
-</tr>
-<tr>
- <td> </td>
- <td> </td>
-</tr>
-<tr>
- <td> </td>
- <td> </td>
-</tr>
-<tr>
- <td class="NormalB">
- <input type="radio" id="riRadio" name="riRadio" value="overWrite" checked> New And Updates
-
- <br>
- <input type="radio" id="riRadio" name="riRadio" value="reject" > New (No Updates)
-</td>
-<td class="NormalB">
- ##<input type="file" id="excelFile" name="excelFile" size="45"></td>
- <input type="file" id="upload" name="upload" size="45" class="{validate:{required:true}}"></td>
- <td> </td>
-</tr>
-<tr>
- <td> </td>
- <td>
- <br>
- <br>
- ##<input type="submit" name="importReport" value='Import Data' onclick="submitImportForm()">
-
- <input type="submit" name="importReport" value='Import Data' style="width:13em">
-
-
- <input type="hidden" name="autogen" id="autogen" value="0" >
- <input type="hidden" name="ouIDTB" id="ouIDTB">
- ##<input type="hidden" name="ouLevelTB" id="ouLevelTB">
- <input type="hidden" name="reportModelTB" id="reportModelTB">
- <input type="hidden" name="reportFileNameTB" id="reportFileNameTB">
- <input type="hidden" name="checkerFileNameTB" id="checkerFileNameTB">
- <input type="hidden" name="reportListFileNameTB" id="reportListFileNameTB" value="excelImportReportsList.xml">
-</td>
-</tr>
-<tr>
-<td colspan="2">
-<span id="message"></span>
-</td></tr>
-</table>
-</form>
-
-<script>
-
-function onloadFun()
-{
- #if($message)
- document.getElementById( 'message' ).innerHTML = '$message';
- document.getElementById( 'message' ).style.display = 'block';
-
- setTimeout(
- function()
- {
- document.getElementById( 'message' ).style.display = 'none';
- },
- 4000
- );
-
- #end
-}
-
-onloadFun();
-</script>
-</body>
-</html>
+
+<script>
+
+ //Global Variables
+ var selriRadioButton = "overWrite";
+ var reportModels = new HashTable();
+ var reportFileNames = new HashTable();
+ var checkerFileNames = new HashTable();
+ var reportDatasets = new HashTable();
+
+ function formValidations()
+ {
+ var reportListIndex = document.reportForm.reportList.selectedIndex;
+ var periodIndex = document.reportForm.availablePeriods.selectedIndex;
+ var periodIDIndex = document.reportForm.periodTypeId.selectedIndex;
+ var orgunitIdValue = document.reportForm.ouIDTB.value;
+
+ if(reportListIndex < 0 || document.reportForm.reportList.options[reportListIndex].text == null) {alert("Please Select Report"); return false;}
+ else if(document.reportForm.availablePeriods.options[periodIndex].text == null || document.reportForm.availablePeriods.options[periodIndex].text== "") {alert("Please Select Period"); return false;}
+ else if(document.reportForm.periodTypeId.options[periodIDIndex].value == "NA") {alert("Please Select Period Type"); return false;}
+ else if(orgunitIdValue == null || orgunitIdValue=="" || orgunitIdValue==" ") {alert("Please Select OrganisationUnit"); return false;}
+
+ document.reportForm.reportModelTB.value = reportModels.get(document.reportForm.reportList.options[reportListIndex].value);
+ document.reportForm.reportFileNameTB.value = reportFileNames.get(document.reportForm.reportList.options[reportListIndex].value);
+ document.reportForm.checkerFileNameTB.value = checkerFileNames.get(document.reportForm.reportList.options[reportListIndex].value);
+ document.reportForm.dataSetId.value = reportDatasets.get(document.reportForm.reportList.options[reportListIndex].value);
+
+ return true;
+ }
+
+ //-----------------------------------------------------------------------
+ //init jQuery validation for reportForm
+ //-----------------------------------------------------------------------
+ jQuery(document).ready(
+ function()
+ {
+ jQuery("#reportForm").validate({
+ meta:"validate"
+ ,errorElement:"td"
+ ,submitHandler: function(form)
+ {
+ submitImportForm();
+ }
+ });
+ jQuery("#name").focus();
+ }
+ );
+
+</script>
+
+<h1>Excel Import Form</h1>
+<hr /><br />
+
+<form id="reportForm" name="reportForm" method="post" enctype="multipart/form-data" action="excelResultForm.action">
+ <input type="hidden" id="curLocaleCode" value="$locale.getLanguage()_$locale.getCountry()"/>
+ <table align="center" style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" width="730" border=0>
+ <tr>
+ <td class="NormalB">
+ PeriodType : <br />
+ <select id="periodTypeId" name="periodTypeId" style="width:200px" onchange="getPeriods()">
+ <option value="NA">[ Select PeriodType ]</option>
+ #foreach ( $type in $periodTypes )
+ <option value="$type.name">$type.name</option>
+ #end
+ </select>
+ </td>
+ <td class="NormalB">
+ OrganisationUnit : <br />
+ <input type="text" name="ouNameTB" id="ouNameTB" size="20" class="{validate:{required:true}}" disabled >
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td class="NormalB">
+ Periods : <br />
+ <select id="availablePeriods" name="availablePeriods" style="width:200px" class="{validate:{required:true}}">
+ <option value="EMPTY_PLACEHOLDER_VALUE"></option>
+ </select>
+ </td>
+ <td class="NormalB">
+ Reports :<br />
+ <select id="reportList" name="reportList" style="width:200px" class="{validate:{required:true}}">
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td class="NormalB">
+ <input type="radio" id="riRadio" name="riRadio" value="overWrite" checked> New And Updates
+ <br>
+ <input type="radio" id="riRadio" name="riRadio" value="reject" > New (No Updates)
+ </td>
+ <td class="NormalB"><input type="file" id="upload" name="upload" size="45" class="{validate:{required:true}}"></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td>
+ <br /><br />
+ <input type="submit" name="importReport" value='Import Data' style="width:13em">
+ <input type="hidden" name="autogen" id="autogen" value="0" >
+ <input type="hidden" name="ouIDTB" id="ouIDTB">
+ <input type="hidden" name="reportModelTB" id="reportModelTB">
+ <input type="hidden" name="reportFileNameTB" id="reportFileNameTB">
+ <input type="hidden" name="checkerFileNameTB" id="checkerFileNameTB">
+ <input type="hidden" name="dataSetId" id="dataSetId">
+ <input type="hidden" name="reportListFileNameTB" id="reportListFileNameTB" value="excelImportReportsList.xml">
+
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><span id="message"></span></td>
+ </tr>
+ </table>
+</form>
+
+<script>
+
+ function onloadFun()
+ {
+ #if($message)
+ document.getElementById( 'message' ).innerHTML = '$message';
+ document.getElementById( 'message' ).style.display = 'block';
+ setTimeout(
+ function()
+ {
+ document.getElementById( 'message' ).style.display = 'none';
+ },
+ 4000
+ );
+ #end
+ }
+
+ onloadFun();
+
+</script>
=== modified file 'local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/javascript/reports.js'
--- local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/javascript/reports.js 2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/javascript/reports.js 2010-08-17 08:35:20 +0000
@@ -1,43 +1,5 @@
-/*
-function validateExcelImport()
-{
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( excelImportCompleted );
-
- reportFileNameTB
- checkerFileNameTB
- reportModelTB
- reportList
- riRadio
- ouIDTB
-
-
- var requestString = 'excelResultForm.action';
-
- request.send( requestString );
-
- return false;
-}
-
-function excelImportCompleted( messageElement )
-{
- var type = messageElement.getAttribute( 'type' );
- var message = messageElement.firstChild.nodeValue;
-
- document.getElementById( 'message' ).innerHTML = message;
- document.getElementById( 'message' ).style.display = 'block';
-
-}
-
-
-*/
-
-
-
-
function getOUDetails(orgUnitIds)
{
var url = "getOrgUnitDetails.action?orgUnitId=" + orgUnitIds;
@@ -172,6 +134,7 @@
var model = reports[ i ].getElementsByTagName( "model" )[0].firstChild.nodeValue;
var fileName = reports[ i ].getElementsByTagName( "fileName" )[0].firstChild.nodeValue;
var checkerFileName = reports[ i ].getElementsByTagName( "checkerFileName" )[0].firstChild.nodeValue;
+ var datasetId = reports[ i ].getElementsByTagName( "datasetid" )[0].firstChild.nodeValue;
var ouName = reports[ i ].getElementsByTagName( "ouName" )[0].firstChild.nodeValue;
orgUnitName.value = ouName;
@@ -181,16 +144,16 @@
option.text = name;
reportsList.add( option, null );
- reportModels.put(id,model);
- reportFileNames.put(id,fileName);
- checkerFileNames.put(id,checkerFileName);
+ reportModels.put( id, model );
+ reportFileNames.put( id, fileName );
+ checkerFileNames.put( id, checkerFileName );
+ reportDatasets.put( id, datasetId );
}
}
function getPeriodsReceived( xmlObject )
{
var availablePeriods = document.getElementById( "availablePeriods" );
- var selectedPeriods = document.getElementById( "selectedPeriods" );
clearList( availablePeriods );
@@ -199,44 +162,15 @@
for ( var i = 0; i < periods.length; i++)
{
var id = periods[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue;
- //var startDate = periods[ i ].getElementsByTagName( "startDate" )[0].firstChild.nodeValue;
- //var endDate = periods[ i ].getElementsByTagName( "endDate" )[0].firstChild.nodeValue;
var periodName = periods[ i ].getElementsByTagName( "periodname" )[0].firstChild.nodeValue;
- if ( listContains( selectedPeriods, id ) == false )
- {
- var option = document.createElement( "option" );
- option.value = id;
- option.text = periodName;
- availablePeriods.add( option, null );
- }
- }
-
- // If the list of available periods is empty, an empty placeholder will be added
- //addOptionPlaceHolder( availablePeriods );
+ var option = document.createElement( "option" );
+ option.value = id;
+ option.text = periodName;
+ availablePeriods.add( option, null );
+ }
}
-/*
-// Overwrite or Don't Import Function
-function riradioSelection(evt)
-{
- selriRadioButton = evt.target.value;
- if(selriRadioButton == "overwrite")
- {
- document.ChartGenerationForm.reject.disabled = false
-
- document.ChartGenerationForm.overWrite.disabled = true;
-
- }// if block end
- else
- {
- document.ChartGenerationForm.reject.disabled = true;
-
- document.ChartGenerationForm.overWrite.disabled = false;
- }// else end
-}// function riradioSelection end
-*/
-
function submitImportForm()
{
if (formValidations())
@@ -245,5 +179,3 @@
document.getElementById( "reportForm" ).submit();
}
}
-
-
=== modified file 'local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/responseImportReport.vm'
--- local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/responseImportReport.vm 2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/responseImportReport.vm 2010-08-17 08:35:20 +0000
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<reports>
#foreach( $report in $reportList )
- <report>
- <id>$report.id</id>
- <name>$report.name</name>
- <model>$report.model</model>
- <fileName>$report.fileName</fileName>
- <checkerFileName>$report.checkerFileName</checkerFileName>
- <ouName>$encoder.xmlEncode( $ouName )</ouName>
- </report>
+ <report>
+ <id>$report.id</id>
+ <name>$report.name</name>
+ <model>$report.model</model>
+ <fileName>$report.fileName</fileName>
+ <checkerFileName>$report.checkerFileName</checkerFileName>
+ <datasetid>$report.datasetId</datasetid>
+ <ouName>$encoder.xmlEncode( $ouName )</ouName>
+ </report>
#end
</reports>
=== added file 'local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/responseStatus.vm'
--- local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/responseStatus.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-excelimport/src/main/webapp/dhis-web-excelimport/responseStatus.vm 2010-08-17 08:35:20 +0000
@@ -0,0 +1,6 @@
+
+<span id="message" style="display:block">$encoder.xmlEncode( $message )</span>
+
+<br/><br/>
+
+<input type="button" value="Back" onclick="window.location.href='excelImportForm.action'" />