Search in sources :

Example 6 with DataRetrievalFailureException

use of org.springframework.dao.DataRetrievalFailureException 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 7 with DataRetrievalFailureException

use of org.springframework.dao.DataRetrievalFailureException 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 8 with DataRetrievalFailureException

use of org.springframework.dao.DataRetrievalFailureException in project opennms by OpenNMS.

the class DefaultEventConfDao method reloadConfig.

private synchronized void reloadConfig() throws DataAccessException {
    try {
        // Load the root event file
        Events events = JaxbUtils.unmarshal(Events.class, m_configResource);
        // Hash the list of event files for efficient lookup
        Set<String> eventFiles = new HashSet<String>();
        eventFiles.addAll(events.getEventFiles());
        // if and only if they exist in the new root
        for (String eventFile : m_events.getEventFiles()) {
            if (!eventFiles.contains(eventFile)) {
                m_lastModifiedEventFiles.remove(eventFile);
                continue;
            }
            events.addLoadedEventFile(eventFile, m_events.getLoadEventsByFile(eventFile));
        }
        // Load/reload the event files as necessary
        events.loadEventFilesIfModified(m_configResource, m_lastModifiedEventFiles);
        // Order the events for efficient searching
        events.initialize(m_partition, new EventOrdering());
        m_events = events;
    } catch (Exception e) {
        throw new DataRetrievalFailureException("Unabled to load " + m_configResource, e);
    }
}
Also used : EventOrdering(org.opennms.netmgt.xml.eventconf.EventOrdering) Events(org.opennms.netmgt.xml.eventconf.Events) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) DataAccessException(org.springframework.dao.DataAccessException) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 9 with DataRetrievalFailureException

use of org.springframework.dao.DataRetrievalFailureException in project opennms by OpenNMS.

the class DefaultEventConfDao method loadConfig.

private synchronized void loadConfig() throws DataAccessException {
    try {
        Events events = JaxbUtils.unmarshal(Events.class, m_configResource);
        m_lastModifiedEventFiles = events.loadEventFiles(m_configResource);
        m_partition = new EnterpriseIdPartition();
        events.initialize(m_partition, new EventOrdering());
        m_events = events;
    } catch (Exception e) {
        throw new DataRetrievalFailureException("Unabled to load " + m_configResource, e);
    }
}
Also used : EventOrdering(org.opennms.netmgt.xml.eventconf.EventOrdering) Events(org.opennms.netmgt.xml.eventconf.Events) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) DataAccessException(org.springframework.dao.DataAccessException) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) IOException(java.io.IOException)

Example 10 with DataRetrievalFailureException

use of org.springframework.dao.DataRetrievalFailureException in project opennms by OpenNMS.

the class DefaultSiteStatusViewService method getAggregateStatus.

/** {@inheritDoc} */
@Override
public AggregateStatus getAggregateStatus(String statusViewName, String statusSite, String rowLabel) {
    AggregateStatusView statusView = createAggregateStatusView(statusViewName);
    Collection<AggregateStatus> stati = createAggregateStatuses(statusView, statusSite);
    for (AggregateStatus status : stati) {
        if (status.getLabel().equals(rowLabel)) {
            return status;
        }
    }
    throw new DataRetrievalFailureException("Unable to locate row: " + rowLabel + " for status view: " + statusViewName);
}
Also used : AggregateStatus(org.opennms.web.svclayer.model.AggregateStatus) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) AggregateStatusView(org.opennms.netmgt.model.AggregateStatusView)

Aggregations

DataRetrievalFailureException (org.springframework.dao.DataRetrievalFailureException)14 IOException (java.io.IOException)3 Ticket (org.opennms.api.integration.ticketing.Ticket)3 EventOrdering (org.opennms.netmgt.xml.eventconf.EventOrdering)3 Events (org.opennms.netmgt.xml.eventconf.Events)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)2 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)2 DataRecord (org.aspcfs.apps.transfer.DataRecord)2 DataAccessException (org.springframework.dao.DataAccessException)2 QuickBaseClient (com.intuit.quickbase.util.QuickBaseClient)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 ResultSetMetaData (java.sql.ResultSetMetaData)1