本文整理汇总了Java中com.redhat.lightblue.query.Projection.isFieldRequiredToEvaluateProjection方法的典型用法代码示例。如果您正苦于以下问题:Java Projection.isFieldRequiredToEvaluateProjection方法的具体用法?Java Projection.isFieldRequiredToEvaluateProjection怎么用?Java Projection.isFieldRequiredToEvaluateProjection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.redhat.lightblue.query.Projection
的用法示例。
在下文中一共展示了Projection.isFieldRequiredToEvaluateProjection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gatherRequiredFields
import com.redhat.lightblue.query.Projection; //导入方法依赖的package包/类
/**
* Returns a list of the field names that are needed for the operation to be
* successful.
* @param md - {@link EntityMetadata}.
* @param projection - (optional) {@link Projection}.
* @param query - (optional) {@link QueryExpression}.
* @param sort - (optional) {@link Sort}.
* @return list of field names.
*/
private Set<Path> gatherRequiredFields(EntityMetadata md,
Projection projection, QueryExpression query, Sort sort) {
Set<Path> paths = new HashSet<>();
FieldCursor cursor = md.getFieldCursor();
while (cursor.next()) {
Path node = cursor.getCurrentPath();
String fieldName = node.getLast();
if (((projection != null) && projection.isFieldRequiredToEvaluateProjection(node))
|| ((query != null) && query.isRequired(node))
|| ((sort != null) && sort.isRequired(node))) {
if (PredefinedFields.isFieldAnArrayCount(fieldName, md.getFields())) {
/*
* Handles the case of an array count field, which will not actually exist in
* the ldap entity.
*/
paths.add(node.mutableCopy().setLast(PredefinedFields.createArrayFieldNameFromCountField(fieldName)).immutableCopy());
}
else {
paths.add(node);
}
}
}
return paths;
}
示例2: getRequiredFields
import com.redhat.lightblue.query.Projection; //导入方法依赖的package包/类
/**
* Returns all the fields required to evaluate the given projection, query,
* and sort
*
* @param md Entity metadata
* @param p Projection
* @param q Query
* @param s Sort
*
* All arguments are optional. The returned set contains the fields required
* to evaluate all the non-null expressions
*/
public static Set<Path> getRequiredFields(EntityMetadata md,
Projection p,
QueryExpression q,
Sort s) {
Set<Path> fields = new HashSet<>();
FieldCursor cursor = md.getFieldCursor();
// skipPrefix will be set to the root of a subtree that needs to be skipped.
// If it is non-null, all fields with a prefix 'skipPrefix' will be skipped.
Path skipPrefix = null;
if (cursor.next()) {
boolean done = false;
do {
Path field = cursor.getCurrentPath();
if (skipPrefix != null) {
if (!field.matchingDescendant(skipPrefix)) {
skipPrefix = null;
}
}
if (skipPrefix == null) {
FieldTreeNode node = cursor.getCurrentNode();
LOGGER.debug("Checking if {} is included ({})", field, node);
if (node instanceof ResolvedReferenceField
|| node instanceof ReferenceField) {
skipPrefix = field;
} else {
if ((node instanceof ObjectField)
|| (node instanceof ArrayField && ((ArrayField) node).getElement() instanceof ObjectArrayElement)
|| (node instanceof ArrayElement)) {
// include its member fields
} else if ((p != null && p.isFieldRequiredToEvaluateProjection(field))
|| (q != null && q.isRequired(field))
|| (s != null && s.isRequired(field))) {
LOGGER.debug("{}: required", field);
fields.add(field);
} else {
LOGGER.debug("{}: not required", field);
}
done = !cursor.next();
}
} else {
done = !cursor.next();
}
} while (!done);
}
return fields;
}
示例3: getIncludedFieldsOfEntityForProjection
import com.redhat.lightblue.query.Projection; //导入方法依赖的package包/类
/**
* Returns the fields included based on the requested projection and
* reference field projection
*/
public static Set<Path> getIncludedFieldsOfEntityForProjection(ExecutionBlock block,
CompositeMetadata root,
Projection requestProjection) {
Set<Path> fields = new HashSet<>();
// What is the path prefix for this entity?
CompositeMetadata md = block.getMetadata();
Path entityPath = md.getEntityPath();
Path globalPrefix = entityPath.isEmpty() ? Path.EMPTY : new Path(entityPath, Path.ANYPATH);
// entityPath is either empty, meaning this is the root, or a path to a reference field
// If entityPath is not empty, then find the projection in the reference field
ResolvedReferenceField reference = block.getReference();
Projection localProjection;
if (reference != null) {
localProjection = reference.getReferenceField().getProjection();
} else {
localProjection = null;
}
FieldCursor cursor = md.getFieldCursor();
Path skipPrefix = null;
Path globalField;
while (cursor.next()) {
Path localField = cursor.getCurrentPath();
globalField = globalPrefix.isEmpty() ? localField : new Path(globalPrefix, localField);
FieldTreeNode node = cursor.getCurrentNode();
if (skipPrefix != null) {
if (!localField.matchingDescendant(skipPrefix)) {
skipPrefix = null;
}
}
if (skipPrefix == null) {
if (node instanceof ResolvedReferenceField
|| node instanceof ReferenceField) {
skipPrefix = localField;
} else if ((node instanceof ObjectField)
|| (node instanceof ArrayField && ((ArrayField) node).getElement() instanceof ObjectArrayElement)
|| (node instanceof ArrayElement)) {
// include its member fields
} else if(node instanceof ArrayField && ((ArrayField) node).getElement() instanceof SimpleArrayElement) {
fields.add(new Path(localField,Path.ANYPATH));
} else {
if (localProjection != null && localProjection.isFieldRequiredToEvaluateProjection(localField)) {
LOGGER.debug("{}: required", localField);
fields.add(localField);
}
if (requestProjection != null && requestProjection.isFieldRequiredToEvaluateProjection(globalField)) {
LOGGER.debug("{}: required", localField);
fields.add(localField);
}
}
}
}
return fields;
}