This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new f212e6fc7e ISIS-3105: JDO: adds missing mapping for OffsetDateTime
f212e6fc7e is described below
commit f212e6fc7e3cb0858c9ad6cfa482d1890130301f
Author: Andi Huber <[email protected]>
AuthorDate: Tue Aug 2 10:41:31 2022 +0200
ISIS-3105: JDO: adds missing mapping for OffsetDateTime
---
.../time/IsoOffsetDateTimeConverter.java | 47 ++++++++++++++++++++++
.../jdo/datanucleus/src/main/resources/plugin.xml | 15 +++++++
2 files changed, 62 insertions(+)
diff --git
a/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/typeconverters/time/IsoOffsetDateTimeConverter.java
b/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/typeconverters/time/IsoOffsetDateTimeConverter.java
new file mode 100644
index 0000000000..68410cffce
--- /dev/null
+++
b/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/typeconverters/time/IsoOffsetDateTimeConverter.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.persistence.jdo.datanucleus.typeconverters.time;
+
+import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
+
+import org.datanucleus.store.types.converters.TypeConverter;
+
+/**
+ * @since 2.0 {@index}
+ */
+public class IsoOffsetDateTimeConverter implements
TypeConverter<OffsetDateTime, String>{
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String toDatastoreType(final OffsetDateTime offsetTime) {
+ return offsetTime != null
+ ? offsetTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
+ : null;
+ }
+
+ @Override
+ public OffsetDateTime toMemberType(final String datastoreValue) {
+ return datastoreValue != null
+ ? OffsetDateTime.parse(datastoreValue,
DateTimeFormatter.ISO_OFFSET_DATE_TIME)
+ : null;
+ }
+
+}
diff --git a/persistence/jdo/datanucleus/src/main/resources/plugin.xml
b/persistence/jdo/datanucleus/src/main/resources/plugin.xml
index 5492224bb5..b2bd10c7d9 100644
--- a/persistence/jdo/datanucleus/src/main/resources/plugin.xml
+++ b/persistence/jdo/datanucleus/src/main/resources/plugin.xml
@@ -67,6 +67,13 @@
converter-name="iso.zoneddatetime-string" />
</extension>
+ <extension point="org.datanucleus.java_type">
+ <java-type
+ name="java.time.OffsetDateTime"
+ dfg="true" priority="10"
+ converter-name="iso.offsetdatetime-string" />
+ </extension>
+
<extension point="org.datanucleus.java_type">
<java-type
name="java.time.OffsetTime"
@@ -149,6 +156,14 @@
converter-class="org.apache.isis.persistence.jdo.datanucleus.typeconverters.time.IsoZonedDateTimeConverter"/>
</extension>
+ <extension point="org.datanucleus.type_converter">
+ <type-converter
+ name="iso.offsetdatetime-string"
+ member-type="java.time.OffsetDateTime"
+ datastore-type="java.lang.String"
+
converter-class="org.apache.isis.persistence.jdo.datanucleus.typeconverters.time.IsoOffsetDateTimeConverter"/>
+ </extension>
+
<extension point="org.datanucleus.type_converter">
<type-converter
name="iso.offsettime-string"