Finding element by propery value

Started by smirnoww, August 04, 2021, 11:04:29 AM

Previous topic - Next topic

smirnoww

August 04, 2021, 11:04:29 AM Last Edit: August 04, 2021, 11:07:39 AM by smirnoww
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!

xiaoqi

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

smirnoww

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?

projetnumero9

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,

smirnoww

August 05, 2021, 13:20:37 PM #4 Last Edit: August 05, 2021, 13:22:10 PM by smirnoww
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;
}