EDIT Project Management: Issueshttps://dev.e-taxonomy.eu/redmine/https://dev.e-taxonomy.eu/redmine/redmine/favicon.ico?14691914852019-07-25T12:50:37ZEDIT Project Management
Redmine EDIT - bug #8407 (New): Fix "FeatureTest"https://dev.e-taxonomy.eu/redmine/issues/84072019-07-25T12:50:37ZAndreas Müller
<p>Fix "FeatureTest" (or may now TermTreeTest) which checks the correkt behavior for exporting (and importing?) TermTrees(?) has been ignored since FeatureTree/Node has been moved to term package. Probably it was further destroyed by renaming FeatureTree/Node to TermTree/Node<br>
It needs to be fixed and unignored.</p>
EDIT - task #2637 (New): Check JodaTime and JAXBhttps://dev.e-taxonomy.eu/redmine/issues/26372011-09-29T10:19:24ZAndreas Müller
<p>Check if JAXB works correctly with JodaTime.</p>
<p>The following came with the JodaTime mailing list:</p>
<p>I was converting some code to use a DateTime instead of a Date and a property has an @XmlElement annotation. Having apparently stumbled on to a web service, some Googling eventually found me <a href="http://blog.bdoughan.com/2011/05/jaxb-and-joda-time-dates-and-times.html">http://blog.bdoughan.com/2011/05/jaxb-and-joda-time-dates-and-times.html</a></p>
<p>Is that kind of thing presently the recommended approach? Is there some semi-standard library we should be using or should I just roll my own marshaller?</p>
<p>Mark</p>
<p>======</p>
<p>I've never used JAXB myself, nor have I heard of anyone doing an integration library, so that blog post is probably the state of the art.</p>
<p>Stephen</p>
<p>======</p>
<p>The blog post covers the basics. If you don't control the Web Service and so can't add your annotations then there's a technique where you use "xjb" to modify the generated source that you create using wsimport.</p>
<p>One issue you will typically find is that there isn't really a "standard" when it comes to webservices - every webservice seems to be ever so slightly different to each other. Date Times with or without time and time zone is often a point of different despite the the "standards".</p>
<p>---XeroCustomBindings.xjb</p>
<pre><?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
version="2.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
<!-- Using bindings
xjc -classpath
/Users/rperfect/IdeaProjects/DataZime/XeroClient/build/classes -p com.xero.domain -b XeroCustomBindings.xjb -d gen-src *.xsd
-->
<jaxb:globalBindings>
<jaxb:javaType name="org.joda.time.DateTime"
xmlType="xs:date"
parseMethod="com.datazime.connector.xero.client.DateAdapter.parseDate"
printMethod="com.datazime.connector.xero.client.DateAdapter.printDate"
/>
<jaxb:javaType name="org.joda.time.DateTime"
xmlType="xs:dateTime"
parseMethod="com.datazime.connector.xero.client.DateAdapter.parseDatetim
e"
printMethod="com.datazime.connector.xero.client.DateAdapter.printDatetim
e"
/>
<xjc:simple />
</jaxb:globalBindings>
</jaxb:bindings>
</pre><pre>package com.datazime.connector.xero.client;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
/**
*/
public class DateAdapter {
private static final DateTimeFormatter XML_DATE_FORMAT = ISODateTimeFormat.dateTimeNoMillis();
private static final DateTimeFormatter XML_DATE_TIME_FORMAT = ISODateTimeFormat.localDateOptionalTimeParser();
private static final DateTimeFormatter DATE_PATTERN = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS");
public static DateTime parseDatetime(String dateStr) {
DateTime result = XML_DATE_TIME_FORMAT.parseDateTime(dateStr);
return result;
}
public static String printDatetime(DateTime date) {
String result = DATE_PATTERN.print(date);
return result;
}
public static DateTime parseDate(String dateStr) {
DateTime result = XML_DATE_FORMAT.parseDateTime(dateStr);
return result;
}
public static String printDate(DateTime date) {
String result = DATE_PATTERN.print(date);
return result;
}
}
</pre>