Search in sources :

Example 46 with ObjectFactory

use of jaxb1.ObjectFactory in project webcert by sklintyg.

the class SendMessageToRecipientTypeConverter method toXml.

public static String toXml(SendMessageToRecipientType request) throws JAXBException {
    StringWriter stringWriter = new StringWriter();
    JAXBElement<SendMessageToRecipientType> requestElement = new ObjectFactory().createSendMessageToRecipient(request);
    JAXBContext.newInstance(SendMessageToRecipientType.class).createMarshaller().marshal(requestElement, stringWriter);
    return stringWriter.toString();
}
Also used : StringWriter(java.io.StringWriter) ObjectFactory(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.ObjectFactory) SendMessageToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType)

Example 47 with ObjectFactory

use of jaxb1.ObjectFactory in project webcert by sklintyg.

the class FKAnswerConverterTest method jaxbToXml.

private String jaxbToXml(AnswerToFkType object) throws JAXBException {
    ObjectFactory objectFactory = new ObjectFactory();
    Writer writer = new StringWriter();
    // Init JAXB context
    JAXBContext jaxbContext = JAXBContext.newInstance(AnswerToFkType.class);
    Marshaller marshaller = jaxbContext.createMarshaller();
    // Create a string representation from JAXB element
    marshaller.marshal(objectFactory.createAnswer(object), writer);
    return writer.toString();
}
Also used : Marshaller(javax.xml.bind.Marshaller) ObjectFactory(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.ObjectFactory) StringWriter(java.io.StringWriter) JAXBContext(javax.xml.bind.JAXBContext) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Example 48 with ObjectFactory

use of jaxb1.ObjectFactory in project webcert by sklintyg.

the class FKQuestionConverterTest method jaxbToXml.

private String jaxbToXml(QuestionToFkType object) throws JAXBException {
    ObjectFactory objectFactory = new ObjectFactory();
    Writer writer = new StringWriter();
    // Init JAXB context
    JAXBContext jaxbContext = JAXBContext.newInstance(QuestionToFkType.class);
    Marshaller marshaller = jaxbContext.createMarshaller();
    // Create a string representation from JAXB element
    marshaller.marshal(objectFactory.createQuestion(object), writer);
    return writer.toString();
}
Also used : Marshaller(javax.xml.bind.Marshaller) ObjectFactory(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.ObjectFactory) StringWriter(java.io.StringWriter) JAXBContext(javax.xml.bind.JAXBContext) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Example 49 with ObjectFactory

use of jaxb1.ObjectFactory in project mapstruct by mapstruct.

the class JaxbBasedMapperTest method shouldMapJaxb.

@Test
public void shouldMapJaxb() throws ParseException, JAXBException {
    SourceTargetMapper mapper = SourceTargetMapper.INSTANCE;
    OrderDto source1 = new OrderDto();
    source1.setOrderDetails(new OrderDetailsDto());
    source1.setOrderNumber(11L);
    source1.setOrderDate(createDate("31-08-1982 10:20:56"));
    source1.setShippingAddress(new ShippingAddressDto());
    source1.getShippingAddress().setCity("SmallTown");
    source1.getShippingAddress().setHouseNumber("11a");
    source1.getShippingAddress().setStreet("Awesome rd");
    source1.getShippingAddress().setCountry("USA");
    source1.getOrderDetails().setDescription(new ArrayList<String>());
    source1.getOrderDetails().setName("Shopping list for a Mapper");
    source1.getOrderDetails().getDescription().add("1 MapStruct");
    source1.getOrderDetails().getDescription().add("3 Lines of Code");
    source1.getOrderDetails().getDescription().add("1 Dose of Luck");
    source1.getOrderDetails().setStatus(OrderStatusDto.ORDERED);
    // map to JAXB
    OrderType target = mapper.targetToSource(source1);
    // do a pretty print
    ObjectFactory of = new ObjectFactory();
    System.out.println(toXml(of.createOrder(target)));
    // map back from JAXB
    OrderDto source2 = mapper.sourceToTarget(target);
    // verify that source1 and source 2 are equal
    assertThat(source2.getOrderNumber()).isEqualTo(source1.getOrderNumber());
    assertThat(source2.getOrderDate()).isEqualTo(source1.getOrderDate());
    assertThat(source2.getOrderDetails().getDescription().size()).isEqualTo(source1.getOrderDetails().getDescription().size());
    assertThat(source2.getOrderDetails().getDescription().get(0)).isEqualTo(source1.getOrderDetails().getDescription().get(0));
    assertThat(source2.getOrderDetails().getDescription().get(1)).isEqualTo(source1.getOrderDetails().getDescription().get(1));
    assertThat(source2.getOrderDetails().getDescription().get(2)).isEqualTo(source1.getOrderDetails().getDescription().get(2));
    assertThat(source2.getOrderDetails().getName()).isEqualTo(source1.getOrderDetails().getName());
    assertThat(source2.getOrderDetails().getStatus()).isEqualTo(source1.getOrderDetails().getStatus());
}
Also used : OrderType(org.mapstruct.itest.jaxb.xsd.test1.OrderType) ObjectFactory(org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory) Test(org.junit.Test)

