Discussion:
[jira] [Created] (ISIS-1972) JAXB view model: add default XmlAdapters for Java 8 Time
Andi Huber (JIRA)
2018-07-22 12:32:00 UTC
Permalink
Andi Huber created ISIS-1972:
--------------------------------

Summary: JAXB view model: add default XmlAdapters for Java 8 Time
Key: ISIS-1972
URL: https://issues.apache.org/jira/browse/ISIS-1972
Project: Isis
Issue Type: Improvement
Components: Core
Affects Versions: 2.0.0-M1
Reporter: Andi Huber
Fix For: 2.0.0-M2


see https://stackoverflow.com/questions/36156741/marshalling-localdate-using-jaxb

sample code:


{code:java}

// DOMAIN CODE

@XmlRootElement(name = "Demo")
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
@Log
public class TemporalDemo extends DemoStub {

@PostConstruct
public void initDefaults() {

log.info("TemporalDemo::initDefaults");

javaLocalDate = LocalDate.now();
javaLocalDateTime = LocalDateTime.now();
}

@XmlJavaTypeAdapter(value = LocalDateAdapter.class)
@XmlElement @Getter @Setter private LocalDate javaLocalDate;

@XmlJavaTypeAdapter(value = LocalDateTimeAdapter.class)
@XmlElement @Getter @Setter private LocalDateTime javaLocalDateTime;

}

// COULD BE PART OF CORE

public final class JaxbAdapters {


public static final class LocalDateAdapter extends XmlAdapter<String, LocalDate>{

public LocalDate unmarshal(String v) throws Exception {
return LocalDate.parse(v);
}

public String marshal(LocalDate v) throws Exception {
return v.toString();
}

}

public static final class LocalDateTimeAdapter extends XmlAdapter<String, LocalDateTime>{

public LocalDateTime unmarshal(String v) throws Exception {
return LocalDateTime.parse(v);
}

public String marshal(LocalDateTime v) throws Exception {
return v.toString();
}

}

...

}
{code}






--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
Andi Huber (JIRA)
2018-10-09 15:22:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andi Huber reassigned ISIS-1972:
--------------------------------

