Genesys CTI User Forum

Genesys CTI User Forum => Genesys-related Development => Topic started by: genesyslearner on February 08, 2018, 05:08:59 PM

Title: To Retrieve applications on the Hosts
Post by: genesyslearner on February 08, 2018, 05:08:59 PM
Hi All,

My goal is to retrieve the hosts in my environment using SDK and then print the applications on these hosts.
I was able to successfully get the hosts using the below code:-

Collection<CfgHost> hos= confservice.retrieveMultipleObjects(CfgHost.class,
    new CfgHostQuery());
    System.out.println(hos.size());
      for (CfgHost hs : hos)
      {
      System.out.println(hs.getName());
              }
I need reference on the code to fetch applications on these particular hosts. Any reference will help me alot.

Thanks
Title: Re: To Retrieve applications on the Hosts
Post by: PeteHoyle on February 14, 2018, 10:59:26 AM
Hi,

I don't think there is a specific search you can do to obtain all applications by host.

Probably the best way would be to retrieve all applications and then iterate through each application and find which host it is on.

Hope this helps,

Pete.
Title: Re: To Retrieve applications on the Hosts
Post by: genesyslearner on February 15, 2018, 08:51:57 AM
Hi Pete,

Thanks for your response!

I found a way to get application by host and it is more or less the way you are suggesting.
Happy to share the code with you/all :-


Collection<CfgHost> hos= confservice.retrieveMultipleObjects(CfgHost.class,
    new CfgHostQuery());
   
      for (CfgHost hs : hos)
      {
   
      Integer dbid = hs.getDBID();
     
     
      CfgApplicationQuery query = new CfgApplicationQuery();
      query.setHostDbid(dbid);
     
      Collection<CfgApplication> app = confservice.retrieveMultipleObjects(CfgApplication.class, query);
      for (CfgApplication ap : app)
      {
         
         
      System.out.println("AppName" + " " + ap.getName());
     
   
      } 
         
      }