Example usage for javax.xml.bind JAXBElement getValue

List of usage examples for javax.xml.bind JAXBElement getValue

Introduction

In this page you can find the example usage for javax.xml.bind JAXBElement getValue.

Prototype

public T getValue() 

Source Link

Document

Return the content model and attribute values for this element.

See #isNil() for a description of a property constraint when this value is null

Usage

From source file:edu.harvard.i2b2.eclipse.plugins.explorer.ontologyMessaging.OntologyResponseData.java

public StatusType processResult(String response) {
    StatusType status = null;/*from w  ww . ja  v  a2 s.c o m*/
    try {
        JAXBElement jaxbElement = ExplorerJAXBUtil.getJAXBUtil().unMashallFromString(response);
        respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status 
        ResponseHeaderType responseHeader = respMessageType.getResponseHeader();
        status = responseHeader.getResultStatus().getStatus();
        String procStatus = status.getType();
        String procMessage = status.getValue();

        if (procStatus.equals("ERROR")) {
            log.error("Error reported by Ont web Service " + procMessage);
        } else if (procStatus.equals("WARNING")) {
            log.error("Warning reported by Ont web Service" + procMessage);
        }

    } catch (JAXBUtilException e) {
        log.error(e.getMessage());
    }
    return status;
}

From source file:edu.harvard.i2b2.eclipse.plugins.query.ontologyMessaging.OntologyResponseData.java

public StatusType processResult(String response) {
    StatusType status = null;//from  ww  w .  jav  a2s. c  o  m
    try {
        JAXBElement jaxbElement = QueryJAXBUtil.getJAXBUtil().unMashallFromString(response);
        respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status
        ResponseHeaderType responseHeader = respMessageType.getResponseHeader();
        status = responseHeader.getResultStatus().getStatus();
        String procStatus = status.getType();
        String procMessage = status.getValue();

        if (procStatus.equals("ERROR")) {
            log.error("Error reported by Ont web Service " + procMessage);
        } else if (procStatus.equals("WARNING")) {
            log.error("Warning reported by Ont web Service" + procMessage);
        }

    } catch (JAXBUtilException e) {
        log.error(e.getMessage());
    }
    return status;
}

From source file:edu.harvard.i2b2.eclipse.plugins.workplace.ws.WorkplaceResponseData.java

public StatusType processResult(String response) {
    StatusType status = null;//from  w w  w.ja v a2 s . co m
    try {
        JAXBElement jaxbElement = WorkplaceJAXBUtil.getJAXBUtil().unMashallFromString(response);
        respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status 
        ResponseHeaderType responseHeader = respMessageType.getResponseHeader();
        status = responseHeader.getResultStatus().getStatus();
        String procStatus = status.getType();
        String procMessage = status.getValue();

        if (procStatus.equals("ERROR")) {
            log.error("Error reported by Workplace web Service " + procMessage);
        } else if (procStatus.equals("WARNING")) {
            log.error("Warning reported by Workplace web Service" + procMessage);
        }

    } catch (JAXBUtilException e) {
        log.error(e.getMessage());
    }
    return status;
}

From source file:edu.harvard.i2b2.eclipse.plugins.patientSet.workplaceMessaging.WorkplaceResponseData.java

public StatusType processResult(String response) {
    StatusType status = null;/*www.ja  v a 2 s  .c  o  m*/
    try {
        JAXBElement jaxbElement = PatientSetJAXBUtil.getJAXBUtil().unMashallFromString(response);
        respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status 
        ResponseHeaderType responseHeader = respMessageType.getResponseHeader();
        status = responseHeader.getResultStatus().getStatus();
        String procStatus = status.getType();
        String procMessage = status.getValue();

        if (procStatus.equals("ERROR")) {
            log.error("Error reported by Workplace web Service " + procMessage);
        } else if (procStatus.equals("WARNING")) {
            log.error("Warning reported by Workplace web Service" + procMessage);
        }

    } catch (JAXBUtilException e) {
        log.error(e.getMessage());
    }
    return status;
}

From source file:com.qpark.eip.core.model.analysis.operation.GetFieldMappingTypeOperation.java

/**
 * @param message//from w  w w  .  ja  va2  s . c o m
 *            the {@link JAXBElement} containing a
 *            {@link GetFieldMappingTypeRequestType}.
 * @return the {@link JAXBElement} with a
 *         {@link GetFieldMappingTypeResponseType} .
 */
