Archi Forum

Archi Plug-ins => jArchi => Topic started by: kkosienski on November 29, 2023, 18:16:17 PM

Title: Working with Collections
Post by: kkosienski on November 29, 2023, 18:16:17 PM
I'm trying to write a script that will result in a collection containing a filtered set of elements. I'm looking to only include elements that contain a specific property name and value. I further want to filter the list of elements by the folder they reside in. Actually, I want to exclude elements that reside in two specific folders in my model tree. So show me all elements in the model with a specific property and value that do not reside in folder A or folder B.  The properties filter is pretty straight forward but I am not sure how to incorporate the folder check into a script. Any thoughts or suggestions are welcome! Thx.
Title: Re: Working with Collections
Post by: Phil Beauvoir on November 29, 2023, 19:30:16 PM
This will return a collection of elements that are not members of folders called "Applications" and "Processes":

var collection = $('element').filter(function(element) {
    var folder = $(element).parent().first();
    return folder.name != "Applications" && folder.name != "Processes";
})
Title: Re: Working with Collections
Post by: Jean-Baptiste Sarrodie on November 29, 2023, 20:09:27 PM
Hi,

also look at the code shared here (it gets the object "path"): https://forum.archimatetool.com/index.php?topic=976.msg5311#msg5311

Regards,

JB
Title: Re: Working with Collections
Post by: kkosienski on November 29, 2023, 21:39:46 PM
Thank you for the suggestions and code sample.

-Kevin