CommandLogEntry

A persistent representation of a Command , being the intention to edit a property or invoke an action.Note that this class doesn’t subclass from Command ( Command is not an interface), but it does implement HasCommandDto , providing access to CommandDto , a serialized representation of the Command .

Use cases requiring persistence including auditing, and for replay of commands for regression testing purposes.

API

CommandLogEntry.java
interface CommandLogEntry {
  public final static String LOGICAL_TYPE_NAME;
  public static final String SCHEMA;
  public static final String TABLE;
  static final DateTimeFormatter DATETIME_FORMATTER;
  static final ToString<CommandLogEntry> TOSTRING;
  void sync(Command command)
  void init(CommandDto commandDto, org.apache.causeway.extensions.commandlog.applib.dom.ReplayState replayState, int targetIndex)     (1)
  void copyOver(CommandDto commandDto, String key, Consumer<String> consume)
  String title()
  ChangeType getType()
  UUID getInteractionId()
  void setInteractionId(UUID interactionId)
  String getUsername()
  void setUsername(String userName)
  java.sql.Timestamp getTimestamp()
  void setTimestamp(java.sql.Timestamp timestamp)
  Bookmark getTarget()
  void setTarget(Bookmark target)
  org.apache.causeway.extensions.commandlog.applib.dom.ExecuteIn getExecuteIn()     (2)
  void setExecuteIn(org.apache.causeway.extensions.commandlog.applib.dom.ExecuteIn replayState)
  UUID getParentInteractionId()     (3)
  void setParentInteractionId(UUID parentInteractionId)
  C getParent()
  String getLogicalMemberIdentifier()
  void setLogicalMemberIdentifier(String logicalMemberIdentifier)
  CommandDto getCommandDto()
  void setCommandDto(CommandDto commandDto)
  java.sql.Timestamp getStartedAt()
  void setStartedAt(java.sql.Timestamp startedAt)
  java.sql.Timestamp getCompletedAt()
  void setCompletedAt(java.sql.Timestamp completedAt)
  BigDecimal getDuration()     (4)
  boolean isComplete()
  Bookmark getResult()
  void setResult(Bookmark result)
  String getException()     (5)
  void setException(String exception)
  void setException(Throwable exception)
  String getResultSummary()
  boolean isCausedException()
  org.apache.causeway.extensions.commandlog.applib.dom.ReplayState getReplayState()     (6)
  void setReplayState(org.apache.causeway.extensions.commandlog.applib.dom.ReplayState replayState)
  String getReplayStateFailureReason()     (7)
  void setReplayStateFailureReason(String replayStateFailureReason)
  boolean hideReplayStateFailureReason()
  void saveAnalysis(String analysis)
  int compareTo(CommandLogEntry other)
}
1 init(CommandDto, org_apache_causeway_extensions_commandlog_applib_dom_ReplayState, int)

Intended for use on secondary (replay) system.

2 getExecuteIn()

Whether the command was executed immediately in the current thread of execution, or scheduled to be executed at some time later in a "background" thread of execution.

3 getParentInteractionId()

The interactionId of the parent command, if any.

4 getDuration()

The number of seconds (to 3 decimal places) that this command lasted, derived from * #getStartedAt() and #getCompletedAt() .

5 getException()

Stack trace of any exception that might have occurred if this interaction/transaction aborted.

6 getReplayState()

For a replayed command, what the outcome was.

7 getReplayStateFailureReason()

For a org.apache.causeway.extensions.commandlog.applib.dom.ReplayState#FAILED failed replayed command, what the reason was for the failure.

Members

init(CommandDto, org_apache_causeway_extensions_commandlog_applib_dom_ReplayState, int)

Intended for use on secondary (replay) system.

getExecuteIn()

Whether the command was executed immediately in the current thread of execution, or scheduled to be executed at some time later in a "background" thread of execution.

getParentInteractionId()

The interactionId of the parent command, if any.

We store only the id rather than a reference to the parent, because the org.apache.causeway.extensions.commandlog.applib.subscriber.CommandSubscriberForCommandLog 's callback is only called at the end of the transaction, meaning that the CommandLogEntry of the "parent" will be persisted only after any of its child background CommandLogEntry s are to be persisted (within the body of the underlying action).

getDuration()

The number of seconds (to 3 decimal places) that this command lasted, derived from * #getStartedAt() and #getCompletedAt() .

Populated only if it has #getCompletedAt() completed .

getException()

Stack trace of any exception that might have occurred if this interaction/transaction aborted.

Not part of the applib API, because the default implementation is not persistent and so there’s no object that can be accessed to be annotated.

getReplayState()

For a replayed command, what the outcome was.

getReplayStateFailureReason()

For a org.apache.causeway.extensions.commandlog.applib.dom.ReplayState#FAILED failed replayed command, what the reason was for the failure.