Skip to content

Commit

Permalink
More efficient xlsx processing; support of timestamp, datetime, time,…
Browse files Browse the repository at this point in the history
… and date data types
  • Loading branch information
Jason Weathersby authored and xgu committed May 3, 2012
1 parent b2777ed commit e3f663d
Show file tree
Hide file tree
Showing 15 changed files with 365 additions and 349 deletions.
Expand Up @@ -2,13 +2,13 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.birt.report.data.oda.excel.ui; singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Version: 4.2.0.qualifier
Bundle-Activator: org.eclipse.birt.report.data.oda.excel.ui.Activator
Bundle-Vendor: Megha Nidhi Dahal
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.datatools.connectivity.oda.design.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.birt.report.data.oda.excel
org.eclipse.birt.report.data.oda.excel;bundle-version="[4.2.0,5.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
@@ -1,6 +1,6 @@
#
#************************************************************************
# Copyright (c) 2006, 2007 Actuate Corporation.
# Copyright (c) 2012 Actuate Corporation.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
Expand All @@ -20,7 +20,6 @@ label.selectFile=Select f&ile:
label.selectworksheet=Worksheet:
label.includeTypeLine=Use second line as &data type indicator.
label.includeColumnNameLine = Use first line &as column name indicator.
label.dateFormat=Date Format:

button.selectFolder.browse=B&rowse...
button.moveUp=&Up
Expand Down
@@ -1,13 +1,15 @@
/*******************************************************************************
* Copyright (c) 2012 Megha Nidhi Dahal.
* Copyright (c) 2012 Megha Nidhi Dahal and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Megha Nidhi Dahal - initial API and implementation and/or initial documentation
* Actuate Corporation - support of timestamp, datetime, time, and date data types
*******************************************************************************/

package org.eclipse.birt.report.data.oda.excel.ui.wizards;

import java.io.File;
Expand Down Expand Up @@ -73,7 +75,6 @@
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

Expand All @@ -95,15 +96,16 @@ public class ExcelFileSelectionWizardPage extends DataSetWizardPage implements
private static String originalName = Messages
.getString("editor.title.originalName"); //$NON-NLS-1$
private static String dataType = Messages.getString("editor.title.type"); //$NON-NLS-1$
private String dateFormat = ExcelODAConstants.DEFAULT_DATE_FORMAT;

private static String[] dataTypeDisplayNames = new String[] {
Messages.getString("datatypes.decimal"), //$NON-NLS-1$
Messages.getString("datatypes.float"), //$NON-NLS-1$
Messages.getString("datatypes.integer"), //$NON-NLS-1$
Messages.getString("datatypes.date"), //$NON-NLS-1$
Messages.getString("datatypes.string"), //$NON-NLS-1$
Messages.getString("datatypes.boolean") //$NON-NLS-1$

private static String[] dataTypeDisplayNames = new String[]{
Messages.getString( "datatypes.dateTime" ), //$NON-NLS-1$
Messages.getString( "datatypes.decimal" ), //$NON-NLS-1$
Messages.getString( "datatypes.float" ), //$NON-NLS-1$
Messages.getString( "datatypes.integer" ), //$NON-NLS-1$
Messages.getString( "datatypes.date" ), //$NON-NLS-1$
Messages.getString( "datatypes.time" ), //$NON-NLS-1$
Messages.getString( "datatypes.string" ), //$NON-NLS-1$
Messages.getString( "datatypes.boolean" ) //$NON-NLS-1$
};

private Map<Object, Object> dataTypeDisplayNameMap = new HashMap<Object, Object>();
Expand All @@ -115,7 +117,6 @@ public class ExcelFileSelectionWizardPage extends DataSetWizardPage implements

private transient ComboViewer fileViewer = null;
private transient ComboViewer worksheetsCombo = null;
private transient Text dateFormatText = null;
private transient List availableList = null;
private transient TableViewer selectedColumnsViewer = null;
private transient Button btnAdd = null;
Expand Down Expand Up @@ -178,36 +179,39 @@ public void createPageCustomControl(Composite parent) {
IHelpConstants.CONEXT_ID_DATASET_EXCEL);
}

