archimatetool / archi-scripting-plugin

jArchi - Scripting for Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
118 stars 33 forks source link

Problem with launching @ArchimateRelationshipProxy.java@ for connection merge #104

Closed dmaximenko closed 2 years ago

dmaximenko commented 2 years ago

Version of jArchi, Operating System

MAC, archi 4.9.3, jArchi 1.2

Expected Behaviour

I suppose that my connections should be merged

Actual Behaviour

Script falls into error

Script Error: javax.script.ScriptException: SyntaxError: .../Library/Application Support/Archi4/scripts/merge connections.ajs:8:0 Expected an operand but found import import com.archimatetool.model.IArchimateRelationship; ^ in at line number 1 at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(Unknown Source)

Steps to Reproduce the Behaviour (with attached test files/script)

  1. Try to add using "Archi Script manager" this script https://github.com/archimatetool/archi-scripting-plugin/blob/master/com.archimatetool.script/src/com/archimatetool/script/dom/model/ArchimateRelationshipProxy.java
Phillipus commented 2 years ago

ArchimateRelationshipProxy.java is not a jArchi script, it's source code for jArchi.

Phillipus commented 2 years ago

I think you might be misunderstanding this. If you want to merge connections you can simply use the in-built merge function of jArchi:

https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object#merge2

dmaximenko commented 2 years ago

Thank you I'm new in jArchi scripting. Could you tell a little bit more how to launch connection merging? Thank you

Phillipus commented 2 years ago

Take a look through the wiki and some examples found here in GitHub and on the Archi Forum.

For merge the basics are to get a reference to the two relationships to be merged and then call:

relation.merge(otherRelation);

Phillipus commented 2 years ago

If two connections are selected in a View:

var selectedRelationship = $(selection).first().concept;
console.log("Selected: ", selectedRelationship);

var otherRelationship = $(selection).get(1).concept;
console.log("Other: ", otherRelationship);

selectedRelationship.merge(otherRelationship);