embulk-parser-poi_excel 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,27 @@
1
1
  package org.embulk.parser.poi_excel.visitor;
2
2
 
3
+ import java.lang.reflect.Method;
4
+
3
5
  import org.apache.poi.ss.usermodel.Sheet;
4
6
  import org.embulk.parser.poi_excel.PoiExcelParserPlugin.PluginTask;
5
7
  import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean;
6
8
  import org.embulk.parser.poi_excel.bean.PoiExcelSheetBean;
7
9
  import org.embulk.spi.Column;
10
+ import org.embulk.spi.FileInput;
8
11
  import org.embulk.spi.PageBuilder;
9
12
  import org.embulk.spi.Schema;
10
13
 
11
14
  public class PoiExcelVisitorValue {
12
15
  private final PluginTask task;
16
+ private final FileInput input;
13
17
  private final Sheet sheet;
14
18
  private final PageBuilder pageBuilder;
15
19
  private final PoiExcelSheetBean sheetBean;
16
20
  private PoiExcelVisitorFactory factory;
17
21
 
18
- public PoiExcelVisitorValue(PluginTask task, Schema schema, Sheet sheet, PageBuilder pageBuilder) {
22
+ public PoiExcelVisitorValue(PluginTask task, Schema schema, FileInput input, Sheet sheet, PageBuilder pageBuilder) {
19
23
  this.task = task;
24
+ this.input = input;
20
25
  this.sheet = sheet;
21
26
  this.pageBuilder = pageBuilder;
22
27
  this.sheetBean = new PoiExcelSheetBean(task, schema, sheet);
@@ -26,6 +31,28 @@ public class PoiExcelVisitorValue {
26
31
  return task;
27
32
  }
28
33
 
34
+ private Method hintOfCurrentInputFileNameForLogging;
35
+ private Method optional_orElse;
36
+
37
+ public String getFileName() {
38
+ if (hintOfCurrentInputFileNameForLogging == null) {
39
+ try {
40
+ this.hintOfCurrentInputFileNameForLogging = FileInput.class
41
+ .getMethod("hintOfCurrentInputFileNameForLogging");
42
+ this.optional_orElse = Class.forName("java.util.Optional").getMethod("orElse", Object.class);
43
+ } catch (Exception e) {
44
+ throw new RuntimeException("use Embulk 0.9.12 or later for value=file_name", e);
45
+ }
46
+ }
47
+
48
+ try {
49
+ Object fileNameOption = hintOfCurrentInputFileNameForLogging.invoke(input);
50
+ return (String) optional_orElse.invoke(fileNameOption, (String) null);
51
+ } catch (Exception e) {
52
+ throw new RuntimeException(e);
53
+ }
54
+ }
55
+
29
56
  public Sheet getSheet() {
30
57
  return sheet;
31
58
  }
@@ -39,6 +39,15 @@ public abstract class CellVisitor {
39
39
 
40
40
  public abstract void visitValueLong(Column column, Object source, long value);
41
41
 
42
+ public void visitFileName(Column column) {
43
+ String fileName = visitorValue.getFileName();
44
+ if (fileName == null) {
45
+ pageBuilder.setNull(column);
46
+ return;
47
+ }
48
+ visitCellValueString(column, null, fileName);
49
+ }
50
+
42
51
  public abstract void visitSheetName(Column column);
43
52
 
44
53
  public abstract void visitSheetName(Column column, Sheet sheet);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-parser-poi_excel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - hishidama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-03 00:00:00.000000000 Z
11
+ date: 2023-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ files:
52
52
  - classpath/commons-codec-1.10.jar
53
53
  - classpath/commons-collections4-4.1.jar
54
54
  - classpath/curvesapi-1.04.jar
55
- - classpath/embulk-parser-poi_excel-0.1.12.jar
55
+ - classpath/embulk-parser-poi_excel-0.1.13.jar
56
56
  - classpath/embulk-standards-0.7.5.jar
57
57
  - classpath/poi-3.17.jar
58
58
  - classpath/poi-ooxml-3.17.jar