當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。