Search in sources :

Example 21 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class JsonToPropertyTreeTranslator method mapValue.

private void mapValue(final PropertySet parent, final String key, final JsonNode value) {
    final Property parentProperty = parent.getProperty();
    final Input input = getInput(parentProperty, key);
    if (input == null) {
        if (this.strictMode) {
            throw new IllegalArgumentException("No mapping defined for property " + key + " with value " + resolveStringValue(value));
        }
        parent.addProperty(key, resolveCoreValue(value));
    } else {
        final InputType type = this.inputTypeResolver.resolve(input.getInputType());
        final Value mappedPropertyValue = type.createValue(resolveCoreValue(value), input.getInputTypeConfig());
        parent.addProperty(key, mappedPropertyValue);
    }
}
Also used : Input(com.enonic.xp.form.Input) InputType(com.enonic.xp.inputtype.InputType) Value(com.enonic.xp.data.Value) Property(com.enonic.xp.data.Property)

Example 22 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class TermExpressionBuilder method build.

public static QueryBuilder build(final CompareExpr compareExpr, final QueryFieldNameResolver resolver) {
    final String queryFieldName = resolver.resolve(compareExpr);
    if (compareExpr.getFirstValue() == null) {
        throw new IllegalArgumentException("Invalid compare expression [" + compareExpr + "]");
    }
    final Value value = compareExpr.getFirstValue().getValue();
    return QueryBuilders.termQuery(queryFieldName, ValueHelper.getValueAsType(value)).queryName(queryFieldName);
}
Also used : Value(com.enonic.xp.data.Value)

Example 23 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class AbstractQueryFieldNameResolver method resolve.

@Override
public String resolve(final ValueFilter valueQueryFilter) {
    final String valueQueryFilterFieldName = valueQueryFilter.getFieldName();
    final String baseFieldName = IndexFieldNameNormalizer.normalize(valueQueryFilterFieldName);
    final ImmutableSet<Value> values = valueQueryFilter.getValues();
    final Value firstValue = values.iterator().next();
    return createValueTypeAwareFieldName(baseFieldName, firstValue);
}
Also used : Value(com.enonic.xp.data.Value)

Example 24 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class GeoDistanceSortFunctionArguments method setLocation.

private void setLocation(final List<ValueExpr> arguments) {
    final Value locationArgument = arguments.get(LOCATION_POSITION).getValue();
    try {
        final GeoPoint geoPoint = locationArgument.asGeoPoint();
        this.latitude = geoPoint.getLatitude();
        this.longitude = geoPoint.getLongitude();
    } catch (Exception e) {
        throw new FunctionQueryBuilderException("geoDistance", LOCATION_POSITION + 1, locationArgument.toString(), e);
    }
}
Also used : GeoPoint(com.enonic.xp.util.GeoPoint) Value(com.enonic.xp.data.Value)

Example 25 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class GeoDistanceSortFunctionArguments method setUnit.

private void setUnit(final List<ValueExpr> arguments) {
    if (arguments.size() == 3) {
        final Value unitArgument = arguments.get(UNIT_POSITION).getValue();
        this.unit = unitArgument.asString();
    }
}
Also used : Value(com.enonic.xp.data.Value)

Aggregations

Value (com.enonic.xp.data.Value)62 Test (org.junit.jupiter.api.Test)48 Input (com.enonic.xp.form.Input)24 Property (com.enonic.xp.data.Property)4 PropertySet (com.enonic.xp.data.PropertySet)4 PropertyTree (com.enonic.xp.data.PropertyTree)3 InputType (com.enonic.xp.inputtype.InputType)2 Instant (java.time.Instant)2 PropertyPath (com.enonic.xp.data.PropertyPath)1 FieldSet (com.enonic.xp.form.FieldSet)1 FormOptionSetOption (com.enonic.xp.form.FormOptionSetOption)1 IndexConfig (com.enonic.xp.index.IndexConfig)1 IndexValueProcessor (com.enonic.xp.index.IndexValueProcessor)1 AttachedBinary (com.enonic.xp.node.AttachedBinary)1 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)1 Node (com.enonic.xp.node.Node)1 NodePath (com.enonic.xp.node.NodePath)1 NodeQuery (com.enonic.xp.node.NodeQuery)1 NodeVersion (com.enonic.xp.node.NodeVersion)1 NodeVersionQuery (com.enonic.xp.node.NodeVersionQuery)1