List of usage examples for javax.xml.bind JAXBException printStackTrace
public void printStackTrace()
From source file:labr_client.xml.ObjToXML.java
public static void jaxbObjectToXML(LabrRequest request, HashMap<String, String> patient) { try {/*from w w w . j a v a 2 s . co m*/ JAXBContext context = JAXBContext.newInstance(LabrRequest.class); Marshaller m = context.createMarshaller(); //for pretty-print XML in JAXB m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); //----------PATIENT---------------------------- request.patient.name.setValue("De Mey"); request.patient.name.setX(20); request.patient.name.setY(50); request.patient.firstName.setValue("Matthias"); request.patient.firstName.setX(150); request.patient.firstName.setY(50); request.patient.birthDate.setValue("07/06/1990"); request.patient.birthDate.setX(20); request.patient.birthDate.setY(80); request.patient.gender.setValue("M"); request.patient.gender.setX(150); request.patient.gender.setY(80); request.patient.straatAndNumber.setValue("Hemelbeekstraat 16"); request.patient.straatAndNumber.setX(20); request.patient.straatAndNumber.setY(110); request.patient.zip.setValue("8000"); request.patient.zip.setX(20); request.patient.zip.setY(140); request.patient.city.setValue("Brugge"); request.patient.city.setX(120); request.patient.city.setY(140); request.patient.country.setValue("Belgie"); request.patient.country.setX(20); request.patient.country.setY(170); request.patient.nationalNumber.setValue("001-12345-223"); request.patient.nationalNumber.setX(120); request.patient.nationalNumber.setY(210); //----------ATTRIBUTEN------------------------- request.attributes.setAge(26); //----------LABELS----------------------------- LabrXMLLabel l = new LabrXMLLabel(); l.setColor("#110000"); l.setSize(12); l.setId("1"); l.setValue("Hematologie"); request.labels.getLabel().add(l); //---------KNOPPEN----------------------------- request.buttons.save.setX(300); request.buttons.save.setY(100); request.buttons.save.setColor(-65536); request.buttons.save.setWidth(100); request.buttons.save.setValue("Save"); //----------AANVRAGEN-------------------------- LabrXMLRequest r = new LabrXMLRequest(); r.setComment("Dit is commentaar"); r.setLoinc("Kalium"); request.requests.getRequest().add(r); r.setLoinc("Natrium"); request.requests.getRequest().add(r); //----------AANVRAGEN-------------------------- // Write to System.out for debugging // m.marshal(emp, System.out); // Write to File m.marshal(request, new File("C:\\Users\\labbl\\Documents\\test.xml")); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:labr_client.xml.ObjToXML.java
public static void saveProfile(Component[] comps, String profile) { try {/*w w w . jav a2 s . c o m*/ if (comps != null) { JAXBContext context = JAXBContext.newInstance(LabrRequest.class); Marshaller m = context.createMarshaller(); //for pretty-print XML in JAXB m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); LabrRequest request = new LabrRequest(); for (Component comp : comps) { if (comp.getName() != null) { if (comp.getName().equals("name")) { request.patient.name.setValue(((JTextField) comp).getText()); request.patient.name.setX(comp.getX()); request.patient.name.setY(comp.getY()); request.patient.name.setWidth(comp.getWidth()); } else if (comp.getName().equals("firstName")) { request.patient.firstName.setValue(((JTextField) comp).getText()); request.patient.firstName.setX(comp.getX()); request.patient.firstName.setY(comp.getY()); request.patient.firstName.setWidth(comp.getWidth()); } else if (comp.getName().equals("birthDate")) { request.patient.birthDate.setValue(((JFormattedTextField) comp).getText()); request.patient.birthDate.setX(comp.getX()); request.patient.birthDate.setY(comp.getY()); request.patient.birthDate.setWidth(comp.getWidth()); } else if (comp.getName().equals("gender")) { request.patient.gender.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.gender.setX(comp.getX()); request.patient.gender.setY(comp.getY()); } else if (comp.getName().equals("straatAndNumber")) { request.patient.straatAndNumber.setValue(((JTextField) comp).getText()); request.patient.straatAndNumber.setX(comp.getX()); request.patient.straatAndNumber.setY(comp.getY()); request.patient.straatAndNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("zip")) { request.patient.zip.setValue(((JTextField) comp).getText()); request.patient.zip.setX(comp.getX()); request.patient.zip.setY(comp.getY()); request.patient.zip.setWidth(comp.getWidth()); } else if (comp.getName().equals("city")) { request.patient.city.setValue(((JTextField) comp).getText()); request.patient.city.setX(comp.getX()); request.patient.city.setY(comp.getY()); request.patient.city.setWidth(comp.getWidth()); } else if (comp.getName().equals("country")) { request.patient.country.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.country.setX(comp.getX()); request.patient.country.setY(comp.getY()); } else if (comp.getName().equals("nationalNumber")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("Save")) { JButton jbut = (JButton) comp; ImageIcon icon = (ImageIcon) jbut.getIcon(); request.buttons.save.setX(comp.getX()); request.buttons.save.setY(comp.getY()); request.buttons.save.setValue("Save"); if (icon != null) { request.buttons.save.setIcon(icon.getDescription()); } } else if (comp.getName().equals("Search")) { } else if (comp.getName().equals("saveAndSend")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("print")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else { Class<? extends Component> c = comp.getClass(); if (c.getSimpleName().equals("JLabel")) { JLabel lbl = (JLabel) comp; LabrXMLLabel l = new LabrXMLLabel(); l.setColor(String.valueOf(lbl.getForeground().getRGB())); l.setSize(lbl.getFont().getSize()); l.setId(lbl.getName()); l.setValue(lbl.getText()); l.setX(lbl.getX()); l.setY(lbl.getY()); request.labels.getLabel().add(l); } ; if (c.getSimpleName().equals("JCheckBox")) { JCheckBox chbx = (JCheckBox) comp; LabrXMLRequest req = new LabrXMLRequest(); req.setX(chbx.getX()); req.setY(chbx.getY()); req.setLoinc(chbx.getName()); req.setValue(chbx.getText()); req.setSelected(chbx.isSelected()); request.requests.getRequest().add(req); } ; if (c.getSimpleName().equals("JTextBox")) { } ; } } } m.marshal(request, new File(PublicVars.getUserData()[9] + "\\" + profile + ".xml")); } } catch (JAXBException e) { e.printStackTrace(); } }
From source file:labr_client.xml.ObjToXML.java
public static LabrRequest saveLabrRequest(Component[] comps) { try {/* w w w. j a v a 2s . c o m*/ if (comps != null) { JAXBContext context = JAXBContext.newInstance(LabrRequest.class); Marshaller m = context.createMarshaller(); //for pretty-print XML in JAXB m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); LabrRequest request = new LabrRequest(); for (Component comp : comps) { if (comp.getName() != null) { if (comp.getName().equals("name")) { request.patient.name.setValue(((JTextField) comp).getText()); request.patient.name.setX(comp.getX()); request.patient.name.setY(comp.getY()); request.patient.name.setWidth(comp.getWidth()); } else if (comp.getName().equals("firstName")) { request.patient.firstName.setValue(((JTextField) comp).getText()); request.patient.firstName.setX(comp.getX()); request.patient.firstName.setY(comp.getY()); request.patient.firstName.setWidth(comp.getWidth()); } else if (comp.getName().equals("birthDate")) { request.patient.birthDate.setValue(((JFormattedTextField) comp).getText()); request.patient.birthDate.setX(comp.getX()); request.patient.birthDate.setY(comp.getY()); request.patient.birthDate.setWidth(comp.getWidth()); } else if (comp.getName().equals("gender")) { request.patient.gender.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.gender.setX(comp.getX()); request.patient.gender.setY(comp.getY()); } else if (comp.getName().equals("straatAndNumber")) { request.patient.straatAndNumber.setValue(((JTextField) comp).getText()); request.patient.straatAndNumber.setX(comp.getX()); request.patient.straatAndNumber.setY(comp.getY()); request.patient.straatAndNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("zip")) { request.patient.zip.setValue(((JTextField) comp).getText()); request.patient.zip.setX(comp.getX()); request.patient.zip.setY(comp.getY()); request.patient.zip.setWidth(comp.getWidth()); } else if (comp.getName().equals("city")) { request.patient.city.setValue(((JTextField) comp).getText()); request.patient.city.setX(comp.getX()); request.patient.city.setY(comp.getY()); request.patient.city.setWidth(comp.getWidth()); } else if (comp.getName().equals("country")) { request.patient.country.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.country.setX(comp.getX()); request.patient.country.setY(comp.getY()); } else if (comp.getName().equals("nationalNumber")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("Save")) { JButton jbut = (JButton) comp; ImageIcon icon = (ImageIcon) jbut.getIcon(); request.buttons.save.setX(comp.getX()); request.buttons.save.setY(comp.getY()); request.buttons.save.setValue("Save"); if (icon != null) { request.buttons.save.setIcon(icon.getDescription()); } } else if (comp.getName().equals("Search")) { } else if (comp.getName().equals("saveAndSend")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("print")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else { Class<? extends Component> c = comp.getClass(); if (c.getSimpleName().equals("JLabel")) { JLabel lbl = (JLabel) comp; LabrXMLLabel l = new LabrXMLLabel(); l.setColor(String.valueOf(lbl.getForeground().getRGB())); l.setSize(lbl.getFont().getSize()); l.setId(lbl.getName()); l.setValue(lbl.getText()); l.setX(lbl.getX()); l.setY(lbl.getY()); request.labels.getLabel().add(l); } ; if (c.getSimpleName().equals("JCheckBox")) { JCheckBox chbx = (JCheckBox) comp; LabrXMLRequest req = new LabrXMLRequest(); req.setX(chbx.getX()); req.setY(chbx.getY()); req.setLoinc(chbx.getName()); req.setValue(chbx.getText()); req.setSelected(chbx.isSelected()); request.requests.getRequest().add(req); } ; if (c.getSimpleName().equals("JTextBox")) { } ; } } } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmm"); String date = dateFormat.format(Calendar.getInstance().getTime()); request.attributes.setTitle("LABR-" + PublicVars.getUserData()[5] + "-" + date); return request; } return null; } catch (JAXBException e) { e.printStackTrace(); return null; } }
From source file:labr_client.xml.ObjToXML.java
public static void saveKmehrRequest(LabrRequest request) { String date = String.format("%1$tY%1$tm%1$td", new Date()); String time = String.format("%1$tH%1$tM%1$tS", new Date()); try {/*from www. jav a 2 s . c o m*/ KmehrMessage kmehrMessage = new KmehrMessage(); JAXBContext context = JAXBContext.newInstance(KmehrMessage.class); Marshaller m = context.createMarshaller(); //for pretty-print XML in JAXB m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); //----------HEADER-------------------------- kmehrMessage.header.id.setS("ID-KMEHR"); kmehrMessage.header.id.setSV("1.15"); kmehrMessage.header.id.setValue(request.attributes.getTitle()); kmehrMessage.header.setDate(date); kmehrMessage.header.setTime(time); kmehrMessage.header.standard.cd.setS("CD-STANDARD"); kmehrMessage.header.standard.cd.setSV("1.15"); kmehrMessage.header.standard.cd.setValue("20150901"); //----------HEADER-ZENDER------------------------- kmehrMessage.header.sender.hcparty.id.setS("ID-HCPARTY"); kmehrMessage.header.sender.hcparty.id.setSV("1.15"); kmehrMessage.header.sender.hcparty.id.setValue(request.attributes.getSenderID()); kmehrMessage.header.sender.hcparty.cd.setS("CD-HCPARTY"); kmehrMessage.header.sender.hcparty.cd.setSV("1.15"); kmehrMessage.header.sender.hcparty.cd.setValue("persphysician"); kmehrMessage.header.sender.hcparty.setFamilyname("Pieters"); kmehrMessage.header.sender.hcparty.setFirstname("Piet"); //----------HEADER-ONTVANGER(S)-------------------- Hcparty receiver = new Hcparty(); receiver.id.setS("ID-HCPARTY"); receiver.id.setSV("1.15"); receiver.id.setValue(request.attributes.receiver1ID); receiver.cd.setS("CD-HCPARTY"); receiver.cd.setSV("1.15"); receiver.cd.setValue("persphysician"); receiver.setFamilyname("Pieters"); receiver.setFirstname("Piet"); kmehrMessage.header.receiver.getHcparty().add(receiver); //----------FOLDER-PATIENT------------------------- kmehrMessage.folder.id.setS("ID-HCPARTY"); kmehrMessage.folder.id.setSV("1.15"); kmehrMessage.folder.id.setValue(request.patient.nationalNumber.getValue()); kmehrMessage.folder.patient.setFamilyname(request.patient.name.getValue()); kmehrMessage.folder.patient.setFirstname(request.patient.firstName.getValue()); kmehrMessage.folder.patient.birthdate.setDate(request.patient.birthDate.getValue()); kmehrMessage.folder.patient.sex.cd.setS("CD-SEX"); kmehrMessage.folder.patient.sex.cd.setSV("1.15"); kmehrMessage.folder.patient.sex.cd.setValue("M"); kmehrMessage.folder.patient.address.cd.setS("CD-ADDRESS"); kmehrMessage.folder.patient.address.cd.setSV("1.15"); kmehrMessage.folder.patient.address.country.cd.setS("CD-COUNTRY"); kmehrMessage.folder.patient.address.country.cd.setSV("1.15"); kmehrMessage.folder.patient.address.country.cd.setValue(request.patient.country.getValue()); kmehrMessage.folder.patient.address.setCity(request.patient.city.getValue()); kmehrMessage.folder.patient.address.setStreetandnumber(request.patient.straatAndNumber.getValue()); kmehrMessage.folder.patient.address.setZip(request.patient.zip.getValue()); Transaction t = new Transaction(); t.id.setS("ID-KMEHR"); t.id.setSV("1.15"); t.id.setValue("1"); t.cd.setS("CD-TRANSACTION"); t.cd.setSV("1.15"); t.cd.setValue("request"); t.setDate(date); t.setTime(time); t.author.hcparty.id.setS("ID-HCPARTY"); t.author.hcparty.id.setSV("1.15"); t.author.hcparty.id.setValue(request.attributes.getSenderID()); t.author.hcparty.cd.setS("CD-HCPARTY"); t.author.hcparty.cd.setSV("1.15"); t.author.hcparty.cd.setValue("persphysician"); t.author.hcparty.setFamilyname("Pieters"); t.author.hcparty.setFirstname("Piet"); Item i = new Item(); i.id.setS("ID-KMEHR"); i.id.setSV("1.15"); i.id.setValue("1"); i.cd.setS("CD-ITEM"); i.cd.setSV("1.15"); i.cd.setValue("lab"); List<LabrXMLRequest> requests = request.requests.getRequest(); for (LabrXMLRequest req : requests) { if (req.isSelected() & req.getLoinc() != null) { Cd cd = new Cd(); cd.setS("CD-LAB"); cd.setSV("1.15"); cd.setValue(req.getLoinc()); i.content.getCd().add(cd); } } t.getItem().add(i); kmehrMessage.folder.getTransaction().add(t); kmehrMessage.setXmlns("http://www.ehealth.fgov.be/standards/kmehr/schema/v1"); //START------ZOEK DE PATIENT OP EN BEWAAR AANVRAAG IN DATABASE------------------------- File KmehrRequest = new File("data/tmp/" + date + time + ".xml"); m.marshal(kmehrMessage, KmehrRequest); List<String[]> patientID = PublicVars.getQueries().selectPatient(request.patient.firstName.getValue(), request.patient.name.getValue(), request.patient.birthDate.getValue()); if (patientID.size() == 0) { PublicVars.getQueries().insertPatient(request); patientID = PublicVars.getQueries().selectPatient(request.patient.firstName.getValue(), request.patient.name.getValue(), request.patient.birthDate.getValue()); PublicVars.getQueries().insertLabRequest(marshallRequest(request), FileUtils.readFileToString(KmehrRequest), Integer.parseInt(patientID.get(0)[0]), Integer.parseInt(PublicVars.getUserData()[1]), kmehrMessage.header.id.getValue()); } else { PublicVars.getQueries().insertLabRequest(marshallRequest(request), FileUtils.readFileToString(KmehrRequest), Integer.parseInt(patientID.get(0)[0]), Integer.parseInt(PublicVars.getUserData()[1]), kmehrMessage.header.id.getValue()); } //EIND--------------------------------------------------------------------------------- } catch (JAXBException e) { e.printStackTrace(); } catch (IOException ex) { Logger.getLogger(ObjToXML.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.konghao.student.ws.interceptor.LicenseInfoOutHandler.java
public void handleMessage(SoapMessage message) throws Fault { try {/*from www. j a v a 2s . c o m*/ List<Header> hs = message.getHeaders(); QName qn = new QName("http://ws.student.konghao.org", "licenseInfo", "ns"); DataBinding db = new JAXBDataBinding(String.class); Header h = new Header(qn, LoginUserContext.getLoginUser(), db); hs.add(h); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:org.wallerlab.yoink.molecular.data.AbstractJaxbReader.java
protected JAXBElement<Cml> init(Object jaxbObject) { JAXBElement<Cml> marshalled = null; try {/* w w w.ja v a 2 s .co m*/ jaxbContext = JAXBContext.newInstance(Class.forName(jaxbObject.getClass().getName())); jaxbUnmarshaller = jaxbContext.createUnmarshaller(); marshalled = unmarshal(jaxbObject); } catch (JAXBException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return marshalled; }
From source file:org.wallerlab.yoink.molecular.data.AbstractJaxbWriter.java
/** * use JAXB writer to write out an instance to a file. * //w w w .ja v a 2 s . c o m * @param nameOfFile * - the name of out put file * @param jaxbObject * - the instance will be written into a file */ protected void marshall() { try { jaxbContext = JAXBContext.newInstance(Class.forName(jaxbObject.getClass().getName())); jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshal(); } catch (JAXBException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
From source file:com.googlecode.sardine.Factory.java
/** */ public Factory() { try {//from w w w .j a va2 s. c o m if (this.context == null) this.context = JAXBContext.newInstance(ObjectFactory.class); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:fr.fastconnect.factory.tibco.bw.codereview.CodeReviewInitialize.java
private ReviewResult loadReviewResult(File f) { try {//from ww w.ja v a 2 s. c o m JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Object o = jaxbUnmarshaller.unmarshal(f); return (ReviewResult) o; } catch (JAXBException e) { e.printStackTrace(); } return null; }
From source file:eu.openminted.toolkit.elsevier.retriever.JaxbMarshalingTest.java
@Before public void initContext() { try {/*from w ww. j av a 2 s.c om*/ jc = JAXBContext.newInstance(FullTextRetrievalResponse.class); } catch (JAXBException ex) { ex.printStackTrace(); } }