Recent posts

#1
Hi Phil, thank you very much for your explanations! :)

Thanks to these I was able to solve this problem.
#2
General Archi Discussion / Re: Seeking Guidance on How to...
Last post by Phil Beauvoir - May 24, 2024, 11:43:33 AM
Hi, you can use the "Paste Special" command instead of "Paste".

First, change the default behaviour of "Paste Special" in Archi's Preferences under "Diagram -> Paste Special Behaviour" and select "Always paste a duplicate of copied element".

Now when you copy an object select "Paste Special".

To duplicate a view with copies:

1. Create a new blank view
2. Select all the elements from the view you want to duplicate and Copy them
3. Select "Paste Special" in the new view

For more information about copying and pasting behaviour please consult the Archi User Guide.

Hope that helps!
#3
Hello Archi Community!  :)

I am currently facing a challenge while using the Archi software and I'm hoping to find some assistance here.

My goal is to create specializations of elements that could be used between different views while preserving some characteristics such as name-value properties and graphical aspects.

With "Specializations Manager" alone it is not possibie to satisfy this need. So I attempted to realize a "template view" and created the elements of interest there, with the intention of copying and pasting them into other views. However, I noticed that the first paste operation results in copying an instance of the same object, which also modifies the properties of the "template elements" in the corresponding view. To obtain a copy of the same object, I need to perform the paste operation twice.

Similarly, when I use the "Duplicate" option for a view, the instances of the same elements are retained, leading to changes in the properties of the elements in both views.

For this reason, I would like to ask you if there is a way to:
  • Generate a "template" of a desired element starting from a specialization, while preserving the graphic and key-value properties of the object.
  • Copy and paste the desired element into another view without needing to perform the operation twice to obtain a copy.
  • Duplicate a view, creating copies of the objects rather than retaining the same instances.

I am using Archi 5.3 with ArchiMate 3.2.

Thank you in advance for your time and consideration.
#4
I love Archi! Incredible tool! This is why I invested quite a portion of my free time to develop archi-powertools. The tools pay off! Today, as business-as-usual, archi-powertools-verifier notified me that a new connection to yet another Kafka had just been added by the developers to that setup I'm describing in the topic. It took me five minutes to think carefully which of the views on the model best represent the new stuff, do all beauty work, write commit message, and click "OK". (The HTML report gets generated and published automatically.) Including two minutes wasted as I initially made the Flow relation go wrong direction (oops!). The verifier spotted the problem. +1 element and +1 relation in the model, 100% guarantee that the model is in perfect shape.
#5
jArchi / Re: error adding existing elem...
Last post by Mate - May 21, 2024, 19:46:24 PM
Thank you, Phil. I now know my mistake and the distinction between diagram objects and model concepts. Thank you for the explanation.

Also grateful for the tips on JS programming. I only occasionally dabble in programming, and this is my first foray into JS and jArchi. So am most thankful for all the guidance that can help me improve :).
#6
General Archi Discussion / Re: How I cope with model of 4...
Last post by Phil Beauvoir - May 21, 2024, 18:48:35 PM
Hi,

thanks for sharing this with the Archi and ArchiMate community! I'm sure everyone will find this very useful. :-)

Phil
#7
Bonus #1: Model linting
I can use the same technique and same instruments to validate internal properties of architecture models against a set of rules expressed in SQL and CQL queries. For example, my automation checks that if a NiFi processor group is presented on a ArchiMate view, the view also contains all model elements which are data source or data sink for this processor group. Otherwise, the view would mislead me and others about ins and outs of this processor group. Check out this example of SQL queries which implement such sort of verifications.
#8
jArchi / Re: error adding existing elem...
Last post by Phil Beauvoir - May 21, 2024, 11:09:46 AM
Hi,

The error means that there is no method with the signature:

View.add(diagramObject, x, y, w, h);

Your script is getting objects based on the current selection here:

