You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2018/01/31 16:21:38 UTC

[isis] branch maint-1.16.1 updated (a2df1fd -> c0e57b9)

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a change to branch maint-1.16.1
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from a2df1fd  ISIS-1813: adds -parameters' compiler argument for both helloworld and simpleapp example applications
     new cd93ad7  ISIS-1832: adds support for UUID panels.
     new 4c9265d  ISIS-1569: adds 'timestamp' to cmd.xsd
     new d27ccd4  ISIS-1569: dynamically updates CommandDto.timestamp, and allows ticking clock to be set using a timestamp.  Also...
     new c0e57b9  ISIS-1569: makes determineIfContinue overridable in BackgroundCommandExecution

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../conmap/ContentMappingServiceForCommandDto.java |  10 ++
 .../isis/applib/fixtures/TickingFixtureClock.java  |   5 +
 .../background/BackgroundCommandExecution.java     | 123 ++++++++++++---------
 .../org/apache/isis/schema/cmd/cmd-1.4.xsd         |   6 +
 .../ComponentFactoryRegistrarDefault.java          |  33 ++++--
 .../ui/components/scalars/uuid/UuidConverter.java  |  60 ++++++++++
 .../UuidPanel.java}                                |  28 ++---
 .../UuidPanelFactory.java}                         |  14 ++-
 .../UuidTextField.java}                            |  24 ++--
 .../scalars/uuid/UuidConverterTest_roundtrip.java  |  73 ++++++++++++
 10 files changed, 283 insertions(+), 93 deletions(-)
 create mode 100644 core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidConverter.java
 copy core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/{jdkmath/JavaMathBigDecimalPanel.java => uuid/UuidPanel.java} (58%)
 copy core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/{primitive/BytePanelFactory.java => uuid/UuidPanelFactory.java} (79%)
 copy core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/{jdkmath/BigDecimalTextField.java => uuid/UuidTextField.java} (68%)
 create mode 100644 core/viewer-wicket-ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidConverterTest_roundtrip.java

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.

[isis] 02/04: ISIS-1569: adds 'timestamp' to cmd.xsd

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch maint-1.16.1
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 4c9265d40f623c490100b96b23a40d00c94de543
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Jan 31 15:28:29 2018 +0000

    ISIS-1569: adds 'timestamp' to cmd.xsd
---
 .../src/main/resources/org/apache/isis/schema/cmd/cmd-1.4.xsd       | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.4.xsd b/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.4.xsd
index 3ff2e90..85a0e98 100644
--- a/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.4.xsd
+++ b/core/schema/src/main/resources/org/apache/isis/schema/cmd/cmd-1.4.xsd
@@ -61,6 +61,12 @@
                         </xs:documentation>
                     </xs:annotation>
                 </xs:element>
+                <xs:element name="timestamp" type="xs:dateTime" minOccurs="0" maxOccurs="1">
+                    <xs:annotation>
+                        <xs:documentation>The timestamp when this command was created, used for sequencing when replaying.  This field is optional because it was introduced in v1.4.  The framework-provided ContentMappingServiceForCommandDto populates this field dynamically whenever querying for commands through the REST API.
+                        </xs:documentation>
+                    </xs:annotation>
+                </xs:element>
                 <xs:element name="user" type="xs:string">
                     <xs:annotation>
                         <xs:documentation>The name of the user that initiated/created this command.

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.

[isis] 04/04: ISIS-1569: makes determineIfContinue overridable in BackgroundCommandExecution

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch maint-1.16.1
in repository https://gitbox.apache.org/repos/asf/isis.git

commit c0e57b9803e5306fde5608a1e35300a0fed03f5d
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Jan 31 16:21:29 2018 +0000

    ISIS-1569: makes determineIfContinue overridable in BackgroundCommandExecution
---
 .../core/runtime/services/background/BackgroundCommandExecution.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
index 49e1ef0..07d2e67 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
@@ -439,8 +439,9 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
         return property;
     }
 
