Search in sources :

Example 1 with ConditionValue

use of io.lumeer.api.model.ConditionValue 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 2 with ConditionValue

use of io.lumeer.api.model.ConditionValue 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)2 ConditionValue (io.lumeer.api.model.ConditionValue)2 List (java.util.List)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 Collection (io.lumeer.api.model.Collection)1 ConditionType (io.lumeer.api.model.ConditionType)1 Constraint (io.lumeer.api.model.Constraint)1 ConstraintType (io.lumeer.api.model.ConstraintType)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 DataUtils (io.lumeer.core.util.DataUtils)1 CoordinatesParser (io.lumeer.core.util.coordinates.CoordinatesParser)1 LatLng (io.lumeer.core.util.coordinates.LatLng)1 DataDocument (io.lumeer.engine.api.data.DataDocument)1