4 Replies Latest reply on Oct 4, 2019 2:18 PM by Laurent Matheo

    ITSM 9.1 DATA EXTRAPOLATION

    Fabio Sparesato
      Share This:

      Hi to everyone,

       

      I have to do a simple .jar desktop application whose takes all the incidents that a users has in his incident console from the itsm 9.1 site, and gets a list of incidents in order of priority, in the way to make easier for the user to choose from which tickets he has to start.

       

      Can you help me to find a way to do this?

      I already thought to make a simple java code whose connect to the itsm and does a get from the itsm site, but i don't know the right url that can give me the json result with all the incidents with their parameters.

       

      ps: sorry for my bad English

        • 1. Re: ITSM 9.1 DATA EXTRAPOLATION
          Laurent Matheo

          Well you can use the AR Java Api, Misi Mladoniczky created posts about them

          AR System APIs Quick Start Java

           

          I did recently a little example how to get incidents, here it is:

          IncidentResult is just a class having a list of Incident class which contain some of the incident attributes so don't worry about that.

           

                  IncidentResult incidentResult = new IncidentResult();
          
                  // Setting connection information
                  String serverHost = "xxx.xxx.xxx.xxx";
                  String userName = "xxxxxxxxxxxxxx";
                  String userPassword = "xxxxxxxxx";
                  Integer serverPort = xxxx;
          
                  // Trying to connect to the AR Server
                  log.warn("Before new ARServerUser()");
                  ARServerUser server;
                  server = new ARServerUser();
                  log.warn("After new ARServerUser()");
          
                  server.setServer(serverHost);
                  server.setPort(serverPort);
                  server.setUser(userName);
                  server.setPassword(userPassword);
                  server.setTimeoutNormal(3600); // timeout in seconds
                  server.setTimeoutLong(3600);
                  server.setTimeoutXLong(3600);
          
                  try
                  {
                      // Testing Server connection
                      log.warn("Testing connection");
                      int[] ar_info = {
                              Constants.AR_SERVER_INFO_VERSION,
                              Constants.AR_SERVER_INFO_SERVER_NAME
                      };
          
                      server.getServerInfo(ar_info);
          
                      log.warn("Connection successful");
          
                      // Getting the incident and building a list.
                      List<Incident> incidentList = new ArrayList<>();
                      String formName = "HPD:Help Desk";
                      // Qualification
                      String qualification = "1=1";
                      List <Field> fieldList = server.getListFieldObjects(formName);
                      QualifierInfo qualifierInfo = server.parseQualification(qualification, fieldList, null, Constants.AR_QUALCONTEXT_DEFAULT);
          
          
                      // Field list (entryId, Description, instanceId, Incident Number):
                      int[] dataFields = {1, 1000000000, 179, 1000000161};
                      OutputInteger numberOfMatches = new OutputInteger();
          
          
                      // Sort Order
                      List<SortInfo> sortOrder = new ArrayList<SortInfo>();
                      sortOrder.add(new SortInfo(1, Constants.AR_SORT_DESCENDING));
          
          
                      // Fetching data
                      List<Entry> entryList = server.getListEntryObjects(formName, qualifierInfo, 0, Constants.AR_NO_MAX_LIST_RETRIEVE, sortOrder, dataFields, true, numberOfMatches);
          
          
                      if (numberOfMatches.intValue() > 0) {
                          for (int i = 0; i < entryList.size(); i++) {
                              Incident incident = new Incident();
                              Entry entry = entryList.get(i);
          
                              incident.setGUID(entry.get(Constants.AR_RESERV_GUID).toString());
                              incident.setIncidentNumber(entry.get(1000000161).toString());
                              incident.setSummary(entry.get(1000000000).toString());
                              incidentList.add(incident);
                          }
                      }
          
                      incidentResult.setIncidentList(incidentList);
                      incidentResult.setIncidentCount(incidentList.size());
                      successful = true;
                  }
                  catch ( Exception e )
                  {
                      log.error("Connection failed");
                  }
          
          2 of 2 people found this helpful
          • 2. Re: ITSM 9.1 DATA EXTRAPOLATION
            Fabio Sparesato

            Hi,

            thank you for your answer.

            Can I ask which imports do you use?

            Cause now I'm using only "com.bmc.arsys.api.ARServerUser" import and I have to do other imports to test your code

            • 3. Re: ITSM 9.1 DATA EXTRAPOLATION
              rodrigo barcat

              Try below imports

               

              On my connection class I am using

               

              import com.bmc.arsys.api.ARException;

              import com.bmc.arsys.api.ARServerUser;

              import com.bmc.arsys.api.Entry;

               

              On ardbc plugin class

              import java.util.ArrayList;

              import java.util.List;

              import com.bmc.arsys.api.*;

              import com.bmc.arsys.pluginsvr.plugins.*;

               

              maybe it is not the same case of Laurent code, but maybe helps.

              2 of 2 people found this helpful
              • 4. Re: ITSM 9.1 DATA EXTRAPOLATION
                Laurent Matheo

                Fabio Sparesato, is it working now with the imports mentioned by rodrigo barcat?

                1 of 1 people found this helpful