Assignee: Andi Huber
Post by Andi Huber (JIRA)
JAXB view model: add default XmlAdapters for Java 8 Time
--------------------------------------------------------
Key: ISIS-1972
URL: https://issues.apache.org/jira/browse/ISIS-1972
Project: Isis
Issue Type: Improvement
Components: Core
Affects Versions: 2.0.0-M1
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
see https://stackoverflow.com/questions/36156741/marshalling-localdate-using-jaxb
{code:java}
// DOMAIN CODE
@XmlRootElement(name = "Demo")
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
@Log
public class TemporalDemo extends DemoStub {
@PostConstruct
public void initDefaults() {
log.info("TemporalDemo::initDefaults");
javaLocalDate = LocalDate.now();
javaLocalDateTime = LocalDateTime.now();
}
@XmlJavaTypeAdapter(value = LocalDateAdapter.class)
@XmlElement @Getter @Setter private LocalDate javaLocalDate;
@XmlJavaTypeAdapter(value = LocalDateTimeAdapter.class)
@XmlElement @Getter @Setter private LocalDateTime javaLocalDateTime;
}
// COULD BE PART OF CORE
public final class JaxbAdapters {
public static final class LocalDateAdapter extends XmlAdapter<String, LocalDate>{
public LocalDate unmarshal(String v) throws Exception {
return LocalDate.parse(v);
}
public String marshal(LocalDate v) throws Exception {
return v.toString();
}
}
public static final class LocalDateTimeAdapter extends XmlAdapter<String, LocalDateTime>{
public LocalDateTime unmarshal(String v) throws Exception {
return LocalDateTime.parse(v);
}
public String marshal(LocalDateTime v) throws Exception {
return v.toString();
}
}
...
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
Andi Huber (JIRA)
2018-10-09 15:24:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andi Huber closed ISIS-1972.
----------------------------
Resolution: Fixed

We do now provide JAXB XmlAdapters for Java built-in temporal types in 'applib'

{code:java}
org.apache.isis.applib.adapters.JaxbAdapters
{code}
Post by Andi Huber (JIRA)
JAXB view model: add default XmlAdapters for Java 8 Time
--------------------------------------------------------
Key: ISIS-1972
URL: https://issues.apache.org/jira/browse/ISIS-1972
Project: Isis
Issue Type: Improvement
Components: Core
Affects Versions: 2.0.0-M1
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
see https://stackoverflow.com/questions/36156741/marshalling-localdate-using-jaxb
{code:java}
// DOMAIN CODE
@XmlRootElement(name = "Demo")
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
@Log
public class TemporalDemo extends DemoStub {
@PostConstruct
public void initDefaults() {
log.info("TemporalDemo::initDefaults");
javaLocalDate = LocalDate.now();
javaLocalDateTime = LocalDateTime.now();
}
@XmlJavaTypeAdapter(value = LocalDateAdapter.class)
@XmlElement @Getter @Setter private LocalDate javaLocalDate;
@XmlJavaTypeAdapter(value = LocalDateTimeAdapter.class)
@XmlElement @Getter @Setter private LocalDateTime javaLocalDateTime;
}
// COULD BE PART OF CORE
public final class JaxbAdapters {
public static final class LocalDateAdapter extends XmlAdapter<String, LocalDate>{
public LocalDate unmarshal(String v) throws Exception {
return LocalDate.parse(v);
}
public String marshal(LocalDate v) throws Exception {
return v.toString();
}
}
public static final class LocalDateTimeAdapter extends XmlAdapter<String, LocalDateTime>{
public LocalDateTime unmarshal(String v) throws Exception {
return LocalDateTime.parse(v);
}
public String marshal(LocalDateTime v) throws Exception {
return v.toString();
}
}
...
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-10-15 09:06:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16649928#comment-16649928 ]

ASF subversion and git services commented on ISIS-1972:
-------------------------------------------------------

Commit 9b0744274af2172c89eb668883a106f6c4dd1349 in isis's branch refs/heads/v2 from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9b07442 ]

ISIS-1972: Moving JaxbAdapters into better suited 'util' package

Task-Url: https://issues.apache.org/jira/browse/ISIS-1972
Post by Andi Huber (JIRA)
JAXB view model: add default XmlAdapters for Java 8 Time
--------------------------------------------------------
Key: ISIS-1972
URL: https://issues.apache.org/jira/browse/ISIS-1972
Project: Isis
Issue Type: Improvement
Components: Core
Affects Versions: 2.0.0-M1
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
see https://stackoverflow.com/questions/36156741/marshalling-localdate-using-jaxb
{code:java}
// DOMAIN CODE
@XmlRootElement(name = "Demo")
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
@Log
public class TemporalDemo extends DemoStub {
@PostConstruct
public void initDefaults() {
log.info("TemporalDemo::initDefaults");
javaLocalDate = LocalDate.now();
javaLocalDateTime = LocalDateTime.now();
}
@XmlJavaTypeAdapter(value = LocalDateAdapter.class)
@XmlElement @Getter @Setter private LocalDate javaLocalDate;
@XmlJavaTypeAdapter(value = LocalDateTimeAdapter.class)
@XmlElement @Getter @Setter private LocalDateTime javaLocalDateTime;
}
// COULD BE PART OF CORE
public final class JaxbAdapters {
public static final class LocalDateAdapter extends XmlAdapter<String, LocalDate>{
public LocalDate unmarshal(String v) throws Exception {
return LocalDate.parse(v);
}
public String marshal(LocalDate v) throws Exception {
return v.toString();
}
}
public static final class LocalDateTimeAdapter extends XmlAdapter<String, LocalDateTime>{
public LocalDateTime unmarshal(String v) throws Exception {
return LocalDateTime.parse(v);
}
public String marshal(LocalDateTime v) throws Exception {
return v.toString();
}
}
...
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
ASF subversion and git services (JIRA)
2018-10-15 09:06:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/ISIS-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16649929#comment-16649929 ]

ASF subversion and git services commented on ISIS-1972:
-------------------------------------------------------

Commit 9b0744274af2172c89eb668883a106f6c4dd1349 in isis's branch refs/heads/v2 from [~hobrom]
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=9b07442 ]

ISIS-1972: Moving JaxbAdapters into better suited 'util' package

Task-Url: https://issues.apache.org/jira/browse/ISIS-1972
Post by Andi Huber (JIRA)
JAXB view model: add default XmlAdapters for Java 8 Time
--------------------------------------------------------
Key: ISIS-1972
URL: https://issues.apache.org/jira/browse/ISIS-1972
Project: Isis
Issue Type: Improvement
Components: Core
Affects Versions: 2.0.0-M1
Reporter: Andi Huber
Assignee: Andi Huber
Priority: Major
Fix For: 2.0.0-M2
see https://stackoverflow.com/questions/36156741/marshalling-localdate-using-jaxb
{code:java}
// DOMAIN CODE
@XmlRootElement(name = "Demo")
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
@Log
public class TemporalDemo extends DemoStub {
@PostConstruct
public void initDefaults() {
log.info("TemporalDemo::initDefaults");
javaLocalDate = LocalDate.now();
javaLocalDateTime = LocalDateTime.now();
}
@XmlJavaTypeAdapter(value = LocalDateAdapter.class)
@XmlElement @Getter @Setter private LocalDate javaLocalDate;
@XmlJavaTypeAdapter(value = LocalDateTimeAdapter.class)
@XmlElement @Getter @Setter private LocalDateTime javaLocalDateTime;
}
// COULD BE PART OF CORE
public final class JaxbAdapters {
public static final class LocalDateAdapter extends XmlAdapter<String, LocalDate>{
public LocalDate unmarshal(String v) throws Exception {
return LocalDate.parse(v);
}
public String marshal(LocalDate v) throws Exception {
return v.toString();
}
}
public static final class LocalDateTimeAdapter extends XmlAdapter<String, LocalDateTime>{
public LocalDateTime unmarshal(String v) throws Exception {
return LocalDateTime.parse(v);
}
public String marshal(LocalDateTime v) throws Exception {
return v.toString();
}
}
...
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Loading...