-    private boolean determineIfContinue(final RuntimeException exceptionIfAny) {
-        final boolean shouldQuit = exceptionIfAny != null && onExceptionPolicy == BackgroundCommandExecution.OnExceptionPolicy.QUIT;
+    protected boolean determineIfContinue(final RuntimeException exceptionIfAny) {
+        final boolean shouldQuit = exceptionIfAny != null &&
+                      onExceptionPolicy == BackgroundCommandExecution.OnExceptionPolicy.QUIT;
         return !shouldQuit;
     }
 

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.

[isis] 01/04: ISIS-1832: adds support for UUID panels.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch maint-1.16.1
in repository https://gitbox.apache.org/repos/asf/isis.git

commit cd93ad71684402d8f7603fdb5f3e2300de6f48eb
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Jan 31 15:27:42 2018 +0000

    ISIS-1832: adds support for UUID panels.
---
 .../ComponentFactoryRegistrarDefault.java          | 33 +++++++---
 .../ui/components/scalars/uuid/UuidConverter.java  | 60 ++++++++++++++++++
 .../ui/components/scalars/uuid/UuidPanel.java      | 59 +++++++++++++++++
 .../components/scalars/uuid/UuidPanelFactory.java  | 46 ++++++++++++++
 .../ui/components/scalars/uuid/UuidTextField.java  | 53 ++++++++++++++++
 .../scalars/uuid/UuidConverterTest_roundtrip.java  | 73 ++++++++++++++++++++++
 6 files changed, 317 insertions(+), 7 deletions(-)

diff --git a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
index ec9e27d..fc06ba5 100644
--- a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
+++ b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
@@ -19,17 +19,20 @@
 
 package org.apache.isis.viewer.wicket.viewer.registries.components;
 
+import java.util.ServiceLoader;
+
 import com.google.inject.Singleton;
+
 import org.apache.isis.viewer.wicket.ui.ComponentFactory;
 import org.apache.isis.viewer.wicket.ui.ComponentType;
 import org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistrar;
 import org.apache.isis.viewer.wicket.ui.components.about.AboutPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.actioninfo.ActionInfoPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.actionlink.ActionLinkPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.actionmenu.serviceactions.ServiceActionsPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.actionmenu.serviceactions.TertiaryMenuPanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.actioninfo.ActionInfoPanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.actions.ActionParametersPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.actions.ActionParametersFormPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.actions.ActionParametersPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.bookmarkedpages.BookmarkedPagesPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.collectioncontents.multiple.CollectionContentsMultipleViewsPanelFactory;
@@ -45,7 +48,16 @@ import org.apache.isis.viewer.wicket.ui.components.footer.FooterPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.header.HeaderPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.property.PropertyEditFormPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.property.PropertyEditPanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.*;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisBlobPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisClobPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisColorPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisDatePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisDateTimePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisMoneyPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisPasswordPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisPercentagePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisTimePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisTimeStampPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.jdkdates.JavaSqlDatePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.jdkdates.JavaSqlTimePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.jdkdates.JavaSqlTimestampPanelFactory;
@@ -56,19 +68,25 @@ import org.apache.isis.viewer.wicket.ui.components.scalars.jodatime.JodaDateTime
 import org.apache.isis.viewer.wicket.ui.components.scalars.jodatime.JodaLocalDatePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.jodatime.JodaLocalDateTimePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.markup.MarkupPanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.scalars.primitive.*;
+import org.apache.isis.viewer.wicket.ui.components.scalars.primitive.BooleanPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.primitive.BytePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.primitive.CharacterPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.primitive.DoublePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.primitive.FloatPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.primitive.IntegerPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.primitive.LongPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.primitive.ShortPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.reference.ReferencePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.string.StringPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.uuid.UuidPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.value.ValuePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.valuechoices.ValueChoicesSelect2PanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.standalonecollection.StandaloneCollectionPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.unknown.UnknownModelPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.value.StandaloneValuePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.voidreturn.VoidReturnPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.welcome.WelcomePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.widgets.entitysimplelink.EntityLinkSimplePanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.scalars.valuechoices.ValueChoicesSelect2PanelFactory;
-
-import java.util.ServiceLoader;
 
 /**
  * Default implementation of {@link ComponentFactoryRegistrar} that registers a
@@ -213,6 +231,7 @@ public class ComponentFactoryRegistrarDefault implements ComponentFactoryRegistr
         
         componentFactories.add(new JavaMathBigIntegerPanelFactory());
         componentFactories.add(new JavaMathBigDecimalPanelFactory());
+        componentFactories.add(new UuidPanelFactory());
 
         componentFactories.add(new JodaLocalDatePanelFactory());
         componentFactories.add(new JodaLocalDateTimePanelFactory());
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidConverter.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidConverter.java
new file mode 100644
index 0000000..0e5a33e
--- /dev/null
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidConverter.java
@@ -0,0 +1,60 @@
+/**
+ *  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.viewer.wicket.ui.components.scalars.uuid;
+
+import java.util.Locale;
+import java.util.UUID;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Strings;
+
+import org.apache.wicket.util.convert.ConversionException;
+import org.apache.wicket.util.convert.IConverter;
+
+/**
+ * The {@link IConverter} implementation that our {@link UuidTextField} delegates to for converting strings into values.
+ */
+public class UuidConverter implements IConverter<UUID>
+{
+    private final static Pattern pattern = Pattern.compile(
+            "[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}");
+
+    @Override
+    public UUID convertToObject(String value, Locale locale)
+            throws ConversionException {
+
+        if(Strings.isNullOrEmpty(value)) {
+            return null;
+        }
+
+        try {
+            return UUID.fromString(value);
+        } catch (IllegalArgumentException e) {
+            throw newConversionException(value);
+        }
+    }
+
+    @Override
+    public String convertToString(UUID value, Locale locale) {
+        return value != null ? value.toString() : null;
+    }
+
+    private ConversionException newConversionException(String value) {
+        return new ConversionException(
+                String.format("Failed to convert '%s' to a UUID", value));
+    }
+}
\ No newline at end of file
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidPanel.java
new file mode 100644
index 0000000..dc34b37
--- /dev/null
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidPanel.java
@@ -0,0 +1,59 @@
+/*
+ *  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.viewer.wicket.ui.components.scalars.uuid;
+
+import java.util.UUID;
+
+import org.apache.wicket.markup.html.form.AbstractTextComponent;
+
+import org.apache.isis.viewer.wicket.model.models.ScalarModel;
+import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelTextFieldAbstract;
+import org.apache.isis.viewer.wicket.ui.components.scalars.TextFieldValueModel;
+
+/**
+ * Panel for rendering scalars of type {@link UUID}.
+ */
+public class UuidPanel extends ScalarPanelTextFieldAbstract<UUID> {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final UuidConverter converter = new UuidConverter();
+
+    public UuidPanel(
+            final String id,
+            final ScalarModel scalarModel) {
+        super(id, scalarModel, UUID.class);
+    }
+
+    protected AbstractTextComponent<UUID> createTextFieldForRegular(final String id) {
+        final ScalarModel model = getModel();
+        final TextFieldValueModel<UUID> textFieldValueModel = new TextFieldValueModel<>(this);
+        return new UuidTextField(id, textFieldValueModel, cls, model, converter);
+    }
+
+
+    @Override
+    protected String getScalarPanelType() {
+        return "javaMathBigDecimalPanel";
+    }
+}
+
+
+
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidPanelFactory.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidPanelFactory.java
new file mode 100644
index 0000000..2b8eee9
--- /dev/null
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidPanelFactory.java
@@ -0,0 +1,46 @@
+/*
+ *  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.viewer.wicket.ui.components.scalars.uuid;
+
+import java.util.UUID;
+
+import org.apache.wicket.Component;
+
+import org.apache.isis.viewer.wicket.model.models.ScalarModel;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.ComponentFactoryScalarAbstract;
+
+/**
+ * {@link ComponentFactory} for {@link UuidPanel}.
+ */
+public class UuidPanelFactory extends ComponentFactoryScalarAbstract {
+
+    private static final long serialVersionUID = 1L;
+
+    public UuidPanelFactory() {
+        super(UuidPanel.class, UUID.class);
+    }
+
+    @Override
+    public Component createComponent(final String id, final ScalarModel scalarModel) {
+        return new UuidPanel(id, scalarModel);
+    }
+
+}
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidTextField.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidTextField.java
new file mode 100644
index 0000000..c8b3cb0
--- /dev/null
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidTextField.java
@@ -0,0 +1,53 @@
+/**
+ *  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.viewer.wicket.ui.components.scalars.uuid;
+
+import java.util.UUID;
+
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.util.convert.IConverter;
+
+import org.apache.isis.viewer.wicket.model.models.ScalarModel;
+import org.apache.isis.viewer.wicket.ui.components.scalars.TextFieldAbstract;
+
+final class UuidTextField extends TextFieldAbstract<UUID> {
+    
+    private static final long serialVersionUID = 1L;
+    
+    private final UuidConverter converter;
+
+    UuidTextField(
+            final String id, final IModel<UUID> model, final Class<UUID> type,
+            final ScalarModel scalarModel, 
+            final UuidConverter converter) {
+        super(id, model, type, scalarModel);
+        this.converter = converter;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <C> IConverter<C> getConverter(Class<C> type) {
+        if (type != UUID.class) {
+            return super.getConverter(type);
+        } 
+        return (IConverter<C>) getConverterFor(scalarModel);
+    }
+
+    protected IConverter<UUID> getConverterFor(ScalarModel scalarModel) {
+        return converter;
+    }
+}
\ No newline at end of file
diff --git a/core/viewer-wicket-ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidConverterTest_roundtrip.java b/core/viewer-wicket-ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidConverterTest_roundtrip.java
new file mode 100644
index 0000000..7170b82
--- /dev/null
+++ b/core/viewer-wicket-ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/scalars/uuid/UuidConverterTest_roundtrip.java
@@ -0,0 +1,73 @@
+/*
+ *  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.viewer.wicket.ui.components.scalars.uuid;
+
+import java.util.Locale;
+import java.util.UUID;
+
+import org.apache.wicket.util.convert.ConversionException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class UuidConverterTest_roundtrip {
+
+    final UUID valid = UUID.randomUUID();
+
+    private UuidConverter converter;
+
+    @Rule
+    public ExpectedException exception = ExpectedException.none();
+    
+    @Before
+    public void setUp() throws Exception {
+        converter = newConverter();
+    }
+    
+    @Test
+    public void happy_case() {
+        
+        Assert.assertEquals(
+                valid, converter.convertToObject(valid.toString(), Locale.ENGLISH));
+        Assert.assertEquals(
+                valid.toString(), converter.convertToString(valid, Locale.ENGLISH));
+    }
+
+    @Test
+    public void when_null() {
+        Assert.assertNull(converter.convertToObject(null, Locale.ENGLISH));
+        Assert.assertNull(converter.convertToObject("", Locale.ENGLISH));
+        Assert.assertNull(converter.convertToString(null, Locale.ENGLISH));
+    }
+
+    @Test
+    public void invalid() {
+        exception.expect(ConversionException.class);
+        exception.expectMessage("Failed to convert 'junk' to a UUID");
+        Assert.assertNull(converter.convertToObject("junk", Locale.ENGLISH));
+    }
+
+    private UuidConverter newConverter() {
+        return new
+                UuidConverter();
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.

[isis] 03/04: ISIS-1569: dynamically updates CommandDto.timestamp, and allows ticking clock to be set using a timestamp. Also...

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch maint-1.16.1
in repository https://gitbox.apache.org/repos/asf/isis.git

commit d27ccd48f25e6e871d851a3f3160c411fa4be026
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Jan 31 16:19:31 2018 +0000

    ISIS-1569: dynamically updates CommandDto.timestamp, and allows ticking clock to be set using a timestamp.  Also...
    
    ... also allows BackgroundCommandExecution's executeCommand to be overridden.
---
 .../conmap/ContentMappingServiceForCommandDto.java |  10 ++
 .../isis/applib/fixtures/TickingFixtureClock.java  |   5 +
 .../background/BackgroundCommandExecution.java     | 118 ++++++++++++---------
 3 files changed, 85 insertions(+), 48 deletions(-)

diff --git a/core/applib/src/main/java/org/apache/isis/applib/conmap/ContentMappingServiceForCommandDto.java b/core/applib/src/main/java/org/apache/isis/applib/conmap/ContentMappingServiceForCommandDto.java
index 717e70d..fdec5da 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/conmap/ContentMappingServiceForCommandDto.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/conmap/ContentMappingServiceForCommandDto.java
@@ -18,6 +18,7 @@
  */
 package org.apache.isis.applib.conmap;
 
+import java.sql.Timestamp;
 import java.util.List;
 
 import javax.inject.Inject;
@@ -30,6 +31,7 @@ import org.apache.isis.applib.services.command.CommandDtoProcessor;
 import org.apache.isis.applib.services.command.CommandWithDto;
 import org.apache.isis.applib.services.metamodel.MetaModelService5;
 import org.apache.isis.schema.cmd.v1.CommandDto;
+import org.apache.isis.schema.utils.jaxbadapters.JavaSqlTimestampXmlGregorianCalendarAdapter;
 
 @DomainService(
         nature = NatureOfService.DOMAIN,
@@ -70,6 +72,14 @@ public class ContentMappingServiceForCommandDto implements ContentMappingService
             CommandWithDto commandWithDto,
             final MetaModelService5 metaModelService) {
         final CommandDto commandDto = commandWithDto.asDto();
+        /**
+         * the timestamp field was only introduced in v1.4 of cmd.xsd, so there's no guarantee it will have been
+         * populated.  We therefore copy the value in from CommandWithDto entity.
+         */
+        if(commandDto.getTimestamp() == null) {
+            final Timestamp timestamp = commandWithDto.getTimestamp();
+            commandDto.setTimestamp(JavaSqlTimestampXmlGregorianCalendarAdapter.print(timestamp));
+        }
         final CommandDtoProcessor commandDtoProcessor =
                 metaModelService.commandDtoProcessorFor(commandDto.getMember().getLogicalMemberIdentifier());
         if (commandDtoProcessor == null) {
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixtures/TickingFixtureClock.java b/core/applib/src/main/java/org/apache/isis/applib/fixtures/TickingFixtureClock.java
index ae19ffd..5959b78 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/fixtures/TickingFixtureClock.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixtures/TickingFixtureClock.java
@@ -18,6 +18,7 @@
  */
 package org.apache.isis.applib.fixtures;
 
+import java.sql.Timestamp;
 import java.util.Calendar;
 import java.util.TimeZone;
 
@@ -119,6 +120,10 @@ public class TickingFixtureClock extends Clock {
         t0 = System.currentTimeMillis();
     }
 
+    public void setTime(final Timestamp timestamp) {
+        calendar.setTimeInMillis(timestamp.getTime());
+    }
+
     /**
      * Sets the date, but the time portion is left unchanged.
      *
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
index 49f2524..49e1ef0 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
@@ -104,21 +104,20 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
     private final SudoPolicy sudoPolicy;
 
     /**
-     * Defaults to {@link OnExceptionPolicy#CONTINUE} and {@link SudoPolicy#NO_SWITCH}, the historical defaults
-     * for running background commands.
+     * Defaults to the historical defaults * for running background commands.
      */
     public BackgroundCommandExecution() {
         this(OnExceptionPolicy.CONTINUE, SudoPolicy.NO_SWITCH);
     }
 
-
     public BackgroundCommandExecution(
             final OnExceptionPolicy onExceptionPolicy,
             final SudoPolicy sudoPolicy) {
-        // same as configured by BackgroundServiceDefault
-        mementoService = new MementoServiceDefault().withNoEncoding();
         this.onExceptionPolicy = onExceptionPolicy;
         this.sudoPolicy = sudoPolicy;
+
+        // same as configured by BackgroundServiceDefault
+        mementoService = new MementoServiceDefault().withNoEncoding();
     }
 
     // //////////////////////////////////////
@@ -128,22 +127,22 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
 
         final PersistenceSession persistenceSession = getPersistenceSession();
         final IsisTransactionManager transactionManager = getTransactionManager(persistenceSession);
-        final List<Command> backgroundCommands = Lists.newArrayList();
+        final List<Command> commands = Lists.newArrayList();
         transactionManager.executeWithinTransaction(new TransactionalClosure() {
             @Override
             public void execute() {
-                backgroundCommands.addAll(findBackgroundCommandsToExecute());
+                commands.addAll(findBackgroundCommandsToExecute());
             }
         });
 
-        LOG.debug("{}: Found {} to execute", getClass().getName(), backgroundCommands.size());
+        LOG.debug("{}: Found {} to execute", getClass().getName(), commands.size());
 
-        for (final Command backgroundCommand : backgroundCommands) {
+        for (final Command command : commands) {
 
-            final boolean shouldContinue = execute(transactionManager, backgroundCommand);
+            final boolean shouldContinue = execute(transactionManager, command);
             if(!shouldContinue) {
                 LOG.info("OnExceptionPolicy is to QUIT, so skipping further processing",
-                        backgroundCommand.getMemberIdentifier());
+                        command.getMemberIdentifier());
                 return;
             }
         }
@@ -159,21 +158,21 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
     
     private boolean execute(
             final IsisTransactionManager transactionManager,
-            final Command backgroundCommand) {
+            final Command command) {
 
         try {
-            return executeWithinTran(transactionManager, backgroundCommand);
+            return executeCommandWithinTran(transactionManager, command);
         } catch (final RuntimeException ex) {
 
             // attempting to commit the xactn itself could cause an issue
             // so we need extra exception handling here, it seems.
 
-            org.apache.isis.applib.annotation.Command.ExecuteIn executeIn = backgroundCommand.getExecuteIn();
-            LOG.warn("Exception when committing for: {} {}", executeIn, backgroundCommand.getMemberIdentifier(), ex);
+            org.apache.isis.applib.annotation.Command.ExecuteIn executeIn = command.getExecuteIn();
+            LOG.warn("Exception when committing for: {} {}", executeIn, command.getMemberIdentifier(), ex);
 
             //
             // the previous transaction will have been aborted as part of the recovery handling within
-            // TransactionManager's executeWithinTran
+            // TransactionManager's executeCommandWithinTran
             //
             // we therefore start a new xactn in order to make sure that this background command is marked as a failure
             // so it won't be attempted again.
@@ -184,13 +183,13 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
 
                     final Interaction backgroundInteraction = interactionContext.getInteraction();
                     final Interaction.Execution currentExecution = backgroundInteraction.getCurrentExecution();
-                    backgroundCommand.setStartedAt(
+                    command.setStartedAt(
                             currentExecution != null
                                     ? currentExecution.getStartedAt()
                                     : clockService.nowAsJavaSqlTimestamp());
 
-                    backgroundCommand.setCompletedAt(clockService.nowAsJavaSqlTimestamp());
-                    backgroundCommand.setException(Throwables.getStackTraceAsString(ex));
+                    command.setCompletedAt(clockService.nowAsJavaSqlTimestamp());
+                    command.setException(Throwables.getStackTraceAsString(ex));
                 }
             });
 
@@ -198,48 +197,71 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
         }
     }
 
-    private Boolean executeWithinTran(
+    private Boolean executeCommandWithinTran(
             final IsisTransactionManager transactionManager,
-            final Command backgroundCommand) {
+            final Command command) {
 
         return transactionManager.executeWithinTransaction(
-                backgroundCommand,
+                command,
                 new TransactionalClosureWithReturn<Boolean>() {
             @Override
             public Boolean execute() {
 
-                switch (sudoPolicy) {
-                case NO_SWITCH:
-                    return exec(transactionManager, backgroundCommand);
-                case SWITCH:
-                    final String user = backgroundCommand.getUser();
-                    return sudoService.sudo(user, new Callable<Boolean>() {
-                        @Override
-                        public Boolean call() {
-                            return exec(transactionManager, backgroundCommand);
-                        }
-                    });
-                default:
-                    throw new IllegalStateException("Unrecognized sudoPolicy: " + sudoPolicy);
-                }
+                return executeCommandPerSudoPolicy(transactionManager, command);
             }
         });
     }
 
-    private Boolean exec(final IsisTransactionManager transactionManager, final Command backgroundCommand) {
+    private Boolean executeCommandPerSudoPolicy(
+            final IsisTransactionManager transactionManager,
+            final Command command) {
+
+        switch (sudoPolicy) {
+        case NO_SWITCH:
+            return executeCommand(transactionManager, command);
+        case SWITCH:
+            final String user = command.getUser();
+            return sudoService.sudo(user, new Callable<Boolean>() {
+                @Override
+                public Boolean call() {
+                    return executeCommand(transactionManager, command);
+                }
+            });
+        default:
+            throw new IllegalStateException("Unrecognized sudoPolicy: " + sudoPolicy);
+        }
+    }
+
+    /**
+     * Simply delegates to {@link #doExecuteCommand(IsisTransactionManager, Command)}.
+     *
+     * Overridable, so execution policy can be adjusted if required.
+     */
+    protected Boolean executeCommand(
+            final IsisTransactionManager transactionManager,
+            final Command command) {
+        return doExecuteCommand(transactionManager, command);
+    }
+
+    /**
+     * Not overrideable, but intended to be called by {@link #executeCommand(IsisTransactionManager, Command)} (which is).
+     */
+    protected final Boolean doExecuteCommand(
+            final IsisTransactionManager transactionManager,
+            final Command command) {
 
         // setup for us by IsisTransactionManager; will have the transactionId of the backgroundCommand
         final Interaction backgroundInteraction = interactionContext.getInteraction();
 
-        final String memento = backgroundCommand.getMemento();
+        final String memento = command.getMemento();
 
-        org.apache.isis.applib.annotation.Command.ExecuteIn executeIn = backgroundCommand.getExecuteIn();
+        org.apache.isis.applib.annotation.Command.ExecuteIn executeIn = command.getExecuteIn();
 
-        LOG.info("Executing: {} {}", executeIn, backgroundCommand.getMemberIdentifier());
+        LOG.info("Executing: {} {}", executeIn, command.getMemberIdentifier());
 
         RuntimeException exceptionIfAny = null;
         try {
-            backgroundCommand.setExecutor(Executor.BACKGROUND);
+            command.setExecutor(Executor.BACKGROUND);
 
             // responsibility for setting the Command#startedAt is in the ActionInvocationFacet or
             // PropertySetterFacet, but tthis is run if the domain object was found.  If the domain object is
@@ -256,8 +278,8 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
                             ? priorExecution.getCompletedAt()
                             : clockService.nowAsJavaSqlTimestamp();  // close enough...
 
-            backgroundCommand.setStartedAt(startedAt);
-            backgroundCommand.setCompletedAt(completedAt);
+            command.setStartedAt(startedAt);
+            command.setCompletedAt(completedAt);
 
             final boolean legacy = memento.startsWith("<memento");
             if(legacy) {
@@ -290,7 +312,7 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
 
                 if(resultAdapter != null) {
                     Bookmark resultBookmark = CommandUtil.bookmarkFor(resultAdapter);
-                    backgroundCommand.setResult(resultBookmark);
+                    command.setResult(resultBookmark);
                     backgroundInteraction.getCurrentExecution().setReturned(resultAdapter.getObject());
                 }
 
@@ -333,7 +355,7 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
                         // responsibility of auditing/profiling
                         if(resultAdapter != null) {
                             Bookmark resultBookmark = CommandUtil.bookmarkFor(resultAdapter);
-                            backgroundCommand.setResult(resultBookmark);
+                            command.setResult(resultBookmark);
                         }
                     }
                 } else {
@@ -360,13 +382,13 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
 
         } catch (RuntimeException ex) {
 
-            LOG.warn("Exception for: {} {}", executeIn, backgroundCommand.getMemberIdentifier(), ex);
+            LOG.warn("Exception for: {} {}", executeIn, command.getMemberIdentifier(), ex);
 
             // hmmm, this doesn't really make sense if >1 action
             //
             // in any case, the capturing of the result of the action invocation should be the
             // responsibility of the interaction...
-            backgroundCommand.setException(Throwables.getStackTraceAsString(ex));
+            command.setException(Throwables.getStackTraceAsString(ex));
 
             // lower down the stack the IsisTransactionManager will have set the transaction to abort
             // however, we don't want that to occur (because any changes made to the backgroundCommand itself
@@ -385,7 +407,7 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
                 priorExecution != null
                         ? priorExecution.getCompletedAt()
                         : clockService.nowAsJavaSqlTimestamp();  // close enough...
-        backgroundCommand.setCompletedAt(completedAt);
+        command.setCompletedAt(completedAt);
 
         // if we hit an exception processing this command, then quit if instructed
         return determineIfContinue(exceptionIfAny);

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.