Search in sources :

Example 1 with DataRecord

use of org.aspcfs.apps.transfer.DataRecord in project opennms by OpenNMS.

the class CentricTicketerPlugin method createDataRecord.

/**
     * Helper method for creating a CentricCRM DataRecord from properties
     * defined in the centric.properties file.
     * 
     * @return a populated <code>org.aspcfs.apps.transfer.DataRecord</code>
     */
private DataRecord createDataRecord() {
    DataRecord record = new DataRecord();
    Properties props = getProperties();
    for (Map.Entry<Object, Object> entry : props.entrySet()) {
        String key = (String) entry.getKey();
        String val = (String) entry.getValue();
        if (!key.startsWith("connection.")) {
            record.addField(key, val);
        }
    }
    return record;
}
Also used : DataRecord(org.aspcfs.apps.transfer.DataRecord) Properties(java.util.Properties) Map(java.util.Map)

Example 2 with DataRecord

use of org.aspcfs.apps.transfer.DataRecord in project opennms by OpenNMS.

the class CentricTicketerPlugin method saveOrUpdate.

/*
     * (non-Javadoc)
     * @see org.opennms.api.integration.ticketing.Plugin#saveOrUpdate(org.opennms.api.integration.ticketing.Ticket)
     */
public void saveOrUpdate(Ticket ticket) {
    CentricConnection crm = createConnection();
    ArrayList<String> returnFields = new ArrayList<String>();
    returnFields.add("id");
    crm.setTransactionMeta(returnFields);
    DataRecord record = createDataRecord();
    record.setName("ticket");
    if (ticket.getId() == null) {
        record.setAction(DataRecord.INSERT);
    } else {
        record.setAction(DataRecord.UPDATE);
        record.addField("id", ticket.getId());
        record.addField("modified", ticket.getModificationTimestamp());
    }
    record.addField("problem", ticket.getSummary());
    record.addField("comment", ticket.getDetails());
    record.addField("stateId", getStateId(ticket.getState()));
    record.addField("closeNow", isClosingState(ticket.getState()));
    crm.save(record);
    boolean success = crm.commit();
    if (!success) {
        throw new DataRetrievalFailureException("Failed to commit Centric transaction: " + crm.getErrorText());
    }
    Assert.isTrue(1 == crm.getRecordCount(), "Unexpected record count from CRM");
    String id = crm.getResponseValue("id");
    ticket.setId(id);
/*
        <map class="org.aspcfs.modules.troubletickets.base.Ticket" id="ticket">
        <property alias="guid">id</property>
        <property lookup="account">orgId</property>
        <property lookup="contact">contactId</property>
        <property>problem</property>
        <property>entered</property>
        <property lookup="user">enteredBy</property>
        <property>modified</property>
        <property lookup="user">modifiedBy</property>
        <property>closed</property>
        <property lookup="ticketPriority">priorityCode</property>
        <property>levelCode</property>
        <property lookup="lookupDepartment">departmentCode</property>
        <property lookup="lookupTicketSource">sourceCode</property>
        <property lookup="ticketCategory">catCode</property>
        <property lookup="ticketCategory">subCat1</property>
        <property lookup="ticketCategory">subCat2</property>
        <property lookup="ticketCategory">subCat3</property>
        <property lookup="user">assignedTo</property>
        <property>comment</property>
        <property>solution</property>
        <property lookup="ticketSeverity">severityCode</property>
        <!-- REMOVE: critical -->
        <!-- REMOVE: notified -->
        <!-- REMOVE: custom_data -->    
        <property>location</property>
        <property>assignedDate</property>
        <property>estimatedResolutionDate</property>
        <property>resolutionDate</property>
        <property>cause</property>
        <property>contractId</property>
        <property>assetId</property>
        <property>productId</property>
        <property>customerProductId</property>
        <property>expectation</property>
        <property>projectTicketCount</property>
        <property>estimatedResolutionDateTimeZone</property>
        <property>assignedDateTimeZone</property>
        <property>resolutionDateTimeZone</property>
        <property>statusId</property>
        <property>trashedDate</property>
        <property>userGroupId</property>
        <property>causeId</property>
        <property>resolutionId</property>
        <property>defectId</property>
        <property>escalationLevel</property>
        <property>resolvable</property>
        <property>resolvedBy</property>
        <property>resolvedByDeptCode</property>
        <property>stateId</property>
        <property>siteId</property>
      </map>
      
*/
}
Also used : ArrayList(java.util.ArrayList) DataRecord(org.aspcfs.apps.transfer.DataRecord) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException)

Example 3 with DataRecord

use of org.aspcfs.apps.transfer.DataRecord 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 4 with DataRecord

use of org.aspcfs.apps.transfer.DataRecord in project opennms by OpenNMS.

the class CentricAPITest method testCreateLead.

