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.wustl.xipHost.avt2ext.RetrieveAIMTest.java

@Test
public void testRetrieveAIM_1A() {
    Map<Integer, Object> dicomCriteria = new HashMap<Integer, Object>();
    dicomCriteria.put(Tag.SeriesInstanceUID, "1.3.6.1.4.1.9328.50.1.10697");
    List<ImageAnnotation> imageAnnots = adService.retrieveAnnotations(dicomCriteria, null);
    ImageAnnotation annot = (ImageAnnotation) imageAnnots.get(0);
    //Assert image annotation uniqueIdentifier
    String strXML = annot.getAIM();
    InputStreamReader isr = new InputStreamReader(IOUtils.toInputStream(strXML));
    try {//from w w  w  . j a  v a  2s  .c om
        JAXBElement<?> obj = (JAXBElement<?>) u.unmarshal(isr);
        gme.cacore_cacore._3_2.edu_northwestern_radiology.ImageAnnotation imageAnnotation = ((gme.cacore_cacore._3_2.edu_northwestern_radiology.ImageAnnotation) obj
                .getValue());
        String annotID = String.valueOf(imageAnnotation.getUniqueIdentifier());
        //System.out.println(annot.getAIM());
        assertEquals("Wrong annotation retrieved. Expected ID: " + "1.2.288.3.2205383238.1512.1207945935.1"
                + " but actual: " + annotID, annotID, "1.2.288.3.2205383238.1512.1207945935.1");
    } catch (JAXBException e) {
        logger.error(e, e);
    }
}

From source file:eu.europa.ec.markt.tlmanager.model.TSPInformationExtensionAdapter.java

/**
 * The default constructor for TSPInformationExtensionAdapter.
 * //from   w  ww .j  av a  2s  .  c  o m
 * @param extensions the extensions
 */
public TSPInformationExtensionAdapter(ExtensionsListType extensions) {
    this.extensions = extensions;

    initialValueKey = Util.getInitialCounterItem();

    List<ExtensionType> extensionTypes = extensions.getExtension();
    if (!extensionTypes.isEmpty()) {
        for (ExtensionType extension : extensionTypes) {
            TSPInformationExtensionModel model = new TSPInformationExtensionModel();
            model.setCritical(extension.isCritical());
            JAXBElement<?> element = Util.extractJAXBElement(extension);
            ObjectIdentifierType oid = (ObjectIdentifierType) element.getValue();
            IdentifierType identifier = oid.getIdentifier();
            if (identifier != null) {
                model.setExtension(identifier.getValue());
                setValue(Util.getCounterItem(createdEntryCounter++), model);
            }
        }
    } else {
        createNewItem();
    }
}

From source file:edu.harvard.i2b2.eclipse.plugins.ontology.ws.GetPsmResponseMessage.java

public AnalysisPluginMetadataTypeType extractAnalysisPluginMetadata(String response) {
    try {//from  ww  w. ja  va 2  s  . co  m
        JAXBElement jaxbElement = OntologyJAXBUtil.getJAXBUtil().unMashallFromString(response);
        respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status 
        BodyType body = respMessageType.getMessageBody();
        JAXBUnWrapHelper helper = new JAXBUnWrapHelper();

        AnalysisPluginMetadataResponseType responseType = (AnalysisPluginMetadataResponseType) helper
                .getObjectByClass(body.getAny(), AnalysisPluginMetadataResponseType.class);
        List<AnalysisPluginMetadataTypeType> plugins = responseType.getAnalysisPluginMetadataType();

        if (plugins.isEmpty())
            return null;

        AnalysisPluginMetadataTypeType pluginMetadata = (AnalysisPluginMetadataTypeType) plugins.get(0);
        return pluginMetadata;

    } catch (JAXBUtilException e) {
        // TODO Auto-generated catch block
        log.error(e.getMessage());
        return null;
    }

}

From source file:fileMapper.ws.GetPsmResponseMessage.java

public StatusType processResult(String response) {
    StatusType status = null;/*w  w w .  j  av  a2s  . c  om*/
    try {
        JAXBElement jaxbElement = FileMapperJAXBUtil.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.info("Error reported by Crc web Service " + procMessage);
        } else if (procStatus.equals("WARNING")) {
            log.info("Warning reported by Crc web Service" + procMessage);
        }

    } catch (JAXBUtilException e) {
        // TODO Auto-generated catch block
        log.error(e.getMessage());
    }
    return status;
}