Example 50 with ObjectFactory

use of jaxb1.ObjectFactory in project ddf by codice.

the class CswEndpoint method getInsertResultFromResponse.

private InsertResultType getInsertResultFromResponse(CreateResponse createResponse) throws CswException {
    InsertResultType result = new InsertResultType();
    WKTReader reader = new WKTReader();
    for (Metacard metacard : createResponse.getCreatedMetacards()) {
        BoundingBoxType boundingBox = new BoundingBoxType();
        Geometry geometry = null;
        String bbox = null;
        try {
            if (metacard.getAttribute(CswConstants.BBOX_PROP) != null) {
                bbox = metacard.getAttribute(CswConstants.BBOX_PROP).getValue().toString();
                geometry = reader.read(bbox);
            } else if (StringUtils.isNotBlank(metacard.getLocation())) {
                bbox = metacard.getLocation();
                geometry = reader.read(bbox);
            }
        } catch (ParseException e) {
            LOGGER.debug("Unable to parse BoundingBox : {}", bbox, e);
        }
        BriefRecordType briefRecordType = new BriefRecordType();
        if (geometry != null) {
            Envelope bounds = geometry.getEnvelopeInternal();
            if (bounds != null) {
                boundingBox.setCrs(CswConstants.SRS_NAME);
                boundingBox.setLowerCorner(Arrays.asList(bounds.getMinX(), bounds.getMinY()));
                boundingBox.setUpperCorner(Arrays.asList(bounds.getMaxX(), bounds.getMaxY()));
                briefRecordType.getBoundingBox().add(new net.opengis.ows.v_1_0_0.ObjectFactory().createBoundingBox(boundingBox));
            }
        }
        SimpleLiteral identifier = new SimpleLiteral();
        identifier.getContent().add(metacard.getId());
        briefRecordType.getIdentifier().add(new JAXBElement<>(CswConstants.DC_IDENTIFIER_QNAME, SimpleLiteral.class, identifier));
        SimpleLiteral title = new SimpleLiteral();
        title.getContent().add(metacard.getTitle());
        briefRecordType.getTitle().add(new JAXBElement<>(CswConstants.DC_TITLE_QNAME, SimpleLiteral.class, title));
        SimpleLiteral type = new SimpleLiteral();
        type.getContent().add(metacard.getContentTypeName());
        briefRecordType.setType(type);
        result.getBriefRecord().add(briefRecordType);
    }
    return result;
}
Also used : WKTReader(org.locationtech.jts.io.WKTReader) Envelope(org.locationtech.jts.geom.Envelope) BriefRecordType(net.opengis.cat.csw.v_2_0_2.BriefRecordType) BoundingBoxType(net.opengis.ows.v_1_0_0.BoundingBoxType) Geometry(org.locationtech.jts.geom.Geometry) Metacard(ddf.catalog.data.Metacard) ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) SimpleLiteral(net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral) MimeTypeParseException(javax.activation.MimeTypeParseException) ParseException(org.locationtech.jts.io.ParseException) InsertResultType(net.opengis.cat.csw.v_2_0_2.InsertResultType)

Aggregations

Test (org.junit.Test)23 JAXBElement (javax.xml.bind.JAXBElement)22 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)20 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)18 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)17 QName (javax.xml.namespace.QName)13 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)13 XStream (com.thoughtworks.xstream.XStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)12 Marshaller (javax.xml.bind.Marshaller)12 GetRecordsResponseType (net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType)12 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)12 ArrayList (java.util.ArrayList)11 JAXBContext (javax.xml.bind.JAXBContext)11 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)11 MarshallingContext (com.thoughtworks.xstream.converters.MarshallingContext)10 HierarchicalStreamWriter (com.thoughtworks.xstream.io.HierarchicalStreamWriter)10 StringWriter (java.io.StringWriter)10 BigInteger (java.math.BigInteger)10 ObjectFactory (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory)8