Search in sources :

Example 1 with MXStringQueryType

use of com.ibm.maximo.MXStringQueryType in project opennms by OpenNMS.

the class TsrmTicketerPlugin method get.

@Override
public Ticket get(String ticketId) throws PluginException {
    SHSIMPINCQueryType queryType = new SHSIMPINCQueryType();
    SHSIMPINCQueryType.INCIDENT incidentQuery = new SHSIMPINCQueryType.INCIDENT();
    List<MXStringQueryType> ticketList = incidentQuery.getTICKETID();
    MXStringQueryType ticketQuery = new MXStringQueryType();
    ticketQuery.setValue(ticketId);
    ticketList.add(ticketQuery);
    queryType.setINCIDENT(incidentQuery);
    QuerySHSIMPINCType queryIncident = new QuerySHSIMPINCType();
    queryIncident.setSHSIMPINCQuery(queryType);
    QuerySHSIMPINCResponseType response = port.querySHSIMPINC(queryIncident);
    if (!CollectionUtils.isEmpty(response.getSHSIMPINCSet().getINCIDENT())) {
        // Response will only have one element in the list
        SHSIMPINCINCIDENTType incident = response.getSHSIMPINCSet().getINCIDENT().get(0);
        if (incident != null) {
            Ticket ticket = new Ticket();
            MXStringType affectedPerson = new MXStringType();
            affectedPerson = incident.getAFFECTEDPERSON();
            MXStringType assetNum = new MXStringType();
            assetNum = incident.getASSETNUM();
            MXStringType classId = new MXStringType();
            classId = incident.getCLASS();
            MXStringType classStructureId = new MXStringType();
            classStructureId = incident.getCLASSSTRUCTUREID();
            MXStringType description = new MXStringType();
            description = incident.getDESCRIPTION();
            MXStringType longDescription = new MXStringType();
            longDescription = incident.getDESCRIPTIONLONGDESCRIPTION();
            MXStringType location = new MXStringType();
            location = incident.getLOCATION();
            MXStringType ownerGroup = new MXStringType();
            ownerGroup = incident.getOWNERGROUP();
            MXStringType reportedBy = new MXStringType();
            reportedBy = incident.getREPORTEDBY();
            MXStringType shsCallerType = new MXStringType();
            shsCallerType = incident.getSHSCALLERTYPE();
            MXStringType shsReasonForOutage = new MXStringType();
            shsReasonForOutage = incident.getSHSREASONFOROUTAGE();
            MXStringType shsResolution = new MXStringType();
            shsResolution = incident.getSHSRESOLUTION();
            MXStringType shsRoomNumber = new MXStringType();
            shsRoomNumber = incident.getSHSROOMNUMBER();
            MXStringType siteId = new MXStringType();
            siteId = incident.getSITEID();
            MXStringType source = new MXStringType();
            source = incident.getSOURCE();
            MXBooleanType statusIface = new MXBooleanType();
            statusIface = incident.getSTATUSIFACE();
            MXStringType ticketIdFromIncident = new MXStringType();
            ticketIdFromIncident = incident.getTICKETID();
            if (ticketIdFromIncident == null) {
                return null;
            }
            ticket.setId(ticketIdFromIncident.getValue());
            if (affectedPerson != null) {
                ticket.addAttribute(AFFECTED_PERSON, affectedPerson.getValue());
            }
            if (assetNum != null) {
                ticket.addAttribute(ASSET_NUM, assetNum.getValue());
            }
            if (classId != null) {
                ticket.addAttribute(CLASS_ID, classId.getValue());
            }
            if (classStructureId != null) {
                ticket.addAttribute(CLASS_STRUCTURE_ID, classStructureId.getValue());
            }
            if (description != null) {
                ticket.setSummary(description.getValue());
            }
            if (longDescription != null) {
                ticket.setDetails(longDescription.getValue());
            }
            if (location != null) {
                ticket.addAttribute(LOCATION, location.getValue());
            }
            if (ownerGroup != null) {
                ticket.addAttribute(OWNER_GROUP, ownerGroup.getValue());
            }
            if (reportedBy != null) {
                ticket.setUser(reportedBy.getValue());
            }
            if (shsCallerType != null) {
                ticket.addAttribute(SHS_CALLER_TYPE, shsCallerType.getValue());
            }
            if (shsReasonForOutage != null) {
                ticket.addAttribute(SHS_REASON_FOR_OUTAGE, shsReasonForOutage.getValue());
            }
            if (shsResolution != null) {
                ticket.addAttribute(SHS_RESOLUTION, shsResolution.getValue());
            }
            if (shsRoomNumber != null) {
                ticket.addAttribute(SHS_ROOM_NUMBER, shsRoomNumber.getValue());
            }
            if (siteId != null) {
                ticket.addAttribute(SITE_ID, siteId.getValue());
            }
            if (source != null) {
                ticket.addAttribute(SOURCE, source.getValue());
            }
            MXStringType status = new MXStringType();
            status = incident.getSTATUS();
            try {
                if ((status != null) && (status.getValue() != null) && (status.getValue().equals(getProperties().getProperty("tsrm.status.open")))) {
                    ticket.setState(Ticket.State.OPEN);
                } else if ((status != null) && (status.getValue() != null) && (status.getValue().equals(getProperties().getProperty("tsrm.status.close")))) {
                    ticket.setState(Ticket.State.CLOSED);
                }
            } catch (IOException e) {
                LOG.error("Unable to load tsrm.status from properties ", e);
            }
            if (statusIface != null) {
                ticket.addAttribute(STATUS_IFACE, statusIface.isValue().toString());
            }
            return ticket;
        }
        return null;
    } else {
        return null;
    }
}
Also used : QuerySHSIMPINCResponseType(com.ibm.maximo.QuerySHSIMPINCResponseType) Ticket(org.opennms.api.integration.ticketing.Ticket) MXStringQueryType(com.ibm.maximo.MXStringQueryType) MXBooleanType(com.ibm.maximo.MXBooleanType) QuerySHSIMPINCType(com.ibm.maximo.QuerySHSIMPINCType) SHSIMPINCQueryType(com.ibm.maximo.SHSIMPINCQueryType) IOException(java.io.IOException) MXStringType(com.ibm.maximo.MXStringType) SHSIMPINCINCIDENTType(com.ibm.maximo.SHSIMPINCINCIDENTType)

