use of org.eclipse.vorto.repository.core.impl.utils.ModelReferencesHelper in project vorto by eclipse.
the class ModelSequencer method execute.
@Override
public boolean execute(Property inputProperty, Node outputNode, Context context) throws Exception {
Binary binaryValue = inputProperty.getBinary();
CheckArg.isNotNull(binaryValue, "binary");
ModelInfo modelResource = ModelParserFactory.getParser(outputNode.getPath()).parse(binaryValue.getStream());
outputNode.setProperty("vorto:description", modelResource.getDescription() != null ? modelResource.getDescription() : "");
outputNode.setProperty("vorto:type", modelResource.getType().name());
outputNode.setProperty("vorto:displayname", modelResource.getDisplayName());
outputNode.setProperty("vorto:version", modelResource.getId().getVersion());
outputNode.setProperty("vorto:namespace", modelResource.getId().getNamespace());
outputNode.setProperty("vorto:name", modelResource.getId().getName());
ModelReferencesHelper referencesHelper = new ModelReferencesHelper(modelResource.getReferences());
if (referencesHelper.hasReferences()) {
List<Value> references = new ArrayList<Value>();
for (ModelId modelId : referencesHelper.getReferences()) {
ModelIdHelper modelIdHelper = new ModelIdHelper(modelId);
Node referencedFolder = outputNode.getSession().getNode(modelIdHelper.getFullPath());
Node reference = referencedFolder.getNodes().nextNode();
references.add(context.valueFactory().createValue(reference));
}
outputNode.setProperty("vorto:references", references.toArray(new Value[references.size()]));
}
return true;
}
use of org.eclipse.vorto.repository.core.impl.utils.ModelReferencesHelper in project vorto by eclipse.
the class JcrModelRepository method createModelResource.
private ModelInfo createModelResource(Node node) throws RepositoryException {
ModelInfo resource = createMinimalModelInfo(node);
if (node.hasProperty("vorto:references")) {
Value[] referenceValues = null;
try {
referenceValues = node.getProperty("vorto:references").getValues();
} catch (Exception ex) {
referenceValues = new Value[] { node.getProperty("vorto:references").getValue() };
}
if (referenceValues != null) {
ModelReferencesHelper referenceHelper = new ModelReferencesHelper();
for (Value referValue : referenceValues) {
String nodeUuid = referValue.getString();
Node referencedNode = session.getNodeByIdentifier(nodeUuid);
referenceHelper.addModelReference(ModelIdHelper.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 = ModelIdHelper.fromPath(referencedByFileNode.getParent().getPath());
resource.getReferencedBy().add(referencedById);
if (referencedByFileNode.getName().endsWith(ModelType.Mapping.getExtension())) {
ModelEMFResource emfResource = getEMFResource(referencedById);
resource.addPlatformMapping(emfResource.getTargetPlatform(), referencedById);
}
}
return resource;
}
Aggregations