How to create diagram-model-connection

Started by margolyesh, July 30, 2021, 15:10:23 PM

Previous topic - Next topic

margolyesh

Hi All,

I can't search how to create visual connection with type "diagram-model-connection" on diagram.

I searched here: https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object.

Please help if you can.

Phil Beauvoir

#1
That will be in the next version of jArchi. Will be released soonish.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

margolyesh

Quote from: Phil Beauvoir on July 30, 2021, 15:12:50 PMThat will be in the next version of jArchi. Will be released soonish.

Hello,
has the functionality been realized?

Phil Beauvoir

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

margolyesh

#4
Quote from: Phil Beauvoir on August 02, 2024, 10:53:23 AM
Quote from: margolyesh on August 02, 2024, 01:14:24 AMHello,
has the functionality been realized?

Hi, yes this was implemented in jArchi 1.1.1, three years ago:

https://github.com/archimatetool/archi-scripting-plugin/wiki/Change-Log#version-111---august-18-2021

And here:

https://github.com/archimatetool/archi-scripting-plugin/wiki/View#createconnection

Thank you, that's magic!

How correctly does jArchi work in this situation:

Here is the code:

console.show()
console.clear()
var elm = $(selection).first()
var view
if (elm.type != "archimate-diagram-model") {
    view = $(elm).parent().first()
} else {
    view = elm
}
$(view).children().each(function(e){
console.log(e.type + " " + e.id)
})
var s = $("archimate-diagram-model").first()
var t = $("diagram-model-note").first()
view.createConnection(s, t)
console.log("done")

Result:
archimate-diagram-model id-d83ff340a1d8415993fdbd485ae6495a
diagram-model-note id-dff834d048df417182492fa8c9de4b1b
javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke "com.archimatetool.script.dom.model.DiagramModelComponentProxy.getEObject()" because "source" is null
    at com.archimatetool.script.dom.model.DiagramModelProxy.createConnection(DiagramModelProxy.java:68)
    at <js>.:program(ÑÑÑ.ajs:20)
    at <js>.:program(<eval>:1)
    at org.graalvm.polyglot.Context.eval(Context.java:399)
    at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:478)

But if I replace
var s = $("archimate-diagram-model").first()
by
var s = $("diagram-model-reference").first()

then everything is ok:

archimate-diagram-model id-d83ff340a1d8415993fdbd485ae6495a
diagram-model-note id-dff834d048df417182492fa8c9de4b1b
done

Phil Beauvoir

"archimate-diagram-model" is not a visual object it's a View (container). "diagram-model-reference" is a visual object.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

margolyesh

Quote from: Phil Beauvoir on August 02, 2024, 19:34:09 PM"archimate-diagram-model" is not a visual object it's a View (container). "diagram-model-reference" is a visual object.

I understand this.
I pull a view from the model tree onto the sheet. And I add a note object. There are 2 objects in total on the sheet. Why when I output the list of objects on the sheet, the console displays "archimate-diagram-model" but not "diagram-model-reference"?

margolyesh


Phil Beauvoir

Quote from: margolyesh on August 02, 2024, 20:31:26 PMI pull a view from the model tree onto the sheet. And I add a note object. There are 2 objects in total on the sheet. Why when I output the list of objects on the sheet, the console displays "archimate-diagram-model" but not "diagram-model-reference"?

I think that's probably a bug. I'll investigate and fix for the next version.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

margolyesh

Quote from: Phil Beauvoir on August 02, 2024, 20:48:59 PM
Quote from: margolyesh on August 02, 2024, 20:31:26 PMI pull a view from the model tree onto the sheet. And I add a note object. There are 2 objects in total on the sheet. Why when I output the list of objects on the sheet, the console displays "archimate-diagram-model" but not "diagram-model-reference"?

I think that's probably a bug. I'll investigate and fix for the next version.

I think it's a bug.
https://disk.yandex.ru/i/xxvAx20xfpjitQ

Phil Beauvoir

#10
It's not a "bug", see https://github.com/archimatetool/archi-scripting-plugin/issues/95

This was originally the intended behaviour (I realise there are arguments for and against this). I need to check with @Jean-Baptiste Sarrodie about this.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.