Search in sources :

Example 1 with AttributeFilter

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());
}
Also used : LinkAttributeFilter(io.lumeer.api.model.LinkAttributeFilter) AttributeFilter(io.lumeer.api.model.AttributeFilter) LinkAttributeFilter(io.lumeer.api.model.LinkAttributeFilter)

Example 2 with AttributeFilter

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);
}
Also used : ConditionValue(io.lumeer.api.model.ConditionValue) AttributeFilter(io.lumeer.api.model.AttributeFilter) List(java.util.List) ConditionType(io.lumeer.api.model.ConditionType)

Example 3 with AttributeFilter

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());
}
Also used : CollectionAttributeFilter(io.lumeer.api.model.CollectionAttributeFilter) CollectionAttributeFilter(io.lumeer.api.model.CollectionAttributeFilter) AttributeFilter(io.lumeer.api.model.AttributeFilter)

Example 4 with AttributeFilter

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);
}
Also used : AttributeFilterEquation(io.lumeer.api.model.AttributeFilterEquation) AttributeFilter(io.lumeer.api.model.AttributeFilter) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Document(org.bson.Document)

Example 5 with AttributeFilter

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);
}
Also used : Position(com.mongodb.client.model.geojson.Position) DataUtils(io.lumeer.core.util.DataUtils) CoordinatesParser(io.lumeer.core.util.coordinates.CoordinatesParser) AttributeFilter(io.lumeer.api.model.AttributeFilter) Date(java.util.Date) ZonedDateTime(java.time.ZonedDateTime) BiFunction(java.util.function.BiFunction) Point(com.mongodb.client.model.geojson.Point) StringUtils(org.apache.commons.lang3.StringUtils) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) Resource(io.lumeer.api.model.common.Resource) Locale(java.util.Locale) Map(java.util.Map) ConditionValue(io.lumeer.api.model.ConditionValue) Query(io.lumeer.api.model.Query) ZoneOffset(java.time.ZoneOffset) ParseException(java.text.ParseException) DateTimeException(java.time.DateTimeException) Decimal128(org.bson.types.Decimal128) DataDocument(io.lumeer.engine.api.data.DataDocument) Iterator(java.util.Iterator) DecimalFormat(java.text.DecimalFormat) Set(java.util.Set) Constraint(io.lumeer.api.model.Constraint) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) LinkType(io.lumeer.api.model.LinkType) LatLng(io.lumeer.core.util.coordinates.LatLng) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) DateTimeParseException(java.time.format.DateTimeParseException) List(java.util.List) ResourceUtils(io.lumeer.api.util.ResourceUtils) DateTimeFormatter(java.time.format.DateTimeFormatter) Optional(java.util.Optional) NamedCoordinateReferenceSystem(com.mongodb.client.model.geojson.NamedCoordinateReferenceSystem) Attribute(io.lumeer.api.model.Attribute) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) ConstraintType(io.lumeer.api.model.ConstraintType) ConditionValue(io.lumeer.api.model.ConditionValue)

Aggregations

AttributeFilter (io.lumeer.api.model.AttributeFilter)5 List (java.util.List)3 ConditionValue (io.lumeer.api.model.ConditionValue)2 ArrayList (java.util.ArrayList)2 NamedCoordinateReferenceSystem (com.mongodb.client.model.geojson.NamedCoordinateReferenceSystem)1 Point (com.mongodb.client.model.geojson.Point)1 Position (com.mongodb.client.model.geojson.Position)1 Attribute (io.lumeer.api.model.Attribute)1 AttributeFilterEquation (io.lumeer.api.model.AttributeFilterEquation)1 Collection (io.lumeer.api.model.Collection)1 CollectionAttributeFilter (io.lumeer.api.model.CollectionAttributeFilter)1 ConditionType (io.lumeer.api.model.ConditionType)1 Constraint (io.lumeer.api.model.Constraint)1 ConstraintType (io.lumeer.api.model.ConstraintType)1 LinkAttributeFilter (io.lumeer.api.model.LinkAttributeFilter)1 LinkType (io.lumeer.api.model.LinkType)1 Query (io.lumeer.api.model.Query)1 Resource (io.lumeer.api.model.common.Resource)1 ResourceUtils (io.lumeer.api.util.ResourceUtils)1 DefaultConfigurationProducer (io.lumeer.core.facade.configuration.DefaultConfigurationProducer)1