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>
*/
}
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;
}
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);
}
}
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);
}
}
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);
}
Aggregations