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


Java PathUtils.getNodeById方法代码示例

本文整理汇总了Java中org.jcrom.util.PathUtils.getNodeById方法的典型用法代码示例。如果您正苦于以下问题:Java PathUtils.getNodeById方法的具体用法?Java PathUtils.getNodeById怎么用?Java PathUtils.getNodeById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jcrom.util.PathUtils的用法示例。


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

示例1: mapSingleReference

import org.jcrom.util.PathUtils; //导入方法依赖的package包/类
private void mapSingleReference(JcrReference jcrReference, Object referenceObject, Node containerNode, String propertyName) throws IllegalAccessException, RepositoryException {

        if (jcrReference.byPath()) {
            String referencePath = mapper.getNodePath(referenceObject);
            if (referencePath != null && !referencePath.equals("")) {
                if (containerNode.getSession().getRootNode().hasNode(PathUtils.relativePath(referencePath))) {
                    containerNode.setProperty(propertyName, containerNode.getSession().getValueFactory().createValue(referencePath));
                }
            }
        } else {
            String referenceId = mapper.getNodeId(referenceObject);
            if (referenceId != null && !referenceId.equals("")) {
                //Node referencedNode = containerNode.getSession().getNodeByUUID(referenceUUID);
                Node referencedNode = PathUtils.getNodeById(referenceId, containerNode.getSession());
                if (jcrReference.weak()) {
                    containerNode.setProperty(propertyName, containerNode.getSession().getValueFactory().createValue(referencedNode, true));
                } else {
                    containerNode.setProperty(propertyName, referencedNode);
                }
            } else {
                // remove the reference
                containerNode.setProperty(propertyName, (Value) null);
            }
        }
    }
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:26,代码来源:ReferenceMapper.java

示例2: getReferenceValues

import org.jcrom.util.PathUtils; //导入方法依赖的package包/类
private List<Value> getReferenceValues(List<?> references, Session session, JcrReference jcrReference) throws IllegalAccessException, RepositoryException {
    List<Value> refValues = new ArrayList<Value>();
    for (Object reference : references) {
        if (jcrReference.byPath()) {
            String referencePath = mapper.getNodePath(reference);
            if (referencePath != null && !referencePath.equals("")) {
                if (session.getRootNode().hasNode(PathUtils.relativePath(referencePath))) {
                    refValues.add(session.getValueFactory().createValue(referencePath));
                }
            }
        } else {
            String referenceId = mapper.getNodeId(reference);
            if (referenceId != null && !referenceId.equals("")) {
                //Node referencedNode = session.getNodeByUUID(referenceUUID);
                Node referencedNode = PathUtils.getNodeById(referenceId, session);
                Value value;
                if (jcrReference.weak()) {
                    value = session.getValueFactory().createValue(referencedNode, true);
                } else {
                    value = session.getValueFactory().createValue(referencedNode);
                }
                refValues.add(value);
            }
        }
    }
    return refValues;
}
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:28,代码来源:ReferenceMapper.java

示例3: getSingleReferencedNode

import org.jcrom.util.PathUtils; //导入方法依赖的package包/类
private Node getSingleReferencedNode(JcrReference jcrReference, Value value, Session session) throws RepositoryException {
    if (jcrReference.byPath()) {
        if (session.getRootNode().hasNode(PathUtils.relativePath(value.getString()))) {
            return PathUtils.getNode(value.getString(), session);
        }
    } else {
        //return session.getNodeByUUID(value.getString());
        return PathUtils.getNodeById(value.getString(), session);
    }
    return null;
}
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:12,代码来源:ReferenceMapper.java

示例4: createReferencedObject

import org.jcrom.util.PathUtils; //导入方法依赖的package包/类
Object createReferencedObject(Field field, Value value, Object obj, Session session, Class<?> referenceObjClass, int depth, NodeFilter nodeFilter, Mapper mapper) throws ClassNotFoundException, InstantiationException, RepositoryException, IllegalAccessException, IOException {

        JcrReference jcrReference = mapper.getJcrom().getAnnotationReader().getAnnotation(field, JcrReference.class);
        Node referencedNode = null;

        if (jcrReference.byPath()) {
            if (session.getRootNode().hasNode(PathUtils.relativePath(value.getString()))) {
                referencedNode = PathUtils.getNode(value.getString(), session);
            }
        } else {
            //referencedNode = session.getNodeByUUID(value.getString());
            referencedNode = PathUtils.getNodeById(value.getString(), session);
        }

        if (referencedNode != null) {
            Object referencedObject = mapper.createInstanceForNode(referenceObjClass, referencedNode);
            if (nodeFilter.isIncluded(field.getName(), depth)) {
                // load and map the object, we don't send the current object as parent
                referencedObject = mapper.mapNodeToClass(referencedObject, referencedNode, nodeFilter, null, depth + 1);
            } else {
                if (jcrReference.byPath()) {
                    // just store the path
                    mapper.setNodePath(referencedObject, value.getString());
                } else {
                    // just store the Identifier
                    mapper.setUUID(referencedObject, value.getString());
                    mapper.setId(referencedObject, value.getString());
                }
            }
            // support JcrFileNode annotation for references
            if (field.isAnnotationPresent(JcrFileNode.class) && referencedObject instanceof JcrFile) {
        		JcrFileNode fileNode = field.getAnnotation(JcrFileNode.class);
        		FileNodeMapper.addFileProperties((JcrFile) referencedObject, referencedNode, fileNode, depth, nodeFilter);
        	}
            return referencedObject;
        } else {
            return null;
        }
    }
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:40,代码来源:ReferenceMapper.java

示例5: createReferencedObject

import org.jcrom.util.PathUtils; //导入方法依赖的package包/类
Object createReferencedObject(Field field, Value value, Object obj, Session session, Class<?> referenceObjClass, int depth, NodeFilter nodeFilter, Mapper mapper) throws ClassNotFoundException, InstantiationException, RepositoryException, IllegalAccessException, IOException {

        JcrReference jcrReference = mapper.getJcrom().getAnnotationReader().getAnnotation(field, JcrReference.class);
        Node referencedNode = null;

        if (jcrReference.byPath()) {
            if (session.getRootNode().hasNode(PathUtils.relativePath(value.getString()))) {
                referencedNode = PathUtils.getNode(value.getString(), session);
            }
        } else {
            //referencedNode = session.getNodeByUUID(value.getString());
            referencedNode = PathUtils.getNodeById(value.getString(), session);
        }

        if (referencedNode != null) {
            Object referencedObject = mapper.createInstanceForNode(referenceObjClass, referencedNode);
            if (nodeFilter.isIncluded(field.getName(), depth)) {
                // load and map the object, we don't send the current object as parent
                referencedObject = mapper.mapNodeToClass(referencedObject, referencedNode, nodeFilter, depth + 1);
            } else {
                if (jcrReference.byPath()) {
                    // just store the path
                    mapper.setNodePath(referencedObject, value.getString());
                } else {
                    // just store the Identifier
                    mapper.setUUID(referencedObject, value.getString());
                    mapper.setId(referencedObject, value.getString());
                }
            }
            // support JcrFileNode annotation for references
            if (field.isAnnotationPresent(JcrFileNode.class) && referencedObject instanceof JcrFile) {
        		JcrFileNode fileNode = field.getAnnotation(JcrFileNode.class);
        		FileNodeMapper.addFileProperties((JcrFile) referencedObject, referencedNode, fileNode, depth, nodeFilter);
        	}
            return referencedObject;
        } else {
            return null;
        }
    }
 
开发者ID:sbrinkmann,项目名称:jcrom-extended,代码行数:40,代码来源:ReferenceMapper.java


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