add file drop handler
You can define a folder and ingest files dropped into it.
This commit is contained in:
@@ -2,6 +2,7 @@ package org.lucares.pdbui;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -12,8 +13,13 @@ import java.util.function.Function;
|
||||
import org.lucares.pdbui.domain.TagMatcher;
|
||||
import org.lucares.utils.Preconditions;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public final class CsvReaderSettings {
|
||||
|
||||
private final static ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
public static String stripPrefixDefault(final String value) {
|
||||
if (value.startsWith("Default")) {
|
||||
return value.replaceFirst("Default", "");
|
||||
@@ -169,7 +175,7 @@ public final class CsvReaderSettings {
|
||||
|
||||
private String comment = "#";
|
||||
|
||||
private List<TagMatcher> firstLineMatcher = new ArrayList<>();
|
||||
private final List<TagMatcher> firstLineMatcher = new ArrayList<>();
|
||||
|
||||
public CsvReaderSettings() {
|
||||
this("@timestamp", "duration", ",", new ColumnDefinitions());
|
||||
@@ -244,7 +250,7 @@ public final class CsvReaderSettings {
|
||||
}
|
||||
|
||||
public void putAdditionalTag(final Map<String, String> additionalTags) {
|
||||
additionalTags.putAll(additionalTags);
|
||||
this.additionalTags.putAll(additionalTags);
|
||||
}
|
||||
|
||||
public Map<String, String> getAdditionalTags() {
|
||||
@@ -267,8 +273,22 @@ public final class CsvReaderSettings {
|
||||
return firstLineMatcher;
|
||||
}
|
||||
|
||||
public void setFirstLineMatcher(final List<TagMatcher> firstLineMatcher) {
|
||||
this.firstLineMatcher = firstLineMatcher;
|
||||
public void setFirstLineMatcher(final Collection<TagMatcher> firstLineMatchers) {
|
||||
this.firstLineMatcher.clear();
|
||||
this.firstLineMatcher.addAll(firstLineMatchers);
|
||||
}
|
||||
|
||||
public void addFirstLineMatcher(final TagMatcher tagMatcher) {
|
||||
this.firstLineMatcher.add(tagMatcher);
|
||||
}
|
||||
|
||||
public CsvReaderSettings copy() {
|
||||
try {
|
||||
final String json = OBJECT_MAPPER.writeValueAsString(this);
|
||||
return OBJECT_MAPPER.readValue(json, CsvReaderSettings.class);
|
||||
} catch (final JsonProcessingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user