Choose an existing relationship when linking 2 components

Started by FB, August 22, 2018, 09:45:08 AM

Previous topic - Next topic

FB

Hello,

Before creating a feature request, I want to check if I did not find the way for the following use case:

I've created two components linked by two relationships, let say 2 technical services TS1 and TS2, linked by 2 flows F1 (created first) and F2 from TS1 to TS2.

I want to create two new instances of TS1 and TS2, linked by F2 only.

So I copy / paste special TS1 and TS2, and then I link TS1 with TS2 with the flow arrow. I get then the message "A relationship of this type already exists between 'TS1' and 'TS2'. Do you want to reference this one ?".
If I answer "Yes", the relationship F1 appears between the new instances of TS1 and TS2, but I can not choose the F2 relationship.

If I drag and drop the F2 relationship on the new TS1 instance, I get the F2 relationship appearing between the 2 instances of TS1 and the 2 instances of TS2. Of course, I can delete from the view the useless F2 relationship instances , but on a complex view with many instances of components, it is quite unpractical.

Is there a possibility to choose one relationship between 2 new instances of existing components with many relationships ?

Regards.

Jean-Baptiste Sarrodie

 Hi,

You can't do that for the moment. A GitHub issue has already been created for that some time ago.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

FB


AdGerrits

Related to the question is a long term need of mine to add an already existing relation between 2 elements in a view. I'm sure it can be done with jArchi but I suspect it's existing functionality that I don't know of. In fact a sort of stripped version of the 'generatie view' function.

Jean-Baptiste Sarrodie

Hi,

Quote from: AdGerrits on August 24, 2018, 08:18:12 AM
Related to the question is a long term need of mine to add an already existing relation between 2 elements in a view. I'm sure it can be done with jArchi but I suspect it's existing functionality that I don't know of. In fact a sort of stripped version of the 'generatie view' function.

I'm not sure to understand...

If you want to add an already existing relationship, you simply have to drag'n drop it from the model tree (or the analysis tab in the property panel of an element) to the view. So simple that I guess I misunderstood your question :-)

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

AdGerrits

Sorry, the question was really badly formulated.
What I meant was if it's possible to add all existing relations between elements in a view automatically (the same functionality as when generating a view, but then in an existing view).

Jean-Baptiste Sarrodie

Hi,

Quote from: AdGerrits on August 28, 2018, 20:43:59 PM
Sorry, the question was really badly formulated.
What I meant was if it's possible to add all existing relations between elements in a view automatically (the same functionality as when generating a view, but then in an existing view).

You mean something like that:
// Find DiagramComponents for a given element in a given view
var getDiagramComponents = function(v, e) {
    return $(v).find().filter(function(o) {
        return o.concept.id == e.id;
    });
}

// Checks if a view contains a visual connection from src and tgt visual objects
var contains = function(r, src, tgt) {
    found = false;
   
    $(r).objectRefs().each(function(o) {
        if (o.source.id == src.id && o.target.id == tgt.id) {
            found = true;
        }
    });
   
    return found;;
}


// Iterate through selected views to add relationships which exist in the model but not in the view
$(selection).filter("archimate-diagram-model").each(function(v) {
    $(v).find("element").each(function(e) {
        $(e.concept).rels().each(function(r) {
            getDiagramComponents(v,r.source).each(function(src) {
                getDiagramComponents(v,r.target).each(function(tgt) {
                    if (! contains(r, src, tgt)) {
                        v.add(r, src, tgt);
                    }
                });
            });
        });
    });
});


;-)

Amazing what we can do with jArchi....

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

AdGerrits

It is almost scary to see how it works right away  :o
And wow, what an example script to learn from. Double thanks!

Jean-Baptiste Sarrodie

Hi,

Quote from: AdGerrits on August 29, 2018, 22:51:55 PM
It is almost scary to see how it works right away  :o
And wow, what an example script to learn from. Double thanks!

Yes, with jArchi (aka scripting plugin) lots of common user request can in fact be addressed in a script and do not require changing code in Archi. This means that everybody can easily contribute to a librairy of scripts snippets. We have yet to find the best way to "collect" those scripts: maybe a repo on GitHub or simply through Gist.

FWIW, I've just created a Gist for this script. I suggest to use #jArchi as a kind of tag in Gist description and keep the .ajs extension for filename, so that it would become to easily find them on GitHub through search. But wait a minute, someone else already shared a jArchi script !

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

AdGerrits

Thanks.
Publishing scripts this way is sufficient for now I think.
Btw: the script from 'the man with the fez' also works flawless #yajs (yet another jarchi script)