diff --git a/plugins/ingest/src/main/java/org/elasticsearch/ingest/processor/date/DateProcessor.java b/plugins/ingest/src/main/java/org/elasticsearch/ingest/processor/date/DateProcessor.java index 4d4beed1dda..8538ee62f9d 100644 --- a/plugins/ingest/src/main/java/org/elasticsearch/ingest/processor/date/DateProcessor.java +++ b/plugins/ingest/src/main/java/org/elasticsearch/ingest/processor/date/DateProcessor.java @@ -23,7 +23,6 @@ import org.elasticsearch.ingest.Data; import org.elasticsearch.ingest.processor.Processor; import org.joda.time.DateTimeZone; -import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -86,60 +85,18 @@ public final class DateProcessor implements Processor { } } - public static class Builder implements Processor.Builder { - - private String timezone; - private String locale; - private String matchField; - private List matchFormats; - private String targetField; - - public Builder() { - matchFormats = new ArrayList(); - } - - public void setTimezone(String timezone) { - this.timezone = timezone; - } - - public void setLocale(String locale) { - this.locale = locale; - } - - public void setMatchField(String matchField) { - this.matchField = matchField; - } - - public void addMatchFormat(String matchFormat) { - matchFormats.add(matchFormat); - } - - public void setTargetField(String targetField) { - this.targetField = targetField; - } + public static class Factory implements Processor.Factory { @SuppressWarnings("unchecked") - public void fromMap(Map config) { - this.timezone = (String) config.get("timezone"); - this.locale = (String) config.get("locale"); - this.matchField = (String) config.get("match_field"); - this.matchFormats = (List) config.get("match_formats"); - this.targetField = (String) config.get("target_field"); - } - - @Override - public Processor build() { + public Processor create(Map config) { + //TODO handle default values + String timezone = (String) config.get("timezone"); + String locale = (String) config.get("locale"); + String matchField = (String) config.get("match_field"); + List matchFormats = (List) config.get("match_formats"); + String targetField = (String) config.get("target_field"); return new DateProcessor(timezone, locale, matchField, matchFormats, targetField); } - - public static class Factory implements Processor.Builder.Factory { - - @Override - public Processor.Builder create() { - return new Builder(); - } - } - } } diff --git a/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/IngestModule.java b/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/IngestModule.java index ced3e930f1e..d7a52d0315c 100644 --- a/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/IngestModule.java +++ b/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/IngestModule.java @@ -22,10 +22,10 @@ package org.elasticsearch.plugin.ingest; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.multibindings.MapBinder; import org.elasticsearch.ingest.processor.Processor; +import org.elasticsearch.ingest.processor.date.DateProcessor; import org.elasticsearch.ingest.processor.geoip.GeoIpProcessor; import org.elasticsearch.ingest.processor.grok.GrokProcessor; import org.elasticsearch.ingest.processor.simple.SimpleProcessor; -import org.elasticsearch.ingest.processor.date.DateProcessor; import org.elasticsearch.plugin.ingest.rest.IngestRestFilter; import java.util.HashMap; @@ -45,8 +45,7 @@ public class IngestModule extends AbstractModule { addProcessor(SimpleProcessor.TYPE, new SimpleProcessor.Factory()); addProcessor(GeoIpProcessor.TYPE, new GeoIpProcessor.Factory()); addProcessor(GrokProcessor.TYPE, new GrokProcessor.Factory()); - - //TODO addProcessor(DateProcessor.TYPE, DateProcessor.Builder.Factory.class); + addProcessor(DateProcessor.TYPE, new DateProcessor.Factory()); MapBinder mapBinder = MapBinder.newMapBinder(binder(), String.class, Processor.Factory.class); for (Map.Entry entry : processors.entrySet()) {