Archi Forum

Discussion Boards => jArchi => Topic started by: gevaertw on July 12, 2019, 13:25:29 PM

Title: jArchi: I have an object ID, I am looking for the relations attached
Post by: gevaertw on July 12, 2019, 13:25:29 PM
Somehow I don't get it by reading the documentation over and over. 

A practical example on the wiki would help me a lot I guess

As a starting point I have the ID of an element. (I have the name also but that's not guaranteed unique). I want jArchi to give me the ID's of the relations that are attached to it, direction does not matter at this point.


//start element contains 6bea61ff-b810-4172-8403-fc338261df72
searchID = "\"#" + startElementID + "\"";
console.log(searchID);
startElementCollection = $(searchID);
//my attempts
console.log (startElementCollection.rels());
console.log (viewCollection.rels(startElementCollection));


assume that viewCollection contains a valid collection of all elements and realtions on the selected view, this works.  one of the elements has the ID 6bea61ff-b810-4172-8403-fc338261df72

and the results, 2 empty arrays?


"#6bea61ff-b810-4172-8403-fc338261df72"
[]
[]


Any thoughts
Title: Re: jArchi: I have an object ID, I am looking for the relations attached
Post by: Phil Beauvoir on July 12, 2019, 13:42:05 PM
You're adding "\" and it doesn't need it.

Try this:

searchID = "#" + startElementID;
startElementCollection = $(searchID);

startElementCollection.rels().each(function(e) {
    console.log(e);
});

Title: Re: jArchi: I have an object ID, I am looking for the relations attached
Post by: gevaertw on July 13, 2019, 05:19:19 AM
Thanks,

while I did not really understand you piece of code (I'm not a pro dev :-[). I managed to get a valid result back using this piece of code:


startElementCollection = $("#2af42d3a-c3b7-4807-bf5a-a3d864bc4f0d");
console.log
    (
    "Relation Name: " + startElementCollection.rels()[0].name
    + " ID: " + startElementCollection.rels()[0].id
    + " Type: " + startElementCollection.rels()[0].type
    );

console.log("length: " + startElementCollection.length);


the result:
Relation Name: Relation1 ID: 2a42b1d2-7f69-497c-b457-ebc0e7080036 Type: realization-relationship
length: 1