Search in sources :

Example 21 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class CentricTicketerPlugin method get.

/**
     * Implementation of TicketerPlugin API call to retrieve a CentricCRM trouble ticket.
     * @return an OpenNMS 
     */
public Ticket get(String ticketId) {
    CentricConnection crm = createConnection();
    ArrayList<String> returnFields = new ArrayList<String>();
    returnFields.add("id");
    returnFields.add("modified");
    returnFields.add("problem");
    returnFields.add("comment");
    returnFields.add("stateId");
    crm.setTransactionMeta(returnFields);
    DataRecord query = new DataRecord();
    query.setName("ticketList");
    query.setAction(DataRecord.SELECT);
    query.addField("id", ticketId);
    boolean success = crm.load(query);
    if (!success) {
        throw new DataRetrievalFailureException(crm.getLastResponse());
    }
    Ticket ticket = new Ticket();
    ticket.setId(crm.getResponseValue("id"));
    ticket.setModificationTimestamp(crm.getResponseValue("modified"));
    ticket.setSummary(crm.getResponseValue("problem"));
    ticket.setDetails(crm.getResponseValue("comment"));
    ticket.setState(getStateFromId(crm.getResponseValue("stateId")));
    return ticket;
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) ArrayList(java.util.ArrayList) DataRecord(org.aspcfs.apps.transfer.DataRecord) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException)

Example 22 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class JiraTicketerPlugin method getInternal.

private Ticket getInternal(String ticketId, JiraRestClient jira) throws PluginException {
    // w00t
    Issue issue;
    try {
        issue = jira.getIssueClient().getIssue(ticketId).get();
    } catch (InterruptedException | ExecutionException e) {
        throw new PluginException("Failed to get issue with id: " + ticketId, e);
    }
    if (issue != null) {
        Ticket ticket = new Ticket();
        ticket.setId(issue.getKey());
        ticket.setModificationTimestamp(String.valueOf(issue.getUpdateDate().toDate().getTime()));
        ticket.setSummary(issue.getSummary());
        ticket.setDetails(issue.getDescription());
        ticket.setState(getStateFromStatusName(issue.getStatus().getName()));
        return ticket;
    } else {
        return null;
    }
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) Issue(com.atlassian.jira.rest.client.api.domain.Issue) BasicIssue(com.atlassian.jira.rest.client.api.domain.BasicIssue) PluginException(org.opennms.api.integration.ticketing.PluginException) ExecutionException(java.util.concurrent.ExecutionException)

Example 23 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class Otrs31TicketerPluginTest method testCreate.

@Test
public void testCreate() throws PluginException {
    otrsPlugin.saveOrUpdate(s_ticket);
    Ticket otrsTicket = otrsPlugin.get(s_ticket.getId());
    assertTicketEquals(s_ticket, otrsTicket);
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) Test(org.junit.Test)

Example 24 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class JiraTicketerPluginTest method get.

private void get(String ticketId) throws PluginException {
    Ticket newTicket = m_ticketer.get(ticketId);
    assertNotNull(newTicket);
    assertEquals(ticketId, newTicket.getId());
    assertEquals(Ticket.State.OPEN, newTicket.getState());
    assertTrue("Unexpected summary: " + newTicket.getSummary(), newTicket.getSummary().contains("This is the summary"));
    assertTrue("Unexpected description: " + newTicket.getDetails(), newTicket.getDetails().contains("details"));
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket)

Example 25 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class JiraTicketerPluginTest method verifyTooManyFiles.

@Test
@Ignore
public void verifyTooManyFiles() throws PluginException {
    JiraTicketerPlugin plugin = new JiraTicketerPlugin();
    for (int i = 0; i < 500; i++) {
        System.out.print(i + ": ");
        Ticket ticket = plugin.get("NMS-8947");
        System.out.print(ticket.getSummary() + "\n");
    }
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Ticket (org.opennms.api.integration.ticketing.Ticket)46 PluginException (org.opennms.api.integration.ticketing.PluginException)15 Date (java.util.Date)9 Test (org.junit.Test)7 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)4 MXStringType (com.ibm.maximo.MXStringType)3 Properties (java.util.Properties)3 Plugin (org.opennms.api.integration.ticketing.Plugin)3 DataRetrievalFailureException (org.springframework.dao.DataRetrievalFailureException)3 BasicIssue (com.atlassian.jira.rest.client.api.domain.BasicIssue)2 Issue (com.atlassian.jira.rest.client.api.domain.Issue)2 QuerySHSIMPINCResponseType (com.ibm.maximo.QuerySHSIMPINCResponseType)2 QuerySHSIMPINCType (com.ibm.maximo.QuerySHSIMPINCType)2 SHSIMPINCINCIDENTType (com.ibm.maximo.SHSIMPINCINCIDENTType)2 File (java.io.File)2 IOException (java.io.IOException)2 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Ignore (org.junit.Ignore)2