src/main/java/org/embulk/input/jdbc/getter/ColumnGetterFactory.java in embulk-input-jdbc-0.8.5 vs src/main/java/org/embulk/input/jdbc/getter/ColumnGetterFactory.java in embulk-input-jdbc-0.8.6
- old
+ new
@@ -3,15 +3,19 @@
import java.lang.reflect.Field;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
+import com.google.common.base.Optional;
import org.embulk.config.ConfigException;
+import org.embulk.config.ConfigSource;
+import org.embulk.config.Task;
import org.embulk.input.jdbc.AbstractJdbcInputPlugin.PluginTask;
import org.embulk.input.jdbc.JdbcColumn;
import org.embulk.input.jdbc.JdbcColumnOption;
import org.embulk.input.jdbc.JdbcInputConnection;
+import org.embulk.spi.Exec;
import org.embulk.spi.PageBuilder;
import org.embulk.spi.time.TimestampFormatter;
import org.embulk.spi.type.TimestampType;
import org.embulk.spi.type.Type;
import org.joda.time.DateTimeZone;
@@ -174,15 +178,24 @@
toType = ((TimestampType)toType).withFormat(option.getTimestampFormat().get().getFormat());
}
return toType;
}
+ private static interface FormatterIntlTask extends Task, TimestampFormatter.Task {}
+ private static interface FormatterIntlColumnOption extends Task, TimestampFormatter.TimestampColumnOption {}
+
private TimestampFormatter newTimestampFormatter(JdbcColumnOption option, String defaultTimestampFormat)
{
+ // TODO: Switch to a newer TimestampFormatter constructor after a reasonable interval.
+ // Traditional constructor is used here for compatibility.
+ final ConfigSource configSource = Exec.newConfigSource();
+ configSource.set("format", option.getTimestampFormat().isPresent()
+ ? option.getTimestampFormat().get().getFormat()
+ : defaultTimestampFormat);
+ configSource.set("timezone", option.getTimeZone().or(this.defaultTimeZone));
return new TimestampFormatter(
- option.getJRuby(),
- option.getTimestampFormat().isPresent() ? option.getTimestampFormat().get().getFormat() : defaultTimestampFormat,
- option.getTimeZone().or(defaultTimeZone));
+ Exec.newConfigSource().loadConfig(FormatterIntlTask.class),
+ Optional.fromNullable(configSource.loadConfig(FormatterIntlColumnOption.class)));
}
private static UnsupportedOperationException unsupportedOperationException(JdbcColumn column)
{
throw new UnsupportedOperationException(