Recent posts

#1
General Archi Discussion / Re: A database of property obj...
Last post by Azix - April 03, 2024, 23:28:40 PM
hi, ohhh I see a bit clearer, thanks for the examples ;D

I've started to do this, does it seem consistent with the view I have or can I simplify the code even more?

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");
});



#2
Hi,

Ok, there is a fundamental misunderstanding on how jArchi API works, which lead to non-needed code and complexity (Btw, don't worry, such misunderstanding is quite frequent).

Most of your 'get_something_from_xxx' function are not needed because jArchi returns a collection which is itself a list of objects.

For example:
var nodes = get_object_from_model("element","node");
Is really only:
var nodes = $("node");
Which in turn makes it easy to rewrite this:
for (var id in nodes) {
    if (nodes.hasOwnProperty(id)) {
        var node = nodes[id];
        console.log("Node ID: " + id + ", Name: " + node.name + ", Type: " + node.type);
    }
}

to this:
nodes.each(function(node) {
  console.log("Node ID:" + node.id + ", Name: " + node.name + ", Type: " + node.type);
});

And because (in this example) node is really a collection (i.e. a list) of object, you can then use them to navigate the model. Based on the previous code sample, let's imagine you want, for each node, to list incoming flow relationships and print the other end, you'll end up with this:
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?

When iterating on a view content, what you get is a collection of visual objects which have their own attributes (such as position and colors), but also act as a "pass-through" to access underlying model concept's type and properties. When navigating using such visual objects as input, the navigation is limited to the view. If you want to navigate the model, then you have to get the underlying concept using the ".concept" attribute of visual objects.

Here's an example based on previously shared code snippets... Let's imagine that the list of nodes doesn't come from the model but from a view, but you still want to list incoming relationships's ends as defined in the model (not the view):
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 + ")");
  });
});


Hope this helps.

Regards,

JB
#3
General Archi Discussion / Re: A database of property obj...
Last post by Phil Beauvoir - April 03, 2024, 12:30:53 PM
> I'm trying to get the relationships from a view but how do I get the right ids between the view and the objects models?

If you want to get the underlying concept for a visual object you can access it with:
object.concept
See https://github.com/archimatetool/archi-scripting-plugin/wiki/Visual-Objects#concept
#4
General Archi Discussion / Re: A database of property obj...
Last post by Azix - April 03, 2024, 10:37:12 AM
Hi, I'm sorry, I'm trying to get the relationships from a view but how do I get the right ids between the view and the objects models?

how do I can retrieve the elements according to the view if they are not ?


function get_relationship_from_view(view,relationship_object){

var relationships = {}; // Objet pour stocker les relations

    $(view).children(relationship_object).each(function(obj) {
        relationships[obj.id] = {
            name: obj.name,
            type: obj.type,
            source: obj.source.id,
            target: obj.target.id,
            documentation: obj.documentation
        };
    });
    console.log(relationships);
    return relationships;
}

function get_object_from_model(model,object){
    var objects = {}; // Objet pour stocker les les variable de l'object

    $(model).filter(object).each(function(obj) {
        objects[obj.id] = {
            name: obj.name,
            type: obj.type,
            documentation: obj.documentation
        };
    });

    return objects;
}

function get_relation_from_model(model,object){
    var relationships = {}; // Objet pour stocker les relations

    $(model).each(function(obj) {
        relationships[obj.id] = {
            name: obj.name,
            type: obj.type,
            source: obj.source.id,
            target: obj.target.id,
            documentation: obj.documentation
        };
    });

    return relationships;
}



var relationships = get_relationship_from_view(".view matrix","flow-relationship");
var nodes = get_object_from_model("element","node");
var network = get_object_from_model("element","communication-network");
var groups = get_object_from_model("element","grouping");
var relationships_from_model = get_relation_from_model("flow-relationship","");

console.log("----------GET OBJECT NODE FROM MODEL-!!!!!!!!!!!!!!!!!!!!------------");


for (var id in nodes) {
    if (nodes.hasOwnProperty(id)) {
        var node = nodes[id];
        console.log("Node ID: " + id + ", Name: " + node.name + ", Type: " + node.type);
    }
}
console.log("\n");

console.log("----------GET OBJECT relationships_from_model FROM MODEL-------------");

for (var id in relationships_from_model) {
    if (relationships_from_model.hasOwnProperty(id)) {
        var relation = relationships_from_model[id];
        console.log("Relation ID: " + id + ", Name: " + relation.name + ", Type: " + relation.type + ", Source ID: " + relation.source + ", Target ID: " + relation.target);
    }
    console.log("\n");
}

console.log("----------GET OBJECT relationships_from_VIEW FROM MODEL-------------");