return $(selection).find("element").filter(e => {

But if the current selection is a View then the elements returned are actually diagram objects, not model concepts. In that case you need to reference the underlying concept like this:

View.add(e.concept, 100, 100, 140, 60);

BTW if you want to select all elements in the model rather than the current selection you can just do this:

return $("element").filter(e => {

Some possible tips:

1. You probably know this but I'll mention it anyway. You don't actually need a "main()" function, you can just put that code block at the start of the script.
2. Because you are catching exceptions in a try/catch block you don't get to see the line number in the script where the error occurred in the console output. I had to remove the try/catch to see the line number where the problem occurred.

Hope that helps!
#9
jArchi / Re: error adding existing elem...
Last post by Mate - May 21, 2024, 00:00:52 AM
seems to work as expected if the selection is the model or a folder. If the selection is a view then I get this error. Do I need to do some additional transformation for elements selected from a view vs elements selected from the whole model or a folder in the model?
#10
jArchi / error adding existing elements...
Last post by Mate - May 20, 2024, 22:27:10 PM
I have written a script ( this is my third jArchi script, so still learning  :) ) that selects elements in a model based on a combination of properties and adds these to a new view. All seems to be as expected except for adding the element to the view. Below is the script followed by the error that I am getting. I expect I am not doing something right. Any guidance is much appreciated.

console.show();
console.clear();
console.log("Start \r");

debug = true;

var propertyDict = {
    "source": "Legacy",
    "state": "Enabled",
    "taxonomyL0": "Common"   
};

function findMatchingElements(properties, matchAll) {
    try {
        return $(selection).find("element").filter(e => {
            debug ? console.log("Checking element: " + e.name + "\r") : true;
            var matches = matchAll ? true : false;
            for (var key in properties) {
                var elementProp = e.prop(key) ? e.prop(key).trim().toLowerCase() : "";
                var filterProp = properties[key] ? properties[key].trim().toLowerCase() : "";
                debug ? console.log("Property: " + key + ", Element: " + elementProp + ", Filter: " + filterProp + "\r") : true;

                if (matchAll) {
                    if (elementProp !== filterProp) {
                        matches = false;
                        break;
                    }
                } else {
                    if (elementProp === filterProp) {
                        matches = true;
                        break;
                    }
                }
            }
            return matches;
        });
    } catch (error) {
        console.error("Error finding matching elements: " + error);
        return [];
    }
}

function addElementsToView(elements, viewName) {
    try {
        var View = $("view").filter(v => v.name === viewName).first();
        if (!View) {
            debug ? console.log("Creating a new view called: " + viewName + "\r") : true;
            View = model.createArchimateView(viewName);     
        } else {
            debug ? console.log("Selecting the existing view: " + viewName + "\r") : true;
        }

        elements.each(e => {
            debug ? console.log("Adding element: " + e.name + " to the view: " + viewName + "\r") : true;
            View.add(e, 100, 100, 140, 60); // x, y, width, height
        });

        // view.openInUI();
        debug ? console.log("Elements added to view: " + viewName) : true;
    } catch (error) {
        console.error("Error adding elements to view: " + error);
    }
}

function main() {
    try {
        if (!model) {
            throw new Error("No model selected. Please select a model before running the script.");
        }
        var matchAllProperties = true; // Set to false to match any property
        var matchingElements = findMatchingElements(propertyDict, matchAllProperties);
        debug ? console.log("Matching elements: " + matchingElements.length + "\r") : true;
        addElementsToView(matchingElements, propertyDict.source);
    } catch (error) {
        console.error("Error in main function: " + error);
    }
}

main();
console.log("done \r");

QuoteError adding elements to view: TypeError: invokeMember (add) on com.archimatetool.script.dom.model.ArchimateDiagramModelProxy failed due to: no applicable overload found (overloads: [Method[public com.archimatetool.script.dom.model.DiagramModelConnectionProxy com.archimatetool.script.dom.model.ArchimateDiagramModelProxy.add(com.archimatetool.script.dom.model.ArchimateRelationshipProxy,com.archimatetool.script.dom.model.DiagramModelComponentProxy,com.archimatetool.script.dom.model.DiagramModelComponentProxy)], Method[public com.archimatetool.script.dom.model.DiagramModelObjectProxy com.archimatetool.script.dom.model.ArchimateDiagramModelProxy.add(com.archimatetool.script.dom.model.ArchimateElementProxy,int,int,int,int,boolean)], Method[public com.archimatetool.script.dom.model.DiagramModelObjectProxy com.archimatetool.script.dom.model.ArchimateDiagramModelProxy.add(com.archimatetool.script.dom.model.ArchimateElementProxy,int,int,int,int)]], arguments: [JavaObject[application-service: AzureSQLAnalytics(DefaultWorkspace-ef74c932-a6bc-4e9e-aca8-d91d2710dce1-NCUS) (com.archimatetool.script.dom.model.DiagramModelObjectProxy)] (HostObject), 100 (Integer), 100 (Integer), 140 (Integer), 60 (Integer)])