Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -268,7 +267,7 @@ protected void run(PluginTask task, Schema schema, Workbook workbook, List<Strin
log.info("ignore: not found sheet={}", sheetName);
continue;
} else {
throw new RuntimeException(MessageFormat.format("not found sheet={0}", sheetName));
throw new RuntimeException(String.format("not found sheet=%s", sheetName));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public PoiExcelCellFontVisitor(PoiExcelVisitorValue visitorValue) {
@Override
protected Font getAttributeSource(PoiExcelColumnBean bean, Cell cell) {
CellStyle style = cell.getCellStyle();
short index = style.getFontIndex();
int index = style.getFontIndex();
Workbook book = visitorValue.getSheet().getWorkbook();
return book.getFontAt(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ protected Map<String, AttributeSupplier<CellStyle>> getAttributeSupplierMap() {
map.put("alignment", new AttributeSupplier<CellStyle>() {
@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<CellStyle>() {
@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);
}
Expand All @@ -60,25 +60,25 @@ public Object get(Column column, Cell cell, CellStyle style) {
map.put("border_bottom", new AttributeSupplier<CellStyle>() {
@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<CellStyle>() {
@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<CellStyle>() {
@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<CellStyle>() {
@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<CellStyle>() {
Expand Down Expand Up @@ -154,7 +154,7 @@ public Object get(Column column, Cell cell, CellStyle style) {
map.put("fill_pattern", new AttributeSupplier<CellStyle>() {
@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<CellStyle>() {
Expand Down Expand Up @@ -190,7 +190,7 @@ public Object get(Column column, Cell cell, CellStyle style) {
map.put("vertical_alignment", new AttributeSupplier<CellStyle>() {
@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<CellStyle>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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) {
Expand All @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions src/test/java/org/embulk/parser/EmbulkPluginTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ public void run(ConfigSource config) {

@Override
public void close() {
if (embulk != null) {
embulk.destroy();
}
return;
}
}
9 changes: 9 additions & 0 deletions src/test/java/org/embulk/parser/EmbulkTestOutputPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down