private ModelResource createModelResource(Node node) throws RepositoryException { ModelResource resource = new ModelResource( ModelId.fromPath(node.getParent().getPath()), ModelType.valueOf(node.getProperty("vorto:type").getString())); resource.setDescription(node.getProperty("vorto:description").getString()); resource.setDisplayName(node.getProperty("vorto:displayname").getString()); resource.setCreationDate(node.getProperty("jcr:created").getDate().getTime()); if (node.hasProperty("vorto:author")) { resource.setAuthor(node.getProperty("vorto:author").getString()); } if (node.hasProperty("vorto:references")) { Value[] referenceValues = node.getProperty("vorto:references").getValues(); if (referenceValues != null) { ModelReferencesHelper referenceHelper = new ModelReferencesHelper(); for (Value referValue : referenceValues) { String nodeUuid = referValue.getString(); Node referencedNode = session.getNodeByIdentifier(nodeUuid); referenceHelper.addModelReference( ModelId.fromPath(referencedNode.getParent().getPath()).getPrettyFormat()); } resource.setReferences(referenceHelper.getReferences()); } } PropertyIterator propIter = node.getReferences(); while (propIter.hasNext()) { Property prop = propIter.nextProperty(); Node referencedByFileNode = prop.getParent(); final ModelId referencedById = ModelId.fromPath(referencedByFileNode.getParent().getPath()); resource.getReferencedBy().add(referencedById); } return resource; }
private boolean isMappingNode(Node node) throws RepositoryException { return node.hasProperty("vorto:type") && ModelType.valueOf(node.getProperty("vorto:type").getString()) == ModelType.Mapping; }