Search in sources :

Example 1 with MXDateTimeType

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

the class TsrmTicketerPlugin method updateIncidentWithTicket.

private void updateIncidentWithTicket(SHSIMPINCINCIDENTType incident, Ticket ticket) {
    if (!StringUtils.isEmpty(ticket.getAttribute(AFFECTED_PERSON))) {
        MXStringType affectedPerson = new MXStringType();
        affectedPerson.setValue(ticket.getAttribute(AFFECTED_PERSON));
        incident.setAFFECTEDPERSON(affectedPerson);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(ASSET_NUM))) {
        MXStringType assetNum = new MXStringType();
        assetNum.setValue(ticket.getAttribute(ASSET_NUM));
        incident.setASSETNUM(assetNum);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(CLASS_ID))) {
        MXStringType classId = new MXStringType();
        classId.setValue(ticket.getAttribute(CLASS_ID));
        incident.setCLASS(classId);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(CLASS_STRUCTURE_ID))) {
        MXStringType classStructureId = new MXStringType();
        classStructureId.setValue(ticket.getAttribute(CLASS_STRUCTURE_ID));
        incident.setCLASSSTRUCTUREID(classStructureId);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(COMMODITY))) {
        MXStringType commodity = new MXStringType();
        commodity.setValue(ticket.getAttribute(COMMODITY));
        incident.setCOMMODITY(commodity);
    }
    if (!StringUtils.isEmpty(ticket.getSummary())) {
        MXStringType description = new MXStringType();
        description.setValue(ticket.getSummary());
        incident.setDESCRIPTION(description);
    }
    if (!StringUtils.isEmpty(ticket.getDetails())) {
        MXStringType longDescription = new MXStringType();
        longDescription.setValue(ticket.getDetails());
        incident.setDESCRIPTIONLONGDESCRIPTION(longDescription);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(LOCATION))) {
        MXStringType location = new MXStringType();
        location.setValue(ticket.getAttribute(LOCATION));
        incident.setLOCATION(location);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(OWNER_GROUP))) {
        MXStringType ownerGroup = new MXStringType();
        ownerGroup.setValue(ticket.getAttribute(OWNER_GROUP));
        incident.setOWNERGROUP(ownerGroup);
    }
    if (!StringUtils.isEmpty(ticket.getUser())) {
        if (StringUtils.isEmpty(ticket.getId())) {
            MXStringType reportedBy = new MXStringType();
            reportedBy.setValue(ticket.getUser());
            incident.setREPORTEDBY(reportedBy);
        } else {
            MXDateTimeType date = new MXDateTimeType();
            GregorianCalendar calendarTime = new GregorianCalendar();
            calendarTime.setTime(new Date());
            XMLGregorianCalendar value;
            @SuppressWarnings({ "unchecked", "rawtypes" }) JAXBElement<MXDateTimeType> jaxbElement = new JAXBElement(new QName(MXDateTimeType.class.getName()), MXDateTimeType.class, date);
            try {
                value = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendarTime);
                date.setValue(value);
                incident.setCHANGEDATE(jaxbElement);
            } catch (DatatypeConfigurationException e) {
                LOG.error("Unable to create changedDate", e);
            }
        }
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(SHS_CALLER_TYPE))) {
        MXStringType shsCallerType = new MXStringType();
        shsCallerType.setValue(ticket.getAttribute(SHS_CALLER_TYPE));
        incident.setSHSCALLERTYPE(shsCallerType);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(SHS_REASON_FOR_OUTAGE))) {
        MXStringType shsReasonForOutage = new MXStringType();
        shsReasonForOutage.setValue(ticket.getAttribute(SHS_REASON_FOR_OUTAGE));
        incident.setSHSREASONFOROUTAGE(shsReasonForOutage);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(SHS_RESOLUTION))) {
        MXStringType shsResolution = new MXStringType();
        shsResolution.setValue(ticket.getAttribute(SHS_RESOLUTION));
        incident.setSHSRESOLUTION(shsResolution);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(SHS_ROOM_NUMBER))) {
        MXStringType shsRoomNumber = new MXStringType();
        shsRoomNumber.setValue(ticket.getAttribute(SHS_ROOM_NUMBER));
        incident.setSHSROOMNUMBER(shsRoomNumber);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(SITE_ID))) {
        MXStringType siteId = new MXStringType();
        siteId.setValue(ticket.getAttribute(SITE_ID));
        incident.setSITEID(siteId);
    }
    if (!StringUtils.isEmpty(ticket.getAttribute(SOURCE))) {
        MXStringType source = new MXStringType();
        source.setValue(ticket.getAttribute(SOURCE));
        incident.setSOURCE(source);
    }
    MXStringType status = new MXStringType();
    try {
        if (ticket.getState().equals(Ticket.State.OPEN)) {
            status.setValue(getProperties().getProperty("tsrm.status.open"));
        } else if (ticket.getState().equals(Ticket.State.CLOSED)) {
            status.setValue(getProperties().getProperty("tsrm.status.close"));
        }
    } catch (IOException e) {
        LOG.error("Unable to load tsrm.status from properties ", e);
    }
    incident.setSTATUS(status);
    if (!StringUtils.isEmpty(ticket.getAttribute(STATUS_IFACE))) {
        MXBooleanType statusIface = new MXBooleanType();
        statusIface.setValue(Boolean.parseBoolean(ticket.getAttribute(STATUS_IFACE)));
        incident.setSTATUSIFACE(statusIface);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) MXBooleanType(com.ibm.maximo.MXBooleanType) QName(javax.xml.namespace.QName) MXDateTimeType(com.ibm.maximo.MXDateTimeType) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) JAXBElement(javax.xml.bind.JAXBElement) IOException(java.io.IOException) MXStringType(com.ibm.maximo.MXStringType) Date(java.util.Date)

Aggregations

MXBooleanType (com.ibm.maximo.MXBooleanType)1 MXDateTimeType (com.ibm.maximo.MXDateTimeType)1 MXStringType (com.ibm.maximo.MXStringType)1 IOException (java.io.IOException)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 JAXBElement (javax.xml.bind.JAXBElement)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 QName (javax.xml.namespace.QName)1