diff --git a/build.gradle b/build.gradle index 5ceef2d..d00f469 100755 --- a/build.gradle +++ b/build.gradle @@ -19,15 +19,18 @@ sourceCompatibility = 1.7 targetCompatibility = 1.7 dependencies { - compile "org.embulk:embulk-core:0.7.5" - provided "org.embulk:embulk-core:0.7.5" - compile "org.embulk:embulk-standards:0.7.5" + compile "org.embulk:embulk-core:0.9.23" + provided "org.embulk:embulk-core:0.9.23" + compile "org.embulk:embulk-standards:0.9.23" + compile 'org.embulk:embulk-deps-buffer:0.9.23' // compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION" - compile group: 'org.apache.poi', name : 'poi', version: '3.17' - compile(group: 'org.apache.poi', name : 'poi-ooxml', version: '3.17') { + compile group: 'org.apache.poi', name : 'poi', version: '5.2.3' + compile(group: 'org.apache.poi', name : 'poi-ooxml', version: '5.2.3') { exclude group: 'stax', module: 'stax-api' } testCompile "junit:junit:4.+" + testCompile 'org.embulk:embulk-test:0.9.23' + testCompile "org.embulk:embulk-core:0.9.23:tests" } task classpath(type: Copy, dependsOn: ["jar"]) { diff --git a/src/main/java/org/embulk/parser/poi_excel/PoiExcelParserPlugin.java b/src/main/java/org/embulk/parser/poi_excel/PoiExcelParserPlugin.java index f580d88..d231dee 100755 --- a/src/main/java/org/embulk/parser/poi_excel/PoiExcelParserPlugin.java +++ b/src/main/java/org/embulk/parser/poi_excel/PoiExcelParserPlugin.java @@ -36,7 +36,6 @@ import org.slf4j.Logger; import com.google.common.base.Optional; -import com.ibm.icu.text.MessageFormat; public class PoiExcelParserPlugin implements ParserPlugin { private final Logger log = Exec.getLogger(getClass()); @@ -197,7 +196,7 @@ public void run(TaskSource taskSource, Schema schema, FileInput input, PageOutpu Workbook workbook; try { workbook = WorkbookFactory.create(is); - } catch (IOException | EncryptedDocumentException | InvalidFormatException e) { + } catch (IOException | EncryptedDocumentException e) { throw new RuntimeException(e); } @@ -268,7 +267,7 @@ protected void run(PluginTask task, Schema schema, Workbook workbook, List> getAttributeSupplierMap() { map.put("alignment", new AttributeSupplier() { @Override public Object get(Column column, Cell cell, CellStyle style) { - return (long) style.getAlignmentEnum().getCode(); + return (long) style.getAlignment().getCode(); } }); map.put("border", new AttributeSupplier() { @Override public Object get(Column column, Cell cell, CellStyle style) { - int n0 = style.getBorderTopEnum().getCode(); - int n1 = style.getBorderBottomEnum().getCode(); - int n2 = style.getBorderLeftEnum().getCode(); - int n3 = style.getBorderRightEnum().getCode(); + int n0 = style.getBorderTop().getCode(); + int n1 = style.getBorderBottom().getCode(); + int n2 = style.getBorderLeft().getCode(); + int n3 = style.getBorderRight().getCode(); if (column.getType() instanceof StringType) { return String.format("%02x%02x%02x%02x", n0, n1, n2, n3); } @@ -60,25 +60,25 @@ public Object get(Column column, Cell cell, CellStyle style) { map.put("border_bottom", new AttributeSupplier() { @Override public Object get(Column column, Cell cell, CellStyle style) { - return (long) style.getBorderBottomEnum().getCode(); + return (long) style.getBorderBottom().getCode(); } }); map.put("border_left", new AttributeSupplier() { @Override public Object get(Column column, Cell cell, CellStyle style) { - return (long) style.getBorderLeftEnum().getCode(); + return (long) style.getBorderLeft().getCode(); } }); map.put("border_right", new AttributeSupplier() { @Override public Object get(Column column, Cell cell, CellStyle style) { - return (long) style.getBorderRightEnum().getCode(); + return (long) style.getBorderRight().getCode(); } }); map.put("border_top", new AttributeSupplier() { @Override public Object get(Column column, Cell cell, CellStyle style) { - return (long) style.getBorderTopEnum().getCode(); + return (long) style.getBorderTop().getCode(); } }); map.put("border_bottom_color", new AttributeSupplier() { @@ -154,7 +154,7 @@ public Object get(Column column, Cell cell, CellStyle style) { map.put("fill_pattern", new AttributeSupplier() { @Override public Object get(Column column, Cell cell, CellStyle style) { - return (long) style.getFillPatternEnum().getCode(); + return (long) style.getFillPattern().getCode(); } }); map.put("font_index", new AttributeSupplier() { @@ -190,7 +190,7 @@ public Object get(Column column, Cell cell, CellStyle style) { map.put("vertical_alignment", new AttributeSupplier() { @Override public Object get(Column column, Cell cell, CellStyle style) { - return (long) style.getVerticalAlignmentEnum().getCode(); + return (long) style.getVerticalAlignment().getCode(); } }); map.put("wrap_text", new AttributeSupplier() { diff --git a/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellValueVisitor.java b/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellValueVisitor.java index fa9fe78..6369a98 100755 --- a/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellValueVisitor.java +++ b/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellValueVisitor.java @@ -42,7 +42,7 @@ public void visitCellValue(PoiExcelColumnBean bean, Cell cell, CellVisitor visit Column column = bean.getColumn(); - CellType cellType = cell.getCellTypeEnum(); + CellType cellType = cell.getCellType(); switch (cellType) { case NUMERIC: visitor.visitCellValueNumeric(column, cell, cell.getNumericCellValue()); @@ -73,7 +73,7 @@ public void visitCellValue(PoiExcelColumnBean bean, Cell cell, CellVisitor visit } protected void visitCellValueBlank(PoiExcelColumnBean bean, Cell cell, CellVisitor visitor) { - assert cell.getCellTypeEnum() == CellType.BLANK; + assert cell.getCellType() == CellType.BLANK; Column column = bean.getColumn(); @@ -109,7 +109,7 @@ protected CellRangeAddress findRegion(PoiExcelColumnBean bean, Cell cell) { } protected void visitCellValueFormula(PoiExcelColumnBean bean, Cell cell, CellVisitor visitor) { - assert cell.getCellTypeEnum() == CellType.FORMULA; + assert cell.getCellType() == CellType.FORMULA; FormulaHandling handling = bean.getFormulaHandling(); switch (handling) { @@ -125,7 +125,7 @@ protected void visitCellValueFormula(PoiExcelColumnBean bean, Cell cell, CellVis protected void visitCellValueFormulaCashedValue(PoiExcelColumnBean bean, Cell cell, CellVisitor visitor) { Column column = bean.getColumn(); - CellType cellType = cell.getCachedFormulaResultTypeEnum(); + CellType cellType = cell.getCachedFormulaResultType(); switch (cellType) { case NUMERIC: visitor.visitCellValueNumeric(column, cell, cell.getNumericCellValue()); @@ -205,7 +205,7 @@ protected void visitCellValueFormulaEvaluate(PoiExcelColumnBean bean, Cell cell, throw new RuntimeException(MessageFormat.format("evaluate error. formula={0}", cell.getCellFormula()), e); } - CellType cellType = cellValue.getCellTypeEnum(); + CellType cellType = cellValue.getCellType(); switch (cellType) { case NUMERIC: visitor.visitCellValueNumeric(column, cellValue, cellValue.getNumberValue()); diff --git a/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelColumnVisitor.java b/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelColumnVisitor.java index 2fbcc73..4019033 100755 --- a/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelColumnVisitor.java +++ b/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelColumnVisitor.java @@ -60,7 +60,12 @@ public final void timestampColumn(Column column) { visitCell0(column, factory.getTimestampCellVisitor()); } - protected final void visitCell0(Column column, CellVisitor visitor) { + @Override + public final void jsonColumn(Column column) { + visitCell0(column, factory.getStringCellVisitor()); + } + + protected final void visitCell0(Column column, CellVisitor visitor) { if (log.isTraceEnabled()) { log.trace("{} start", column); } @@ -142,13 +147,13 @@ protected void visitCell(Column column, CellVisitor visitor) { visitCellComment(bean, cell, visitor); return; case CELL_TYPE: - visitCellType(bean, cell, cell.getCellTypeEnum(), visitor); + visitCellType(bean, cell, cell.getCellType(), visitor); return; case CELL_CACHED_TYPE: - if (cell.getCellTypeEnum() == CellType.FORMULA) { - visitCellType(bean, cell, cell.getCachedFormulaResultTypeEnum(), visitor); + if (cell.getCellType() == CellType.FORMULA) { + visitCellType(bean, cell, cell.getCachedFormulaResultType(), visitor); } else { - visitCellType(bean, cell, cell.getCellTypeEnum(), visitor); + visitCellType(bean, cell, cell.getCellType(), visitor); } return; default: diff --git a/src/test/java/org/embulk/parser/EmbulkPluginTester.java b/src/test/java/org/embulk/parser/EmbulkPluginTester.java index 3585734..e0ca104 100755 --- a/src/test/java/org/embulk/parser/EmbulkPluginTester.java +++ b/src/test/java/org/embulk/parser/EmbulkPluginTester.java @@ -169,8 +169,6 @@ public void run(ConfigSource config) { @Override public void close() { - if (embulk != null) { - embulk.destroy(); - } + return; } } diff --git a/src/test/java/org/embulk/parser/EmbulkTestOutputPlugin.java b/src/test/java/org/embulk/parser/EmbulkTestOutputPlugin.java index 919a98e..8880fdf 100755 --- a/src/test/java/org/embulk/parser/EmbulkTestOutputPlugin.java +++ b/src/test/java/org/embulk/parser/EmbulkTestOutputPlugin.java @@ -157,6 +157,15 @@ public void booleanColumn(Column column) { } record.set(column.getName(), reader.getBoolean(column)); } + + @Override + public void jsonColumn(Column column) { + if (reader.isNull(column)) { + record.set(column.getName(), null); + return; + } + record.set(column.getName(), reader.getString(column)); + } }); } result.add(record);