本文整理汇总了Java中com.redhat.lightblue.metadata.EntityMetadata.getFieldCursor方法的典型用法代码示例。如果您正苦于以下问题:Java EntityMetadata.getFieldCursor方法的具体用法?Java EntityMetadata.getFieldCursor怎么用?Java EntityMetadata.getFieldCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.redhat.lightblue.metadata.EntityMetadata
的用法示例。
在下文中一共展示了EntityMetadata.getFieldCursor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJson
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
private TranslatedDoc toJson(DBObject object, EntityMetadata md) {
// Translation is metadata driven. We don't know how to
// translate something that's not defined in metadata.
FieldCursor cursor = md.getFieldCursor();
if (cursor.firstChild()) {
return new TranslatedDoc(new JsonDoc(objectToJson(object,object, md, cursor)),getDocMetadata(object));
} else {
return null;
}
}
示例2: validateNoHiddenInMetaData
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
private void validateNoHiddenInMetaData(EntityMetadata emd) {
FieldCursor cursor = emd.getFieldCursor();
while (cursor.next()) {
if (cursor.getCurrentPath().getLast().equals(DocTranslator.HIDDEN_SUB_PATH.getLast())) {
throw Error.get(MongoCrudConstants.ERR_RESERVED_FIELD);
}
}
}
示例3: gatherRequiredFields
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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;
}
示例4: getRequiredFields
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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;
}