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);
}
}
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);
}
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);
}
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);
}
}
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();
}
}
Aggregations