本文整理汇总了Java中com.redhat.lightblue.query.NaryValueRelationalExpression类的典型用法代码示例。如果您正苦于以下问题:Java NaryValueRelationalExpression类的具体用法?Java NaryValueRelationalExpression怎么用?Java NaryValueRelationalExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NaryValueRelationalExpression类属于com.redhat.lightblue.query包,在下文中一共展示了NaryValueRelationalExpression类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: itrNaryValueRelationalExpression
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
@Override
protected Filter itrNaryValueRelationalExpression(NaryValueRelationalExpression query, Path path){
String attributeName = fieldNameTranslator.translateFieldName(query.getField());
List<Filter> filters = new ArrayList<>();
for(Value value : query.getValues()){
filters.add(Filter.createEqualityFilter(attributeName, value.getValue().toString()));
}
switch (query.getOp()){
case _in:
return Filter.createORFilter(filters);
case _not_in:
return Filter.createNOTFilter(Filter.createORFilter(filters));
default:
throw new UnsupportedOperationException("Unsupported operation: " + query.getOp());
}
}
示例2: rewrite
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
@Override
public QueryExpression rewrite(QueryExpression q) {
UnaryLogicalExpression le = dyncast(UnaryLogicalExpression.class, q);
if (le != null && le.getOp() == UnaryLogicalOperator._not) {
ValueComparisonExpression vce = dyncast(ValueComparisonExpression.class, le.getQuery());
if (vce != null) {
return new ValueComparisonExpression(vce.getField(), vce.getOp().negate(), vce.getRvalue());
} else {
FieldComparisonExpression fce = dyncast(FieldComparisonExpression.class, le.getQuery());
if (fce != null) {
return new FieldComparisonExpression(fce.getField(), fce.getOp().negate(), fce.getRfield());
} else {
NaryValueRelationalExpression nre = dyncast(NaryValueRelationalExpression.class, le.getQuery());
if (nre != null) {
return new NaryValueRelationalExpression(nre.getField(), nre.getOp().negate(), nre.getValues());
} else {
NaryFieldRelationalExpression nfe = dyncast(NaryFieldRelationalExpression.class, le.getQuery());
if (nfe != null) {
return new NaryFieldRelationalExpression(nfe.getField(), nfe.getOp().negate(), nfe.getRfield());
}
}
}
}
}
return q;
}
示例3: getInstance
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
public static QueryEvaluator getInstance(QueryExpression expr,
FieldTreeNode context) {
QueryEvaluator ret = null;
if (expr instanceof ValueComparisonExpression) {
return new ValueComparisonEvaluator((ValueComparisonExpression) expr, context);
} else if (expr instanceof FieldComparisonExpression) {
return new FieldComparisonEvaluator((FieldComparisonExpression) expr, context);
} else if (expr instanceof RegexMatchExpression) {
return new RegexEvaluator((RegexMatchExpression) expr, context);
} else if (expr instanceof NaryValueRelationalExpression) {
return new NaryValueRelationalExpressionEvaluator((NaryValueRelationalExpression) expr, context);
} else if (expr instanceof NaryFieldRelationalExpression) {
return new NaryFieldRelationalExpressionEvaluator((NaryFieldRelationalExpression) expr, context);
} else if (expr instanceof UnaryLogicalExpression) {
return new UnaryLogicalExpressionEvaluator((UnaryLogicalExpression) expr, context);
} else if (expr instanceof NaryLogicalExpression) {
return new NaryLogicalExpressionEvaluator((NaryLogicalExpression) expr, context);
} else if (expr instanceof ArrayContainsExpression) {
return new ArrayContainsEvaluator((ArrayContainsExpression) expr, context);
} else if (expr instanceof ArrayMatchExpression) {
return new ArrayMatchEvaluator((ArrayMatchExpression) expr, context);
}
return ret;
}
示例4: equals
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
private boolean equals(QueryExpression q, QueryExpression w) {
if (q.getClass().equals(w.getClass())) {
if (q instanceof ValueComparisonExpression) {
return equals((ValueComparisonExpression) q, (ValueComparisonExpression) w);
} else if (q instanceof FieldComparisonExpression) {
return equals((FieldComparisonExpression) q, (FieldComparisonExpression) w);
} else if (q instanceof RegexMatchExpression) {
return equals((RegexMatchExpression) q, (RegexMatchExpression) w);
} else if (q instanceof NaryValueRelationalExpression) {
return equals((NaryValueRelationalExpression) q, (NaryValueRelationalExpression) w);
} else if (q instanceof UnaryLogicalExpression) {
return equals((UnaryLogicalExpression) q, (UnaryLogicalExpression) w);
} else if (q instanceof NaryLogicalExpression) {
return equals((NaryLogicalExpression) q, (NaryLogicalExpression) w);
} else if (q instanceof ArrayContainsExpression) {
return equals((ArrayContainsExpression) q, (ArrayContainsExpression) w);
} else if (q instanceof ArrayMatchExpression) {
return equals((ArrayMatchExpression) q, (ArrayMatchExpression) w);
}
}
return false;
}
示例5: translate
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
/**
* @param context The field tree node for the latest enclosing context (array of elemMatch, or top level node)
* @param query The query to translate
* @param emd The metadata
* @param fullPath Current full path
*/
private DBObject translate(FieldTreeNode context, QueryExpression query, EntityMetadata emd, MutablePath fullPath) {
DBObject ret;
try {
if (query instanceof ArrayContainsExpression) {
ret = translateArrayContains(context, emd, (ArrayContainsExpression) query,fullPath);
} else if (query instanceof ArrayMatchExpression) {
ret = translateArrayElemMatch(context, emd, (ArrayMatchExpression) query, emd, fullPath);
} else if (query instanceof FieldComparisonExpression) {
ret = translateFieldComparison(context, emd, (FieldComparisonExpression) query, fullPath);
} else if (query instanceof NaryLogicalExpression) {
ret = translateNaryLogicalExpression(context, emd, (NaryLogicalExpression) query, emd, fullPath);
} else if (query instanceof NaryValueRelationalExpression) {
ret = translateNaryValueRelationalExpression(context, emd, (NaryValueRelationalExpression) query,fullPath);
} else if (query instanceof NaryFieldRelationalExpression) {
ret = translateNaryFieldRelationalExpression(context, emd, (NaryFieldRelationalExpression) query,fullPath);
} else if (query instanceof RegexMatchExpression) {
ret = translateRegexMatchExpression(context, emd, (RegexMatchExpression) query, emd, fullPath);
} else if (query instanceof UnaryLogicalExpression) {
ret = translateUnaryLogicalExpression(context, emd, (UnaryLogicalExpression) query, emd, fullPath);
} else {
ret = translateValueComparisonExpression(context, emd, (ValueComparisonExpression) query,fullPath);
}
} catch (NeedsJS x) {
// We can't translate the query, we have to write a $where query
// But we can't do that if we're in an arrayElemMatch
if(fullPath.isEmpty()) {
JSQueryTranslator tx=new JSQueryTranslator(emd);
ret=new BasicDBObject("$where",tx.translateQuery(query).toString());
} else
throw x; // Continue unroll stack
}
return ret;
}
示例6: translateNaryValueRelationalExpression
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
private DBObject translateNaryValueRelationalExpression(FieldTreeNode context, EntityMetadata md, NaryValueRelationalExpression expr,MutablePath fullPath) {
FieldInfo finfo=resolveFieldForQuery(context,fullPath.immutableCopy(),expr.getField());
Type t = finfo.fieldMd.getType();
if (t.supportsEq()) {
List<Object> values = translateValueList(t, expr.getValues(),finfo.field.equals(ID_PATH));
return new BasicDBObject(translatePath(finfo.field),
new BasicDBObject(NARY_RELATIONAL_OPERATOR_MAP.get(expr.getOp()),
values));
} else {
throw Error.get(ERR_INVALID_FIELD, expr.toString());
}
}
示例7: testbuild_NaryValueRelationalExpression_IN
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
@Test
public void testbuild_NaryValueRelationalExpression_IN(){
QueryExpression query = new NaryValueRelationalExpression(
new Path("somekey"),
NaryRelationalOperator._in,
Arrays.asList(new Value("somevalue"), new Value("someothervalue")));
Filter filter = new FilterBuilder(new TrivialLdapFieldNameTranslator()).build(query);
assertEquals("(|(somekey=somevalue)(somekey=someothervalue))", filter.toString());
}
示例8: testbuild_NaryValueRelationalExpression_NOT_IN
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
@Test
public void testbuild_NaryValueRelationalExpression_NOT_IN(){
QueryExpression query = new NaryValueRelationalExpression(
new Path("somekey"),
NaryRelationalOperator._not_in,
Arrays.asList(new Value("somevalue"), new Value("someothervalue")));
Filter filter = new FilterBuilder(new TrivialLdapFieldNameTranslator()).build(query);
assertEquals("(!(|(somekey=somevalue)(somekey=someothervalue)))", filter.toString());
}
示例9: NaryValueRelationalExpressionEvaluator
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
public NaryValueRelationalExpressionEvaluator(NaryValueRelationalExpression expr, FieldTreeNode context) {
field = expr.getField();
fieldMd = context.resolve(field);
if (fieldMd == null) {
throw new EvaluationError(expr, CrudConstants.ERR_FIELD_NOT_THERE + field);
}
operator = expr.getOp();
values = new HashSet<>();
for (Value x : expr.getValues()) {
values.add(fieldMd.getType().cast(x.getValue()));
}
LOGGER.debug("ctor {} {} {}", expr.getField(), operator, values);
}
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:14,代码来源:NaryValueRelationalExpressionEvaluator.java
示例10: inq
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
private QueryExpression inq(String field, String... values) {
List<Value> v = new ArrayList<>();
for (String x : values) {
v.add(new Value(x));
}
return new NaryValueRelationalExpression(new Path(field),
NaryRelationalOperator._in, v);
}
示例11: ninq
import com.redhat.lightblue.query.NaryValueRelationalExpression; //导入依赖的package包/类
private QueryExpression ninq(String field, String... values) {
List<Value> v = new ArrayList<>();
for (String x : values) {
v.add(new Value(x));
}
return new NaryValueRelationalExpression(new Path(field),
NaryRelationalOperator._not_in, v);
}