From source file:com.eventestimator.mvc.ContactCollectionController.java

@RequestMapping(value = "/json.j", method = RequestMethod.GET)
protected ResponseEntity<Object> getContacts(Model model, HttpServletRequest request) throws Exception {

    HttpSession session = request.getSession();
    String userName = (String) session.getAttribute("userName");
    String accessToken = (String) session.getAttribute("accessToken");
    String contactUrl = WS_URL_PREFIX + userName + "/contacts?access_token=" + accessToken;
    Feed contactSource = restTemplate.getForObject(contactUrl, Feed.class);
    List<Entry> contacts = contactSource.getEntries();
    List<Contact> contactObjects = new ArrayList<Contact>(contacts.size());
    for (Entry contact : contacts) {

        Link link = (Link) contact.getOtherLinks().get(0);

        String linkHref = link.getHref();
        String contentXML = restTemplate.getForObject(WS_DOMAIN + linkHref + "?access_token=" + accessToken,
                String.class);
        //            List<Content> contactContents = contactEntry.getBody().getContents();
        //            List<Content> contactContents = contactEntry.getContents();
        //// ww  w. j  a  v a  2  s .c o m
        //            Content contactContent = contactContents.get(0);
        //            String contentXML = contactContent.getValue();

        final SAXParserFactory sax = SAXParserFactory.newInstance();
        sax.setNamespaceAware(false);
        final XMLReader reader;
        try {
            reader = sax.newSAXParser().getXMLReader();
        } catch (SAXException e) {
            throw new RuntimeException(e);
        }
        InputSource is = new InputSource(new StringReader(contentXML));
        SAXSource source = new SAXSource(reader, is);
        JAXBContext context = JAXBContext.newInstance(ContactEntry.class);
        javax.xml.bind.Unmarshaller unmarshaller = context.createUnmarshaller();
        JAXBElement<ContactEntry> contactEntry = (JAXBElement<ContactEntry>) unmarshaller.unmarshal(source,
                ContactEntry.class);
        Contact contactObject = contactEntry.getValue().getContent().getContact();
        contactObjects.add(contactObject);
    }
    ResponseEntity<Object> response = new ResponseEntity<Object>(contactObjects, HttpStatus.OK);
    return response;

}

From source file:edu.harvard.i2b2.eclipse.plugins.ontology.ws.GetPsmResponseMessage.java

public List extractXMLResult(String response) {
    List<DataType> counts = null;
    try {//ww w.  jav a 2 s .c  o m
        JAXBElement jaxbElement = OntologyJAXBUtil.getJAXBUtil().unMashallFromString(response);
        respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status 
        BodyType body = respMessageType.getMessageBody();
        JAXBUnWrapHelper helper = new JAXBUnWrapHelper();

        CrcXmlResultResponseType responseType = (CrcXmlResultResponseType) helper
                .getObjectByClass(body.getAny(), CrcXmlResultResponseType.class);
        XmlValueType xml = responseType.getCrcXmlResult().getXmlValue();

        String xmlString = (String) xml.getContent().get(0);
        jaxbElement = OntologyJAXBUtil.getJAXBUtil().unMashallFromString(xmlString);
        ResultEnvelopeType resultEnvelopeType1 = (ResultEnvelopeType) jaxbElement.getValue();
        ResultType resultType = (ResultType) helper.getObjectByClass(resultEnvelopeType1.getBody().getAny(),
                ResultType.class);
        counts = resultType.getData();

    } catch (JAXBUtilException e) {
        // TODO Auto-generated catch block
        log.error(e.getMessage());
        return null;
    }
    return counts;
}

From source file:fileMapper.ws.GetPsmResponseMessage.java

