dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12882
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4032: local vn
------------------------------------------------------------
revno: 4032
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-06-29 14:29:06 +0700
message:
local vn
- Fixed bug period list which does not change after pressed next/preview button.
- Fixed bug when adding export report item.
- Fixed bug copy import item.
- Changed a new style for previewing when generated report.
- Upgraded the import function in allowing user to preview the imported file and check (all) the needed value to import data for Normal and Category type.
added:
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/ViewDataGeneric.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java
modified:
local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/DefaultImportItemService.java
local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/ImportItemService.java
local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/ImportItemStore.java
local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/hibernate/HibernateImportItemStore.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exportitem/action/AddExportItemAction.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/GetPeriodsByImportReportAction.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataCategoryAction.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataNormalAction.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataCategoryAction.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataNormalAction.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/ExportXMLAction.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java
local/vn/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties
local/vn/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties
local/vn/dhis-web-excel-reporting/src/main/resources/struts.xml
local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/importDataParams.vm
local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js
local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/imports.js
local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js
local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/style/previewStyle.css
--
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/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/DefaultImportItemService.java'
--- local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/DefaultImportItemService.java 2011-06-24 07:04:01 +0000
+++ local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/DefaultImportItemService.java 2011-06-29 07:29:06 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.reportexcel.importitem;
/*
- * Copyright (c) 2004-2010, University of Oslo
+ * Copyright (c) 2004-2011, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -93,6 +93,11 @@
return i18n( i18nService, importItemStore.getImportReport( id ) );
}
+ public ExcelItemGroup getImportReport( String name )
+ {
+ return importItemStore.getImportReport( name );
+ }
+
public void updateImportReport( ExcelItemGroup importReport )
{
importItemStore.updateImportReport( importReport );
@@ -120,7 +125,6 @@
public void deleteImportItem( int id )
{
-
i18nService.removeObject( importItemStore.getImportItem( id ) );
importItemStore.deleteImportItem( id );
@@ -128,13 +132,11 @@
public Collection<ExcelItem> getAllImportItem()
{
-
return i18n( i18nService, importItemStore.getAllImportItem() );
}
public void updateImportItem( ExcelItem excelItem )
{
-
importItemStore.updateImportItem( excelItem );
i18nService.verify( excelItem );
@@ -142,10 +144,19 @@
public ExcelItem getImportItem( int id )
{
-
return i18n( i18nService, importItemStore.getImportItem( id ) );
}
+ public ExcelItem getImportItem( String name )
+ {
+ return importItemStore.getImportItem( name );
+ }
+
+ public Collection<Integer> getAllSheet()
+ {
+ return importItemStore.getSheets();
+ }
+
// -------------------------------------------------------------------------
// DataElement Order
// -------------------------------------------------------------------------
@@ -164,15 +175,4 @@
{
importItemStore.deleteDataElementGroupOrder( id );
}
-
- public ExcelItem getImportItem( String name )
- {
- return importItemStore.getImportItem( name );
- }
-
- public ExcelItemGroup getImportReport( String name )
- {
- return importItemStore.getImportReport( name );
- }
-
}
=== modified file 'local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/ImportItemService.java'
--- local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/ImportItemService.java 2011-05-24 07:48:23 +0000
+++ local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/ImportItemService.java 2011-06-29 07:29:06 +0000
@@ -42,6 +42,8 @@
public ExcelItem getImportItem( int id );
public ExcelItem getImportItem( String name );
+
+ public Collection<Integer> getAllSheet();
// -------------------------------------------------------------------------
// DataElement Order
=== modified file 'local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/ImportItemStore.java'
--- local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/ImportItemStore.java 2011-05-24 07:48:23 +0000
+++ local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/ImportItemStore.java 2011-06-29 07:29:06 +0000
@@ -28,7 +28,7 @@
public Collection<ExcelItemGroup> getImportReports( OrganisationUnit organisationUnit );
// -------------------------------------------------------------------------
- // Excelitem services
+ // Import Item services
// -------------------------------------------------------------------------
public int addImportItem( ExcelItem importItem );
@@ -42,6 +42,8 @@
public ExcelItem getImportItem( int id );
public ExcelItem getImportItem( String name );
+
+ public Collection <Integer> getSheets();
// -------------------------------------------------------------------------
// DataElement Order
=== modified file 'local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/hibernate/HibernateImportItemStore.java'
--- local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/hibernate/HibernateImportItemStore.java 2011-05-24 07:48:23 +0000
+++ local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importitem/hibernate/HibernateImportItemStore.java 2011-06-29 07:29:06 +0000
@@ -5,6 +5,7 @@
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.PeriodStore;
@@ -15,7 +16,7 @@
import org.hisp.dhis.reportexcel.importitem.ImportItemStore;
/*
- * Copyright (c) 2004-2010, University of Oslo
+ * Copyright (c) 2004-2011, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -190,7 +191,6 @@
@SuppressWarnings( "unchecked" )
public Collection<ExcelItemGroup> getImportReports( OrganisationUnit organisationUnit )
{
-
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria( ExcelItemGroup.class );
@@ -226,4 +226,14 @@
session.delete( getDataElementGroupOrder( id ) );
}
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<Integer> getSheets()
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ExcelItem.class );
+
+ return criteria.setProjection( Projections.distinct( Projections.property( "sheetNo" ) ) ).list();
+ }
}
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exportitem/action/AddExportItemAction.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exportitem/action/AddExportItemAction.java 2011-05-24 07:48:23 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exportitem/action/AddExportItemAction.java 2011-06-29 07:29:06 +0000
@@ -103,7 +103,7 @@
this.exportReportId = exportReportId;
}
- public Integer getReportId()
+ public Integer getExportReportId()
{
return exportReportId;
}
=== added file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/ViewDataGeneric.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/ViewDataGeneric.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/ViewDataGeneric.java 2011-06-29 07:29:06 +0000
@@ -0,0 +1,127 @@
+package org.hisp.dhis.reportexcel.importing;
+
+/*
+ * Copyright (c) 2004-2011, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.reportexcel.importitem.ExcelItem;
+import org.hisp.dhis.reportexcel.importitem.ExcelItemGroup;
+import org.hisp.dhis.reportexcel.importitem.ImportItemService;
+import org.hisp.dhis.reportexcel.state.SelectionManager;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id
+ */
+
+public abstract class ViewDataGeneric
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ protected ImportItemService importItemService;
+
+ public void setImportItemService( ImportItemService importItemService )
+ {
+ this.importItemService = importItemService;
+ }
+
+ protected SelectionManager selectionManager;
+
+ public void setSelectionManager( SelectionManager selectionManager )
+ {
+ this.selectionManager = selectionManager;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input && Output
+ // -------------------------------------------------------------------------
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ protected String xmlStructureResponse;
+
+ public String getXmlStructureResponse()
+ {
+ return xmlStructureResponse;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ try
+ {
+ ExcelItemGroup importReport = importItemService.getImportReport( selectionManager.getSelectedReportId() );
+
+ List<ExcelItem> importItems = new ArrayList<ExcelItem>( importReport.getExcelItems() );
+
+ if ( importItems == null || importItems.isEmpty() )
+ {
+ message = i18n.getString( "import_excel_items_cannot_be_empty" );
+
+ return ERROR;
+ }
+
+ executeViewData( importReport, importItems );
+
+ return SUCCESS;
+
+ }
+ catch ( Exception ex )
+ {
+ throw new RuntimeException( "Error while previewing the imported value", ex );
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Abstract method
+ // -------------------------------------------------------------------------
+
+ public abstract void executeViewData( ExcelItemGroup importReport, List<ExcelItem> importItems );
+}
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/GetPeriodsByImportReportAction.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/GetPeriodsByImportReportAction.java 2011-05-27 04:45:31 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/GetPeriodsByImportReportAction.java 2011-06-29 07:29:06 +0000
@@ -41,7 +41,6 @@
public class GetPeriodsByImportReportAction
extends ActionSupport
{
-
// -------------------------------------------------------------------------
// Dependences
// -------------------------------------------------------------------------
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataCategoryAction.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataCategoryAction.java 2011-06-07 05:41:55 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataCategoryAction.java 2011-06-29 07:29:06 +0000
@@ -29,7 +29,6 @@
import java.util.Date;
-import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -38,11 +37,10 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.reportexcel.importing.ImportDataGeneric;
-import org.hisp.dhis.reportexcel.importitem.ExcelItem;
-import org.hisp.dhis.reportexcel.utils.ExcelUtils;
/**
* @author Chau Thu Tran
+ * @author Dang Duy Hieu
* @version $Id$
*/
@@ -57,22 +55,14 @@
{
for ( int i = 0; i < importItemIds.length; i++ )
{
- int importItemId = Integer.parseInt( importItemIds[i].split( "-" )[0] );
-
- int rowIndex = Integer.parseInt( importItemIds[i].split( "-" )[1] );
-
- String expression = importItemIds[i].split( "-" )[2];
-
- ExcelItem importItem = importItemService.getImportItem( importItemId );
-
- Sheet sheet = wb.getSheetAt( importItem.getSheetNo() - 1 );
-
- String value = ExcelUtils.readValueImportingByPOI( rowIndex, importItem.getColumn(), sheet );
-
- addDataValue( expression, value, organisationUnit, period );
+ addDataValue( importItemIds[i].split( "-" )[0], importItemIds[i].split( "-" )[1], organisationUnit, period );
}
}
+ // -------------------------------------------------------------------------
+ // Supportive method
+ // -------------------------------------------------------------------------
+
private void addDataValue( String expression, String value, OrganisationUnit organisationUnit, Period period )
{
DataElementOperand operand = expressionService.getOperandsInExpression( expression ).iterator().next();
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataNormalAction.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataNormalAction.java 2011-06-07 05:41:55 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataNormalAction.java 2011-06-29 07:29:06 +0000
@@ -27,11 +27,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.Date;
-import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -40,11 +37,10 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.reportexcel.importing.ImportDataGeneric;
-import org.hisp.dhis.reportexcel.importitem.ExcelItem;
-import org.hisp.dhis.reportexcel.utils.ExcelUtils;
/**
* @author Chau Thu Tran
+ * @author Dang Duy Hieu
* @version $Id$
*/
@@ -52,45 +48,20 @@
extends ImportDataGeneric
{
// -------------------------------------------------------------------------
- // Inputs && Outputs
- // -------------------------------------------------------------------------
-
- private Integer importReportId;
-
- public void setImportReportId( Integer importReportId )
- {
- this.importReportId = importReportId;
- }
-
- // -------------------------------------------------------------------------
// Override the abstract method
// -------------------------------------------------------------------------
public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds, Workbook wb )
{
- Collection<ExcelItem> importItems = new ArrayList<ExcelItem>();
-
- if ( importItemIds != null )
- {
- for ( int i = 0; i < importItemIds.length; i++ )
- {
- importItems.add( importItemService.getImportItem( importItemIds[i] ) );
- }
- }
- else
- {
- importItems = importItemService.getImportReport( importReportId ).getExcelItems();
- }
-
- for ( ExcelItem importItem : importItems )
- {
- Sheet sheet = wb.getSheetAt( importItem.getSheetNo() - 1 );
-
- String value = ExcelUtils.readValueImportingByPOI( importItem.getRow(), importItem.getColumn(), sheet );
+ String value = null;
+
+ for ( int i = 0; i < importItemIds.length; i++ )
+ {
+ value = importItemIds[i].split( "_" )[1];
if ( value.length() > 0 )
{
- DataElementOperand operand = expressionService.getOperandsInExpression( importItem.getExpression() )
+ DataElementOperand operand = expressionService.getOperandsInExpression( importItemIds[i].split( "_" )[0] )
.iterator().next();
DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() );
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataCategoryAction.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataCategoryAction.java 2011-06-07 05:41:55 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataCategoryAction.java 2011-06-29 07:29:06 +0000
@@ -27,152 +27,72 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.File;
-import java.io.FileInputStream;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.reportexcel.DataElementGroupOrder;
-import org.hisp.dhis.reportexcel.importing.ImportItemValue;
+import org.hisp.dhis.reportexcel.importing.ViewDataGeneric;
import org.hisp.dhis.reportexcel.importitem.ExcelItem;
import org.hisp.dhis.reportexcel.importitem.ExcelItemGroup;
-import org.hisp.dhis.reportexcel.importitem.ImportItemService;
-import org.hisp.dhis.reportexcel.importitem.comparator.ImportItemComparator;
-import org.hisp.dhis.reportexcel.state.SelectionManager;
-import org.hisp.dhis.reportexcel.utils.ExcelUtils;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.reportexcel.preview.action.XMLStructureResponseImport;
/**
- * @author Chau Thu Tran
+ * @author Dang Duy Hieu
* @version $Id
*/
public class ViewDataCategoryAction
- implements Action
+ extends ViewDataGeneric
{
// -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private ImportItemService importItemService;
-
- public void setImportItemService( ImportItemService importItemService )
- {
- this.importItemService = importItemService;
- }
-
- private SelectionManager selectionManager;
-
- public void setSelectionManager( SelectionManager selectionManager )
- {
- this.selectionManager = selectionManager;
- }
-
- // -------------------------------------------------------------------------
- // Inputs && Outputs
- // -------------------------------------------------------------------------
-
- private List<ImportItemValue> importItemValues = new ArrayList<ImportItemValue>();
-
- private String message;
-
- private I18n i18n;
-
- // -------------------------------------------------------------------------
- // Getters and Setters
- // -------------------------------------------------------------------------
-
- public List<ImportItemValue> getImportItemValues()
- {
- return importItemValues;
- }
-
- public String getMessage()
- {
- return message;
- }
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
- // -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
- public String execute()
+ @Override
+ public void executeViewData( ExcelItemGroup importReport, List<ExcelItem> importItems )
{
try
{
- FileInputStream inputStream = new FileInputStream( new File( selectionManager.getUploadFilePath() ) );
-
- Workbook wb = new HSSFWorkbook( inputStream );
-
- ExcelItemGroup importReport = importItemService.getImportReport( selectionManager.getSelectedReportId() );
-
- List<ExcelItem> importItems = new ArrayList<ExcelItem>( importReport.getExcelItems() );
-
- if ( importItems == null || importItems.isEmpty() )
- {
- message = i18n.getString( "import_excel_items_cannot_be_empty" );
-
- return ERROR;
- }
-
- Collections.sort( importItems, new ImportItemComparator() );
-
- for ( ExcelItem importItem : importItems )
- {
- Sheet sheet = wb.getSheetAt( importItem.getSheetNo() - 1 );
-
- int rowBegin = importItem.getRow();
-
- for ( DataElementGroupOrder dataElementGroup : importReport.getDataElementOrders() )
- {
- for ( DataElement dataElement : dataElementGroup.getDataElements() )
- {
- String value = ExcelUtils.readValueImportingByPOI( rowBegin, importItem.getColumn(), sheet );
-
- ExcelItem item = new ExcelItem();
-
- item.setId( importItem.getId() );
-
- item.setExpression( importItem.getExpression().replace( "*",
- String.valueOf( dataElement.getId() ) ) );
-
- item.setName( importItem.getName() + " - " + dataElement.getName() );
-
- item.setRow( rowBegin );
-
- ImportItemValue importItemValue = new ImportItemValue( item, value );
-
- importItemValues.add( importItemValue );
-
- rowBegin++;
-
- } // for (DataElementGroupOrder ...
-
- } // for (DataElement ...
-
- }// end for (ImportItem ...
-
- return SUCCESS;
-
+ List<ExcelItem> categoryImportItems = new ArrayList<ExcelItem>();
+
+ setUpImportItems( importReport, importItems, categoryImportItems );
+
+ xmlStructureResponse = new XMLStructureResponseImport( selectionManager.getUploadFilePath(),
+ importItemService.getAllSheet(), categoryImportItems, true, ExcelItemGroup.TYPE.CATEGORY ).getXml();
}
catch ( Exception ex )
{
ex.printStackTrace();
}
-
- return ERROR;
- }
-
+ }
+
+ // -------------------------------------------------------------------------
+ // Supportive method
+ // -------------------------------------------------------------------------
+
+ private void setUpImportItems( ExcelItemGroup importReport, List<ExcelItem> importItemsSource,
+ List<ExcelItem> importItemsDest )
+ {
+ for ( ExcelItem importItem : importItemsSource )
+ {
+ int rowBegin = importItem.getRow();
+
+ for ( DataElementGroupOrder dataElementGroup : importReport.getDataElementOrders() )
+ {
+ for ( DataElement dataElement : dataElementGroup.getDataElements() )
+ {
+ ExcelItem item = new ExcelItem();
+
+ item.setId( importItem.getId() );
+
+ item.setExpression( importItem.getExpression().replace( "*", dataElement.getId() + "" ) );
+
+ item.setRow( rowBegin++ );
+
+ importItemsDest.add( item );
+ }
+ }
+ }
+ }
}
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataNormalAction.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataNormalAction.java 2011-06-07 05:41:55 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataNormalAction.java 2011-06-29 07:29:06 +0000
@@ -27,120 +27,32 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.reportexcel.importing.ImportItemValue;
+import org.hisp.dhis.reportexcel.importing.ViewDataGeneric;
import org.hisp.dhis.reportexcel.importitem.ExcelItem;
import org.hisp.dhis.reportexcel.importitem.ExcelItemGroup;
-import org.hisp.dhis.reportexcel.importitem.ImportItemService;
-import org.hisp.dhis.reportexcel.importitem.comparator.ImportItemComparator;
-import org.hisp.dhis.reportexcel.state.SelectionManager;
-import org.hisp.dhis.reportexcel.utils.ExcelUtils;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.reportexcel.preview.action.XMLStructureResponseImport;
/**
- * @author Chau Thu Tran
* @author Dang Duy Hieu
* @version $Id
*/
public class ViewDataNormalAction
- implements Action
+ extends ViewDataGeneric
{
// -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private ImportItemService importItemService;
-
- public void setImportItemService( ImportItemService importItemService )
- {
- this.importItemService = importItemService;
- }
-
- private SelectionManager selectionManager;
-
- public void setSelectionManager( SelectionManager selectionManager )
- {
- this.selectionManager = selectionManager;
- }
-
- // -------------------------------------------------------------------------
- // Inputs && Outputs
- // -------------------------------------------------------------------------
-
- private List<ImportItemValue> importItemValues = new ArrayList<ImportItemValue>();
-
- private String message;
-
- private I18n i18n;
-
- // -------------------------------------------------------------------------
- // Getters and Setters
- // -------------------------------------------------------------------------
-
- public List<ImportItemValue> getImportItemValues()
- {
- return importItemValues;
- }
-
- public String getMessage()
- {
- return message;
- }
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
+ // Override abstract method
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void executeViewData( ExcelItemGroup importReport, List<ExcelItem> importItems )
{
try
{
- FileInputStream inputStream = new FileInputStream( new File( selectionManager.getUploadFilePath() ) );
-
- Workbook wb = new HSSFWorkbook( inputStream );
-
- ExcelItemGroup importReport = importItemService.getImportReport( selectionManager.getSelectedReportId() );
-
- List<ExcelItem> importItems = new ArrayList<ExcelItem>( importReport.getExcelItems() );
-
- if ( importItems == null || importItems.isEmpty() )
- {
- message = i18n.getString( "import_excel_items_cannot_be_empty" );
-
- return ERROR;
- }
-
- Collections.sort( importItems, new ImportItemComparator() );
-
- for ( ExcelItem importItem : importItems )
- {
- Sheet sheet = wb.getSheetAt( importItem.getSheetNo() - 1 );
-
- String value = ExcelUtils.readValueImportingByPOI( importItem.getRow(), importItem.getColumn(), sheet );
-
- ImportItemValue importItemValue = new ImportItemValue( importItem, value.trim() );
-
- importItemValues.add( importItemValue );
- }
-
- return SUCCESS;
-
+ xmlStructureResponse = new XMLStructureResponseImport( selectionManager.getUploadFilePath(),
+ importItemService.getAllSheet(), importItems, true, ExcelItemGroup.TYPE.NORMAL ).getXml();
}
catch ( Exception ex )
{
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/ExportXMLAction.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/ExportXMLAction.java 2011-06-07 05:41:55 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/ExportXMLAction.java 2011-06-29 07:29:06 +0000
@@ -27,7 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.File;
import java.io.IOException;
import org.hisp.dhis.reportexcel.ExportReportService;
@@ -46,9 +45,6 @@
public class ExportXMLAction
implements Action
{
-
- private static final String ENCODING = "UTF8";
-
// -------------------------------------------------------------------------
// Dependency
// -------------------------------------------------------------------------
@@ -70,11 +66,9 @@
// -------------------------------------------------------------------------
// Input && Output
// -------------------------------------------------------------------------
-
+
private String xmlStructureResponse;
- private File FILE_XLS;
-
// -------------------------------------------------------------------------
// Getter & Setter
// -------------------------------------------
@@ -88,38 +82,21 @@
// Action implementation
// -------------------------------------------------------------------------
- @SuppressWarnings( "static-access" )
public String execute()
throws IOException
{
try
{
- this.init();
-
- xmlStructureResponse = new XMLStructureResponse( this.FILE_XLS.getPath(), this.ENCODING, exportReportService
- .getSheets( selectionManager.getSelectedReportId() ), true, false, true, false, false )
- .getSTRUCTURE_DATA_RESPONSE();
-
- // this.FILE_XLS.deleteOnExit();
+ xmlStructureResponse = new XMLStructureResponse( selectionManager.getDownloadFilePath(),
+ exportReportService.getSheets( selectionManager.getSelectedReportId() ), false, false, true, false,
+ true ).getXml();
return SUCCESS;
}
catch ( Exception e )
{
- e.printStackTrace();
+ System.out.println( e.toString() );
return ERROR;
}
}
-
- // -------------------------------------------------------------------------
- // Supportive methods
- // -------------------------------------------------------------------------
-
- private void init()
- throws Exception
- {
- this.FILE_XLS = new File( selectionManager.getDownloadFilePath() );
-
- // inputStream.close();
- }
-}
+}
\ No newline at end of file
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java 2010-04-12 21:23:33 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java 2011-06-29 07:29:06 +0000
@@ -28,12 +28,9 @@
*/
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.util.Collection;
-import org.hisp.dhis.reportexcel.utils.StringUtils;
-
import jxl.Cell;
import jxl.CellType;
import jxl.Range;
@@ -41,8 +38,11 @@
import jxl.Workbook;
import jxl.format.CellFormat;
import jxl.format.Colour;
+import jxl.format.Font;
import jxl.format.Pattern;
+import org.hisp.dhis.reportexcel.utils.StringUtils;
+
/**
* Simple demo class which uses the api to present the contents of an excel 97
* spreadsheet as an XML document, using a workbook and output stream of your
@@ -57,25 +57,18 @@
/**
* The encoding to write
*/
- private StringBuffer STRUCTURE_DATA_RESPONSE = new StringBuffer( 200000 );
-
- /**
- * The encoding to write
- */
- private String ENCODING;
-
- /**
- * The workbook we are reading from
+ private StringBuffer xml = new StringBuffer( 200000 );
+
+ /**
+ * The workbook we are reading from a given file
*/
private Workbook WORKBOOK;
- private String PATH_FILE_NAME;
-
private boolean bWRITE_VERSION;
private boolean bWRITE_DTD;
- private static final String PREFIX_VERSION_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ private static final String XML_VERSION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
private static final String DOCTYPE_NORMAL = "<!DOCTYPE WORKBOOK SYSTEM \"WORKBOOK.dtd\">";
@@ -89,14 +82,13 @@
private static final String MERGEDCELL_CLOSETAG = "</MergedCells>";
- private static final String PRINT_END_LINE = "\n";
-
- // ------------------------------------------------
- // Get & Set methods //
- // ------------------------------------------------
- public String getSTRUCTURE_DATA_RESPONSE()
+ // -------------------------------------------------------------------------
+ // Get & Set methods
+ // -------------------------------------------------------------------------
+
+ protected String getXml()
{
- return STRUCTURE_DATA_RESPONSE.toString();
+ return xml.toString();
}
private void cleanUpForResponse()
@@ -115,28 +107,16 @@
* @exception java.io.IOException
*/
- public XMLStructureResponse()
- {
- }
-
- public XMLStructureResponse( String pathFileName, String enc, Collection<Integer> collectSheets, boolean bFormat,
- boolean bDetailed, boolean bWriteDescription, boolean bWriteVersion, boolean bWriteDTD )
-
+ public XMLStructureResponse( String pathFileName, Collection<Integer> collectSheets, boolean bWriteDTD,
+ boolean bWriteVersion, boolean bFormat, boolean bDetailed, boolean bWriteDescription )
throws Exception
{
this.cleanUpForResponse();
- this.ENCODING = enc;
this.bWRITE_DTD = bWriteDTD;
this.bWRITE_VERSION = bWriteVersion;
- this.PATH_FILE_NAME = pathFileName;
this.WORKBOOK = Workbook.getWorkbook( new File( pathFileName ) );
- if ( this.ENCODING == null || !this.ENCODING.equals( "UnicodeBig" ) )
- {
- this.ENCODING = "UTF8";
- }
-
if ( bFormat )
{
writeFormattedXML( collectSheets, bDetailed, bWriteDescription );
@@ -155,55 +135,45 @@
{
if ( this.bWRITE_VERSION )
{
- STRUCTURE_DATA_RESPONSE.append( PREFIX_VERSION_XML );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( XML_VERSION );
}
if ( this.bWRITE_DTD )
{
- STRUCTURE_DATA_RESPONSE.append( DOCTYPE_NORMAL );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( DOCTYPE_NORMAL );
}
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
- STRUCTURE_DATA_RESPONSE.append( WORKBOOK_OPENTAG );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( WORKBOOK_OPENTAG );
for ( Integer sheet : collectSheets )
{
Sheet s = WORKBOOK.getSheet( sheet - 1 );
- STRUCTURE_DATA_RESPONSE.append( " <sheet id=\"" + sheet + "\">" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
- STRUCTURE_DATA_RESPONSE.append( " <name><![CDATA[" + s.getName() + "]]></name>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<sheet id='" + sheet + "'>" );
+ xml.append( "<name><![CDATA[" + s.getName() + "]]></name>" );
Cell[] row = null;
for ( int i = 0; i < s.getRows(); i++ )
{
- STRUCTURE_DATA_RESPONSE.append( " <row number=\"" + i + "\">" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<row number='" + i + "'>" );
+
row = s.getRow( i );
for ( int j = 0; j < row.length; j++ )
{
if ( row[j].getType() != CellType.EMPTY )
{
- STRUCTURE_DATA_RESPONSE.append( " <col number=\"" + j + "\">" );
- STRUCTURE_DATA_RESPONSE.append( "<![CDATA[" + row[j].getContents() + "]]>" );
- STRUCTURE_DATA_RESPONSE.append( "</col>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<col number='" + j + "'>" );
+ xml.append( "<![CDATA[" + row[j].getContents() + "]]>" );
+ xml.append( "</col>" );
}
}
- STRUCTURE_DATA_RESPONSE.append( " </row>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "</row>" );
}
- STRUCTURE_DATA_RESPONSE.append( " </sheet>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "</sheet>" );
}
- STRUCTURE_DATA_RESPONSE.append( WORKBOOK_CLOSETAG );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( WORKBOOK_CLOSETAG );
}
/**
@@ -217,59 +187,47 @@
private void writeFormattedXML( Collection<Integer> collectSheets, boolean bDetailed, boolean bWriteDescription )
throws Exception
{
- FileInputStream fis = new FileInputStream( this.PATH_FILE_NAME );
- org.apache.poi.ss.usermodel.Workbook hssfwb = new org.apache.poi.hssf.usermodel.HSSFWorkbook( fis );
-
if ( bWriteDescription )
{
- this.writeXMLDescription( collectSheets );
+ this.writeXMLMergedDescription( collectSheets );
}
if ( this.bWRITE_VERSION )
{
- STRUCTURE_DATA_RESPONSE.append( PREFIX_VERSION_XML );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( XML_VERSION );
}
if ( this.bWRITE_DTD )
{
- STRUCTURE_DATA_RESPONSE.append( DOCTYPE_FORMAT );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( DOCTYPE_FORMAT );
}
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
- STRUCTURE_DATA_RESPONSE.append( WORKBOOK_OPENTAG );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( WORKBOOK_OPENTAG );
for ( Integer sheet : collectSheets )
{
- writeBySheetNo( hssfwb, (sheet - 1), bDetailed );
+ writeBySheetNo( sheet, bDetailed );
}
- STRUCTURE_DATA_RESPONSE.append( WORKBOOK_CLOSETAG );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( WORKBOOK_CLOSETAG );
}
// -------------------------------------------------------------------------
// Sub-methods
// -------------------------------------------------------------------------
- private void writeBySheetNo( org.apache.poi.ss.usermodel.Workbook wb, int sheetNo, boolean bDetailed )
+ private void writeBySheetNo( int sheetNo, boolean bDetailed )
{
- Sheet s = WORKBOOK.getSheet( sheetNo );
+ Sheet s = WORKBOOK.getSheet( sheetNo - 1 );
- STRUCTURE_DATA_RESPONSE.append( " <sheet id=\"" + (sheetNo + 1) + "\">" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
- STRUCTURE_DATA_RESPONSE.append( " <name><![CDATA[" + s.getName() + "]]></name>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<sheet id='" + (sheetNo) + "'>" );
+ xml.append( "<name><![CDATA[" + s.getName() + "]]></name>" );
Cell[] cell = null;
- CellFormat format = null;
for ( int i = 0; i < s.getRows(); i++ )
{
- STRUCTURE_DATA_RESPONSE.append( " <row index=\"" + i + "\">" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<row index='" + i + "'>" );
cell = s.getRow( i );
@@ -277,121 +235,97 @@
{
// Remember that empty cells can contain format
// information
- if ( (cell[j].getType() != CellType.EMPTY) || (cell[j].getCellFormat() != null) )
+ if ( !cell[j].getType().equals( CellType.EMPTY ) || (cell[j].getCellFormat() != null) )
{
- STRUCTURE_DATA_RESPONSE.append( " <col no=\"" + j + "\">" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
- STRUCTURE_DATA_RESPONSE.append( " <data>" );
-
- STRUCTURE_DATA_RESPONSE.append( "<![CDATA["
- + StringUtils.applyPatternDecimalFormat( cell[j].getContents() ) + "]]>" );
-
- STRUCTURE_DATA_RESPONSE.append( "</data>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
-
- this.readingDetailsFormattedCell( format, cell[j], bDetailed );
-
- STRUCTURE_DATA_RESPONSE.append( " </col>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<col no='" + j + "'><data>" );
+ xml.append( "<![CDATA[" + StringUtils.applyPatternDecimalFormat( cell[j].getContents() )
+ + "]]></data>" );
+
+ this.readingDetailsFormattedCell( cell[j], bDetailed );
+
+ xml.append( "</col>" );
}
}
- STRUCTURE_DATA_RESPONSE.append( " </row>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "</row>" );
}
- STRUCTURE_DATA_RESPONSE.append( " </sheet>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "</sheet>" );
}
- private void readingDetailsFormattedCell( jxl.format.CellFormat format, jxl.Cell objCell, boolean bDetailed )
+ private void readingDetailsFormattedCell( Cell objCell, boolean bDetailed )
{
// The format information
- format = objCell.getCellFormat();
- jxl.format.Font font = null;
+ CellFormat format = objCell.getCellFormat();
+ Font font = null;
if ( format != null )
{
- STRUCTURE_DATA_RESPONSE.append( " <format align=\""
- + StringUtils.convertAlignmentString( format.getAlignment().getDescription() ) + "\"" );
+ xml.append( "<format align='" + StringUtils.convertAlignmentString( format.getAlignment().getDescription() )
+ + "'" );
if ( bDetailed )
{
- STRUCTURE_DATA_RESPONSE.append( " valign=\"" + format.getVerticalAlignment().getDescription() + "\"" );
- STRUCTURE_DATA_RESPONSE.append( ">" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( " valign='" + format.getVerticalAlignment().getDescription() + "'>" );
// The font information
font = format.getFont();
- STRUCTURE_DATA_RESPONSE.append( " <font point_size=\"" + font.getPointSize() + "\"" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
- STRUCTURE_DATA_RESPONSE.append( " bold_weight=\"" + font.getBoldWeight() + "\"" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
- STRUCTURE_DATA_RESPONSE.append( " italic=\"" + font.isItalic() + "\"" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
- STRUCTURE_DATA_RESPONSE.append( " underline=\""
- + font.getUnderlineStyle().getDescription() + "\"" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
- STRUCTURE_DATA_RESPONSE.append( " colour=\"" + font.getColour().getDescription() + "\"" );
- STRUCTURE_DATA_RESPONSE.append( " />" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<font point_size='" + font.getPointSize() + "'" );
+ xml.append( " bold_weight='" + font.getBoldWeight() + "'" );
+ xml.append( " italic='" + font.isItalic() + "'" );
+ xml.append( " underline='" + font.getUnderlineStyle().getDescription() + "'" );
+ xml.append( " colour='" + font.getColour().getDescription() + "'" );
+ xml.append( " />" );
// The cell background information
if ( format.getBackgroundColour() != Colour.DEFAULT_BACKGROUND || format.getPattern() != Pattern.NONE )
{
- STRUCTURE_DATA_RESPONSE.append( " <background colour=\""
- + format.getBackgroundColour().getDescription() + "\"" );
- STRUCTURE_DATA_RESPONSE.append( " />" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<background colour='" + format.getBackgroundColour().getDescription() + "'" );
+ xml.append( " />" );
}
// The cell number/date format
if ( !format.getFormat().getFormatString().equals( "" ) )
{
- STRUCTURE_DATA_RESPONSE.append( " <format_string string=\"" );
- STRUCTURE_DATA_RESPONSE.append( format.getFormat().getFormatString() );
- STRUCTURE_DATA_RESPONSE.append( "\" />" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<format_string string='" );
+ xml.append( format.getFormat().getFormatString() );
+ xml.append( "' />" );
}
- STRUCTURE_DATA_RESPONSE.append( " </format>" );
+ xml.append( "</format>" );
}
else
{
- STRUCTURE_DATA_RESPONSE.append( "/>" );
+ xml.append( "/>" );
}
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
}
}
// -------------------------------------------------------------------------
// Get the merged cell's information
// -------------------------------------------------------------------------
- private void writeXMLDescription( Collection<Integer> collectSheets )
+ private void writeXMLMergedDescription( Collection<Integer> collectSheets )
throws IOException
{
// Get the Range of the Merged Cells //
if ( this.bWRITE_VERSION )
{
- STRUCTURE_DATA_RESPONSE.append( PREFIX_VERSION_XML );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE + PRINT_END_LINE );
+ xml.append( XML_VERSION );
}
// Open the main Tag //
- STRUCTURE_DATA_RESPONSE.append( MERGEDCELL_OPENTAG );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( MERGEDCELL_OPENTAG );
for ( Integer sheet : collectSheets )
{
- writeBySheetNo( sheet - 1 );
+ writeBySheetNo( sheet );
}
// Close the main Tag //
- STRUCTURE_DATA_RESPONSE.append( MERGEDCELL_CLOSETAG );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( MERGEDCELL_CLOSETAG );
}
private void writeBySheetNo( int sheetNo )
{
- Sheet sheet = WORKBOOK.getSheet( sheetNo );
+ Sheet sheet = WORKBOOK.getSheet( sheetNo - 1 );
Range[] aMergedCell = sheet.getMergedCells();
int iColTopLeft = 0;
@@ -406,11 +340,9 @@
if ( iColTopLeft != iColBottomRight )
{
- STRUCTURE_DATA_RESPONSE.append( " <cell" + " iKey=\"" + (sheetNo + 1) + "#" + iRowTopLeft + "#"
- + iColTopLeft + "\">" + (iColBottomRight - iColTopLeft + 1) + "</cell>" );
- STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
+ xml.append( "<cell " + "iKey='" + (sheetNo) + "#" + iRowTopLeft + "#" + iColTopLeft + "'>"
+ + (iColBottomRight - iColTopLeft + 1) + "</cell>" );
}
}
}
-
-}
+}
\ No newline at end of file
=== added file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java 2011-06-29 07:29:06 +0000
@@ -0,0 +1,248 @@
+package org.hisp.dhis.reportexcel.preview.action;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import static org.hisp.dhis.reportexcel.utils.StringUtils.convertAlignmentString;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import jxl.Cell;
+import jxl.CellType;
+import jxl.Range;
+import jxl.Sheet;
+import jxl.Workbook;
+import jxl.format.CellFormat;
+
+import org.hisp.dhis.reportexcel.importitem.ExcelItem;
+import org.hisp.dhis.reportexcel.importitem.ExcelItemGroup;
+
+/**
+ *
+ * @author Dang Duy Hieu
+ * @version $Id XMLStructureResponse.java 2011-06-28 16:08:00$
+ */
+
+public class XMLStructureResponseImport
+{
+ /**
+ * The encoding to write
+ */
+ private StringBuffer xml = new StringBuffer( 200000 );
+
+ /**
+ * The workbook we are reading from a given file
+ */
+ private Workbook WORKBOOK;
+
+ 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>";
+
+ // -------------------------------------------------------------------------
+ // Get & Set methods
+ // -------------------------------------------------------------------------
+
+ public String getXml()
+ {
+ return xml.toString();
+ }
+
+ /**
+ * Constructor
+ *
+ * @param importItems
+ * @param type The TYPE for importing
+ *
+ * @param w The workbook to interrogate
+ * @param enc The encoding used by the output stream. Null or unrecognized
+ * values cause the encoding to default to UTF8
+ * @param f Indicates whether the generated XML document should contain the
+ * cell format information
+ * @exception java.io.IOException
+ */
+
+ public XMLStructureResponseImport( String pathFileName, Collection<Integer> collectSheets,
+ List<ExcelItem> importItems, boolean bWriteDescription, String type )
+ throws Exception
+ {
+ this.cleanUpForResponse();
+
+ FileInputStream inputStream = new FileInputStream( new File( pathFileName ) );
+
+ this.WORKBOOK = Workbook.getWorkbook( inputStream );
+
+ this.writeFormattedXML( collectSheets, importItems, bWriteDescription, type );
+ }
+
+ // -------------------------------------------------------------------------
+ // Public methods
+ // -------------------------------------------------------------------------
+
+ public void writeData( int sheetNo, List<ExcelItem> importItems, String TYPE )
+ {
+ Sheet s = WORKBOOK.getSheet( sheetNo - 1 );
+
+ xml.append( "<sheet id='" + (sheetNo) + "'>" );
+ xml.append( "<name><![CDATA[" + s.getName() + "]]></name>" );
+
+ Cell[] cell = null;
+ int run = 0;
+
+ for ( int i = 0; i < s.getRows(); i++ )
+ {
+ xml.append( "<row index='" + i + "'>" );
+
+ cell = s.getRow( i );
+
+ for ( int j = 0; j < cell.length; j++ )
+ {
+ // Remember that empty cells can contain format information
+ if ( !cell[j].getType().equals( CellType.EMPTY ) || (cell[j].getCellFormat() != null) )
+ {
+ xml.append( "<col no='" + j + "'" );
+
+ for ( ExcelItem importItem : importItems )
+ {
+ if ( (importItem.getSheetNo() == sheetNo) && (importItem.getRow() == (i + 1))
+ && (importItem.getColumn() == (j + 1)) )
+ {
+ if ( TYPE.equals( ExcelItemGroup.TYPE.NORMAL ) )
+ {
+ xml.append( " id='" + importItem.getExpression() + "'>" );
+ }
+ else if ( TYPE.equals( ExcelItemGroup.TYPE.CATEGORY ) )
+ {
+ xml.append( " id='" + importItem.getExpression() + "'>" );
+ }
+
+ break;
+ }
+
+ run++;
+ }
+
+ if ( run == importItems.size() )
+ {
+ xml.append( ">" );
+ } // end checking
+
+ xml.append( "<data><![CDATA[" + cell[j].getContents() + "]]></data>" );
+
+ this.readingDetailsFormattedCell( cell[j] );
+
+ xml.append( "</col>" );
+ }
+ }
+ xml.append( "</row>" );
+ }
+ xml.append( "</sheet>" );
+ }
+
+ // -------------------------------------------------------------------------
+ // Private methods
+ // -------------------------------------------------------------------------
+
+ private void cleanUpForResponse()
+ {
+ System.gc();
+ }
+
+ private void writeFormattedXML( Collection<Integer> collectSheets, List<ExcelItem> importItems,
+ boolean bWriteDescription, String type )
+ throws Exception
+ {
+ if ( bWriteDescription )
+ {
+ this.writeXMLMergedDescription( collectSheets );
+ }
+
+ xml.append( WORKBOOK_OPENTAG );
+
+ for ( Integer sheet : collectSheets )
+ {
+ writeData( sheet, importItems, type );
+ }
+
+ xml.append( WORKBOOK_CLOSETAG );
+ }
+
+ private void writeXMLMergedDescription( Collection<Integer> collectSheets )
+ throws IOException
+ {
+ xml.append( MERGEDCELL_OPENTAG );
+
+ for ( Integer sheet : collectSheets )
+ {
+ writeBySheetNo( sheet );
+ }
+
+ xml.append( MERGEDCELL_CLOSETAG );
+ }
+
+ private void writeBySheetNo( int sheetNo )
+ {
+ Sheet sheet = WORKBOOK.getSheet( sheetNo - 1 );
+ Range[] aMergedCell = sheet.getMergedCells();
+
+ int iColTopLeft = 0;
+ int iRowTopLeft = 0;
+ int iColBottomRight = 0;
+
+ for ( int j = 0; j < aMergedCell.length; j++ )
+ {
+ iColTopLeft = aMergedCell[j].getTopLeft().getColumn();
+ iRowTopLeft = aMergedCell[j].getTopLeft().getRow();
+ iColBottomRight = aMergedCell[j].getBottomRight().getColumn();
+
+ if ( iColTopLeft != iColBottomRight )
+ {
+ xml.append( "<cell " + "iKey='" + (sheetNo) + "#" + iRowTopLeft + "#" + iColTopLeft + "'>"
+ + (iColBottomRight - iColTopLeft + 1) + "</cell>" );
+ }
+ }
+ }
+
+ private void readingDetailsFormattedCell( Cell objCell )
+ {
+ // The format information
+ CellFormat format = objCell.getCellFormat();
+
+ if ( format != null )
+ {
+ xml.append( "<format align='" + convertAlignmentString( format.getAlignment().getDescription() ) + "'/>" );
+ }
+ }
+}
\ No newline at end of file
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties'
--- local/vn/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2011-06-07 10:07:02 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2011-06-29 07:29:06 +0000
@@ -59,7 +59,10 @@
filter_by_sheet = Filter by sheet
configuration = Configuration
excel_file_directory = Excel template directory
-copy_selected_item_to = Copy selected items to
+copy_export_item_to_exportreport = Copy export items to Export report
+copy_export_item_to_importreport = Copy export items to Import report
+copy_import_item_to_exportreport = Copy import items to Export report
+copy_import_item_to_importreport = Copy import items to Import report
import_excel_file_manager = Import excel files
select_excel_file = Select excel file
upload_file = Upload
@@ -112,7 +115,7 @@
select = [Select]
working_in_progress = Working in progress...
sheet_of_excel_file = Sheet of Excel file
-generate_report_by_orgunit_group = Generate report by orgunit group
+generate_report_by_orgunit_group = Generate report by orgunit group
clean_up = Clean temporary directory
cleanup_success = Clean up successful
individual_report = Individual reports
@@ -129,13 +132,12 @@
upload_file_first = Upload file first \!
please_enter_sheet_no = Please enter 'Sheet No'
please_enter_group_name = Please enter group name
-import_item = Excel items
+import_items = Excel items
associations = Associations
sheetNo = Sheet
choose_import_item = Please choose import items
copy_items_duplicated = Warning! Cannot copy the duplicated item(s)
copy_successful = Copy successful \!
-copy_selected_item_to_import_item = Copy export item to import item
import_report = Import Report
copy_items = Copy items
filter_by_name = Filter by name
@@ -229,9 +231,10 @@
report_import_item = Report Excel Item
name_ready_exist_in_sheet = This report item name was exits in this sheet
please_enter_row_and_column_first = Please enter row and column first
-add_report_import_item = Add Report Excel Item
+add_import_item = Add Import Item
+add_export_item = Add Export Item
report_excel = Report Excel
-update_report_import_item = Update Report Excel Item
+update_report_import_item = Update Report Import Item
import_type = Import type
excel_importing = Excel Importing
import_item = Import Item
@@ -281,4 +284,5 @@
import_successfully = Import successfully
period_listing_importing_not_support = Sorry\! Period Listing Importing is not supported.
missing_template = Warning\! Missing template.
-the_specified_report_is_not_exist = Warning\! The specified report is not available/non-existance.
\ No newline at end of file
+the_specified_report_is_not_exist = Warning\! The specified report is not available/non-existance.
+select_sheet_for_filter = Select sheet for filter
\ No newline at end of file
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties'
--- local/vn/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2011-06-07 10:07:02 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2011-06-29 07:29:06 +0000
@@ -96,7 +96,10 @@
filter_by_sheet = Xem theo sheet
configuration = C\u1ea5u h\u00ecnh
excel_file_directory = Th\u01b0 m\u1ee5c ch\u1ee9 t\u1eadp tin b\u00e1o c\u00e1o m\u1eabu
-copy_selected_item_to = Sao ch\u00e9p c\u00e1c m\u1ee5c ch\u1ecdn
+copy_export_item_to_exportreport = Sao ch\u00e9p ph\u1ea7n t\u1eed Xu\u1ea5t t\u1edbi b\u00e1o c\u00e1o Xu\u1ea5t
+copy_export_item_to_importreport = Sao ch\u00e9p ph\u1ea7n t\u1eed Xu\u1ea5t t\u1edbi b\u00e1o c\u00e1o Nh\u1eadp
+copy_import_item_to_exportreport = Sao ch\u00e9p ph\u1ea7n t\u1eed Nh\u1eadp t\u1edbi b\u00e1o c\u00e1o Xu\u1ea5t
+copy_import_item_to_importreport = Sao ch\u00e9p ph\u1ea7n t\u1eed Nh\u1eadp t\u1edbi b\u00e1o c\u00e1o Nh\u1eadp
import_excel_file_manager = Qu\u1ea3n l\u00fd t\u1eadp tin b\u00e1o c\u00e1o excel
select_excel_file = Ch\u1ecdn t\u1eadp tin excel
upload_file = T\u1ea3i l\u00ean
@@ -148,7 +151,6 @@
please_enter_group_name = Vui l\u00f2ng nh\u1eadp t\u00ean nh\u00f3m
copy_items_duplicated = Item b\u1ecb tr\u00f9ng l\u1eb7p, kh\u00f4ng th\u1ec3 sao ch\u00e9p \!
copy_successful = Sao ch\u00e9p th\u00e0nh c\u00f4ng \!
-copy_selected_item_to_import_item = Sao ch\u00e9p export item cho import item
improt_report = B\u00e1o c\u00e1o Nh\u1eadp
copy_items = Sao ch\u00e9p ph\u1ea7n t\u1eed excel
period_type = Lo\u1ea1i th\u1eddi \u0111i\u1ec3m
@@ -275,4 +277,5 @@
import_successfully = Import kh\u00f4ng th\u00e0nh c\u00f4ng
period_listing_importing_not_support = R\u1ea5t ti\u1ebfc, hi\u00ean t\u1ea1i h\u1ec7 th\u1ed1ng ch\u01b0a h\u1ed7 tr\u1ee3 import d\u1eef li\u1ec7u d\u1ea1ng danh s\u00e1ch theo th\u1eddi gian.
missing_template = C\u1ea3nh b\u00e1o\! T\u1eadp tin excel b\u1ecb thi\u1ebfu.
-the_specified_report_is_not_exist = C\u1ea3nh b\u00e1o\! B\u00e1o c\u00e1o n\u00e0y hi\u1ec7n t\u1ea1i kh\u00f4ng c\u00f2n gi\u00e1 tr\u1ecb.
\ No newline at end of file
+the_specified_report_is_not_exist = C\u1ea3nh b\u00e1o\! B\u00e1o c\u00e1o n\u00e0y hi\u1ec7n t\u1ea1i kh\u00f4ng c\u00f2n gi\u00e1 tr\u1ecb.
+select_sheet_for_filter = L\u1ecdc theo sheet
\ No newline at end of file
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/resources/struts.xml'
--- local/vn/dhis-web-excel-reporting/src/main/resources/struts.xml 2011-06-24 07:04:01 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/resources/struts.xml 2011-06-29 07:29:06 +0000
@@ -983,7 +983,7 @@
<action name="copyImportItems"
class="org.hisp.dhis.reportexcel.importitem.action.CopyImportItemAction">
- <result name="success" type="velocity-xml">
+ <result name="success" type="velocity-json">
/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
</action>
@@ -1021,16 +1021,19 @@
<param name="menuTreeHeight">220</param>
<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,
javascript/export.js,
+ javascript/preview.js,
javascript/imports.js</param>
- <param name="stylesheets">style/style.css</param>
+ <param name="stylesheets">
+ style/style.css,
+ style/previewStyle.css</param>
</action>
<action name="getPeriodsByImportReport"
class="org.hisp.dhis.reportexcel.importing.action.GetPeriodsByImportReportAction">
- <result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlPeriods.vm</result>
- <result name="error" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseError.vm</result>
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonPeriods.vm</result>
+ <result name="error" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseError.vm</result>
</action>
<action name="openImportReportAssociations"
@@ -1057,8 +1060,8 @@
<!-- function - Prewiew Data - NORMAL -->
<action name="previewDataNormal"
class="org.hisp.dhis.reportexcel.importing.action.ViewDataNormalAction">
- <result name="success" type="velocity">
- /dhis-web-excel-reporting/responseImportItemValues.vm</result>
+ <result name="success" type="velocity-xml">
+ /dhis-web-excel-reporting/responseExportReportPreview.vm</result>
<result name="error" type="velocity-xml">
/dhis-web-commons/ajax/xmlResponseError.vm</result>
</action>
@@ -1067,7 +1070,7 @@
<action name="previewDataCategory"
class="org.hisp.dhis.reportexcel.importing.action.ViewDataCategoryAction">
<result name="success" type="velocity">
- /dhis-web-excel-reporting/responseImportItemValuesByCategory.vm
+ /dhis-web-excel-reporting/responseExportReportPreview.vm
</result>
<result name="error" type="velocity-xml">
/dhis-web-commons/ajax/xmlResponseError.vm</result>
@@ -1087,37 +1090,37 @@
<action name="importData"
class="org.hisp.dhis.reportexcel.importing.action.ImportDataFlowAction">
<result name="NORMAL" type="redirect">
- importDataNormal?importReportId=${importReportId}</result>
+ importDataNormal.action</result>
<result name="CATEGORY" type="redirect">
- importDataCategory</result>
+ importDataCategory.action</result>
<result name="ORGANIZATION_GROUP_LISTING" type="redirect">
- importDataOrganizationGroup</result>
+ importDataOrganizationGroup.action</result>
<result name="PERIOD_COLUMN_LISTING" type="redirect">
- generateExportReportPeriodColumnListingAjax</result>
+ generateExportReportPeriodColumnListingAjax.action</result>
</action>
<action name="importDataNormal"
class="org.hisp.dhis.reportexcel.importing.action.ImportDataNormalAction">
- <result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseSuccess.vm</result>
- <result name="error" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseError.vm</result>
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseError.vm</result>
</action>
<action name="importDataCategory"
class="org.hisp.dhis.reportexcel.importing.action.ImportDataCategoryAction">
- <result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseSuccess.vm</result>
- <result name="error" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseError.vm</result>
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseError.vm</result>
</action>
<action name="importDataOrganizationGroup"
class="org.hisp.dhis.reportexcel.importing.action.ImportDataOrganizationGroupAction">
- <result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseSuccess.vm</result>
- <result name="error" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseError.vm</result>
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseError.vm</result>
</action>
<!-- Period Column -->
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/importDataParams.vm'
--- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/importDataParams.vm 2011-06-07 05:41:55 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/importDataParams.vm 2011-06-29 07:29:06 +0000
@@ -6,7 +6,7 @@
#end
<span id="message" style="top:70px;right:5px;position:fixed;width:200px;z-index:100009" onclick="hideById(this.id);"></span>
-<table width="62%">
+<table width="82%">
<h3>$i18n.getString('import_data') #openHelp( "excelReportingImportData" )</h3>
<form name="importingParam" id="importingParam" action="uploadExcelImport.action" method="POST" enctype="multipart/form-data">
<tr>
@@ -25,9 +25,17 @@
<option value="$!importReport.id">$!encoder.htmlEncode($!importReport.name)</option>
#end
</select>
- <input type="button" onClick="javascript: getPreviewImportData();" style="width:100px" value="$i18n.getString('preview')" #if(!$!fileExcel || !$!organisationUnit) disabled #end>
- </td>
- </tr>
+ </td>
+ </tr>
+ <tr>
+ <td>$i18n.getString( 'period' )</td>
+ <td>
+ <select name="period" id="period" style="min-width:20em;" type="text" #if(!$!fileExcel || !$!organisationUnit) disabled #end>
+ </select>
+ <input type="button" value="<<" id="lastYear" name="lastYear" onclick="getPreviousPeriod();" #if(!$!fileExcel || !$!organisationUnit) disabled #end/>
+ <input type="button" value=">>" id="nextYear" name="nextYear" onclick="getNextPeriod()" #if(!$!fileExcel || !$!organisationUnit) disabled #end />
+ </td>
+ </tr>
<tr>
<td> </td>
<td> </td>
@@ -35,39 +43,24 @@
</table>
<hr/>
+<input type="button" onClick="javascript: getPreviewImportData();" style="width:100px" value="$i18n.getString('preview')" #if(!$!fileExcel || !$!organisationUnit) disabled #end/>
+<input type="button" onClick="javascript: importData();" style="width:100px" value="$i18n.getString('import')" #if(!$!fileExcel || !$!organisationUnit) disabled #end/>
+<input type="button" onClick="javascript: selectAllData( this );" style="width:100px" value="$i18n.getString('select_all')" #if(!$!fileExcel || !$!organisationUnit) disabled #end/>
<br/><br/>
- <div id="showValue" style="display:none; width:100%" >
- <table>
- <tr style="vertical-align:bottom;">
- <td style="width:100px">$i18n.getString( 'period' )</td>
- <td>
- <select name="period" id="period" style="min-width:20em; width:100%" type="text" #if(!$!fileExcel || !$!organisationUnit) disabled #end>
- </select>
- </td>
- <td>
- <input type="button" value="<<" id="lastYear" name="lastYear" onclick="lastPeriod();" #if(!$!fileExcel || !$!organisationUnit) disabled #end/>
- <input type="button" value=">>" id="nextYear" name="nextYear" onclick="nextPeriod()" #if(!$!fileExcel || !$!organisationUnit) disabled #end />
- <input type="button" onClick="javascript: importData();" style="width:100px" value="$i18n.getString('import')" #if(!$!fileExcel || !$!organisationUnit) disabled #end>
- </td>
- </tr>
- </table>
- <table id="showImportItemValues" width="100%">
- <tr>
- <th width="20px"><input type="checkbox" name="selectAll" id="selectAll" onClick="javascript: selectAll();"/></th>
- <th>$i18n.getString('report')</th>
- <th>$i18n.getString('value')</th>
- </tr>
- <tbody>
-
- </tbody>
- </table>
- </div>
+
+<div id="previewDiv">
+</div>
+
+<script language="javascript">
- <script language="javascript">
- #if ( $!fileExcel && $!organisationUnit )
- getPeriodsByImportReport( $("#importReportId").val() );
- #end
- </script>
+ var i18n_choose_import_item = '$encoder.jsEscape( $i18n.getString( "choose_import_item" ) , "'")';
+ var i18n_select_all = '$encoder.jsEscape( $i18n.getString( "select_all" ) , "'")';
+ var i18n_unselect_all = '$encoder.jsEscape( $i18n.getString( "unselect_all" ) , "'")';
+
+ #if ( $!fileExcel && $!organisationUnit )
+ getPeriodsByImportReport( jQuery("#importReportId").val() );
+ #end
+</script>
</body>
\ No newline at end of file
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js'
--- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js 2011-06-07 10:07:02 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js 2011-06-29 07:29:06 +0000
@@ -56,21 +56,28 @@
function getPreviousPeriod()
{
- jQuery.postJSON('previousPeriodsGeneric.action', responseListPeriodReceived );
+ jQuery.postJSON('previousPeriodsGeneric.action', {}, responseListPeriodReceived );
}
function getNextPeriod()
{
- jQuery.postJSON('nextPeriodsGeneric.action', responseListPeriodReceived );
+ jQuery.postJSON('nextPeriodsGeneric.action', {}, responseListPeriodReceived );
}
function responseListPeriodReceived( json )
-{
- clearListById('period');
-
- jQuery.each( json.periods, function(i, item ){
- addOption('period', item.name , i );
- });
+{
+ if ( json.response == "error" )
+ {
+ setHeaderDelayMessage( json.message );
+ }
+ else
+ {
+ clearListById('period');
+
+ jQuery.each( json.periods, function(i, item ){
+ addOption('period', item.name , i );
+ });
+ }
}
function validateGenerateReport( isAdvanced )
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/imports.js'
--- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/imports.js 2011-06-07 05:41:55 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/imports.js 2011-06-29 07:29:06 +0000
@@ -7,263 +7,86 @@
// IMPORT DATA FROM EXCEL FILE INTO DATABASE
// -----------------------------------------------------------------------------
-function importData(){
-
- var importReportId = byId('importReportId').value;
- var periodId = byId('period').value;
-
- var request = new Request();
- request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( importDataCompleted );
-
- // URL
- var params = 'importReportId='+importReportId;
- // USER choose exportItem
- var preview = byId('showValue').style.display;
-
- if(preview == 'block'){
- var importItems = document.getElementsByName('importItems');
- for(var i=0;i<importItems.length;i++){
- if(importItems[i].checked ){
- params +='&importItemIds=' + importItems[i].value;
- }
+function importData()
+{
+ if ( importItemIds && importItemIds.length > 0 )
+ {
+ lockScreen();
+ var params = 'importData.action?';
+
+ for ( var i = 0 ; i < importItemIds.length ; i ++ )
+ {
+ params += 'importItemIds=' + importItemIds[i];
+ params += (i < importItemIds.length-1) ? "&" : "";
}
+
+ jQuery.postJSON( params,
+ {
+ importReportId: byId('importReportId').value,
+ periodId: byId('period').value
+ }, function( json ) {
+ unLockScreen();
+ showSuccessMessage( json.message );
+ });
}
- params += '&periodId='+ periodId;
- request.sendAsPost(params);
- request.send('importData.action');
-}
-
-function importDataCompleted( xmlObject )
-{
- setMessage(xmlObject.firstChild.nodeValue);
+ else showWarningMessage( i18n_choose_import_item );
}
// -----------------------------------------------------------------------------
// PREVIEW DATA FLOW
+// @param isImport This is a global variable which declared in preview.js
// -----------------------------------------------------------------------------
function getPreviewImportData(){
+ lockScreen();
+
+ isImport = true;
+
var request = new Request();
request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( getExportItemValuesReceived );
+ request.setCallbackSuccess( previewExportReportReceived );
request.send( "previewDataFlow.action?importReportId=" + byId("importReportId").value );
}
-function getExportItemValuesReceived( xmlObject ){
-
- if(xmlObject.getElementsByTagName('importItemValueByOrgUnit').length > 0 ){
- previewOrganisation(xmlObject);
- }
- else if(xmlObject.getElementsByTagName('importItemValueByCategory').length > 0 ){
- previewCategory(xmlObject);
- }
- else{
- previewNormal(xmlObject);
- }
-}
-
-
-// -----------------------------------------------------------------------------
-// PREVIEW DATA - NORMAL
-// -----------------------------------------------------------------------------
-
-function previewNormal( xmlObject ){
-
- byId('selectAll').checked = false;
- var availableDiv = byId('showValue');
- availableDiv.style.display = 'block';
-
- var availableObjectList = xmlObject.getElementsByTagName('importItemValue');
-
- var myTable = byId('showImportItemValues');
- var tBody = myTable.getElementsByTagName('tbody')[0];
-
- for(var i = byId("showImportItemValues").rows.length; i > 1;i--)
- {
- byId("showImportItemValues").deleteRow(i -1);
- }
-
- for(var i=0;i<availableObjectList.length;i++){
-
- // get values
- var itemValue = availableObjectList.item(i);
- // add new row
- var newTR = document.createElement('tr');
- // create new column
- var newTD2 = document.createElement('td');
- newTD2.innerHTML = itemValue.getElementsByTagName('name')[0].firstChild.nodeValue;
- // create new column
- var newTD3 = document.createElement('td');
- var value = 0;
- if( itemValue.getElementsByTagName('value')[0].firstChild != null ) {
- value = itemValue.getElementsByTagName('value')[0].firstChild.nodeValue;
- }
- newTD3.innerHTML = value;
- // create new column
- var newTD1 = document.createElement('td');
- var id = itemValue.getElementsByTagName('id')[0].firstChild.nodeValue;
- if(value!=0){
- newTD1.innerHTML= "<input type='checkbox' name='importItems' onChange='javascript: checkAllSelect(this);' id='importItems' value='" + id + "'>" ;
- }
-
- newTR.appendChild (newTD1);
- newTR.appendChild (newTD2);
- newTR.appendChild (newTD3);
- // add row into the table
- tBody.appendChild(newTR);
- }
-}
-
-function checkAllSelect(checkBox){
- if(!checkBox.checked){
- byId('selectAll').checked = false;
- }
-}
-
-// -----------------------------------------------------------------------------
-// PREVIEW DATA - ORGANISATION
-// -----------------------------------------------------------------------------
-
-function previewOrganisation( xmlObject ){
-
- // show preview table
- byId('selectAll').checked = false;
- var availableDiv = byId('showValue');
- availableDiv.style.display = 'block';
-
- var availableObjectList = xmlObject.getElementsByTagName('importItemValueByOrgUnit');
- var myTable = byId('showImportItemValues');
- var tBody = myTable.getElementsByTagName('tbody')[0];
-
- for(var i = byId("showImportItemValues").rows.length; i > 1;i--)
- {
- myTable.deleteRow(i -1);
- }
-
- for(var i=0;i<availableObjectList.length;i++){
-
- // get item into XML
- var itemValue = availableObjectList.item(i);
-
- // Add new row which contains to Organisation's name
- var newTR = document.createElement('tr');
- var newTD = document.createElement('td');
- newTD.colSpan = 3;
- var nameOrgUnit= itemValue.getElementsByTagName('orgUnit')[0];
- newTD.innerHTML = "<b>" + nameOrgUnit.getElementsByTagName('name')[0].firstChild.nodeValue + "</b>";
- var orgunitId = nameOrgUnit.getElementsByTagName('id')[0].firstChild.nodeValue;
- newTR.appendChild (newTD);
- // add row into the table
- tBody.appendChild(newTR);
-
- // get values
- var valueList = itemValue.getElementsByTagName('importItemValue');
- for(var j=0;j<valueList.length;j++) {
-
- // get itemValue into XML
- itemValue = valueList.item(j);
- // add new row which contains to value
- var newTR = document.createElement('tr');
- // create new column
- var newTD2 = document.createElement('td');
- newTD2.innerHTML = itemValue.getElementsByTagName('name')[0].firstChild.nodeValue;
- // create new column
- var newTD3 = document.createElement('td');
- var value = 0;
- if( itemValue.getElementsByTagName('value')[0].firstChild != null ) {
- value = itemValue.getElementsByTagName('value')[0].firstChild.nodeValue;
- }
- //var value = itemValue.getElementsByTagName('value')[0].firstChild.nodeValue;
- newTD3.innerHTML = value;
- // create new column
- var newTD1 = document.createElement('td');
- var id = itemValue.getElementsByTagName('id')[0].firstChild.nodeValue;
- if(value!=0){
- newTD1.innerHTML= "<input type='checkbox' name='importItems' id='importItems' value='" + orgunitId + "-" + i + "-" + id + "'>" ;
- }
-
- newTR.appendChild (newTD1);
- newTR.appendChild (newTD2);
- newTR.appendChild (newTD3);
- // add row into the table
- tBody.appendChild(newTR);
-
-
- }// end for Get values
-
- }// end for availableObjectList
-}
-
-
-// -----------------------------------------------------------------------------
-// PREVIEW DATA - CATEGORY
-// -----------------------------------------------------------------------------
-
-function previewCategory( xmlObject ){
-
- byId('selectAll').checked = false;
- var availableDiv = byId('showValue');
- availableDiv.style.display = 'block';
-
- var availableObjectList = xmlObject.getElementsByTagName('importItemValueByCategory');
-
- var myTable = byId('showImportItemValues');
- var tBody = myTable.getElementsByTagName('tbody')[0];
-
- for(var i = byId("showImportItemValues").rows.length; i > 1;i--)
- {
- byId("showImportItemValues").deleteRow(i -1);
- }
-
- for(var i=0;i<availableObjectList.length;i++){
-
- // get values
- var itemValue = availableObjectList.item(i);
- // add new row
- var newTR = document.createElement('tr');
- // create new column
- var newTD2 = document.createElement('td');
- newTD2.innerHTML = itemValue.getElementsByTagName('name')[0].firstChild.nodeValue;
- // create new column
- var newTD3 = document.createElement('td');
- var value = 0;
- if( itemValue.getElementsByTagName('value')[0].firstChild != null ) {
- value = itemValue.getElementsByTagName('value')[0].firstChild.nodeValue;
- }
-
- newTD3.innerHTML = value;
-
- // create new column
- var newTD1 = document.createElement('td');
- var id = itemValue.getElementsByTagName('id')[0].firstChild.nodeValue;
- var row = itemValue.getElementsByTagName('row')[0].firstChild.nodeValue;
- var expression = itemValue.getElementsByTagName('expression')[0].firstChild.nodeValue
- if(value!=0){
- newTD1.innerHTML= "<input type='checkbox' name='importItems' id='importItems' value='" + id + "-" + row + "-" + expression + "'>" ;
- }
-
- newTR.appendChild (newTD1);
- newTR.appendChild (newTD2);
- newTR.appendChild (newTD3);
- // add row into the table
- tBody.appendChild(newTR);
- }
-}
-
-
-function selectAll(){
-
- var select = byId('selectAll').checked;
-
- var exportItems = document.getElementsByName('importItems');
-
- for(var i=0;i<exportItems.length;i++){
- exportItems[i].checked = select;
- }
- }
+isToggled = true;
+
+function selectAllData( _this )
+{
+ if ( isToggled )
+ {
+ jQuery( _this ).val( i18n_unselect_all );
+
+ for ( var i = 0 ; i < importlist.length ; i ++ )
+ {
+ importlist[i].className = 'ui-selected';
+
+ idTemp = jQuery(importlist[i]).attr( 'id' ) + "_" + jQuery(importlist[i]).html();
+
+ if ( jQuery.inArray(idTemp, importItemIds) != -1 )
+ {
+ importItemIds = jQuery.grep( importItemIds, function(value) {
+ return value != idTemp
+ });
+ }
+ else importItemIds.push( idTemp );
+ }
+ }
+ else
+ {
+ jQuery( _this ).val( i18n_select_all );
+
+ for ( var i = 0 ; i < importlist.length ; i ++ )
+ {
+ importlist[i].className = 'ui-unselected';
+ }
+
+ importItemIds.length = 0;
+ }
+
+ isToggled = !isToggled;
+}
// --------------------------------------------------------------------
// PERIOD TYPE
@@ -271,50 +94,9 @@
function getPeriodsByImportReport( importReportId ) {
- var request = new Request();
- request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( responseListPeriodReceived );
- request.send( 'getPeriodsByImportReport.action?importReportId=' + importReportId);
-}
-
-function responseListPeriodReceived( xmlObject ) {
-
- clearListById('period');
+ var url = 'getPeriodsByImportReport.action';
- var type = xmlObject.getAttribute( 'type' );
-
- if ( (type != undefined) && (type == 'error') )
- {
- setHeaderDelayMessage( xmlObject.firstChild.nodeValue );
- }
- else
- {
- var list = xmlObject.getElementsByTagName('period');
-
- for ( var i = 0; i < list.length; i++ )
- {
- item = list[i];
- var name = item.getElementsByTagName('name')[0].firstChild.nodeValue;
-
- addOption('period', name, i);
- }
- }
-}
-
-function lastPeriod() {
-
- var request = new Request();
- request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( responseListPeriodReceived );
- request.send( 'previousPeriodsGeneric.action' );
-}
-
-function nextPeriod() {
-
- var request = new Request();
- request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( responseListPeriodReceived );
- request.send( 'nextPeriodsGeneric.action' );
+ jQuery.postJSON( url, {'importReportId':importReportId}, responseListPeriodReceived );
}
function validateUploadExcelImportByJSON(){
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js'
--- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js 2011-06-21 08:29:23 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js 2011-06-29 07:29:06 +0000
@@ -1,3 +1,16 @@
+/**
+ * Global variables
+ */
+
+isImport = false;
+idTemp = null;
+importlist = null;
+importItemIds = new Array();
+
+// ----------------------------------------------------------------------
+// Methods
+// ----------------------------------------------------------------------
+
function validatePreviewReport( isAdvanced )
{
var exportReport = getFieldValue('exportReport');
@@ -80,7 +93,7 @@
contentsHTML += '<div id="tabs-' + s + '">';
- _sHTML = "<table class='formatTablePreview'>";
+ _sHTML = "<table class='ui-widget-content'>";
for (var i = 0 ; i < _rows.length ; i ++)
{
@@ -91,12 +104,13 @@
for (var j = 0 ; j < _cols.length ; )
{
- var _number = getRootElementAttribute( _cols[j], 'no' );
+ var _number = getRootElementAttribute( _cols[j], 'no' );
+ var keyId = getRootElementAttribute( _cols[j], 'id' );
// Printing out the unformatted cells
for (; _index < _number ; _index ++)
{
- _sHTML += "<td/>";
+ _sHTML += "<td class='ui-widget-content'/>";
}
if ( _index == _number )
@@ -113,16 +127,17 @@
_index = Number(_index) + Number(_colspan);
_sHTML += "<td align='" + _align + "' colspan='" + _colspan + "' ";
-
- if ( (_sData != "") && !isNaN(_sData) )
- {
- _sHTML += "class='formatNumberPreview' "
- + "title='" + i18n_value_rounded;
- }
- else
- {
- _sHTML += "class='formatStringPreview" ;
- }
+ _sHTML += "class='ui-widget-content";
+
+ if ( keyId && keyId.length > 0 )
+ {
+ _sHTML += " ui-unselected' id='" + keyId;
+ }
+ else if ( !isImport && parseFloat(_sData) )
+ {
+ _sHTML += " ui-normal' title='" + i18n_value_rounded + "'";
+ }
+
_sHTML += "'>" + _sData + "</td>";
}
}
@@ -133,23 +148,54 @@
contentsHTML += _sHTML;
contentsHTML += '</div>';
}
+
titleHTML += '</ul>';
-
tabsHTML += titleHTML;
tabsHTML += contentsHTML;
tabsHTML += '</div>';
jQuery( '#previewDiv' ).html( tabsHTML );
-
- jQuery('#tabs').tabs({ collapsible : true });
-
+ jQuery( '#tabs' ).tabs({ collapsible : true });
enable( 'printExcelReportButton' );
-
+ applyStyleIntoPreview();
unLockScreen();
}
-function getMergedNumberForEachCell( aKey, sKey, aMerged ) {
-
+function applyStyleIntoPreview()
+{
+ importlist = jQuery( 'table.ui-widget-content tr > td.ui-unselected' );
+
+ if ( importlist.length > 0 )
+ {
+ importlist.mouseover(function()
+ {
+ jQuery(this).addClass( 'ui-mouseover' );
+ });
+
+ importlist.mouseout(function()
+ {
+ jQuery(this).removeClass( 'ui-mouseover' );
+ });
+
+ importlist.click(function()
+ {
+ idTemp = jQuery(this).attr( 'id' ) + "_" + jQuery(this).html();
+
+ if ( jQuery.inArray(idTemp, importItemIds) != -1 )
+ {
+ importItemIds = jQuery.grep( importItemIds, function(value) {
+ return value != idTemp
+ });
+ }
+ else importItemIds.push( idTemp );
+
+ jQuery(this).toggleClass( 'ui-selected' );
+ });
+ }
+}
+
+function getMergedNumberForEachCell( aKey, sKey, aMerged )
+{
for (var i = 0 ; i < aKey.length ; i ++)
{
if ( aKey[i] == sKey )
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/style/previewStyle.css'
--- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/style/previewStyle.css 2009-11-30 04:26:38 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/style/previewStyle.css 2011-06-29 07:29:06 +0000
@@ -1,38 +1,4 @@
-
-
-/* table sector
------------------------------------------*/
- table.formatTablePreview {
- border:2px dotted #FF9933;
- border-collapse:seperate;
- border-spacing:3px;
- font-weight:bold;
- width:100%;
- }
-
-
-/* td sector
------------------------------------------*/
-
- td.formatStringPreview {
- border-style:outset;
- border-width:1px;
- }
- td.formatNumberPreview {
- border-style:outset;
- border-width:1px;
- color:blue;
- margin:60%;
- text-align:center;
- }
-
-/* label sector
------------------------------------------*/
-
- label.formatLabelPreview {
- color:red;
- font-weight:bold;
- text-transform:uppercase;
- text-decoration:blink;
-
- }
\ No newline at end of file
+.ui-normal{ font-weight: bold; color: blue }
+.ui-unselected{ font-weight: bold; color: blue; cursor:pointer }
+.ui-selected{ background: #F39814; color: white; cursor:pointer }
+.ui-mouseover{ background: #FECA40; color: white; cursor:pointer }