/** Recursively outputs the contents of the given node. */ private static void dump(Node node) throws RepositoryException { // First output the node path System.out.println(node.getPath()); // Skip the virtual (and large!) jcr:system subtree if (node.getName().equals("jcr:system")) { return; } // Then output the properties PropertyIterator properties = node.getProperties(); while (properties.hasNext()) { Property property = properties.nextProperty(); if (property.getDefinition().isMultiple()) { // A multi-valued property, print all values Value[] values = property.getValues(); for (int i = 0; i < values.length; i++) { System.out.println(property.getPath() + " = " + values[i].getString()); } } else { // A single-valued property System.out.println(property.getPath() + " = " + property.getString()); } } // Finally output all the child nodes recursively NodeIterator nodes = node.getNodes(); while (nodes.hasNext()) { dump(nodes.nextNode()); } }
@SuppressWarnings("unchecked") public void setParent(Node<Mesh> parent) { this.parent = parent; Deque<Node<?>> queue = new ArrayDeque<Node<?>>(parent.getNodes().values()); while (!queue.isEmpty()) { Node<?> node = queue.pop(); if (node.getKind() instanceof Bone) { bones.add((Node<Bone>) node); queue.addAll(node.getNodes().values()); } } ImmutableMultimap.Builder<Vertex, Pair<Float, Node<Bone>>> builder = ImmutableMultimap.builder(); for (Node<Bone> bone : getBones()) { for (Pair<Vertex, Float> b : bone.getKind().getData()) { builder.put(b.getLeft(), Pair.of(b.getRight(), bone)); } } weightMap = builder.build(); }
public void setAnimation(Animation animation) { this.animation = animation; Deque<Node<?>> q = new ArrayDeque<Node<?>>(nodes.values()); while (!q.isEmpty()) { Node<?> node = q.pop(); if (node.getAnimation() != null) continue; node.setAnimation(animation); q.addAll(node.getNodes().values()); } }
public VNodeDefinition(Node node) throws RepositoryException { name = node.getProperty(JCR_NODETYPENAME).getString(); // do properties properties = new HashMap<String, VPropertyDefinitionI>(); childSuggestions = new HashMap<String, String>(); NodeIterator nodeIterator = node.getNodes(); while (nodeIterator.hasNext()) { Node definitionNode = nodeIterator.nextNode(); String nodeType = definitionNode.getProperty(AbstractProperty.JCR_PRIMARYTYPE).getString(); // do a property if (NT_PROPERTYDEFINITION.equals(nodeType)) { String propertyName = "*"; // default to wildcard name if (definitionNode.hasProperty(JCR_NAME)) { // only add non-autogenerated properties if (!definitionNode.getProperty(JCR_AUTOCREATED).getBoolean()) { propertyName = definitionNode.getProperty(JCR_NAME).getString(); properties.put(propertyName, new VPropertyDefinition(definitionNode)); } } else { // property with no name means this node can accept custom properties canAddProperties = true; } } // do a child suggestion if (NT_CHILDNODEDEFINITION.equals(nodeType)) { String childName = "*"; // only do well-defined childnodedefinitions with the following 2 jcr properties if (definitionNode.hasProperty(JCR_NAME) && definitionNode.hasProperty(JCR_DEFAULTPRIMARYTYPE)) { childSuggestions.put( definitionNode.getProperty(JCR_NAME).getString(), definitionNode.getProperty(JCR_DEFAULTPRIMARYTYPE).getString()); } } } // do supertypes supertypes = new HashSet<String>(); if (node.hasProperty(JCR_SUPERTYPES)) { for (Value value : node.getProperty(JCR_SUPERTYPES).getValues()) { supertypes.add(value.getString()); } } // set mixin status isMixin = node.hasProperty(JCR_ISMIXIN) && node.getProperty(JCR_ISMIXIN).getBoolean(); }
public static void buildDefinitions(Session session) { log.info("started building node definitions"); String nodeName = ""; try { allNodes = new HashMap<String, VNodeDefinition>(); Node rootNode = session.getNode("/jcr:system/jcr:nodeTypes"); NodeIterator nodeIterator = rootNode.getNodes(); while (nodeIterator.hasNext()) { Node node = nodeIterator.nextNode(); nodeName = node.getName(); VNodeDefinition vNodeDefinition = new VNodeDefinition(node); customizeDefinition(vNodeDefinition); // possibly customize this definition allNodes.put(nodeName, vNodeDefinition); } log.info("finished building nodes"); } catch (RepositoryException re) { log.warn("Could not build node definitions, died at " + nodeName, re); } finally { if (session != null) session.logout(); } }