=== 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 orgUnitList; public List 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 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(); List deCodesList = new ArrayList(); @@ -608,17 +620,15 @@ if ( deCodesList.isEmpty() ) deCodesList = getDECodes( deCodesImportXMLFileName ); - Iterator it = orgUnitList.iterator(); + Iterator it = orgUnitList.iterator(); OrganisationUnit currentOrgUnit = new OrganisationUnit(); while ( it.hasNext() ) - { - currentOrgUnit = (OrganisationUnit) it.next(); - Iterator it1 = deCodesList.iterator(); + Iterator 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 getStartingEndingPeriods( String deType, Calendar tempStartDate, Calendar tempEndDate ) { - List calendarList = new ArrayList(); 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"> - - + + @@ -47,6 +47,9 @@ + + + @@ -104,6 +107,9 @@ + + + === 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 css/StylesForTags.css - - - - - excelImportForm - - + + /main.vm + /dhis-web-excelimport/responseStatus.vm + /dhis-web-excelimport/menu.vm + + @@ -56,13 +45,11 @@ - - + /dhis-web-excelimport/responseDataElement.vm - plainTextError @@ -70,7 +57,6 @@ class="org.hisp.dhis.excelimport.action.GetPeriodsAction"> /dhis-web-excelimport/responsePeriod.vm - plainTextError @@ -80,7 +66,6 @@ /dhis-web-excelimport/responseImportReport.vm ../dhis-web-commons/ouwt/ouwt.js,javascript/reports.js,../dhis-web-commons/lists/lists.js,javascript/hashtable.js - plainTextError @@ -88,7 +73,6 @@ class="org.hisp.dhis.excelimport.action.GetOrgUnitsAction"> /dhis-web-excelimport/responseOrgUnit.vm - plainTextError === 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 @@ - - - Excel Import Form - - - -

Excel Import Form

-
-
-
- - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- PeriodType :
- -
- OrganisationUnit :
- -
  
  
- Periods :
- - -
- Reports :
- -
  
  
- New And Updates -   -
- New (No Updates) -
- ## 
  -
-
- ## - - - - - - - ## - - - - -
- -
-
- - - - + + + +

Excel Import Form

+

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ PeriodType :
+ +
+ OrganisationUnit :
+ +
  
  
+ Periods :
+ +
+ Reports :
+ +
  
  
+ New And Updates +  
+ New (No Updates) +
 
  +

+ + + + + + + + + +
+
+ + === 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 @@ #foreach( $report in $reportList ) - - $report.id - $report.name - $report.model - $report.fileName - $report.checkerFileName - $encoder.xmlEncode( $ouName ) - + + $report.id + $report.name + $report.model + $report.fileName + $report.checkerFileName + $report.datasetId + $encoder.xmlEncode( $ouName ) + #end === 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 @@ + +$encoder.xmlEncode( $message ) + +

+ +