List of usage examples for javax.xml.bind JAXBElement JAXBElement
public JAXBElement(QName name, Class<T> declaredType, T value)
From source file:org.openhie.openempi.openpixpdq.v3.util.Utilities.java
public static MCCIMT000200UV01Receiver generateMCCIMT00200UV01Receiver(MCCIMT000300UV01Sender sender) { MCCIMT000200UV01Receiver receiver = new MCCIMT000200UV01Receiver(); II oid = null;//from w w w. j a v a 2 s. c o m receiver.setTypeCode(CommunicationFunctionType.RCV); if (sender.getDevice() != null && sender.getDevice().getAsAgent() != null && sender.getDevice().getAsAgent().getValue() != null && sender.getDevice().getAsAgent().getValue().getRepresentedOrganization() != null && sender.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue() != null && isNotNullish( sender.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue().getId()) && sender.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue().getId() .get(0) != null && isNotNullish(sender.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue() .getId().get(0).getRoot())) { oid = sender.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue().getId().get(0); } String senderDeviceIdRoot = "1.2.345.678.999"; if (sender.getDevice() != null && sender.getDevice().getId() != null && sender.getDevice().getId().size() > 0 && sender.getDevice().getId().get(0) != null && sender.getDevice().getId().get(0).getRoot() != null) { senderDeviceIdRoot = sender.getDevice().getId().get(0).getRoot(); } MCCIMT000200UV01Device receiverDevice = new MCCIMT000200UV01Device(); receiverDevice.setClassCode(EntityClassDevice.DEV); receiverDevice.setDeterminerCode(ConversionConstants.ENTITY_DETERMINER_CODE_INSTANCE); log.debug("Setting receiver application to " + senderDeviceIdRoot); receiverDevice.getId().add(generateHl7Id(senderDeviceIdRoot, null)); MCCIMT000200UV01Agent agent = new MCCIMT000200UV01Agent(); MCCIMT000200UV01Organization org = new MCCIMT000200UV01Organization(); org.setClassCode(ConversionConstants.ENTITY_CLASS_CODE_ORG); org.setDeterminerCode(ConversionConstants.ENTITY_DETERMINER_CODE_INSTANCE); org.getId().add(oid); javax.xml.namespace.QName xmlqnameorg = new javax.xml.namespace.QName("urn:hl7-org:v3", "representedOrganization"); JAXBElement<MCCIMT000200UV01Organization> orgElem = new JAXBElement<MCCIMT000200UV01Organization>( xmlqnameorg, MCCIMT000200UV01Organization.class, org); agent.setRepresentedOrganization(orgElem); agent.getClassCode().add(ConversionConstants.ROLE_CLASS_AGENT); javax.xml.namespace.QName xmlqnameagent = new javax.xml.namespace.QName("urn:hl7-org:v3", "asAgent"); JAXBElement<MCCIMT000200UV01Agent> agentElem = new JAXBElement<MCCIMT000200UV01Agent>(xmlqnameagent, MCCIMT000200UV01Agent.class, agent); receiverDevice.setAsAgent(agentElem); receiver.setDevice(receiverDevice); return receiver; }
From source file:org.openhie.openempi.openpixpdq.v3.util.Utilities.java
public static MCCIMT000300UV01Sender generateMCCIMT00300UV01SenderByMCCIMT000300UV01Receiver( List<MCCIMT000300UV01Receiver> receivers) { MCCIMT000300UV01Sender sender = new MCCIMT000300UV01Sender(); if (receivers == null || receivers.size() == 0 || receivers.get(0) == null) { log.error("Unable to generate message since receiver entry is missing: " + receivers); return sender; }//from w w w . java 2s. c om MCCIMT000300UV01Receiver receiver = receivers.get(0); sender.setTypeCode(CommunicationFunctionType.SND); MCCIMT000300UV01Device device = new MCCIMT000300UV01Device(); device.setDeterminerCode("INSTANCE"); II oid = null; if (receiver.getDevice() != null && receiver.getDevice().getAsAgent() != null && receiver.getDevice().getAsAgent().getValue() != null && receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization() != null && receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue() != null && isNotNullish(receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue() .getId()) && receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue().getId() .get(0) != null) { oid = receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue().getId() .get(0); } MCCIMT000300UV01Device senderDevice = new MCCIMT000300UV01Device(); senderDevice.setClassCode(EntityClassDevice.DEV); senderDevice.setDeterminerCode(ConversionConstants.ENTITY_DETERMINER_CODE_INSTANCE); String receiverDeviceIdRoot = "1.2.345.678.999"; if (receiver.getDevice() != null && receiver.getDevice().getId() != null && receiver.getDevice().getId().size() > 0 && receiver.getDevice().getId().get(0) != null && receiver.getDevice().getId().get(0).getRoot() != null) { receiverDeviceIdRoot = receiver.getDevice().getId().get(0).getRoot(); } log.debug("Setting sender OID to " + receiverDeviceIdRoot); senderDevice.getId().add(generateHl7Id(receiverDeviceIdRoot, null)); MCCIMT000300UV01Agent agent = new MCCIMT000300UV01Agent(); MCCIMT000300UV01Organization org = new MCCIMT000300UV01Organization(); org.setClassCode(ConversionConstants.ENTITY_CLASS_CODE_ORG); org.setDeterminerCode(ConversionConstants.ENTITY_DETERMINER_CODE_INSTANCE); org.getId().add(oid); javax.xml.namespace.QName xmlqnameorg = new javax.xml.namespace.QName("urn:hl7-org:v3", "representedOrganization"); JAXBElement<MCCIMT000300UV01Organization> orgElem = new JAXBElement<MCCIMT000300UV01Organization>( xmlqnameorg, MCCIMT000300UV01Organization.class, org); agent.setRepresentedOrganization(orgElem); agent.getClassCode().add(ConversionConstants.CLASS_CODE_AGENT); javax.xml.namespace.QName xmlqnameagent = new javax.xml.namespace.QName("urn:hl7-org:v3", "asAgent"); JAXBElement<MCCIMT000300UV01Agent> agentElem = new JAXBElement<MCCIMT000300UV01Agent>(xmlqnameagent, MCCIMT000300UV01Agent.class, agent); senderDevice.setAsAgent(agentElem); sender.setDevice(senderDevice); return sender; }
From source file:org.openhie.openempi.openpixpdq.v3.util.Utilities.java
public static MCCIMT000200UV01Sender generateMCCIMT00200UV01Sender(List<MCCIMT000300UV01Receiver> receivers) { MCCIMT000200UV01Sender sender = new MCCIMT000200UV01Sender(); if (receivers == null || receivers.size() == 0 || receivers.get(0) == null) { log.error("Unable to generate message since receiver entry is missing: " + receivers); return sender; }/* w w w.j av a 2 s . c om*/ MCCIMT000300UV01Receiver receiver = receivers.get(0); sender.setTypeCode(CommunicationFunctionType.SND); MCCIMT000300UV01Device device = new MCCIMT000300UV01Device(); device.setDeterminerCode("INSTANCE"); II oid = null; if (receiver.getDevice() != null && receiver.getDevice().getAsAgent() != null && receiver.getDevice().getAsAgent().getValue() != null && receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization() != null && receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue() != null && isNotNullish(receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue() .getId()) && receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue().getId() .get(0) != null) { oid = receiver.getDevice().getAsAgent().getValue().getRepresentedOrganization().getValue().getId() .get(0); } MCCIMT000200UV01Device senderDevice = new MCCIMT000200UV01Device(); senderDevice.setClassCode(EntityClassDevice.DEV); senderDevice.setDeterminerCode(ConversionConstants.ENTITY_DETERMINER_CODE_INSTANCE); String receiverDeviceIdRoot = "1.2.345.678.999"; if (receiver.getDevice() != null && receiver.getDevice().getId() != null && receiver.getDevice().getId().size() > 0 && receiver.getDevice().getId().get(0) != null && receiver.getDevice().getId().get(0).getRoot() != null) { receiverDeviceIdRoot = receiver.getDevice().getId().get(0).getRoot(); } log.debug("Setting sender OID to " + receiverDeviceIdRoot); senderDevice.getId().add(generateHl7Id(receiverDeviceIdRoot, null)); MCCIMT000200UV01Agent agent = new MCCIMT000200UV01Agent(); MCCIMT000200UV01Organization org = new MCCIMT000200UV01Organization(); org.setClassCode(ConversionConstants.ENTITY_CLASS_CODE_ORG); org.setDeterminerCode(ConversionConstants.ENTITY_DETERMINER_CODE_INSTANCE); org.getId().add(oid); javax.xml.namespace.QName xmlqnameorg = new javax.xml.namespace.QName("urn:hl7-org:v3", "representedOrganization"); JAXBElement<MCCIMT000200UV01Organization> orgElem = new JAXBElement<MCCIMT000200UV01Organization>( xmlqnameorg, MCCIMT000200UV01Organization.class, org); agent.setRepresentedOrganization(orgElem); agent.getClassCode().add(ConversionConstants.CLASS_CODE_AGENT); javax.xml.namespace.QName xmlqnameagent = new javax.xml.namespace.QName("urn:hl7-org:v3", "asAgent"); JAXBElement<MCCIMT000200UV01Agent> agentElem = new JAXBElement<MCCIMT000200UV01Agent>(xmlqnameagent, MCCIMT000200UV01Agent.class, agent); senderDevice.setAsAgent(agentElem); sender.setDevice(senderDevice); return sender; }
From source file:org.osate.atsv.integration.EngineConfigModel.ExplorationEngineModel.java
public void renderConfigurator() throws JAXBException, UnsatisfiableConstraint, ConfiguratorRepresentationException, UnsupportedFeatureException { if (cm.isEmpty()) { configurator = ""; return;//from ww w . ja v a 2 s . c om } JAXBContext context = JAXBContext.newInstance(ConfiguratorsModel.class, SimpleConfiguratorModel.class, ImpliesConfiguratorModel.class, SetRestrictionConfiguratorModel.class); ConfiguratorModelAdapter configuratorAdapter = new ConfiguratorModelAdapter(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); Marshaller marshal = context.createMarshaller(); marshal.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); marshal.setProperty(Marshaller.JAXB_FRAGMENT, true); marshal.setAdapter(configuratorAdapter); JAXBElement<ConfiguratorsModel> configuratorXML = new JAXBElement<ConfiguratorsModel>( new QName("Configurator"), ConfiguratorsModel.class, cm); marshal.marshal(configuratorXML, stream); configurator = stream.toString(); }
From source file:org.osate.atsv.integration.preparser.EngineConfigGenerator.java
public EngineConfigGenerator() { try {//from w w w . ja va2 s. co m JAXBContext context = JAXBContext.newInstance(ExplorationEngineModel.class, InputTokenModel.class, VariableModel.class); InputTokenAdapter inputAdapter = new InputTokenAdapter(); VariableModelAdapter variableAdapter = new VariableModelAdapter(); marshal = context.createMarshaller(); // ATSV actually cannot parse formatted output :( marshal.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); marshal.setAdapter(inputAdapter); marshal.setAdapter(variableAdapter); eem = new ExplorationEngineModel(); cfg = new JAXBElement<ExplorationEngineModel>(new QName("ExplorationEngineModel"), ExplorationEngineModel.class, eem); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:org.overlord.sramp.server.atom.workspaces.AbstractWorkspaceTest.java
/** * Marshalls the app service to XML./* w w w. ja va2 s. co m*/ * @param appService */ public static String marshall(AppService appService) throws Exception { JAXBContext jaxbContext = JAXBContext.newInstance(AppService.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); //$NON-NLS-1$ StringWriter writer = new StringWriter(); JAXBElement<AppService> element = new JAXBElement<AppService>(new QName("", "app:service", "app"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ AppService.class, appService); marshaller.marshal(element, writer); return writer.toString(); }
From source file:org.socraticgrid.taskmanager.TaskManagerImpl.java
/** * Creates a lab order./* w w w. j a v a2s. c om*/ * * @param createLabOrderRequest * @return */ public org.socraticgrid.common.task.TaskManagerResponseType createLabOrder( org.socraticgrid.common.task.CreateLabOrderRequestType request) { TaskManagerResponseType response = new TaskManagerResponseType(); try { //Serialize lab order JAXBContext context = JAXBContext.newInstance(LabOrderFactType.class); Marshaller marshaller = context.createMarshaller(); StringWriter sw = new StringWriter(); marshaller.marshal( new JAXBElement(new QName("uri", "local"), LabOrderFactType.class, request.getLabOrderFact()), sw); //Create message LabOrderMessage message = new LabOrderMessage(); message.setTaskID(request.getTaskID()); message.setLabOrder(sw.toString()); //Send message QueueResponse result = queueMessage(message); //Set response info response.setTicket(result.ticket); response.setDetail(result.detail); } catch (Exception e) { String msg = e.getMessage(); if ((msg == null) || msg.isEmpty()) { msg = "Error handling lab order message."; } log.error("Error handling lab order message.", e); response.setTicket(TASK_MESSAGE_FAILURE_ID); response.setDetail(msg); } return response; }
From source file:org.socraticgrid.taskmanager.TaskManagerImpl.java
/** * Schedule appointment.//from w w w . j av a 2 s . c o m * * @param scheduleApptRequest * @return */ public org.socraticgrid.common.task.TaskManagerResponseType scheduleAppt( org.socraticgrid.common.task.ScheduleApptRequestType request) { TaskManagerResponseType response = new TaskManagerResponseType(); try { //Serialize lab order JAXBContext context = JAXBContext.newInstance(SlotFactType.class); Marshaller marshaller = context.createMarshaller(); StringWriter sw = new StringWriter(); marshaller.marshal( new JAXBElement(new QName("uri", "local"), SlotFactType.class, request.getSlotRequest()), sw); //Create message SlotRequestMessage message = new SlotRequestMessage(); message.setTaskID(request.getTaskID()); message.setSlotRequest(sw.toString()); //Send message QueueResponse result = queueMessage(message); //Set response info response.setTicket(result.ticket); response.setDetail(result.detail); } catch (Exception e) { String msg = e.getMessage(); if ((msg == null) || msg.isEmpty()) { msg = "Error handling schedule appointment message."; } log.error("Error handling schedule appointment message.", e); response.setTicket(TASK_MESSAGE_FAILURE_ID); response.setDetail(msg); } return response; }
From source file:org.springside.modules.utils.encode.JaxbBinder.java
/** * Java Object->Xml, ?Root ElementCollection. *//*from ww w . jav a2 s . c om*/ @SuppressWarnings("rawtypes") public String toXml(Collection root, String rootName, String encoding) { try { CollectionWrapper wrapper = new CollectionWrapper(); wrapper.collection = root; JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName), CollectionWrapper.class, wrapper); StringWriter writer = new StringWriter(); createMarshaller(encoding).marshal(wrapperElement, writer); return writer.toString(); } catch (JAXBException e) { throw new RuntimeException(e); } }
From source file:org.talend.components.marketo.runtime.client.MarketoSOAPClient.java
public LeadRecord convertToLeadRecord(IndexedRecord record, Map<String, String> mappings) throws MarketoException { // first, check if a mandatory field is in the schema Boolean ok = Boolean.FALSE; for (Entry<String, String> e : mappings.entrySet()) { ok |= (e.getKey().equals(FIELD_ID) || e.getKey().equals(FIELD_EMAIL) || e.getKey().equals(FIELD_FOREIGN_SYS_PERSON_ID) || e.getValue().equals(FIELD_ID) || e.getValue().equals(FIELD_EMAIL) || e.getValue().equals(FIELD_FOREIGN_SYS_PERSON_ID)) && record.get(record.getSchema().getField(e.getKey()).pos()) != null; }//from w w w . jav a2s .c om if (!ok) { MarketoException err = new MarketoException("SOAP", "syncLead error: Missing mandatory field for operation."); LOG.error(err.toString()); throw err; } // LeadRecord lead = new LeadRecord(); ArrayOfAttribute aoa = new ArrayOfAttribute(); for (Field f : record.getSchema().getFields()) { // find matching marketo column name String col = mappings.get(f.name()); if (col.equals(FIELD_ID)) { final Integer id = (Integer) record.get(f.pos()); if (id != null) { lead.setId(objectFactory.createLeadRecordId(id)); } } else if (col.equals(FIELD_EMAIL)) { final String email = (String) record.get(f.pos()); if (email != null) { lead.setEmail(objectFactory.createLeadRecordEmail(email)); } } else if (col.equals(FIELD_FOREIGN_SYS_PERSON_ID)) { final String fspid = (String) record.get(f.pos()); if (fspid != null) { lead.setForeignSysPersonId(objectFactory.createLeadRecordForeignSysPersonId(fspid)); } } else if (col.equals(FIELD_FOREIGN_SYS_TYPE)) { final String fst = (String) record.get(f.pos()); if (fst != null) { lead.setForeignSysType( objectFactory.createLeadRecordForeignSysType(ForeignSysType.valueOf(fst))); } } else { // skip status & error fields if (FIELD_STATUS.equals(col) || FIELD_ERROR_MSG.equals(col)) { continue; } Attribute attr = new Attribute(); Object value = record.get(f.pos()); attr.setAttrName(col); if (MarketoClientUtils.isDateTypeField(f) && value != null) { attr.setAttrValue( MarketoClientUtils.formatLongToDateString(Long.valueOf(String.valueOf(value)))); } else { attr.setAttrValue(String.valueOf(value)); } aoa.getAttributes().add(attr); } } QName qname = new QName("http://www.marketo.com/mktows/", "leadAttributeList"); JAXBElement<ArrayOfAttribute> attrList = new JAXBElement(qname, ArrayOfAttribute.class, aoa); lead.setLeadAttributeList(attrList); return lead; }