use of org.graylog2.plugin.lookup.LookupResult in project graylog2-server by Graylog2.
the class Lookup method evaluate.
@Override
public Map<Object, Object> evaluate(FunctionArgs args, EvaluationContext context) {
Object key = keyParam.required(args, context);
if (key == null) {
return Collections.singletonMap(SINGLE_VALUE_KEY, defaultParam.optional(args, context).orElse(null));
}
LookupTableService.Function table = lookupTableParam.required(args, context);
if (table == null) {
return Collections.singletonMap(SINGLE_VALUE_KEY, defaultParam.optional(args, context).orElse(null));
}
LookupResult result = table.lookup(key);
if (result == null || result.isEmpty()) {
return Collections.singletonMap(SINGLE_VALUE_KEY, defaultParam.optional(args, context).orElse(null));
}
return result.multiValue();
}
use of org.graylog2.plugin.lookup.LookupResult in project graylog2-server by Graylog2.
the class LookupStringList method evaluate.
@Override
public List<String> evaluate(FunctionArgs args, EvaluationContext context) {
Object key = keyParam.required(args, context);
if (key == null) {
// noinspection unchecked
return defaultParam.optional(args, context).orElse(ImmutableList.of());
}
LookupTableService.Function table = lookupTableParam.required(args, context);
if (table == null) {
// noinspection unchecked
return defaultParam.optional(args, context).orElse(ImmutableList.of());
}
LookupResult result = table.lookup(key);
if (result == null || result.isEmpty()) {
// noinspection unchecked
return defaultParam.optional(args, context).orElse(ImmutableList.of());
}
return result.stringListValue();
}
use of org.graylog2.plugin.lookup.LookupResult in project graylog2-server by Graylog2.
the class LookupValue method evaluate.
@Override
public Object evaluate(FunctionArgs args, EvaluationContext context) {
Object key = keyParam.required(args, context);
if (key == null) {
return defaultParam.optional(args, context).orElse(null);
}
LookupTableService.Function table = lookupTableParam.required(args, context);
if (table == null) {
return defaultParam.optional(args, context).orElse(null);
}
LookupResult result = table.lookup(key);
if (result == null || result.isEmpty()) {
return defaultParam.optional(args, context).orElse(null);
}
return result.singleValue();
}
use of org.graylog2.plugin.lookup.LookupResult in project graylog2-server by Graylog2.
the class LookupStringListContains method evaluate.
@Override
public Boolean evaluate(FunctionArgs args, EvaluationContext context) {
Object value = valueParam.required(args, context);
if (value == null) {
return false;
}
Object key = keyParam.required(args, context);
if (key == null) {
return false;
}
LookupTableService.Function table = lookupTableParam.required(args, context);
if (table == null) {
return false;
}
LookupResult result = table.lookup(key);
if (result == null || result.isEmpty()) {
return false;
}
return result.stringListValue().contains(value);
}
use of org.graylog2.plugin.lookup.LookupResult in project graylog2-server by Graylog2.
the class LookupTableExtractor method run.
@Override
@Nullable
protected Result[] run(String sourceFieldValue) {
final LookupResult result = lookupTable.lookup(sourceFieldValue);
if (result == null || result.isEmpty()) {
return null;
}
final Object value = result.singleValue();
if (value == null) {
return null;
}
return new Result[] { new Result(value, targetField, -1, -1) };
}
Aggregations