@Override
public final JAXBElement<GetFieldMappingTypeResponseType> invoke(
        final JAXBElement<GetFieldMappingTypeRequestType> message) {
    this.logger.debug("+getFieldMappingType");
    GetFieldMappingTypeRequestType request = message.getValue();
    GetFieldMappingTypeResponseType response = this.of.createGetFieldMappingTypeResponseType();
    long start = System.currentTimeMillis();
    try {
        String modelVersion = request.getRevision();
        if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) {
            modelVersion = this.dao.getLastModelVersion();
        }
        response.getFieldMappingType().addAll(this.dao.getFieldMappingTypesById(modelVersion, request.getId()));
    } catch (Throwable e) {
        /* Add a not covered error to the response. */
        this.logger.error(e.getMessage(), e);
    } finally {
        this.logger.debug(" getFieldMappingType duration {}",
                DateUtil.getDuration(start, System.currentTimeMillis()));
        this.logger.debug("-getFieldMappingType #{}", response.getFieldMappingType().size());
    }
    return this.of.createGetFieldMappingTypeResponse(response);
}

From source file:com.qpark.eip.core.model.analysis.operation.GetFlowOperation.java

/**
 * @param message/*from   w  w w .ja  va 2  s.c  o  m*/
 *            the {@link JAXBElement} containing a
 *            {@link GetFlowRequestType}.
 * @return the {@link JAXBElement} with a {@link GetFlowResponseType}.
 */
@Override
public final JAXBElement<GetFlowResponseType> invoke(final JAXBElement<GetFlowRequestType> message) {
    this.logger.debug("+getFlow");
    final GetFlowRequestType request = message.getValue();
    final GetFlowResponseType response = this.of.createGetFlowResponseType();
    final long start = System.currentTimeMillis();
    try {
        final List<String> namePattern = new ArrayList<>();
        request.getNamePattern().stream()
                .forEach(s -> translateNamePattern(s).ifPresent(translated -> namePattern.add(translated)));
        if (!namePattern.isEmpty()) {
            String modelVersion = request.getRevision();
            if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) {
                modelVersion = this.dao.getLastModelVersion();
            }
            response.getFlow().addAll(this.dao.getFlowByNamePattern(modelVersion, namePattern));
        }
    } catch (final Throwable e) {
        /* Add a not covered error to the response. */
        this.logger.error(e.getMessage(), e);
    } finally {
        this.logger.debug(" getFlow duration {}", DateUtil.getDuration(start, System.currentTimeMillis()));
        this.logger.debug("-getFlow #{}", response.getFlow().size());
    }
    return this.of.createGetFlowResponse(response);
}

From source file:com.evolveum.midpoint.schema.util.PolicyRuleTypeUtil.java

public static String toShortString(PolicyConstraintsType constraints, char join) {
    if (constraints == null) {
        return "null";
    }//w  ww  .  ja  v a 2 s  .c o m
    StringBuilder sb = new StringBuilder();
    // we ignore refs to be able to dump even unresolved policy rules
    for (JAXBElement<AbstractPolicyConstraintType> constraint : toConstraintsList(constraints, false, true)) {
        QName name = constraint.getName();
        String abbreviation = CONSTRAINT_NAMES.get(name.getLocalPart());
        if (sb.length() > 0) {
            sb.append(join);
        }
        if (QNameUtil.match(name, PolicyConstraintsType.F_AND)) {
            sb.append('(');
            sb.append(toShortString((PolicyConstraintsType) constraint.getValue(), JOIN_AND));
            sb.append(')');
        } else if (QNameUtil.match(name, PolicyConstraintsType.F_OR)) {
            sb.append('(');
            sb.append(toShortString((PolicyConstraintsType) constraint.getValue(), JOIN_OR));
            sb.append(')');
        } else if (QNameUtil.match(name, PolicyConstraintsType.F_NOT)) {
            sb.append('(');
            sb.append(toShortString((PolicyConstraintsType) constraint.getValue(), JOIN_AND));
            sb.append(')');
        } else if (QNameUtil.match(name, PolicyConstraintsType.F_TRANSITION)) {
            TransitionPolicyConstraintType trans = (TransitionPolicyConstraintType) constraint.getValue();
            sb.append(SYMBOL_TRANSITION);
            sb.append(toTransSymbol(trans.isStateBefore()));
            sb.append(toTransSymbol(trans.isStateAfter()));
            sb.append('(');
            sb.append(toShortString(trans.getConstraints(), JOIN_AND));
            sb.append(')');
        } else {
            sb.append(abbreviation != null ? abbreviation : name.getLocalPart());
        }
    }
    for (PolicyConstraintReferenceType ref : constraints.getRef()) {
        if (sb.length() > 0) {
            sb.append(join);
        }
        sb.append("ref:").append(ref.getName());
    }
    return sb.toString();
}

