use of io.lumeer.api.model.AttributeFilter in project engine by Lumeer.
the class LinkAttributeFilterCodec method convertFromDocument.
public static LinkAttributeFilter convertFromDocument(final Document document) {
String linkTypeId = document.getString(LINK_TYPE_ID);
AttributeFilter filter = AttributeFilterCodec.convertFromDocument(document);
return new LinkAttributeFilter(linkTypeId, filter.getAttributeId(), filter.getCondition(), filter.getConditionValues());
}
use of io.lumeer.api.model.AttributeFilter in project engine by Lumeer.
the class AttributeFilterCodec method convertFromDocument.
public static AttributeFilter convertFromDocument(final Document document) {
if (document == null) {
return null;
}
String attributeId = document.getString(ATTRIBUTE_ID);
String conditionString = document.getString(CONDITION);
ConditionType operator = ConditionType.fromString(conditionString);
List<ConditionValue> values;
Object value = document.get(VALUE);
if (value instanceof List<?>) {
values = document.getList(VALUE, Document.class).stream().map(ConditionValueCodec::convertFromDocument).collect(Collectors.toList());
} else {
values = Collections.singletonList(new ConditionValue(value));
}
return new AttributeFilter(attributeId, operator, values);
}
use of io.lumeer.api.model.AttributeFilter in project engine by Lumeer.
the class CollectionAttributeFilterCodec method convertFromDocument.
public static CollectionAttributeFilter convertFromDocument(final Document document) {
String collectionId = document.getString(COLLECTION_ID);
AttributeFilter filter = AttributeFilterCodec.convertFromDocument(document);
return new CollectionAttributeFilter(collectionId, filter.getAttributeId(), filter.getCondition(), filter.getConditionValues());
}
use of io.lumeer.api.model.AttributeFilter in project engine by Lumeer.
the class AttributeFilterEquationCodec method convertFromDocument.
public static AttributeFilterEquation convertFromDocument(final Document document) {
AttributeFilter filter = AttributeFilterCodec.convertFromDocument(document.get(FILTER, Document.class));
String operator = document.getString(OPERATOR);
List<AttributeFilterEquation> equations;
List equationsList = document.get(EQUATIONS, List.class);
if (equationsList != null) {
equations = new ArrayList<Document>(equationsList).stream().map(AttributeFilterEquationCodec::convertFromDocument).collect(Collectors.toList());
} else {
equations = Collections.emptyList();
}
return new AttributeFilterEquation(equations, filter, operator);
}
use of io.lumeer.api.model.AttributeFilter in project engine by Lumeer.
the class ConstraintManager method processAttributeFilter.
private void processAttributeFilter(final Constraint constraint, final AttributeFilter filter, final BiFunction<Object, Constraint, Object> processor) {
var conditionValues = filter.getConditionValues().stream().map(f -> {
if (f.getValue() != null) {
return new ConditionValue(processor.apply(f.getValue(), constraint));
}
return f;
}).collect(Collectors.toList());
filter.setConditionValues(conditionValues);
}
Aggregations