public AnalysisPluginMetadataTypeType extractAnalysisPluginMetadata(String response) {
    try {//from w  w w.j a va  2  s  .c  o m
        JAXBElement jaxbElement = FileMapperJAXBUtil.getJAXBUtil().unMashallFromString(response);
        respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status 
        BodyType body = respMessageType.getMessageBody();
        JAXBUnWrapHelper helper = new JAXBUnWrapHelper();

        AnalysisPluginMetadataResponseType responseType = (AnalysisPluginMetadataResponseType) helper
                .getObjectByClass(body.getAny(), AnalysisPluginMetadataResponseType.class);
        List<AnalysisPluginMetadataTypeType> plugins = responseType.getAnalysisPluginMetadataType();

        if (plugins.isEmpty())
            return null;

        AnalysisPluginMetadataTypeType pluginMetadata = (AnalysisPluginMetadataTypeType) plugins.get(0);
        return pluginMetadata;

    } catch (JAXBUtilException e) {
        // TODO Auto-generated catch block
        log.error(e.getMessage());
        return null;
    }

}

From source file:org.socialhistoryservices.pid.ws.PidServiceEndPoint.java

@PayloadRoot(localPart = "GetPidByAttributeRequest", namespace = namespace)
@ResponsePayload/*from   w  w w  .  j  a va 2 s .co m*/
public JAXBElement<GetPidByAttributeResponseType> getPidByAttribute(
        @RequestPayload JAXBElement<GetPidByAttributeRequestType> requestElement) throws IOException {
    final String na = normalize(requestElement.getValue().getNa(), true);
    final String attribute = normalize(requestElement.getValue().getAttribute(), true);
    final GetPidByAttributeResponseType response = objectFactory.createGetPidByAttributeResponseType();
    pidResourceService.getPidByAttribute(response.getHandle(), na, attribute);
    return objectFactory.createGetPidByAttributeResponse(response);
}

From source file:fileMapper.ws.GetPsmResponseMessage.java

public List extractXMLResult(String response) {
    List<DataType> counts = null;
    try {//from  w w  w.ja va2 s  .c o m
        JAXBElement jaxbElement = FileMapperJAXBUtil.getJAXBUtil().unMashallFromString(response);
        respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status 
        BodyType body = respMessageType.getMessageBody();
        JAXBUnWrapHelper helper = new JAXBUnWrapHelper();

        CrcXmlResultResponseType responseType = (CrcXmlResultResponseType) helper
                .getObjectByClass(body.getAny(), CrcXmlResultResponseType.class);
        XmlValueType xml = responseType.getCrcXmlResult().getXmlValue();

        String xmlString = (String) xml.getContent().get(0);
        jaxbElement = FileMapperJAXBUtil.getJAXBUtil().unMashallFromString(xmlString);
        ResultEnvelopeType resultEnvelopeType1 = (ResultEnvelopeType) jaxbElement.getValue();
        ResultType resultType = (ResultType) helper.getObjectByClass(resultEnvelopeType1.getBody().getAny(),
                ResultType.class);
        counts = resultType.getData();

    } catch (JAXBUtilException e) {
        // TODO Auto-generated catch block
        log.error(e.getMessage());
        return null;
    }
    return counts;
}

From source file:com.trifork.batchcopy.client.BatchCopyClient.java

/**
 * Perform a batch copy request//from   w w  w .  j av  a 2  s.co m
 * @param register Register name
 * @param dataType Datatype
 * @param offsetToken offset token
 * @return offset token of last entry
 * @throws JAXBException
 * @throws IOException
 * @throws SAXException
 * @throws ParserConfigurationException
 */
public String performRequest(String register, String dataType, String offsetToken)
        throws JAXBException, IOException, SAXException, ParserConfigurationException {
    ReplicationRequestType request = new ReplicationRequestType();
    if (offsetToken != null) {
        request.setOffset(offsetToken);
    } else {
        request.setOffset("00000000000000000000");
    }
    request.setVersion(1L);
    request.setDatatype(dataType);
    request.setRegister(register);
    request.setMaxRecords(1L);

    String requestString = createRequestString(request);
    Reply reply = sosiUtil.sendServiceRequest(endpointUrl, requestString);

    Element body = reply.getBody();

    Unmarshaller unmarshaller = jaxContext.createUnmarshaller();
    JAXBElement<ReplicationResponseType> jaxbResponse = unmarshaller.unmarshal(body,
            ReplicationResponseType.class);
    ReplicationResponseType response = jaxbResponse.getValue();
    Node atomFeedNode = (Node) response.getAny();

    printResponse(atomFeedNode);

    return extractLastToken(atomFeedNode);
}