From source file:edu.harvard.i2b2.eclipse.plugins.patientMapping.ontologyMessaging.OntologyResponseData.java

public StatusType processResult(String response) {
    StatusType status = null;//  w  ww .j a  va  2s.c  om
    try {
        JAXBElement jaxbElement = PatientMappingJAXBUtil.getJAXBUtil().unMashallFromString(response);
        respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status 
        ResponseHeaderType responseHeader = respMessageType.getResponseHeader();
        status = responseHeader.getResultStatus().getStatus();
        String procStatus = status.getType();
        String procMessage = status.getValue();

        if (procStatus.equals("ERROR")) {
            log.error("Error reported by Ont web Service " + procMessage);
        } else if (procStatus.equals("WARNING")) {
            log.error("Warning reported by Ont web Service" + procMessage);
        }

    } catch (JAXBUtilException e) {
        log.error(e.getMessage());
    }
    return status;
}

From source file:com.googlecode.refit.runner.TreeRunnerTest.java

public void checkXmlReport(File xmlReport) throws JAXBException {
    assertTrue(xmlReport.exists());/*from   ww  w .  j a v  a  2s . c  o  m*/

    JAXBContext ctx = JAXBContext.newInstance(ReportIO.CONTEXT_PATH);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();

    @SuppressWarnings("unchecked")
    JAXBElement<Summary> root = (JAXBElement<Summary>) unmarshaller.unmarshal(xmlReport);

    Summary summary = root.getValue();
    assertTrue(summary.getInputDir().endsWith("src/test/fit"));
    assertTrue(summary.getOutputDir().endsWith("target/fit"));
    assertEquals(1, summary.getExceptions());
    assertEquals(0, summary.getIgnored());
    assertEquals(10, summary.getWrong());
    assertEquals(339, summary.getRight());
    assertEquals(4, summary.getNumTests());

    List<TestResult> results = summary.getTest();
    checkResult(results.get(0), 0, 0, 0, 95, true, "MusicExample.html");
    checkResult(results.get(1), 1, 0, 0, 95, false, "MusicExampleWithErrors.html");
    checkResult(results.get(2), 0, 0, 10, 54, false, "MusicExampleWithFailures.html");
    checkResult(results.get(3), 0, 0, 0, 95, true, "subdir/MusicExample.html");
}

From source file:com.qpark.eip.core.model.analysis.operation.GetFlowInterfaceMappingTypeOperation.java

/**
 * @param message/*from   w w  w  .j a  v  a2s.c o  m*/
 *            the {@link JAXBElement} containing a
 *            {@link GetFlowInterfaceMappingTypeRequestType}.
 * @return the {@link JAXBElement} with a
 *         {@link GetFlowInterfaceMappingTypeResponseType}.
 */
@Override
public final JAXBElement<GetFlowInterfaceMappingTypeResponseType> invoke(
        final JAXBElement<GetFlowInterfaceMappingTypeRequestType> message) {
    this.logger.debug("+getFlowInterfaceMappingType");
    GetFlowInterfaceMappingTypeRequestType request = message.getValue();
    GetFlowInterfaceMappingTypeResponseType response = this.of.createGetFlowInterfaceMappingTypeResponseType();
    long start = System.currentTimeMillis();
    try {
        String modelVersion = request.getRevision();
        if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) {
            modelVersion = this.dao.getLastModelVersion();
        }
        response.getInterfaceType()
                .addAll(this.dao.getFlowInterfaceMappingTypes(modelVersion, request.getFlowId()));
    } catch (Throwable e) {
        /* Add a not covered error to the response. */
        this.logger.error(e.getMessage(), e);
    } finally {
        this.logger.debug(" getFlowInterfaceMappingType duration {}",
                DateUtil.getDuration(start, System.currentTimeMillis()));
        this.logger.debug("-getFlowInterfaceMappingType #{}", response.getInterfaceType().size());
    }
    return this.of.createGetFlowInterfaceMappingTypeResponse(response);
}