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 2016/04/14 12:11:30 UTC

[21/31] isis git commit: ISIS-1372: also pass the Command through to CommandMementoService#newEventMetadata, and the sequenceName rather than the eventSequence. Also updating javadoc.

ISIS-1372: also pass the Command through to CommandMementoService#newEventMetadata, and the sequenceName rather than the eventSequence.  Also updating javadoc.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/bf26fc39
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/bf26fc39
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/bf26fc39

Branch: refs/heads/ISIS-1291
Commit: bf26fc391fc8cd5db9dd061ce14ce310b4746715
Parents: 3c1f9eb
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Apr 12 20:56:44 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Apr 12 20:56:44 2016 +0100

----------------------------------------------------------------------
 .../isis/applib/services/command/Command.java   | 25 ++++++++++++++++++++
 .../services/command/CommandMementoService.java | 25 +++++++++++++++++---
 .../command/CommandMementoServiceDefault.java   |  7 ++++--
 3 files changed, 52 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/bf26fc39/core/applib/src/main/java/org/apache/isis/applib/services/command/Command.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/command/Command.java b/core/applib/src/main/java/org/apache/isis/applib/services/command/Command.java
index 275e78b..14820a5 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/command/Command.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/command/Command.java
@@ -28,7 +28,32 @@ import org.apache.isis.applib.services.background.BackgroundCommandService;
 import org.apache.isis.applib.services.background.BackgroundService;
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.services.publish.EventMetadata;
+import org.apache.isis.applib.services.publish.EventPayload;
+import org.apache.isis.applib.services.wrapper.WrapperFactory;
 
+/**
+ * Represents either an action or a property edit.
+ *
+ * <p>
+ *     Note that when invoking an action, other actions may be invoked courtesy of the {@link WrapperFactory}.  These
+ *     "sub-actions" do <i>not</i> modify the contents of the command object; in other words think of the command
+ *     object as representing the outer-most originating action.
+ * </p>
+ *
+ * <p>
+ *     One of the responsibilities of the command is to generate unique sequence numbers for a given transactionId.
+ *     This is done by {@link #next(String)}.  There are three possible sequences that might be generated:
+ *     the sequence of changed domain objects being published by the {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)}; the
+ *     sequence of wrapped action invocations (each being published), and finally one or more background commands
+ *     that might be scheduled via the {@link BackgroundService}.
+ * </p>
+ *
+ * <p>
+ *     Known limitation: it isn't, I believe, possible for the outer command to be published and also the inner
+ *     sub-actions; the sub-actions will overwrite the {@link Command#getMemento()} and leave it set to <tt>null</tt>.
+ * </p>
+ */
 public interface Command extends HasTransactionId {
 
     // //////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/isis/blob/bf26fc39/core/applib/src/main/java/org/apache/isis/applib/services/command/CommandMementoService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/command/CommandMementoService.java b/core/applib/src/main/java/org/apache/isis/applib/services/command/CommandMementoService.java
index 3e94f0f..088a5d2 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/command/CommandMementoService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/command/CommandMementoService.java
@@ -22,6 +22,9 @@ import java.sql.Timestamp;
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.background.ActionInvocationMemento;
 import org.apache.isis.applib.services.publish.EventMetadata;
+import org.apache.isis.applib.services.sudo.SudoService;
+import org.apache.isis.applib.services.user.UserService;
+import org.apache.isis.applib.services.wrapper.WrapperFactory;
 import org.apache.isis.schema.aim.v1.ActionInvocationMementoDto;
 
 /**
@@ -45,14 +48,30 @@ public interface CommandMementoService {
     @Programmatic
     ActionInvocationMemento asActionInvocationMemento(Method m, Object domainObject, Object[] args);
 
+    /**
+     *
+     * @param command
+     * @param currentUser - as provided by {@link UserService} (might change within an action if {@link SudoService} has been used).
+     * @param timestamp - as obtained from clock (might want multiple events to all have the same clock, eg publishing muliple changed objects)
+     * @param sequenceName - to create unique events per {@link Command#getTransactionId()}; see {@link EventMetadata#getId()}.
+     */
     @Programmatic
     EventMetadata newEventMetadata(
+            final Command command,
             final String currentUser,
             final Timestamp timestamp,
-            final int eventSequence);
+            final String sequenceName);
 
+    /**
+     * For {@link EventMetadata event}s representing an {@link org.apache.isis.applib.services.publish.EventType#ACTION_INVOCATION action invocation}, converts to an {@link ActionInvocationMementoDto}.
+     *
+     * <p>
+     *     The additional information needed for the {@link ActionInvocationMementoDto DTO} (namely the action arguments and
+     *     result) can be obtained from the thread-local in <tt>ActionInvocationFacet</tt>; this thread-local is reset for
+     *     each action invoked (eg for outer action, or for each sub-action invoked via {@link WrapperFactory}).
+     * </p>
+     */
     @Programmatic
-    ActionInvocationMementoDto asActionInvocationMementoDto(
-            final EventMetadata metadata);
+    ActionInvocationMementoDto asActionInvocationMementoDto(final EventMetadata metadata);
 
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/bf26fc39/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
index b2fd0e7..baefd29 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
@@ -32,6 +32,7 @@ import org.apache.isis.applib.services.background.ActionInvocationMemento;
 import org.apache.isis.applib.services.background.BackgroundCommandService;
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.command.CommandMementoService;
 import org.apache.isis.applib.services.publish.EventMetadata;
 import org.apache.isis.core.commons.ensure.Ensure;
@@ -147,12 +148,14 @@ public class CommandMementoServiceDefault implements CommandMementoService {
 
     @Override
     public EventMetadata newEventMetadata(
-            final String currentUser, final Timestamp timestamp, final int eventSequence) {
+            final Command command,
+            final String currentUser, final Timestamp timestamp, final String sequenceName) {
         throw new RuntimeException("not yet implemented");
     }
 
     @Override
-    public ActionInvocationMementoDto asActionInvocationMementoDto(final EventMetadata metadata) {
+    public ActionInvocationMementoDto asActionInvocationMementoDto(
+            final EventMetadata metadata) {
         throw new RuntimeException("not yet implemented");
     }