Archi Forum

Archi Plug-ins => jArchi => Topic started by: smirnoww on August 04, 2021, 11:04:29 AM

Title: Finding element by propery value
Post by: smirnoww on August 04, 2021, 11:04:29 AM
Hello! Our IT architecture is modeled in Jira now. Elements are represented by jira issues with matching types. it looks ugly. I want to synchronize Jira model with archi model. And update jira from archi and backway.
For this purpose, I need to match Jira issues and archi model elements. I think I need to store jira key in the element property. But I didn't found a way for searching for elements by their property value. Can I do it with a selector? Or any other way?

Thanks for your work!

Sincerely, Evgeny!
Title: Re: Finding element by propery value
Post by: xiaoqi on August 05, 2021, 00:19:31 AM
Hi Evgeny,

If you click "search" icon, the search bar is appearing, and you can click the icon in the left, there're "name", "documentation" and "property" can be select, the "Property" is a further expanded list which shows all of your created properties.

Hope that can help to point to the elements with specific Property.

Regards, Xiaoqi
Title: Re: Finding element by propery value
Post by: smirnoww on August 05, 2021, 07:17:04 AM
Thanks, xiaoqi!

But, I need to do it with JArchi script. I've written script for extracting issues from jira and creating element in Archi. But now I want to update elements. For this purpose script writes jira's key into element property.

Could you help me to find the element by jira's key written in property via script?
Title: Re: Finding element by propery value
Post by: projetnumero9 on August 05, 2021, 08:54:36 AM
Hi,

Using the following, I managed to select only the business-processes which have a property functional-index:

var list = $("business-process").filter(function(o) { if (o.prop("functional-index", true)) { return o; } }); 


If I understood your usecase, a filter function with the following conditional test should do the trick: o.prop("JIRAKEY") === "123456789"

Regards,
Title: Re: Finding element by propery value
Post by: smirnoww on August 05, 2021, 13:20:37 PM
thanks. It has helped.
Code (javascript) Select

var JireIssues = getIssues("project=CI AND issuetype=ИТ-система", "summary,description");

var is;
var ArchiElement, newElem=0, existsElem=0;
for (var issueKey in JireIssues) {

var elemByJiraKey =$("*").filter(function(o) {
if (o.prop('jira key')==JireIssues[issueKey].key)
return o;
});
console.log(elemByJiraKey.length + '-' + JireIssues[issueKey].fields.summary);
if (elemByJiraKey.length) {
ArchiElement = elemByJiraKey[0];
existsElem++;
}
else {
ArchiElement = model.createElement("application-component", JireIssues[issueKey].fields.summary);
ArchiElement.prop('jira key',JireIssues[issueKey].key);
newElem++;
}
ArchiElement.documentation = JireIssues[issueKey].fields.description;
}