This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch CAUSEWAY-3866 in repository https://gitbox.apache.org/repos/asf/causeway.git
commit fdff79b721a211124289d8538d1e0e70a197d457 Author: Dan Haywood <[email protected]> AuthorDate: Sun Oct 19 11:24:43 2025 +0100 CAUSEWAY-3866: removes references to joda --- .../userguide/modules/ROOT/pages/overview.adoc | 2 +- .../userguide/modules/ROOT/pages/value-types.adoc | 20 +- .../properties-collections-actions/actions.adoc | 4 +- .../partials/view-models/jaxb-view-models.adoc | 52 ++-- .../pages/sections/causeway.viewer.graphql.adoc | 16 +- .../adoc/modules/fakedata/pages/about.adoc | 3 - testing/fakedata/integtests/translations.pot | 24 -- .../adoc/modules/ROOT/partials/component-nav.adoc | 1 - valuetypes/asciidoc/builder/pom.xml | 22 +- valuetypes/asciidoc/pom.xml | 9 - valuetypes/asciidoc/ui/pom.xml | 22 +- .../service/valuerender/_JsonValueConverters.java | 292 +++------------------ .../pages/extending/replacing-page-elements.adoc | 2 +- 13 files changed, 97 insertions(+), 372 deletions(-) diff --git a/antora/components/userguide/modules/ROOT/pages/overview.adoc b/antora/components/userguide/modules/ROOT/pages/overview.adoc index e45d5b4173f..0f151d33901 100644 --- a/antora/components/userguide/modules/ROOT/pages/overview.adoc +++ b/antora/components/userguide/modules/ROOT/pages/overview.adoc @@ -16,7 +16,7 @@ These will be either a xref:domain-entities.adoc[domain entity] (persisted state To access them, a menu xref:domain-services.adoc[domain service] will be used to find from the database (a repository service) or occasionally to create a new instance (a factory service). The state managed by entities and view models is expressed in terms of xref:properties-collections-actions.adoc[properties and collections], with properties whose value either refers to other domain objects (reference types) or alternatively holds a value directly (xref:value-types.adoc[value types]). -Apache Causeway supports a wide variety of xref:value-types.adoc[value types], including JDK types (primitives, strings or dates) Causeway-specific (eg AsciiDoc, Vega) and 3rd party (eg Jodatime). +Apache Causeway supports a wide variety of xref:value-types.adoc[value types], including JDK types (primitives, strings or dates) and Causeway-specific (eg AsciiDoc, Vega). Moreover it is possible to define your own custom types, and you can teach the framework about other 3rd party libraries you might wish to use, eg https://jscience.org[JScience]. Actions allow the end-user to invoke business logic. diff --git a/antora/components/userguide/modules/ROOT/pages/value-types.adoc b/antora/components/userguide/modules/ROOT/pages/value-types.adoc index 2173df1b54f..a9c9efa6c8c 100644 --- a/antora/components/userguide/modules/ROOT/pages/value-types.adoc +++ b/antora/components/userguide/modules/ROOT/pages/value-types.adoc @@ -10,8 +10,8 @@ The state managed by entities and view models is expressed in terms of xref:prop This latter is the topic of this page. -Apache Causeway supports a wide variety of value types, including JDK types (eg primitives, dates and `String`) Causeway-specific (eg `AsciiDoc`, `Vega`) and 3rd party (eg Joda Time). -Moreover it is possible to define your own custom types. +Apache Causeway supports a wide variety of value types, including JDK types (eg primitives, dates and `String`) and Causeway-specific (eg `AsciiDoc`, `Vega`). +It is also possible to define your own custom types. You can even teach the framework about other 3rd party libraries you might wish to use. @@ -129,16 +129,6 @@ Unfortunately also not immutable. And `java.sql.Date` compounds the crimes by actually being a subclass of `java.util.Date`. Nevertheless, these are sometimes used for optimistic locking. -* in `org.joda.time` package; a very popular 3rd party library that is still widely. -The JDK `java.time` library took substantial inspiration from Joda. - -** local date/times (no timezone) -+ -`org.joda.time.LocalDate,` `org.joda.time.LocalDateTime,` `org.joda.time.LocalTime` - -** exact -+ -`org.joda.time.DateTime` (similar to `java.time.ZonedDateTime`) Depending on context, additional entities may be required on the property's field: @@ -148,7 +138,7 @@ Depending on context, additional entities may be required on the property's fiel This tells JAXB how to serialize the value in and out of XML. Apache Causeway provides adapters for all of these. -In addition to supporting JDK and Joda, Apache Causeway defines a number of its own custom value types, described next. +Apache Causeway defines a number of its own custom value types, described next. [#causeway-specific] == Causeway-specific @@ -204,10 +194,6 @@ This renders Markdown content (as defined by the link:https://spec.commonmark.or + This renders graphics defined by the link:https://vega.github.io/vega-lite/[Vega-Lite] grammar. -* `Joda Time`, provided by the xref:valuetypes:jodatime:about.adoc[jodatime] value type extension -+ -This provides support for four value types defined within the link:https://www.joda.org/joda-time/[Joda Time] library. - [#custom-value-types] diff --git a/antora/components/userguide/modules/ROOT/partials/properties-collections-actions/actions.adoc b/antora/components/userguide/modules/ROOT/partials/properties-collections-actions/actions.adoc index 1faa755a1b8..2fe6cfa7712 100644 --- a/antora/components/userguide/modules/ROOT/partials/properties-collections-actions/actions.adoc +++ b/antora/components/userguide/modules/ROOT/partials/properties-collections-actions/actions.adoc @@ -181,7 +181,7 @@ For example: import jakarta.persistence.Column; import lombok.Getter; import lombok.Setter; -import org.joda.time.LocalDate; +import java.time.LocalDate; @Action(semantics=SemanticsOf.IDEMPOTENT) public Order invoice( @@ -190,7 +190,7 @@ public Order invoice( @ParameterLayout(named="Ship no later than") LocalDate shipBy) { // ... - setShipBy(shipBy) + setShipBy(shipBy); return this; } diff --git a/antora/components/userguide/modules/ROOT/partials/view-models/jaxb-view-models.adoc b/antora/components/userguide/modules/ROOT/partials/view-models/jaxb-view-models.adoc index a987443c5ff..593638a6ea3 100644 --- a/antora/components/userguide/modules/ROOT/partials/view-models/jaxb-view-models.adoc +++ b/antora/components/userguide/modules/ROOT/partials/view-models/jaxb-view-models.adoc @@ -112,16 +112,17 @@ public class CompareCustomers { ---- -[[joda-datatypes]] -== JODA Time Datatypes +== JDK Time Datatypes -If your JAXB view model contains fields using the JODA datatypes (`LocalDate` and so on), then `@XmlJavaTypeAdapter` additional annotations in order to "teach" JAXB how to serialize out the state. +If your JAXB view model contains fields using the `java.time` datatypes (`LocalDate` and so on), then `@XmlJavaTypeAdapter` additional annotations in order to "teach" JAXB how to serialize out the state. The Apache Causeway applib provides a number of adapters to use out-of-the-box. For example: [source,java] ---- +import java.time.LocalDate; + @XmlRootElement(name = "categorizeIncomingInvoice") @XmlType( propOrder = { @@ -133,49 +134,52 @@ For example: @XmlAccessorType(XmlAccessType.FIELD) public class IncomingInvoiceViewModel extends IncomingOrderAndInvoiceViewModel { - @XmlJavaTypeAdapter(JodaLocalDateStringAdapter.ForJaxb.class) + @XmlJavaTypeAdapter(JavaTimeJaxbAdapters.LocalDateToStringAdapter.class) private LocalDate dateReceived; ... } ---- -The full list of adapter classes are: +The full list of adapter classes are nested classes of the top-level `JavaTimeJaxbAdapters` class. +They all marshall the value to/from a string representation. .JAXB adapters [cols="1a,2a",options="header"] |=== -| JODA datatype +| Datatype | Adapter -.2+| `org.joda.time.DateTime` -| `JodaDateTimeStringAdapter.ForJaxb` -| `JodaDateTimeXMLGregorianCalendarAdapter.ForJaxb` +| `java.time.LocalTime` +| `JavaTimeJaxbAdapters.LocalTimeToStringAdapter` + + +| `java.time.LocalDate` +| `JavaTimeJaxbAdapters.LocalDateToStringAdapter` + + +| `java.time.LocalDateTime` +| `JavaTimeJaxbAdapters.LocalDateTimeToStringAdapter` -.2+| `org.joda.time.LocalDate` -| `JodaLocalDateStringAdapter.ForJaxb` -| `JodaLocalDateXMLGregorianCalendarAdapter.ForJaxb` -.2+| `org.joda.time.LocalDateTime` -| `JodaLocalDateTimeStringAdapter.ForJaxb` -| `JodaLocalDateTimeXMLGregorianCalendarAdapter.ForJaxb` +| `java.time.OffsetTime` +| `JavaTimeJaxbAdapters.OffsetTimeAdapter` +| `java.time.OffsetDateTimeToStringAdapter` +| `JavaTimeJaxbAdapters.OffsetDateTime` -.2+| `org.joda.time.LocalTime` -| `JodaLocalTimeStringAdapter.ForJaxb` -| `JodaLocalTimeXMLGregorianCalendarAdapter.ForJaxb` +| `java.time.ZonedDateTimeAdapter` +| `JavaTimeJaxbAdapters.ZonedDate` -| `java.sql.Timestamp` -| `JavaSqlTimestampXmlGregorianCalendarAdapter.ForJaxb` +| `java.time.Duration` +| `JavaTimeJaxbAdapters.DurationToStringAdapter` +| `java.time.Period` +| `JavaTimeJaxbAdapters.PeriodToStringAdapter` |=== -[TIP] -==== -If you want use other Joda data types, check out link:http://blog.bdoughan.com/2011/05/jaxb-and-joda-time-dates-and-times.html[this blog post]. -==== diff --git a/core/config/src/main/adoc/modules/config/pages/sections/causeway.viewer.graphql.adoc b/core/config/src/main/adoc/modules/config/pages/sections/causeway.viewer.graphql.adoc index f6322c03b4d..e29a9dbf4d6 100644 --- a/core/config/src/main/adoc/modules/config/pages/sections/causeway.viewer.graphql.adoc +++ b/core/config/src/main/adoc/modules/config/pages/sections/causeway.viewer.graphql.adoc @@ -33,7 +33,7 @@ api-variant causeway.viewer.graphql. + authentication.fallback.roles -| +| | Used as the set of roles for the default username (if not provided by other means). @@ -42,7 +42,7 @@ authentication.fallback.roles causeway.viewer.graphql. + authentication.fallback.username -| +| | Used as the default username (if not provided by other means). @@ -60,7 +60,7 @@ arg-name causeway.viewer.graphql.lookup. + field-name-prefix -| +| | Lookup field prefix @@ -69,7 +69,7 @@ field-name-prefix causeway.viewer.graphql.lookup. + field-name-suffix -| +| | Lookup field suffix @@ -109,7 +109,7 @@ scalar-marshaller. + local-date-format | yyyy-MM-dd -| For both JDK8's `LocalDate` and JodaTime's `LocalDate` +| For JDK8's `LocalDate` | @@ -119,7 +119,7 @@ scalar-marshaller. + local-time-format | HH:mm:ss -| For both JDK8's `LocalTime` and JodaTime's `LocalTime` +| For JDK8's `LocalTime` | @@ -129,7 +129,7 @@ scalar-marshaller. + zoned-date-time-format | yyyy-MM-dd'T'HH:mm:ssXXX -| for JDK8's `ZonedDateTime` and JodaTime's `DateTime` +| for JDK8's `ZonedDateTime` | @@ -146,7 +146,7 @@ schema-style causeway.viewer.graphql.schema. + rich.enable-scenario-testing -| +| | If the `#getSchemaStyle()` is set to either `SchemaStyle#RICH++_++ONLY` or `SchemaStyle#SIMPLE++_++AND++_++RICH`, then determines whether the "Scenario" field is included in order to allow given/when/then tests to be expressed. Ignored if the `#getSchemaStyle()` is `SchemaStyle#SIMPLE++_++ONLY`. diff --git a/testing/fakedata/adoc/modules/fakedata/pages/about.adoc b/testing/fakedata/adoc/modules/fakedata/pages/about.adoc index 8106320ff4c..7ffee20aa5e 100644 --- a/testing/fakedata/adoc/modules/fakedata/pages/about.adoc +++ b/testing/fakedata/adoc/modules/fakedata/pages/about.adoc @@ -126,9 +126,6 @@ This provides numerous methods, each for a specific data type, providing an obje * xref:refguide:testing:index/fakedata/applib/services/JavaTimeLocalDates.adoc[JavaTimeLocalDates] * xref:refguide:testing:index/fakedata/applib/services/JavaTimePeriods.adoc[JavaTimePeriods] * xref:refguide:testing:index/fakedata/applib/services/JavaUtilDates.adoc[JavaUtilDates] -* xref:refguide:testing:index/fakedata/applib/services/JodaDateTimes.adoc[JodaDateTimes] -* xref:refguide:testing:index/fakedata/applib/services/JodaLocalDates.adoc[JodaLocalDates] -* xref:refguide:testing:index/fakedata/applib/services/JodaPeriods.adoc[JodaPeriods] Note: these require the xref:refguide:applib:index/services/clock/ClockService.adoc[ClockService] to be injected through the constructor): diff --git a/testing/fakedata/integtests/translations.pot b/testing/fakedata/integtests/translations.pot index 3714893d6bc..9eb58ac87ef 100644 --- a/testing/fakedata/integtests/translations.pot +++ b/testing/fakedata/integtests/translations.pot @@ -455,8 +455,6 @@ msgstr "" #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#resetSomeJavaSqlDate() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#resetSomeJavaSqlTimestamp() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#resetSomeJavaUtilDate() -#: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#resetSomeJodaDateTime() -#: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#resetSomeJodaLocalDate() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#resetSomeLongWrapper() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#resetSomeMoney() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#resetSomePassword() @@ -607,16 +605,6 @@ msgid "Some Java Util Date" msgstr "" -#: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#someJodaDateTime -msgid "Some Joda Date Time" -msgstr "" - - -#: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#someJodaLocalDate -msgid "Some Joda Local Date" -msgstr "" - - #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#someLong msgid "Some Long" msgstr "" @@ -716,8 +704,6 @@ msgstr "" #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#updateSomeJavaSqlDate() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#updateSomeJavaSqlTimestamp() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#updateSomeJavaUtilDate() -#: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#updateSomeJodaDateTime() -#: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#updateSomeJodaLocalDate() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#updateSomeLongWrapper() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#updateSomeMoney() #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll#updateSomePassword() @@ -899,16 +885,6 @@ msgid "someJavaUtilDate" msgstr "" -#: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll -msgid "someJodaDateTime" -msgstr "" - - -#: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll -msgid "someJodaLocalDate" -msgstr "" - - #: org.causewayaddons.module.fakedata.fixture.demoapp.demomodule.dom.FakeDataDemoObjectWithAll msgid "someLong" msgstr "" diff --git a/valuetypes/adoc/modules/ROOT/partials/component-nav.adoc b/valuetypes/adoc/modules/ROOT/partials/component-nav.adoc index ba46be09103..afa48db3ba9 100644 --- a/valuetypes/adoc/modules/ROOT/partials/component-nav.adoc +++ b/valuetypes/adoc/modules/ROOT/partials/component-nav.adoc @@ -5,7 +5,6 @@ include::valuetypes:ROOT:partial$module-nav.adoc[] include::valuetypes:asciidoc:partial$module-nav.adoc[] -include::valuetypes:jodatime:partial$module-nav.adoc[] include::valuetypes:markdown:partial$module-nav.adoc[] include::valuetypes:vega:partial$module-nav.adoc[] diff --git a/valuetypes/asciidoc/builder/pom.xml b/valuetypes/asciidoc/builder/pom.xml index 177ae52177f..0f364557b24 100644 --- a/valuetypes/asciidoc/builder/pom.xml +++ b/valuetypes/asciidoc/builder/pom.xml @@ -1,15 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more -contributor +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 +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. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -69,10 +69,6 @@ additional <groupId>org.jruby</groupId> <artifactId>jruby</artifactId> </dependency> - <dependency> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> - </dependency> <dependency> <groupId>com.github.jnr</groupId> <artifactId>jnr-posix</artifactId> diff --git a/valuetypes/asciidoc/pom.xml b/valuetypes/asciidoc/pom.xml index 3fd09870e92..7545bcc3d5f 100644 --- a/valuetypes/asciidoc/pom.xml +++ b/valuetypes/asciidoc/pom.xml @@ -65,10 +65,6 @@ <artifactId>jruby</artifactId> <version>10.0.2.0</version> <exclusions> - <exclusion> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> - </exclusion> <exclusion> <groupId>com.github.jnr</groupId> <artifactId>jnr-constants</artifactId> @@ -95,11 +91,6 @@ </exclusion> </exclusions> </dependency> - <dependency> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> - <version>2.14.0</version> - </dependency> <dependency> <groupId>com.github.jnr</groupId> <artifactId>jnr-posix</artifactId> diff --git a/valuetypes/asciidoc/ui/pom.xml b/valuetypes/asciidoc/ui/pom.xml index ee33acf8c58..1a42938cc65 100644 --- a/valuetypes/asciidoc/ui/pom.xml +++ b/valuetypes/asciidoc/ui/pom.xml @@ -1,15 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more -contributor +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 +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. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -54,10 +54,6 @@ additional <groupId>org.jruby</groupId> <artifactId>jruby</artifactId> </dependency> - <dependency> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> - </dependency> <dependency> <groupId>com.github.jnr</groupId> <artifactId>jnr-posix</artifactId> diff --git a/viewers/restfulobjects/rendering/src/main/java/org/apache/causeway/viewer/restfulobjects/rendering/service/valuerender/_JsonValueConverters.java b/viewers/restfulobjects/rendering/src/main/java/org/apache/causeway/viewer/restfulobjects/rendering/service/valuerender/_JsonValueConverters.java index 99f22fc89e9..6587af55eab 100644 --- a/viewers/restfulobjects/rendering/src/main/java/org/apache/causeway/viewer/restfulobjects/rendering/service/valuerender/_JsonValueConverters.java +++ b/viewers/restfulobjects/rendering/src/main/java/org/apache/causeway/viewer/restfulobjects/rendering/service/valuerender/_JsonValueConverters.java @@ -451,263 +451,43 @@ public Object appendValueAndFormat(final ManagedObject objectAdapter, final Cont } }); -// converters.add(new JsonValueConverter.Abstract(DefaultFormat.JODALOCALDATE){ -// -// // these formatters do NOT use withZoneUTC() -// final List<DateTimeFormatter> formatters = _JodaLegacy.formattersJodaLocalDate(); -// -// @Override -// public Object recoverValueAsPojo(final JsonRepresentation repr, final Context context) { -// if (repr.isString()) { -// final String dateStr = repr.asString(); -// for (DateTimeFormatter formatter : formatters) { -// try { -// final LocalDate parsedDate = formatter.parseLocalDate(dateStr); -// return parsedDate; -// } catch (IllegalArgumentException ex) { -// // fall through -// } -// } -// } -// return null; -// } -// -// @Override -// public Object appendValueAndFormat(final ManagedObject objectAdapter, final Context context, -// final JsonRepresentation repr) { -// final Object obj = unwrapAsObjectElseNullNode(objectAdapter); -// if(obj instanceof LocalDate) { -// final LocalDate date = (LocalDate) obj; -// final String dateStr = formatters.get(0).print(date.toDateTimeAtStartOfDay()); -// repr.mapPutString("value", dateStr); -// } else { -// repr.mapPut("value", obj); -// } -// appendFormats(repr, context); -// return obj; -// } -// }); -// -// converters.add(new JsonValueConverter.Abstract(DefaultFormat.JODALOCALDATETIME){ -// -// final List<DateTimeFormatter> formatters = _JodaLegacy.formattersJodaLocalDateTime(); -// -// @Override -// public Object recoverValueAsPojo(final JsonRepresentation repr, final Context context) { -// if (repr.isString()) { -// final String dateStr = repr.asString(); -// for (DateTimeFormatter formatter : formatters) { -// try { -// final LocalDateTime parsedDate = formatter.parseLocalDateTime(dateStr); -// return parsedDate; -// } catch (IllegalArgumentException ex) { -// // fall through -// } -// } -// } -// return null; -// } -// -// @Override -// public Object appendValueAndFormat(final ManagedObject objectAdapter, final Context context, -// final JsonRepresentation repr) { -// final Object obj = unwrapAsObjectElseNullNode(objectAdapter); -// if(obj instanceof LocalDateTime) { -// final LocalDateTime date = (LocalDateTime) obj; -// final String dateStr = formatters.get(0).print(date.toDateTime()); -// repr.mapPutString("value", dateStr); -// } else { -// repr.mapPut("value", obj); -// } -// appendFormats(repr, context); -// return obj; -// } -// }); -// -// converters.add(new JsonValueConverter.Abstract(DefaultFormat.JODADATETIME){ -// -// final List<DateTimeFormatter> formatters = _JodaLegacy.formattersJodaDateTime(); -// -// @Override -// public Object recoverValueAsPojo(final JsonRepresentation repr, final Context context) { -// if (repr.isString()) { -// final String dateStr = repr.asString(); -// for (DateTimeFormatter formatter : formatters) { -// try { -// final DateTime parsedDate = formatter.parseDateTime(dateStr); -// return parsedDate; -// } catch (IllegalArgumentException ex) { -// // fall through -// } -// } -// } -// return null; -// } -// -// @Override -// public Object appendValueAndFormat(final ManagedObject objectAdapter, final Context context, -// final JsonRepresentation repr) { -// final Object obj = unwrapAsObjectElseNullNode(objectAdapter); -// if(obj instanceof DateTime) { -// final DateTime date = (DateTime) obj; -// final String dateStr = formatters.get(0).print(date.toDateTime()); -// repr.mapPutString("value", dateStr); -// } else { -// repr.mapPut("value", obj); -// } -// appendFormats(repr, context); -// return obj; -// } -// }); + converters.add(new JsonValueConverter.Abstract(DefaultFormat.JAVASQLTIMESTAMP){ -// converters.add(new JsonValueConverter.Abstract(DefaultFormat.JAVAUTILDATE){ -// -// final List<DateTimeFormatter> formatters = _JodaLegacy.formattersJavaUtilDate(); -// -// @Override -// public Object recoverValueAsPojo(final JsonRepresentation repr, final Context context) { -// if (repr.isString()) { -// final String dateStr = repr.asString(); -// for (DateTimeFormatter formatter : formatters) { -// try { -// final DateTime parseDateTime = formatter.parseDateTime(dateStr); -// final java.util.Date parsedDate = parseDateTime.toDate(); -// return parsedDate; -// } catch (IllegalArgumentException ex) { -// // fall through -// } -// } -// } -// return null; -// } -// -// @Override -// public Object appendValueAndFormat(final ManagedObject objectAdapter, final Context context, -// final JsonRepresentation repr) { -// final Object obj = unwrapAsObjectElseNullNode(objectAdapter); -// if(obj instanceof java.util.Date) { -// final java.util.Date date = (java.util.Date) obj; -// final DateTimeFormatter dateTimeFormatter = formatters.get(0); -// final String dateStr = dateTimeFormatter.print(new DateTime(date)); -// repr.mapPutString("value", dateStr); -// } else { -// repr.mapPut("value", obj); -// } -// appendFormats(repr, context); -// return obj; -// } -// }); -// -// converters.add(new JsonValueConverter.Abstract(DefaultFormat.JAVASQLDATE){ -// -// final List<DateTimeFormatter> formatters = _JodaLegacy.formattersJavaSqlDate(); -// -// @Override -// public Object recoverValueAsPojo(final JsonRepresentation repr, final Context context) { -// if (repr.isString()) { -// final String dateStr = repr.asString(); -// for (DateTimeFormatter formatter : formatters) { -// try { -// final DateTime parseDateTime = formatter.parseDateTime(dateStr); -// final java.sql.Date parsedDate = new java.sql.Date(parseDateTime.getMillis()); -// return parsedDate; -// } catch (IllegalArgumentException ex) { -// // fall through -// } -// } -// } -// return null; -// } -// -// @Override -// public Object appendValueAndFormat(final ManagedObject objectAdapter, final Context context, -// final JsonRepresentation repr) { -// final Object obj = unwrapAsObjectElseNullNode(objectAdapter); -// if(obj instanceof java.sql.Date) { -// final java.sql.Date date = (java.sql.Date) obj; -// final String dateStr = formatters.get(0).print(new DateTime(date)); -// repr.mapPutString("value", dateStr); -// } else { -// repr.mapPut("value", obj); -// } -// appendFormats(repr, context); -// return obj; -// } -// }); -// -// converters.add(new JsonValueConverter.Abstract(DefaultFormat.JAVASQLTIME){ -// -// final List<DateTimeFormatter> formatters = _JodaLegacy.formattersJavaSqlTime(); -// @Override -// public Object recoverValueAsPojo(final JsonRepresentation repr, final Context context) { -// if (repr.isString()) { -// final String dateStr = repr.asString(); -// for (DateTimeFormatter formatter : formatters) { -// try { -// final DateTime parseDateTime = formatter.parseDateTime(dateStr); -// final java.sql.Time parsedTime = new java.sql.Time(parseDateTime.getMillis()); -// return parsedTime; -// } catch (IllegalArgumentException ex) { -// // fall through -// } -// } -// } -// return null; -// } -// -// @Override -// public Object appendValueAndFormat(final ManagedObject objectAdapter, final Context context, -// final JsonRepresentation repr) { -// final Object obj = unwrapAsObjectElseNullNode(objectAdapter); -// if(obj instanceof java.sql.Time) { -// final java.sql.Time date = (java.sql.Time) obj; -// final String dateStr = formatters.get(0).print(new DateTime(date)); -// repr.mapPutString("value", dateStr); -// } else { -// repr.mapPut("value", obj); -// } -// appendFormats(repr, context); -// return obj; -// } -// }); -// -// converters.add(new JsonValueConverter.Abstract(DefaultFormat.JAVASQLTIMESTAMP){ -// -// @Override -// public Object recoverValueAsPojo(final JsonRepresentation repr, final Context context) { -// if (repr.isLong()) { -// final Long millis = repr.asLong(); -// final java.sql.Timestamp parsedTimestamp = new java.sql.Timestamp(millis); -// return parsedTimestamp; -// } -// if (repr.isString()) { -// final String dateStr = repr.asString(); -// try { -// final Long parseMillis = Long.parseLong(dateStr); -// final java.sql.Timestamp parsedTimestamp = new java.sql.Timestamp(parseMillis); -// return parsedTimestamp; -// } catch (IllegalArgumentException ex) { -// // fall through -// } -// } -// return null; -// } -// -// @Override -// public Object appendValueAndFormat(final ManagedObject objectAdapter, final Context context, -// final JsonRepresentation repr) { -// final Object obj = unwrapAsObjectElseNullNode(objectAdapter); -// if(obj instanceof java.sql.Timestamp) { -// final java.sql.Timestamp date = (java.sql.Timestamp) obj; -// final long millisStr = date.getTime(); -// repr.mapPutLong("value", millisStr); -// } else { -// repr.mapPut("value", obj); -// } -// appendFormats(repr, context); -// return obj; -// } -// }); + @Override + public Object recoverValueAsPojo(final JsonRepresentation repr, final Context context) { + if (repr.isLong()) { + final Long millis = repr.asLong(); + final java.sql.Timestamp parsedTimestamp = new java.sql.Timestamp(millis); + return parsedTimestamp; + } + if (repr.isString()) { + final String dateStr = repr.asString(); + try { + final Long parseMillis = Long.parseLong(dateStr); + final java.sql.Timestamp parsedTimestamp = new java.sql.Timestamp(parseMillis); + return parsedTimestamp; + } catch (IllegalArgumentException ex) { + // fall through + } + } + return null; + } + + @Override + public Object appendValueAndFormat(final ManagedObject objectAdapter, final Context context, + final JsonRepresentation repr) { + final Object obj = unwrapAsObjectElseNullNode(objectAdapter); + if(obj instanceof java.sql.Timestamp) { + final java.sql.Timestamp date = (java.sql.Timestamp) obj; + final long millisStr = date.getTime(); + repr.mapPutLong("value", millisStr); + } else { + repr.mapPut("value", obj); + } + appendFormats(repr, context); + return obj; + } + }); return converters; } diff --git a/viewers/wicket/adoc/modules/ROOT/pages/extending/replacing-page-elements.adoc b/viewers/wicket/adoc/modules/ROOT/pages/extending/replacing-page-elements.adoc index 0c3166201b0..9d2a647aa12 100644 --- a/viewers/wicket/adoc/modules/ROOT/pages/extending/replacing-page-elements.adoc +++ b/viewers/wicket/adoc/modules/ROOT/pages/extending/replacing-page-elements.adoc @@ -28,7 +28,7 @@ In some cases there are several factories for a given `ComponentType`; this is m After doing a first pass selection of candidate factories by `ComponentType`, each factory is then asked if it `appliesTo(Model)`. This is an opportunity for the factory to check the model itself to see if the data within it is of the appropriate type. -Thus, the `BooleanPanelFactory` checks that the `ScalarModel` holds a boolean, while the `JodaLocalDatePanelFactory` checks to see if it holds `org.joda.time.LocalDate`. +Thus, the `BooleanAttributePanelFactory` checks that the `ScalarModel` holds a boolean, while the `BlobAttributePanelFactory` checks to see if it holds `Blob`. There will typically be only one `ComponentFactory` capable of rendering a particular `ComponentType`/`ScalarModel` combination; at any rate, the framework stops as soon as one is found.