public void testCreateLead() {
    CRMConnection crm = createConnection();
    DataRecord contact = new DataRecord();
    contact.setName("contact");
    contact.setAction(DataRecord.INSERT);
    contact.setShareKey(true);
    contact.addField("nameFirst", "Jeff");
    contact.addField("nameLast", "Gehlbach");
    contact.addField("company", "Malta");
    contact.addField("title", "Knight of Order");
    contact.addField("source", "Always");
    contact.addField("isLead", "true");
    contact.addField("accessType", 2);
    contact.addField("leadStatus", 1);
    contact.addField("enteredBy", 0);
    contact.addField("modifiedBy", 0);
    assertTrue(crm.save(contact));
    // Transform the email
    DataRecord email = new DataRecord();
    email.setName("contactEmailAddress");
    email.setAction(DataRecord.INSERT);
    email.addField("email", "jeff@example.com");
    email.addField("contactId", "$C{contact.id}");
    email.addField("type", 1);
    email.addField("enteredBy", 0);
    email.addField("modifiedBy", 0);
    assertTrue(crm.save(email));
    commit(crm);
}
Also used : DataRecord(org.aspcfs.apps.transfer.DataRecord) CRMConnection(org.aspcfs.utils.CRMConnection)

Example 5 with DataRecord

use of org.aspcfs.apps.transfer.DataRecord in project opennms by OpenNMS.

the class CentricAPITest method testCreateTicket.

public void testCreateTicket() {
    CRMConnection crm = createConnection();
    ArrayList<String> sucky = new ArrayList<String>();
    sucky.add("id");
    crm.setTransactionMeta(sucky);
    DataRecord email = new DataRecord();
    email.setName("ticket");
    email.setAction(DataRecord.INSERT);
    email.setShareKey(true);
    //email.addField("orgId", 1);
    //email.addField("contactId", 1);
    email.addField("problem", "can't get there from here");
    email.addField("enteredBy", 0);
    email.addField("modifiedBy", 0);
    crm.save(email);
    commit(crm);
    assertEquals(1, crm.getRecordCount());
    @SuppressWarnings("unchecked") List<RecordLocator> results = crm.getRecords(RecordLocator.class.getName());
    assertEquals(1, results.size());
    RecordLocator record = results.get(0);
    assertTrue(0 < record.getIdAsInt());
/*
        <map class="org.aspcfs.modules.troubletickets.base.Ticket" id="ticket">
        <property alias="guid">id</property>
        <property lookup="account">orgId</property>
        <property lookup="contact">contactId</property>
        <property>problem</property>
        <property>entered</property>
        <property lookup="user">enteredBy</property>
        <property>modified</property>
        <property lookup="user">modifiedBy</property>
        <property>closed</property>
        <property lookup="ticketPriority">priorityCode</property>
        <property>levelCode</property>
        <property lookup="lookupDepartment">departmentCode</property>
        <property lookup="lookupTicketSource">sourceCode</property>
        <property lookup="ticketCategory">catCode</property>
        <property lookup="ticketCategory">subCat1</property>
        <property lookup="ticketCategory">subCat2</property>
        <property lookup="ticketCategory">subCat3</property>
        <property lookup="user">assignedTo</property>
        <property>comment</property>
        <property>solution</property>
        <property lookup="ticketSeverity">severityCode</property>
        <!-- REMOVE: critical -->
        <!-- REMOVE: notified -->
        <!-- REMOVE: custom_data -->    
        <property>location</property>
        <property>assignedDate</property>
        <property>estimatedResolutionDate</property>
        <property>resolutionDate</property>
        <property>cause</property>
        <property>contractId</property>
        <property>assetId</property>
        <property>productId</property>
        <property>customerProductId</property>
        <property>expectation</property>
        <property>projectTicketCount</property>
        <property>estimatedResolutionDateTimeZone</property>
        <property>assignedDateTimeZone</property>
        <property>resolutionDateTimeZone</property>
        <property>statusId</property>
        <property>trashedDate</property>
        <property>userGroupId</property>
        <property>causeId</property>
        <property>resolutionId</property>
        <property>defectId</property>
        <property>escalationLevel</property>
        <property>resolvable</property>
        <property>resolvedBy</property>
        <property>resolvedByDeptCode</property>
        <property>stateId</property>
        <property>siteId</property>
      </map>
      
*/
}
Also used : ArrayList(java.util.ArrayList) DataRecord(org.aspcfs.apps.transfer.DataRecord) CRMConnection(org.aspcfs.utils.CRMConnection)

Aggregations

DataRecord (org.aspcfs.apps.transfer.DataRecord)6 ArrayList (java.util.ArrayList)4 CRMConnection (org.aspcfs.utils.CRMConnection)3 DataRetrievalFailureException (org.springframework.dao.DataRetrievalFailureException)2 Map (java.util.Map)1 Properties (java.util.Properties)1 Ticket (org.opennms.api.integration.ticketing.Ticket)1