Service Desk Practitioners Forum
cancel

Problem with adding to Web Api Application field that would sepped up getCiOrgs() function.

Highlighted
Siekierko Przem
Respected Contributor.

Problem with adding to Web Api Application field that would sepped up getCiOrgs() function.

Right now, when I’m getting organization from configuration items (500 configuration items) by getCiOrgs() function, it takes about 3 minutes.

Which Web Api Selection should I add to ("TESTCI")Web Api Application to speedup my code ??
Maybe some one knows other way to improve this code ?

public Main() {
ApiSDSession session45 = ApiSDSession.openSession("172.21.1.11", "xxx", "xxx");

IWebApiApplicationWhere where;
IWebApiApplication[] applications;
IWebApiApplicationHome applicationHome = session45.getWebApiApplicationHome();
where = applicationHome.createWebApiApplicationWhere();
where.addCriteriumOnText("TESTCI");
applications = applicationHome.findWebApiApplication(where);

if(applications!=null && applications.length>0)
session45.setApplicationSettings(applications[0]);


IOrganization org = session45.getOrganizationHome().openOrganization(new Long("281479955873867"));
IConfigurationItem[] cis = org.getOwnerOfCI();

for(int i=0; i {
System.out.println("Serial Number: "+cis[i].getSerialNumber());


//when I’m using getCiOrgs() then 500 configuration items displays In 3 minutes
//when it’s commented it takes only 1 second
IOrganization[] ciorgs = cis[i].getCiOrgs();
if(ciorgs!=null && ciorgs.length>0)
System.out.println("CIOrg: " + ciorgs[0].getName1());

}
}