specialization=element-type
console.log("----------GET OBJECT NODE FROM MODEL------------");
var nodes = $("node");
console.log(nodes);
console.log("----------GET VIEW------------");
var view = $(".5-Prod").first(); // Get view from its name (pick the first one if multiple views share the same name)
var flowRelationship = $(view).find("flow-relationship"); // Build a collection containing the view, and then get all flow-relationship in this view.
var compositionRelationship = $(view).find("composition-relationship"); // Build a collection containing the composition-relationship, and then get all flow-relationship in this view.
console.log(flowRelationship);
flowRelationship.each(function(flowRelationship) {
console.log("Relation " + flowRelationship.concept.name + ""); // we can still access the name attribute through the visual object
console.log(flowRelationship.prop("port")); // get port of the relation
console.log(flowRelationship.concept.source.id); // get source id of the relation
console.log(flowRelationship.concept.target.id); // get target id of the relation
console.log(flowRelationship.concept.documentation); // get documentation of the relation
console.log("Source"+$("#"+flowRelationship.concept.source.id)); // get source object of the relation
console.log("Target"+$("#"+flowRelationship.concept.target.id)); // get target object of the relation
if ($("#"+flowRelationship.concept.source.id)
[o].type == "technology-interface") { // if source is a technology-interface
compositionRelationship.each(function(compositionRelationship) { // get all composition-relationship
if (compositionRelationship.concept.target.id == $("#"+flowRelationship.concept.source.id)
[o].concept.id) { // if target of the composition-relationship is the source of the flow-relationship
console.log(" Source: " + compositionRelationship.concept.source.id + " Target: " + compositionRelationship.concept.target.id); // get source and target of the composition-relationship
console.log($("#"+compositionRelationship.concept.source.id)
[o].name); // get name of the source of the composition-relationship
}
}
);
}
console.log("\n");
});
var nodes = get_object_from_model("element","node");
var nodes = $("node");
for (var id in nodes) {
if (nodes.hasOwnProperty(id)) {
var node = nodes[id];
console.log("Node ID: " + id + ", Name: " + node.name + ", Type: " + node.type);
}
}
nodes.each(function(node) {
console.log("Node ID:" + node.id + ", Name: " + node.name + ", Type: " + node.type);
});
nodes.each(function(node) {
console.log("Node " + node.name + " has the following remote ends:");
$(node).inRels("flow-relationship").sourceEnds().each(function(end) {
console.log("- [" + end.id + "] " + end.name + " (" + end.type + ")");
});
});
Quote from: Azix on April 03, 2024, 10:37:12 AMI'm trying to get the relationships from a view but how do I get the right ids between the view and the objects models?
var view = $("view.ViewName").first(); // Get view from its name (pick the first one if multiple views share the same name)
//var view = selection.parents().add(selection).filter("view").first(); // Another option: get the selected view, or the one containing the selected visual object
var nodes = $(view).find("node"); // Build a collection containing the view, and then get all nodes in this view. Note: 'nodes' is a collection of Visual Objects
nodes.each(function(node) { // Note: 'node' is a Visual Object
console.log("Node " + node.name + " has the following remote ends:"); // we can still access the name attribute through the visual object
$(node.concept).inRels("flow-relationship").sourceEnds().each(function(end) { // by using 'node.concept' we switch to the underlying model element
console.log("- [" + end.id + "] " + end.name + " (" + end.type + ")");
});
});
object.concept