Example 2 with MXStringQueryType

use of com.ibm.maximo.MXStringQueryType in project opennms by OpenNMS.

the class TsrmTicketerPlugin method saveOrUpdate.

@Override
public void saveOrUpdate(Ticket ticket) throws PluginException {
    LOG.debug("saveOrUpdate called with ticket: {}", ticket);
    String ticketId = ticket.getId();
    if (StringUtils.isEmpty(ticketId)) {
        SHSIMPINCINCIDENTType incident = new SHSIMPINCINCIDENTType();
        updateIncidentWithTicket(incident, ticket);
        SHSIMPINCSetType incSetType = new SHSIMPINCSetType();
        List<SHSIMPINCINCIDENTType> incidentList = incSetType.getINCIDENT();
        incidentList.add(incident);
        CreateSHSIMPINCType createIncidentType = new CreateSHSIMPINCType();
        createIncidentType.setSHSIMPINCSet(incSetType);
        CreateSHSIMPINCResponseType response = port.createSHSIMPINC(createIncidentType);
        if (response != null) {
            List<INCIDENTKeyType> incidentKeyList = response.getINCIDENTMboKeySet().getINCIDENT();
            if (!CollectionUtils.isEmpty(incidentKeyList)) {
                // Response will only have one element in the list
                INCIDENTKeyType incidentKey = incidentKeyList.get(0);
                ticket.setId(incidentKey.getTICKETID().getValue());
            }
        }
    } else {
        SHSIMPINCQueryType queryType = new SHSIMPINCQueryType();
        SHSIMPINCQueryType.INCIDENT incidentQuery = new SHSIMPINCQueryType.INCIDENT();
        List<MXStringQueryType> ticketList = incidentQuery.getTICKETID();
        MXStringQueryType ticketQuery = new MXStringQueryType();
        ticketQuery.setValue(ticketId);
        ticketList.add(ticketQuery);
        queryType.setINCIDENT(incidentQuery);
        QuerySHSIMPINCType queryIncident = new QuerySHSIMPINCType();
        queryIncident.setSHSIMPINCQuery(queryType);
        QuerySHSIMPINCResponseType response = port.querySHSIMPINC(queryIncident);
        if (!CollectionUtils.isEmpty(response.getSHSIMPINCSet().getINCIDENT())) {
            // Response will only have one element in the list
            SHSIMPINCINCIDENTType incident = response.getSHSIMPINCSet().getINCIDENT().get(0);
            updateIncidentWithTicket(incident, ticket);
            UpdateSHSIMPINCType updateIncident = new UpdateSHSIMPINCType();
            SHSIMPINCSetType updateIncidentType = new SHSIMPINCSetType();
            updateIncidentType.getINCIDENT().add(incident);
            updateIncident.setSHSIMPINCSet(updateIncidentType);
            port.updateSHSIMPINC(updateIncident);
        }
    }
}
Also used : QuerySHSIMPINCResponseType(com.ibm.maximo.QuerySHSIMPINCResponseType) SHSIMPINCSetType(com.ibm.maximo.SHSIMPINCSetType) MXStringQueryType(com.ibm.maximo.MXStringQueryType) UpdateSHSIMPINCType(com.ibm.maximo.UpdateSHSIMPINCType) CreateSHSIMPINCResponseType(com.ibm.maximo.CreateSHSIMPINCResponseType) QuerySHSIMPINCType(com.ibm.maximo.QuerySHSIMPINCType) CreateSHSIMPINCType(com.ibm.maximo.CreateSHSIMPINCType) SHSIMPINCQueryType(com.ibm.maximo.SHSIMPINCQueryType) INCIDENTKeyType(com.ibm.maximo.INCIDENTKeyType) SHSIMPINCINCIDENTType(com.ibm.maximo.SHSIMPINCINCIDENTType)

Aggregations

MXStringQueryType (com.ibm.maximo.MXStringQueryType)2 QuerySHSIMPINCResponseType (com.ibm.maximo.QuerySHSIMPINCResponseType)2 QuerySHSIMPINCType (com.ibm.maximo.QuerySHSIMPINCType)2 SHSIMPINCINCIDENTType (com.ibm.maximo.SHSIMPINCINCIDENTType)2 SHSIMPINCQueryType (com.ibm.maximo.SHSIMPINCQueryType)2 CreateSHSIMPINCResponseType (com.ibm.maximo.CreateSHSIMPINCResponseType)1 CreateSHSIMPINCType (com.ibm.maximo.CreateSHSIMPINCType)1 INCIDENTKeyType (com.ibm.maximo.INCIDENTKeyType)1 MXBooleanType (com.ibm.maximo.MXBooleanType)1 MXStringType (com.ibm.maximo.MXStringType)1 SHSIMPINCSetType (com.ibm.maximo.SHSIMPINCSetType)1 UpdateSHSIMPINCType (com.ibm.maximo.UpdateSHSIMPINCType)1 IOException (java.io.IOException)1 Ticket (org.opennms.api.integration.ticketing.Ticket)1