for (var id in relationships) {
    if (relationships.hasOwnProperty(id)) {
        var relation = relationships[id];
       
        var relation_name = relation.name;
        var sourceId = relation.source;
        var targetId = relation.target;

        // Trouver la source et la cible dans nodes, network ou groups
        var sourceElement = nodes[sourceId] || network[sourceId] || groups[sourceId];
        var targetElement = nodes[targetId] || network[targetId] || groups[targetId];

        console.log("Name: "+relation_name+" Relation ID: " + id + ", Source ID: " + sourceId + ", Target ID: " + targetId);

        if (sourceElement) {
            console.log("Source Element: " + sourceElement.name + " (" + sourceElement.type + ")");
        } else {
            console.log("Source element not found for ID: " + sourceId);
        }

        if (targetElement) {
            console.log("Target Element: " + targetElement.name + " (" + targetElement.type + ")");
        } else {
            console.log("Target element not found for ID: " + targetId);
        }
    }
    console.log("\n");
}
#5
General Archi Discussion / Re: A database of property obj...
Last post by Phil Beauvoir - April 03, 2024, 09:28:22 AM
@Azix I merged your latest topic into this one to keep everything together.

Regarding jArchi scripting, it would be easier to help you if you could take one simple problem at a time. Perhaps if you could explain what you have already tried, and then say where you are stuck. For example, "how to add a property to a concept?", "how to add a concept to a view?"

Phil
#6
General Archi Discussion / JArchi get object and flow rel...
Last post by Azix - April 02, 2024, 20:54:23 PM
Hi, I'm trying to figure out how to use JArchi but I haven't found how to retrieve objects or flow relationships in a specific view... :

And how to do that :

- Use one "Node" (could also be "Device" but most of the time, "Node" is more generic and good-enough) per object (individual server, workstation, network equipment...). Keep track of object's IP in a property named "IP Address". If an object has multiple IP, then create multiple "IP Address" properties on the same node, one for each IP (in Archi the property's name does not have to be unique).
- If you also want to manage IPs ranges, then create "Communication Networks", and again, keep track of the network address in a property named "IP Network".
- Create resources groups using "Grouping" elements which aggregates "Nodes" and/or "Communication Networks". Create one or several views for this specific purpose.
- Model your network architecture with flows to/from "Nodes", "Communication Networks", and "Groupings". No need to add Groupings' content on each view (unless it is needed for people to better understand the context).
- Create a script which takes selected views as input and iterate on all flow relationships contained into these views. When the source or target of a flow is a Grouping, then navigate the model (not the views) to get the list of Nodes and Communication Network. Last, using the properties, generate the expected export file (start by exporting CSV-formatted text on the console, and when ok, use some javascript XLS library to generate a real XLS file).


Can someone explain or give me a piece of code to understand? please
#7
Hi,

Quote from: Jean-Baptiste Sarrodie on February 16, 2024, 10:58:21 AMI'll share this here in the coming weeks.

I'm still working on it internally (as usual, this takes more time than expected)...

Quote from: rchevallier on March 28, 2024, 13:09:14 PMuid are opaque and technical and specific to a model
Just for reconciling shared objects between imported sources, I'm using an custom uri built, and which is stored as a property.

Some advices:
- A reference model is a model which has its own lifecycle
- Stable versions of a reference model are imported into other models, which can then reuse some views of concepts (but not alter them)
- When a newer version is published, the reference model is imported again, which updates its content into the target model, without impacting other part of the model
- Because importing a model cannot remove objects, a good practice is to set a property (e.g. "Lifecycle Status") on each objects to know if they are CURRENT or DEPRECATED. This way, it becomes possible to check objects which are now deprecated and analyse the impact on the target model.

Regards,

JB
#8
General Archi Discussion / Re: Reference Models - best pr...
Last post by rchevallier - March 28, 2024, 13:09:14 PM
uid are opaque and technical and specific to a model

Just for reconciling shared objects between imported sources, I'm using an custom uri built, and which is stored as a property.

ex: for a database table data object the uri I create is __uri=db://<instance>/<database>.<schema>.<table>
The source extraction and reconciliation scripts/programs are using this property __uri as the identifier
#9
jArchi / Re: pb script with archi 5.2
Last post by wnad - March 28, 2024, 11:25:00 AM
Thanks JB your solution is OK
#10
General Archi Discussion / Re: How would u model a vpn?
Last post by m4ttmcg - March 28, 2024, 00:36:49 AM
There is a decent example on the bizzdesign documentation site



This shows the realisation at the tech layer of how the VPN components.

You could represent VPN as a path, or as a network, depending on what you are intending to describe in the view