Commit 65ec1190e923d6e997a4f7cac621d2d03b5ec3af

Authored by Ricardo Pereira
1 parent cb919e7e3f
Exists in API_v3.0

Workaround to ORCID API issue, it doesn't accept month "7", padding

necessary "07".
src/main/java/org/um/dsi/gavea/orcid/model/common/adapters/DayAdapter.java
... ... @@ -0,0 +1,17 @@
  1 +package org.um.dsi.gavea.orcid.model.common.adapters;
  2 +
  3 +import javax.xml.bind.annotation.adapters.XmlAdapter;
  4 +
  5 +public class DayAdapter extends XmlAdapter<String, Integer> {
  6 +
  7 + @Override
  8 + public Integer unmarshal(String v) throws Exception {
  9 + return Integer.valueOf(v);
  10 + }
  11 +
  12 + @Override
  13 + public String marshal(Integer v) throws Exception {
  14 + return String.format("%02d", v);
  15 + }
  16 +
  17 +}
... ...
src/main/java/org/um/dsi/gavea/orcid/model/common/adapters/MonthAdapter.java
... ... @@ -0,0 +1,17 @@
  1 +package org.um.dsi.gavea.orcid.model.common.adapters;
  2 +
  3 +import javax.xml.bind.annotation.adapters.XmlAdapter;
  4 +
  5 +public class MonthAdapter extends XmlAdapter<String, Integer> {
  6 +
  7 + @Override
  8 + public Integer unmarshal(String v) throws Exception {
  9 + return Integer.valueOf(v);
  10 + }
  11 +
  12 + @Override
  13 + public String marshal(Integer v) throws Exception {
  14 + return String.format("%02d", v);
  15 + }
  16 +
  17 +}
... ...
src/main/resources/binding/orcid-3.0.xjb
... ... @@ -9,12 +9,12 @@
9 9 <jaxb:bindings schemaLocation="../xsd/record_3.0/activities-3.0.xsd" node="/xs:schema">
10 10 <jaxb:globalBindings>
11 11 <jaxb:serializable uid="1" />
12   -<!-- <xjc:javaType name="java.lang.String" -->
13   -<!-- xmlType="common:month" -->
14   -<!-- adapter="org.um.dsi.gavea.orcid.model.common.adapters.MonthAdapter" /> -->
15   -<!-- <xjc:javaType name="java.lang.String" -->
16   -<!-- xmlType="common:day" -->
17   -<!-- adapter="org.um.dsi.gavea.orcid.model.common.adapters.DayAdapter" /> -->
  12 + <xjc:javaType name="java.lang.Integer"
  13 + xmlType="common:month"
  14 + adapter="org.um.dsi.gavea.orcid.model.common.adapters.MonthAdapter" />
  15 + <xjc:javaType name="java.lang.Integer"
  16 + xmlType="common:day"
  17 + adapter="org.um.dsi.gavea.orcid.model.common.adapters.DayAdapter" />
18 18 <xjc:javaType name="org.um.dsi.gavea.orcid.model.common.Relationship"
19 19 xmlType="common:relationship-type"
20 20 adapter="org.um.dsi.gavea.orcid.model.common.adapters.RelationshipAdapter" />
... ...