/**
*
*
*/
private void createColumnTypeMap() {
dataTypeDisplayNameMap.put(new Integer(4),
Messages.getString("datatypes.integer")); //$NON-NLS-1$
dataTypeDisplayNameMap.put(new Integer(8),
Messages.getString("datatypes.float")); //$NON-NLS-1$
dataTypeDisplayNameMap.put(new Integer(12),
Messages.getString("datatypes.string")); //$NON-NLS-1$
dataTypeDisplayNameMap.put(new Integer(91),
Messages.getString("datatypes.date")); //$NON-NLS-1$
dataTypeDisplayNameMap.put(new Integer(2),
Messages.getString("datatypes.decimal")); //$NON-NLS-1$
dataTypeDisplayNameMap.put(new Integer(16),
Messages.getString("datatypes.boolean")); //$NON-NLS-1$

dataTypeValueMape.put(Messages.getString("datatypes.integer"), "INT"); //$NON-NLS-1$ //$NON-NLS-2$
dataTypeValueMape.put(Messages.getString("datatypes.float"), //$NON-NLS-1$
"DOUBLE"); //$NON-NLS-1$
dataTypeValueMape.put(Messages.getString("datatypes.string"), //$NON-NLS-1$
"STRING"); //$NON-NLS-1$
dataTypeValueMape.put(Messages.getString("datatypes.date"), "DATE"); //$NON-NLS-1$ //$NON-NLS-2$
dataTypeValueMape.put(Messages.getString("datatypes.decimal"), //$NON-NLS-1$
"BIGDECIMAL"); //$NON-NLS-1$
dataTypeValueMape.put(Messages.getString("datatypes.boolean"), //$NON-NLS-1$
"BOOLEAN"); //$NON-NLS-1$
private void createColumnTypeMap( )
{
dataTypeDisplayNameMap.put( new Integer(4),
Messages.getString( "datatypes.integer" ) ); //$NON-NLS-1$
dataTypeDisplayNameMap.put( new Integer(8),
Messages.getString( "datatypes.float" ) ); //$NON-NLS-1$
dataTypeDisplayNameMap.put( new Integer(12),
Messages.getString( "datatypes.string" ) ); //$NON-NLS-1$
dataTypeDisplayNameMap.put( new Integer(91),
Messages.getString( "datatypes.date" ) ); //$NON-NLS-1$
dataTypeDisplayNameMap.put( new Integer(92),
Messages.getString( "datatypes.time" ) ); //$NON-NLS-1$
dataTypeDisplayNameMap.put( new Integer(93),
Messages.getString( "datatypes.dateTime" ) ); //$NON-NLS-1$
dataTypeDisplayNameMap.put( new Integer(2),
Messages.getString( "datatypes.decimal" ) ); //$NON-NLS-1$
dataTypeDisplayNameMap.put( new Integer(16),
Messages.getString( "datatypes.boolean" ) ); //$NON-NLS-1$

dataTypeValueMape.put( Messages.getString( "datatypes.integer" ), "INT" ); //$NON-NLS-1$ //$NON-NLS-2$
dataTypeValueMape.put( Messages.getString( "datatypes.float" ), //$NON-NLS-1$
"DOUBLE" ); //$NON-NLS-1$
dataTypeValueMape.put( Messages.getString( "datatypes.string" ), //$NON-NLS-1$
"STRING" ); //$NON-NLS-1$
dataTypeValueMape.put( Messages.getString( "datatypes.date" ), "DATE" ); //$NON-NLS-1$ //$NON-NLS-2$
dataTypeValueMape.put( Messages.getString( "datatypes.time" ), "TIME" ); //$NON-NLS-1$ //$NON-NLS-2$
dataTypeValueMape.put( Messages.getString( "datatypes.dateTime" ), //$NON-NLS-1$
"TIMESTAMP" ); //$NON-NLS-1$
dataTypeValueMape.put( Messages.getString( "datatypes.decimal" ), //$NON-NLS-1$
"BIGDECIMAL" ); //$NON-NLS-1$
dataTypeValueMape.put( Messages.getString( "datatypes.boolean" ), //$NON-NLS-1$
"BOOLEAN" ); //$NON-NLS-1$
}

/**
*
*
Expand All @@ -232,12 +236,7 @@ private void initializeControl() {
currentSheetName = dataSetDesign.getPublicProperties().getProperty(
ExcelODAConstants.CONN_WORKSHEETS_PROP);
}
if (dataSetDesign.getPublicProperties() != null) {
dateFormat = dataSetDesign.getPublicProperties().getProperty(
ExcelODAConstants.CONN_DATE_FORMAT_PROP);
dateFormat = dateFormat == null ? ExcelODAConstants.DEFAULT_DATE_FORMAT : dateFormat.trim();
dateFormatText.setText(dateFormat);
}

/*
* Optionally honor the request for an editable or read-only design
* session isSessionEditable();
Expand Down Expand Up @@ -368,17 +367,6 @@ public String getText(Object element) {
data = new FormData();
data.left = new FormAttachment(worksheetsCombo.getControl(), 5);
data.top = new FormAttachment(0, 5);

label = new Label(composite, SWT.NONE);
label.setText(Messages.getString("label.dateFormat")); //$NON-NLS-1$
label.setLayoutData(data);

data = new FormData();
data.left = new FormAttachment(label, 5);
data.right = new FormAttachment(100, -5);
dateFormatText = new Text(composite, SWT.BORDER);
dateFormatText.setLayoutData(data);
dateFormatText.setText(dateFormat);
}

/**
Expand Down Expand Up @@ -914,10 +902,6 @@ private void loadProperties() {
currentSheetName = dataSetDesign.getPublicProperties().getProperty(
ExcelODAConstants.CONN_WORKSHEETS_PROP);
}
if (dataSetDesign.getPublicProperties() != null) {
dateFormat = dataSetDesign.getPublicProperties().getProperty(
ExcelODAConstants.CONN_DATE_FORMAT_PROP);
}
}

/**
Expand Down Expand Up @@ -1598,17 +1582,7 @@ else if (dataSetDesign.getPublicProperties() != null) {
.findProperty(ExcelODAConstants.CONN_WORKSHEETS_PROP)
.setNameValue(ExcelODAConstants.CONN_WORKSHEETS_PROP,
currentSheetName);
if (dataSetDesign.getPublicProperties().findProperty(
ExcelODAConstants.CONN_DATE_FORMAT_PROP) != null)
dateFormat = dateFormatText.getText();
dateFormat = dateFormat != null ? dateFormat.trim() : ExcelODAConstants.DEFAULT_DATE_FORMAT;
dataSetDesign
.getPublicProperties()
.findProperty(ExcelODAConstants.CONN_DATE_FORMAT_PROP)
.setNameValue(ExcelODAConstants.CONN_DATE_FORMAT_PROP,
dateFormat);
}

}

private java.util.Properties getPageProperties() {
Expand Down
Expand Up @@ -2,15 +2,13 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.birt.report.data.oda.excel; singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Version: 4.2.0.qualifier
Bundle-ClassPath: .,
src,
lib/poi-3.7/poi-3.7-20101029.jar,
lib/poi-3.7/poi-ooxml-3.7-20101029.jar,
lib/poi-3.7/poi-ooxml-schemas-3.7-20101029.jar,
lib/poi-3.7/lib/log4j-1.2.13.jar,
lib/poi-3.7/ooxml-lib/dom4j-1.6.1.jar,
lib/poi-3.7/ooxml-lib/geronimo-stax-api_1.0_spec-1.0.jar,
lib/poi-3.7/ooxml-lib/xmlbeans-2.3.0.jar
Bundle-Activator: org.eclipse.birt.report.data.oda.excel.Activator
Bundle-Vendor: Megha Nidhi Dahal
Expand All @@ -24,6 +22,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.datatools.connectivity.oda.profile;bundle-version="[3.2.0,4.0.0)",
org.apache.xerces;bundle-version="[2.9.0,3.0.0)",
org.apache.xml.serializer;bundle-version="[2.7.1,3.0.0)",
org.apache.commons.logging;bundle-version="[1.0.4,2.0.0)"
org.apache.commons.logging;bundle-version="[1.0.4,2.0.0)",
javax.xml.stream;bundle-version="[1.0.1,2.0.0)";resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Binary file not shown.
Binary file not shown.
22 changes: 9 additions & 13 deletions data/org.eclipse.birt.report.data.oda.excel/plugin.xml
Expand Up @@ -62,6 +62,14 @@
nativeDataType="DATE"
nativeDataTypeCode="91"
odaScalarDataType="Date"/>
<dataTypeMapping
nativeDataType="TIME"
nativeDataTypeCode="92"
odaScalarDataType="Time"/>
<dataTypeMapping
nativeDataType="DATETIME"
nativeDataTypeCode="93"
odaScalarDataType="Timestamp"/>
<dataTypeMapping
nativeDataType="TIMESTAMP"
nativeDataTypeCode="93"
Expand All @@ -83,21 +91,9 @@
name="WORKSHEETS"
canInherit="true"
type="string"/>
<property
allowsEmptyValueAsNull="true"
canInherit="true"
defaultDisplayName="dataset.property.worksheets.dateFormat"
defaultValue="yyyy-MM-dd"
isEncryptable="false"
name="DATEFORMAT"
type="string">
</property>
</propertyGroup>
<propertyVisibility name="WORKSHEETS" visibility="change"/>
<propertyVisibility
name="DATEFORMAT"
visibility="change">
</propertyVisibility>

</properties>
</dataSet>
</extension>
Expand Down
@@ -1,31 +1,30 @@
/*******************************************************************************
* Copyright (c) 2012 Megha Nidhi Dahal.
* Copyright (c) 2012 Megha Nidhi Dahal and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Megha Nidhi Dahal - initial API and implementation and/or initial documentation
* Actuate Corporation - support of timestamp, datetime, time, and date data types
*******************************************************************************/


package org.eclipse.birt.report.data.oda.excel;

public class ExcelODAConstants {

public static final String CONN_HOME_DIR_PROP = "HOME";
public static final String XLS_FORMAT = "xls";
public static final String XLSX_FORMAT = "xlsx";
public static final String CONN_INCLCOLUMNNAME_PROP = "INCLCOLUMNNAME";
public static final String INC_COLUMN_NAME_YES = "YES";
public static final String CONN_INCLTYPELINE_PROP = "INCLTYPELINE";
public static final String INC_TYPE_LINE_YES = "YES";
public static final String INC_TYPE_LINE_NO = "NO";
public static final String INC_COLUMN_NAME_NO = "NO";
public static final String CONN_HOME_DIR_PROP = "HOME"; //$NON-NLS-1$
public static final String XLS_FORMAT = "xls"; //$NON-NLS-1$
public static final String XLSX_FORMAT = "xlsx"; //$NON-NLS-1$
public static final String CONN_INCLCOLUMNNAME_PROP = "INCLCOLUMNNAME"; //$NON-NLS-1$
public static final String INC_COLUMN_NAME_YES = "YES"; //$NON-NLS-1$
public static final String CONN_INCLTYPELINE_PROP = "INCLTYPELINE"; //$NON-NLS-1$
public static final String INC_TYPE_LINE_YES = "YES"; //$NON-NLS-1$
public static final String INC_TYPE_LINE_NO = "NO"; //$NON-NLS-1$
public static final String INC_COLUMN_NAME_NO = "NO"; //$NON-NLS-1$

public static final String CONN_WORKSHEETS_PROP = "WORKSHEETS";
public static final String CONN_DATE_FORMAT_PROP = "DATEFORMAT";
public static final String CONN_WORKSHEETS_PROP = "WORKSHEETS"; //$NON-NLS-1$

public static final String DELIMITER_SPACE = " "; //$NON-NLS-1$
public static final char DELIMITER_DOUBLEQUOTE = '"';
Expand All @@ -37,7 +36,6 @@ public class ExcelODAConstants {
public static final String KEYWORD_ASTERISK = "*";//$NON-NLS-1$
public static final String KEYWORD_AS = "AS"; //$NON-NLS-1$
public static final String KEYWORD_FROM = "FROM"; //$NON-NLS-1$
public static final String EMPTY_STRING = "";
public static final String ALL_SHEETS = "ALL";
public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
public static final String ALL_SHEETS = "ALL"; //$NON-NLS-1$
}

0 comments on commit e3f663d

Please sign in to comment.