当前位置: 首页>>代码示例>>Java>>正文


Java ReferenceField类代码示例

本文整理汇总了Java中com.redhat.lightblue.metadata.ReferenceField的典型用法代码示例。如果您正苦于以下问题:Java ReferenceField类的具体用法?Java ReferenceField怎么用?Java ReferenceField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ReferenceField类属于com.redhat.lightblue.metadata包,在下文中一共展示了ReferenceField类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: objectToJson

import com.redhat.lightblue.metadata.ReferenceField; //导入依赖的package包/类
/**
 * Called after firstChild is called on cursor
 */
private ObjectNode objectToJson(DBObject root, DBObject object, EntityMetadata md, FieldCursor mdCursor) {
    ObjectNode node = factory.objectNode();
    do {
        Path p = mdCursor.getCurrentPath();
        FieldTreeNode field = mdCursor.getCurrentNode();
        String fieldName = field.getName();
        LOGGER.debug("{}", p);
        boolean translate=true;
        if(isResultMetadataNode(field)) {
            injectResultMetadata(root,node,fieldName);
            translate=false;
        } else {
            if(isDocVerNode(field)) {
                injectDocumentVersion(root,node,fieldName);
                translate=false;
            }
        }
        if(translate) {
            // Retrieve field value
            Object value = object.get(fieldName);
            if (value != null) {
                if (field instanceof SimpleField) {
                    convertSimpleFieldToJson(root, node, field, value, fieldName);
                } else if (field instanceof ObjectField) {
                    convertObjectFieldToJson(root, node, fieldName, md, mdCursor, value, p);
                } else if (field instanceof ResolvedReferenceField) {
                    // This should not happen
                } else if (field instanceof ArrayField && value instanceof List && mdCursor.firstChild()) {
                    convertArrayFieldToJson(root, node, fieldName, md, mdCursor, value);
                } else if (field instanceof ReferenceField) {
                    convertReferenceFieldToJson(root, value);
                }
            }
        } // Don't add any null values to the document
    } while (mdCursor.nextSibling());
    return node;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:41,代码来源:DocTranslator.java

示例2: objectToBson

import com.redhat.lightblue.metadata.ReferenceField; //导入依赖的package包/类
/**
 * @param cursor The cursor, pointing to the first element of the object
 */
private BasicDBObject objectToBson(JsonNodeCursor cursor, EntityMetadata md,ResultMetadata rmd) {
    BasicDBObject ret = new BasicDBObject();
    do {
        Path path = cursor.getCurrentPath();
        JsonNode node = cursor.getCurrentNode();
        LOGGER.debug("field: {}", path);
        FieldTreeNode fieldMdNode = md.resolve(path);

        // Do not translate result metadata fields
        if(isResultMetadataNode(fieldMdNode)) {
            fillMetadata(node,rmd);
        } else if(isDocVerNode(fieldMdNode)) {
            fillDocVer(node,rmd);
        } else {
            if (fieldMdNode instanceof SimpleField) {
                toBson(ret, (SimpleField) fieldMdNode, path, node, md);
            } else if (fieldMdNode instanceof ObjectField) {
                convertObjectFieldToBson(node, cursor, ret, path, md,rmd);
            } else if (fieldMdNode instanceof ArrayField) {
                convertArrayFieldToBson(node, cursor, ret, fieldMdNode, path, md,rmd);
            } else if (fieldMdNode instanceof ReferenceField) {
                convertReferenceFieldToBson(node, path);
            }
        }
    } while (cursor.nextSibling());
    return ret;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:31,代码来源:DocTranslator.java

示例3: testTranslate_ReferenceField

import com.redhat.lightblue.metadata.ReferenceField; //导入依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testTranslate_ReferenceField() throws JSONException{
    SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{new Attribute("fake")});

    EntityMetadata md = fakeEntityMetadata("fakeMetadata",
            new ReferenceField("fake")
            );

    new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:11,代码来源:ResultTranslatorToJsonTest.java

示例4: parseReferenceField

import com.redhat.lightblue.metadata.ReferenceField; //导入依赖的package包/类
private ReferenceField parseReferenceField(String name,
                                           T object) {
    ReferenceField field = new ReferenceField(name);
    field.setEntityName(getRequiredStringProperty(object, STR_ENTITY));
    field.setVersionValue(getStringProperty(object, STR_VERSION_VALUE));
    field.setProjection(getProjection(object, STR_PROJECTION));
    field.setQuery(getQuery(object, STR_QUERY));
    field.setSort(getSort(object, STR_SORT));
    parseProperties(field, object, REFERENCE_FIELD_ELEMENTS);

    return field;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:13,代码来源:MetadataParser.java

示例5: convertReferenceField

import com.redhat.lightblue.metadata.ReferenceField; //导入依赖的package包/类
private void convertReferenceField(ReferenceField field, T fieldObject) {
    putString(fieldObject, STR_ENTITY, field.getEntityName());
    if(field.getVersionValue()!=null)
        putString(fieldObject, STR_VERSION_VALUE, field.getVersionValue());
    if (field.getProjection() != null) {
        putProjection(fieldObject, STR_PROJECTION, field.getProjection());
    }
    if (field.getQuery() != null) {
        putQuery(fieldObject, STR_QUERY, field.getQuery());
    }
    if (field.getSort() != null) {
        putSort(fieldObject, STR_SORT, field.getSort());
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:15,代码来源:MetadataParser.java

示例6: getRequiredFields

import com.redhat.lightblue.metadata.ReferenceField; //导入依赖的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;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:59,代码来源:ExpressionTranslator.java

示例7: getIncludedFieldsOfEntityForProjection

import com.redhat.lightblue.metadata.ReferenceField; //导入依赖的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;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:58,代码来源:ExecutionPlan.java


注:本文中的com.redhat.lightblue.metadata.ReferenceField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。