This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch ISIS-2735-command-log in repository https://gitbox.apache.org/repos/asf/isis.git
commit bea28e19a33311357dfda623c8b5805a05f03de5 Author: Dan Haywood <[email protected]> AuthorDate: Tue Sep 21 07:29:03 2021 +0100 ISIS-2735: factoring out PublishedCommandRepositoryAbstract --- .../primary/restapi/CommandRetrievalService.adoc | 6 +- .../primary/ui/CommandReplayOnPrimaryService.adoc | 14 +- .../secondary/mixins/CommandJdo_replayQueue.adoc | 2 +- .../ExposePersistedCommands_commands.java | 2 +- .../dom/PublishedCommandRepositoryAbstract.java} | 155 +++++++++++---------- .../jdo/src/main/java/META-INF/persistence.xml | 2 +- .../commandlog/jdo/CommandSubscriberForJdo.java | 4 +- .../commandlog/jdo/IsisModuleExtCommandLogJdo.java | 6 +- .../entities/PublishedCommandForJdoRepository.java | 55 ++++++++ .../jdo/mixins/HasInteractionId_command.java | 4 +- .../mixins/HasUsername_recentCommandsByUser.java | 4 +- .../jdo/mixins/Object_recentCommands.java | 4 +- .../extensions/commandlog/jdo/mixins/T_recent.java | 4 +- .../commandlog/jdo/ui/CommandServiceMenu.java | 4 +- .../primary/restapi/CommandRetrievalService.java | 7 +- .../primary/spiimpl/CaptureResultOfCommand.java | 15 +- .../primary/ui/CommandReplayOnPrimaryService.java | 7 +- .../secondary/analyser/CommandReplayAnalyser.java | 6 +- .../analyser/CommandReplayAnalyserException.java | 7 +- .../analyser/CommandReplayAnalyserResult.java | 7 +- .../analysis/CommandReplayAnalysisService.java | 11 +- .../secondary/fetch/CommandFetcher.java | 5 +- .../jobcallables/ReplicateAndRunCommands.java | 26 ++-- ..._exclude.java => PublishedCommand_exclude.java} | 18 +-- ...ueue.java => PublishedCommand_replayQueue.java} | 14 +- .../ui/CommandReplayOnSecondaryService.java | 5 +- 26 files changed, 230 insertions(+), 164 deletions(-) diff --git a/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/primary/restapi/CommandRetrievalService.adoc b/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/primary/restapi/CommandRetrievalService.adoc index 689b0ec..da42ac4 100644 --- a/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/primary/restapi/CommandRetrievalService.adoc +++ b/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/primary/restapi/CommandRetrievalService.adoc @@ -8,7 +8,7 @@ ---- class CommandRetrievalService { public static final String LOGICAL_TYPE_NAME; - List<? extends CommandModel> findCommandsOnPrimaryFrom(final UUID interactionId, final Integer batchSize) // <.> + List<PublishedCommand> findCommandsOnPrimaryFrom(final UUID interactionId, final Integer batchSize) // <.> Integer default1FindCommandsOnPrimaryFrom() } ---- @@ -16,7 +16,7 @@ class CommandRetrievalService { <.> xref:#findCommandsOnPrimaryFrom__UUID_Integer[findCommandsOnPrimaryFrom(UUID, Integer)] + -- -These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` +These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` -- == Members @@ -24,4 +24,4 @@ These actions should be called with HTTP Accept Header set to: `application/xml; [#findCommandsOnPrimaryFrom__UUID_Integer] === findCommandsOnPrimaryFrom(UUID, Integer) -These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` +These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` diff --git a/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/primary/ui/CommandReplayOnPrimaryService.adoc b/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/primary/ui/CommandReplayOnPrimaryService.adoc index 53e06ef..60d157b 100644 --- a/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/primary/ui/CommandReplayOnPrimaryService.adoc +++ b/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/primary/ui/CommandReplayOnPrimaryService.adoc @@ -8,7 +8,7 @@ ---- class CommandReplayOnPrimaryService { public static final String LOGICAL_TYPE_NAME; - List<? extends CommandModel> findCommands(final UUID interactionId, final Integer batchSize) // <.> + List<PublishedCommand> findCommands(final UUID interactionId, final Integer batchSize) // <.> Integer default1FindCommandsOnPrimaryFrom() Clob downloadCommands(final UUID interactionId, final Integer batchSize, final String filenamePrefix) // <.> Integer default1DownloadCommands() @@ -21,17 +21,17 @@ class CommandReplayOnPrimaryService { <.> xref:#findCommands__UUID_Integer[findCommands(UUID, Integer)] + -- -These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` +These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` -- <.> xref:#downloadCommands__UUID_Integer_String[downloadCommands(UUID, Integer, String)] + -- -These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` +These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` -- <.> xref:#downloadCommandById__UUID_String[downloadCommandById(UUID, String)] + -- -This action should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandDto"` +This action should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandDto"` -- == Members @@ -39,14 +39,14 @@ This action should be called with HTTP Accept Header set to: `application/xml;pr [#findCommands__UUID_Integer] === findCommands(UUID, Integer) -These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` +These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` [#downloadCommands__UUID_Integer_String] === downloadCommands(UUID, Integer, String) -These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` +These actions should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandsDto"` [#downloadCommandById__UUID_String] === downloadCommandById(UUID, String) -This action should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandDto"` +This action should be called with HTTP Accept Header set to: `application/xml;profile="urn:org.restfulobjects:repr-types/action-result";x-ro-domain-type="org.apache.isis.schema.cmd.v1.CommandDto"` diff --git a/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/secondary/mixins/CommandJdo_replayQueue.adoc b/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/secondary/mixins/CommandJdo_replayQueue.adoc index 822489a..0ed1b41 100644 --- a/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/secondary/mixins/CommandJdo_replayQueue.adoc +++ b/antora/components/refguide-index/modules/extensions/pages/index/commandreplay/secondary/mixins/CommandJdo_replayQueue.adoc @@ -7,7 +7,7 @@ .CommandJdo_replayQueue.java ---- class CommandJdo_replayQueue { - List<? extends CommandModel> coll() + List<PublishedCommand> coll() boolean hideColl() } ---- diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/_commands/ExposePersistedCommands_commands.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/_commands/ExposePersistedCommands_commands.java index f544f65..bc16811 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/_commands/ExposePersistedCommands_commands.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/_commands/ExposePersistedCommands_commands.java @@ -38,7 +38,7 @@ public class ExposePersistedCommands_commands { private final ExposePersistedCommands exposePersistedCommands; //tag::class[] - public List<? extends CommandModel> coll() { + public List<PublishedCommand> coll() { return commandJdoRepository.findCompleted(); } diff --git a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/entities/CommandJdoRepository.java b/extensions/core/command-log/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/PublishedCommandRepositoryAbstract.java similarity index 59% rename from extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/entities/CommandJdoRepository.java rename to extensions/core/command-log/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/PublishedCommandRepositoryAbstract.java index 3b1e60c..0b9c81a 100644 --- a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/entities/CommandJdoRepository.java +++ b/extensions/core/command-log/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/PublishedCommandRepositoryAbstract.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.isis.extensions.commandlog.jdo.entities; +package org.apache.isis.extensions.commandlog.applib.dom; import java.sql.Timestamp; import java.time.Instant; @@ -28,14 +28,12 @@ import java.util.List; import java.util.Optional; import java.util.UUID; -import org.springframework.lang.Nullable; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; -import org.apache.isis.applib.annotation.PriorityPrecedence; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; +import org.springframework.lang.Nullable; +import org.springframework.stereotype.Repository; import org.apache.isis.applib.annotation.Programmatic; import org.apache.isis.applib.jaxb.JavaSqlXMLGregorianCalendarMarshalling; @@ -45,91 +43,92 @@ import org.apache.isis.applib.services.bookmark.Bookmark; import org.apache.isis.applib.services.iactn.InteractionProvider; import org.apache.isis.applib.services.repository.RepositoryService; import org.apache.isis.applib.util.schema.CommandDtoUtils; -import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommandRepository; -import org.apache.isis.extensions.commandlog.applib.dom.ReplayState; -import org.apache.isis.persistence.jdo.applib.services.JdoSupportService; +import org.apache.isis.commons.internal.base._Casts; import org.apache.isis.schema.cmd.v2.CommandDto; import org.apache.isis.schema.cmd.v2.CommandsDto; import org.apache.isis.schema.cmd.v2.MapDto; import org.apache.isis.schema.common.v2.InteractionType; import org.apache.isis.schema.common.v2.OidDto; -import lombok.RequiredArgsConstructor; import lombok.val; /** * Provides supporting functionality for querying and persisting - * {@link PublishedCommandForJdo command} entities. + * {@link PublishedCommand command} entities. */ -@Service -@Named("isis.ext.commandLog.CommandJdoRepository") [email protected](PriorityPrecedence.MIDPOINT) -@Qualifier("Jdo") -@RequiredArgsConstructor -//@Log4j2 -public class CommandJdoRepository -implements PublishedCommandRepository<PublishedCommandForJdo> { - - @Inject final Provider<InteractionProvider> interactionProviderProvider; - @Inject final Provider<RepositoryService> repositoryServiceProvider; - @Inject final JdoSupportService jdoSupport; +@Repository +@Named("isis.ext.commandLog.PublishedCommandRepository") +public abstract class PublishedCommandRepositoryAbstract<PC extends PublishedCommand> +implements PublishedCommandRepository { + + private final Class<PC> publishedCommandClass; + + @Inject Provider<InteractionProvider> interactionProviderProvider; + @Inject Provider<RepositoryService> repositoryServiceProvider; + + protected PublishedCommandRepositoryAbstract( + final Class<PC> publishedCommandClass) { + this.publishedCommandClass = publishedCommandClass; + } @Override - public List<PublishedCommandForJdo> findByFromAndTo( + public List<PublishedCommand> findByFromAndTo( final @Nullable LocalDate from, final @Nullable LocalDate to) { final Timestamp fromTs = toTimestampStartOfDayWithOffset(from, 0); final Timestamp toTs = toTimestampStartOfDayWithOffset(to, 1); - final Query<PublishedCommandForJdo> query; + final Query<PC> query; if(from != null) { if(to != null) { - query = Query.named(PublishedCommandForJdo.class, "findByTimestampBetween") + query = Query.named(publishedCommandClass, "findByTimestampBetween") .withParameter("from", fromTs) .withParameter("to", toTs); } else { - query = Query.named(PublishedCommandForJdo.class, "findByTimestampAfter") + query = Query.named(publishedCommandClass, "findByTimestampAfter") .withParameter("from", fromTs); } } else { if(to != null) { - query = Query.named(PublishedCommandForJdo.class, "findByTimestampBefore") + query = Query.named(publishedCommandClass, "findByTimestampBefore") .withParameter("to", toTs); } else { - query = Query.named(PublishedCommandForJdo.class, "find"); + query = Query.named(publishedCommandClass, "find"); } } - return repositoryService().allMatches(query); + return _Casts.uncheckedCast( + repositoryService().allMatches(query)); } @Override - public Optional<PublishedCommandForJdo> findByInteractionId(final UUID interactionId) { - return repositoryService().firstMatch( - Query.named(PublishedCommandForJdo.class, "findByInteractionIdStr") - .withParameter("interactionIdStr", interactionId.toString())); + public Optional<PublishedCommand> findByInteractionId(final UUID interactionId) { + return _Casts.uncheckedCast( + repositoryService().firstMatch( + Query.named(publishedCommandClass, "findByInteractionIdStr") + .withParameter("interactionIdStr", interactionId.toString()))); } @Override - public List<PublishedCommandForJdo> findByParent(final CommandModel parent) { + public List<PublishedCommand> findByParent(final PublishedCommand parent) { return repositoryService().allMatches( - Query.named(PublishedCommandForJdo.class, "findByParent") + Query.named(publishedCommandClass, "findByParent") .withParameter("parent", parent)); } @Override - public List<PublishedCommandForJdo> findCurrent() { + public List<PublishedCommand> findCurrent() { return repositoryService().allMatches( - Query.named(PublishedCommandForJdo.class, "findCurrent")); + Query.named(publishedCommandClass, "findCurrent")); } @Override - public List<PublishedCommandForJdo> findCompleted() { + public List<PublishedCommand> findCompleted() { return repositoryService().allMatches( - Query.named(PublishedCommandForJdo.class, "findCompleted")); + Query.named(publishedCommandClass, "findCompleted")); } @Override - public List<PublishedCommandForJdo> findByTargetAndFromAndTo( + public List<PublishedCommand> findByTargetAndFromAndTo( final Bookmark target, final @Nullable LocalDate from, final @Nullable LocalDate to) { @@ -137,25 +136,25 @@ implements PublishedCommandRepository<PublishedCommandForJdo> { final Timestamp fromTs = toTimestampStartOfDayWithOffset(from, 0); final Timestamp toTs = toTimestampStartOfDayWithOffset(to, 1); - final Query<PublishedCommandForJdo> query; + final Query<PublishedCommand> query; if(from != null) { if(to != null) { - query = Query.named(PublishedCommandForJdo.class, "findByTargetAndTimestampBetween") + query = Query.named(publishedCommandClass, "findByTargetAndTimestampBetween") .withParameter("target", target) .withParameter("from", fromTs) .withParameter("to", toTs); } else { - query = Query.named(PublishedCommandForJdo.class, "findByTargetAndTimestampAfter") + query = Query.named(publishedCommandClass, "findByTargetAndTimestampAfter") .withParameter("target", target) .withParameter("from", fromTs); } } else { if(to != null) { - query = Query.named(PublishedCommandForJdo.class, "findByTargetAndTimestampBefore") + query = Query.named(publishedCommandClass, "findByTargetAndTimestampBefore") .withParameter("target", target) .withParameter("to", toTs); } else { - query = Query.named(PublishedCommandForJdo.class, "findByTarget") + query = Query.named(publishedCommandClass, "findByTarget") .withParameter("target", target); } } @@ -167,58 +166,58 @@ implements PublishedCommandRepository<PublishedCommandForJdo> { final int daysOffset) { return dt!=null - ? new java.sql.Timestamp( + ? new Timestamp( Instant.from(dt.atStartOfDay().plusDays(daysOffset).atZone(ZoneId.systemDefault())) .toEpochMilli()) : null; } @Override - public List<PublishedCommandForJdo> findRecentByUsername(final String username) { + public List<PublishedCommand> findRecentByUsername(final String username) { return repositoryService().allMatches( - Query.named(PublishedCommandForJdo.class, "findRecentByUsername") + Query.named(publishedCommandClass, "findRecentByUsername") .withParameter("username", username)); } @Override - public List<PublishedCommandForJdo> findRecentByTarget(final Bookmark target) { + public List<PublishedCommand> findRecentByTarget(final Bookmark target) { return repositoryService().allMatches( - Query.named(PublishedCommandForJdo.class, "findRecentByTarget") + Query.named(publishedCommandClass, "findRecentByTarget") .withParameter("target", target)); } @Override - public List<PublishedCommandForJdo> findSince(final UUID interactionId, final Integer batchSize) { + public List<PublishedCommand> findSince(final UUID interactionId, final Integer batchSize) { if(interactionId == null) { return findFirst(); } - final PublishedCommandForJdo from = findByInteractionIdElseNull(interactionId); + final PublishedCommand from = findByInteractionIdElseNull(interactionId); if(from == null) { return Collections.emptyList(); } return findSince(from.getTimestamp(), batchSize); } - private List<PublishedCommandForJdo> findFirst() { - Optional<PublishedCommandForJdo> firstCommandIfAny = repositoryService().firstMatch( - Query.named(PublishedCommandForJdo.class, "findFirst")); + private List<PublishedCommand> findFirst() { + Optional<PublishedCommand> firstCommandIfAny = repositoryService().firstMatch( + Query.named(publishedCommandClass, "findFirst")); return firstCommandIfAny .map(Collections::singletonList) .orElse(Collections.emptyList()); } - private PublishedCommandForJdo findByInteractionIdElseNull(final UUID interactionId) { - val tsq = jdoSupport.newTypesafeQuery(PublishedCommandForJdo.class); + private PublishedCommand findByInteractionIdElseNull(final UUID interactionId) { + val tsq = jdoSupport.newTypesafeQuery(publishedCommandClass); val cand = QCommandJdo.candidate(); val q = tsq.filter( - cand.interactionIdStr.eq(tsq.parameter("interactionIdStr", String.class)) + cand.interactionIdStr.eq(tsq.parameter("interactionId", String.class)) ); - q.setParameter("interactionIdStr", interactionId.toString()); + q.setParameter("interactionId", interactionId); return q.executeUnique(); } - private List<PublishedCommandForJdo> findSince( + private List<PublishedCommand> findSince( final Timestamp timestamp, final Integer batchSize) { @@ -226,13 +225,13 @@ implements PublishedCommandRepository<PublishedCommandForJdo> { // XXX that's a historic workaround, should rather be fixed upstream val needsTrimFix = batchSize != null && batchSize == 1; - val q = Query.named(PublishedCommandForJdo.class, "findSince") + val q = Query.named(publishedCommandClass, "findSince") .withParameter("timestamp", timestamp) .withRange(QueryRange.limit( needsTrimFix ? 2L : batchSize )); - final List<PublishedCommandForJdo> publishedCommands = repositoryService().allMatches(q); + final List<PublishedCommand> publishedCommands = repositoryService().allMatches(q); return needsTrimFix && publishedCommands.size() > 1 ? publishedCommands.subList(0,1) : publishedCommands; @@ -240,34 +239,34 @@ implements PublishedCommandRepository<PublishedCommandForJdo> { @Override - public Optional<PublishedCommandForJdo> findMostRecentReplayed() { + public Optional<PublishedCommand> findMostRecentReplayed() { return repositoryService().firstMatch( - Query.named(PublishedCommandForJdo.class, "findMostRecentReplayed")); + Query.named(publishedCommandClass, "findMostRecentReplayed")); } @Override - public Optional<PublishedCommandForJdo> findMostRecentCompleted() { + public Optional<PublishedCommand> findMostRecentCompleted() { return repositoryService().firstMatch( - Query.named(PublishedCommandForJdo.class, "findMostRecentCompleted")); + Query.named(publishedCommandClass, "findMostRecentCompleted")); } @Override - public List<PublishedCommandForJdo> findNotYetReplayed() { + public List<PublishedCommand> findNotYetReplayed() { return repositoryService().allMatches( - Query.named(PublishedCommandForJdo.class, "findNotYetReplayed")); + Query.named(publishedCommandClass, "findNotYetReplayed")); } @Override - public List<PublishedCommandForJdo> findReplayedOnSecondary() { + public List<PublishedCommand> findReplayedOnSecondary() { return repositoryService().allMatches( - Query.named(PublishedCommandForJdo.class, "findReplayableMostRecentStarted")); + Query.named(publishedCommandClass, "findReplayableMostRecentStarted")); } @Override - public List<PublishedCommandForJdo> saveForReplay(final CommandsDto commandsDto) { + public List<PublishedCommand> saveForReplay(final CommandsDto commandsDto) { List<CommandDto> commandDto = commandsDto.getCommandDto(); - List<PublishedCommandForJdo> commands = new ArrayList<>(); + List<PublishedCommand> commands = new ArrayList<>(); for (final CommandDto dto : commandDto) { commands.add(saveForReplay(dto)); } @@ -276,7 +275,7 @@ implements PublishedCommandRepository<PublishedCommandForJdo> { @Programmatic @Override - public PublishedCommandForJdo saveForReplay(final CommandDto dto) { + public PublishedCommand saveForReplay(final CommandDto dto) { if(dto.getMember().getInteractionType() == InteractionType.ACTION_INVOCATION) { final MapDto userData = dto.getUserData(); @@ -287,9 +286,9 @@ implements PublishedCommandRepository<PublishedCommandForJdo> { } } - final PublishedCommandForJdo publishedCommand = new PublishedCommandForJdo(); + final PublishedCommand publishedCommand = newPublishedCommand(); - publishedCommand.setInteractionIdStr(dto.getInteractionId()); + publishedCommand.setInteractionId(UUID.fromString(dto.getInteractionId())); publishedCommand.setTimestamp(JavaSqlXMLGregorianCalendarMarshalling.toTimestamp(dto.getTimestamp())); publishedCommand.setUsername(dto.getUser()); @@ -305,14 +304,16 @@ implements PublishedCommandRepository<PublishedCommandForJdo> { return publishedCommand; } + protected abstract PublishedCommand newPublishedCommand(); + @Override - public void persist(final PublishedCommandForJdo publishedCommand) { + public void persist(final PublishedCommand publishedCommand) { repositoryService().persist(publishedCommand); } @Override public void truncateLog() { - repositoryService().removeAll(PublishedCommandForJdo.class); + repositoryService().removeAll(PublishedCommand.class); } private RepositoryService repositoryService() { diff --git a/extensions/core/command-log/jdo/src/main/java/META-INF/persistence.xml b/extensions/core/command-log/jdo/src/main/java/META-INF/persistence.xml index 7719606..9a6b5df 100644 --- a/extensions/core/command-log/jdo/src/main/java/META-INF/persistence.xml +++ b/extensions/core/command-log/jdo/src/main/java/META-INF/persistence.xml @@ -14,6 +14,6 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="org-apache-isis-extensions-commandlog"> - <class>org.apache.isis.extensions.commandlog.jdo.entities.CommandModel</class> + <class>org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdo</class> </persistence-unit> </persistence> diff --git a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/CommandSubscriberForJdo.java b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/CommandSubscriberForJdo.java index f3ab1d2..13a9e24 100644 --- a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/CommandSubscriberForJdo.java +++ b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/CommandSubscriberForJdo.java @@ -29,7 +29,7 @@ import org.apache.isis.applib.services.command.Command; import org.apache.isis.applib.services.publishing.spi.CommandSubscriber; import org.apache.isis.applib.util.JaxbUtil; import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdo; -import org.apache.isis.extensions.commandlog.jdo.entities.CommandJdoRepository; +import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdoRepository; import lombok.RequiredArgsConstructor; import lombok.val; @@ -46,7 +46,7 @@ import lombok.extern.log4j.Log4j2; @RequiredArgsConstructor public class CommandSubscriberForJdo implements CommandSubscriber { - @Inject final CommandJdoRepository commandJdoRepository; + @Inject final PublishedCommandForJdoRepository commandJdoRepository; @Override public void onCompleted(Command command) { diff --git a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/IsisModuleExtCommandLogJdo.java b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/IsisModuleExtCommandLogJdo.java index 9b2911e..2a06374 100644 --- a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/IsisModuleExtCommandLogJdo.java +++ b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/IsisModuleExtCommandLogJdo.java @@ -23,7 +23,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdo; -import org.apache.isis.extensions.commandlog.jdo.entities.CommandJdoRepository; +import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdoRepository; import org.apache.isis.extensions.commandlog.jdo.ui.CommandServiceMenu; import org.apache.isis.extensions.commandlog.applib.IsisModuleExtCommandLogApplib; import org.apache.isis.testing.fixtures.applib.fixturescripts.FixtureScript; @@ -35,7 +35,7 @@ import org.apache.isis.testing.fixtures.applib.teardown.jdo.TeardownFixtureJdoAb @Configuration @Import({ // @DomainService's - CommandJdoRepository.class + PublishedCommandForJdoRepository.class , CommandServiceMenu.class // @Service's @@ -61,7 +61,7 @@ implements IsisModuleExtCommandLogApplib { return new TeardownFixtureJdoAbstract() { @Override protected void execute(final ExecutionContext executionContext) { - deleteFrom(CommandModel.class); + deleteFrom(PublishedCommandForJdo.class); } }; } diff --git a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/entities/PublishedCommandForJdoRepository.java b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/entities/PublishedCommandForJdoRepository.java new file mode 100644 index 0000000..e049961 --- /dev/null +++ b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/entities/PublishedCommandForJdoRepository.java @@ -0,0 +1,55 @@ +/* + * 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.extensions.commandlog.jdo.entities; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.isis.applib.annotation.PriorityPrecedence; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommandRepositoryAbstract; +import org.apache.isis.persistence.jdo.applib.services.JdoSupportService; + +import lombok.RequiredArgsConstructor; + +/** + * Provides supporting functionality for querying and persisting + * {@link PublishedCommandForJdo command} entities. + */ +@Service +@Named("isis.ext.commandLog.PublishedCommandRepository") [email protected](PriorityPrecedence.MIDPOINT) +@Qualifier("Jdo") +public class PublishedCommandForJdoRepository +extends PublishedCommandRepositoryAbstract<PublishedCommandForJdo> { + + @Inject JdoSupportService jdoSupport; + + public PublishedCommandForJdoRepository() { + super(PublishedCommandForJdo.class); + } + + + @Override protected PublishedCommand newPublishedCommand() { + return new PublishedCommandForJdo(); + } +} diff --git a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/HasInteractionId_command.java b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/HasInteractionId_command.java index feb4fcc..da0213f 100644 --- a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/HasInteractionId_command.java +++ b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/HasInteractionId_command.java @@ -29,7 +29,7 @@ import org.apache.isis.applib.mixins.system.HasInteractionId; import org.apache.isis.applib.services.command.Command; import org.apache.isis.extensions.commandlog.jdo.IsisModuleExtCommandLogJdo; import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdo; -import org.apache.isis.extensions.commandlog.jdo.entities.CommandJdoRepository; +import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdoRepository; import lombok.RequiredArgsConstructor; @@ -75,5 +75,5 @@ public class HasInteractionId_command { .orElse(null); } - @Inject CommandJdoRepository commandServiceRepository; + @Inject PublishedCommandForJdoRepository commandServiceRepository; } diff --git a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/HasUsername_recentCommandsByUser.java b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/HasUsername_recentCommandsByUser.java index cb59296..2de12bf 100644 --- a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/HasUsername_recentCommandsByUser.java +++ b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/HasUsername_recentCommandsByUser.java @@ -28,7 +28,7 @@ import org.apache.isis.applib.annotation.CollectionLayout; import org.apache.isis.applib.mixins.security.HasUsername; import org.apache.isis.extensions.commandlog.jdo.IsisModuleExtCommandLogJdo; import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdo; -import org.apache.isis.extensions.commandlog.jdo.entities.CommandJdoRepository; +import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdoRepository; /** @@ -61,5 +61,5 @@ public class HasUsername_recentCommandsByUser { return hasUsername.getUsername() == null; } - @Inject CommandJdoRepository commandServiceRepository; + @Inject PublishedCommandForJdoRepository commandServiceRepository; } diff --git a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/Object_recentCommands.java b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/Object_recentCommands.java index 85a4401..16ad916 100644 --- a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/Object_recentCommands.java +++ b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/Object_recentCommands.java @@ -34,7 +34,7 @@ import org.apache.isis.applib.mixins.system.HasInteractionId; import org.apache.isis.applib.services.bookmark.BookmarkService; import org.apache.isis.extensions.commandlog.jdo.IsisModuleExtCommandLogJdo; import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdo; -import org.apache.isis.extensions.commandlog.jdo.entities.CommandJdoRepository; +import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdoRepository; import lombok.RequiredArgsConstructor; @@ -79,7 +79,7 @@ public class Object_recentCommands { return (domainObject instanceof HasInteractionId); } - @Inject CommandJdoRepository commandServiceRepository; + @Inject PublishedCommandForJdoRepository commandServiceRepository; @Inject BookmarkService bookmarkService; } diff --git a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/T_recent.java b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/T_recent.java index 7b90bf7..128e914 100644 --- a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/T_recent.java +++ b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/mixins/T_recent.java @@ -29,7 +29,7 @@ import org.apache.isis.applib.services.bookmark.BookmarkService; import org.apache.isis.applib.services.queryresultscache.QueryResultsCache; import org.apache.isis.extensions.commandlog.jdo.IsisModuleExtCommandLogJdo; import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdo; -import org.apache.isis.extensions.commandlog.jdo.entities.CommandJdoRepository; +import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdoRepository; @Collection( domainEvent = T_recent.CollectionDomainEvent.class @@ -61,7 +61,7 @@ public abstract class T_recent<T> { .orElse(Collections.emptyList()); } - @Inject CommandJdoRepository commandJdoRepository; + @Inject PublishedCommandForJdoRepository commandJdoRepository; @Inject BookmarkService bookmarkService; @Inject QueryResultsCache queryResultsCache; diff --git a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/ui/CommandServiceMenu.java b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/ui/CommandServiceMenu.java index 2c3d511..e50a186 100644 --- a/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/ui/CommandServiceMenu.java +++ b/extensions/core/command-log/jdo/src/main/java/org/apache/isis/extensions/commandlog/jdo/ui/CommandServiceMenu.java @@ -44,7 +44,7 @@ import org.apache.isis.applib.annotation.SemanticsOf; import org.apache.isis.applib.services.clock.ClockService; import org.apache.isis.extensions.commandlog.jdo.IsisModuleExtCommandLogJdo; import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdo; -import org.apache.isis.extensions.commandlog.jdo.entities.CommandJdoRepository; +import org.apache.isis.extensions.commandlog.jdo.entities.PublishedCommandForJdoRepository; import lombok.RequiredArgsConstructor; @@ -75,7 +75,7 @@ public class CommandServiceMenu { extends IsisModuleExtCommandLogJdo.ActionDomainEvent<CommandServiceMenu> { } - final CommandJdoRepository commandServiceRepository; + final PublishedCommandForJdoRepository commandServiceRepository; final ClockService clockService; public static class ActiveCommandsDomainEvent extends ActionDomainEvent { } diff --git a/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/restapi/CommandRetrievalService.java b/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/restapi/CommandRetrievalService.java index 1c129f9..73bb01e 100644 --- a/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/restapi/CommandRetrievalService.java +++ b/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/restapi/CommandRetrievalService.java @@ -28,6 +28,7 @@ import javax.inject.Named; import org.apache.isis.applib.annotation.*; import org.apache.isis.applib.annotation.PriorityPrecedence; import org.apache.isis.applib.exceptions.RecoverableException; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommandRepository; import org.apache.isis.extensions.commandreplay.primary.IsisModuleExtCommandReplayPrimary; @@ -69,7 +70,7 @@ public class CommandRetrievalService { * @throws NotFoundException - if the command with specified transaction cannot be found. */ @Action(domainEvent = FindCommandsOnPrimaryFromDomainEvent.class, semantics = SemanticsOf.SAFE) - public List<? extends CommandModel> findCommandsOnPrimaryFrom( + public List<PublishedCommand> findCommandsOnPrimaryFrom( @Nullable @ParameterLayout(named="Interaction Id") final UUID interactionId, @@ -77,7 +78,7 @@ public class CommandRetrievalService { @ParameterLayout(named="Batch size") final Integer batchSize) throws NotFoundException { - final List<? extends CommandModel> commands = publishedCommandRepository.findSince(interactionId, batchSize); + final List<PublishedCommand> commands = publishedCommandRepository.findSince(interactionId, batchSize); if(commands == null) { throw new NotFoundException(interactionId); } @@ -88,6 +89,6 @@ public class CommandRetrievalService { } @Inject - PublishedCommandRepository<? extends CommandModel> publishedCommandRepository; + PublishedCommandRepository publishedCommandRepository; } diff --git a/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/spiimpl/CaptureResultOfCommand.java b/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/spiimpl/CaptureResultOfCommand.java index fd53083..66e9b49 100644 --- a/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/spiimpl/CaptureResultOfCommand.java +++ b/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/spiimpl/CaptureResultOfCommand.java @@ -29,6 +29,7 @@ import org.apache.isis.applib.services.command.Command; import org.apache.isis.applib.services.commanddto.conmap.UserDataKeys; import org.apache.isis.applib.services.commanddto.processor.spi.CommandDtoProcessorService; import org.apache.isis.applib.util.schema.CommandDtoUtils; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.schema.cmd.v2.CommandDto; import lombok.val; @@ -50,16 +51,16 @@ public class CaptureResultOfCommand implements CommandDtoProcessorService { @Override public CommandDto process(final Object domainObject, CommandDto commandDto) { - if (!(domainObject instanceof CommandModel)) { + if (!(domainObject instanceof PublishedCommand)) { return commandDto; } - val commandModel = (CommandModel) domainObject; + val publishedCommand = (PublishedCommand) domainObject; if(commandDto == null) { - commandDto = commandModel.getCommandDto(); + commandDto = publishedCommand.getCommandDto(); } - final Bookmark result = commandModel.getResult(); + final Bookmark result = publishedCommand.getResult(); CommandDtoUtils.setUserData(commandDto, UserDataKeys.RESULT, result); // knowing whether there was an exception is on the primary is @@ -67,11 +68,11 @@ public class CaptureResultOfCommand implements CommandDtoProcessorService { // secondary if an exception occurs there also CommandDtoUtils.setUserData(commandDto, UserDataKeys.EXCEPTION, - commandModel.getException()); + publishedCommand.getException()); val timings = CommandDtoUtils.timingsFor(commandDto); - timings.setStartedAt(JavaSqlXMLGregorianCalendarMarshalling.toXMLGregorianCalendar(commandModel.getStartedAt())); - timings.setCompletedAt(JavaSqlXMLGregorianCalendarMarshalling.toXMLGregorianCalendar(commandModel.getCompletedAt())); + timings.setStartedAt(JavaSqlXMLGregorianCalendarMarshalling.toXMLGregorianCalendar(publishedCommand.getStartedAt())); + timings.setCompletedAt(JavaSqlXMLGregorianCalendarMarshalling.toXMLGregorianCalendar(publishedCommand.getCompletedAt())); return commandDto; } diff --git a/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/ui/CommandReplayOnPrimaryService.java b/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/ui/CommandReplayOnPrimaryService.java index 6508a86..13c911f 100644 --- a/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/ui/CommandReplayOnPrimaryService.java +++ b/extensions/core/command-replay/primary/src/main/java/org/apache/isis/extensions/commandreplay/primary/ui/CommandReplayOnPrimaryService.java @@ -40,6 +40,7 @@ import org.apache.isis.applib.services.commanddto.conmap.ContentMappingServiceFo import org.apache.isis.applib.services.jaxb.JaxbService; import org.apache.isis.applib.services.message.MessageService; import org.apache.isis.applib.value.Clob; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommandRepository; import org.apache.isis.extensions.commandreplay.primary.IsisModuleExtCommandReplayPrimary; import org.apache.isis.extensions.commandreplay.primary.restapi.CommandRetrievalService; @@ -68,7 +69,7 @@ public class CommandReplayOnPrimaryService { public static final String LOGICAL_TYPE_NAME = IsisModuleExtCommandReplayPrimary.NAMESPACE + ".CommandReplayOnPrimaryService"; - @Inject final PublishedCommandRepository<? extends CommandModel> publishedCommandRepository; + @Inject final PublishedCommandRepository publishedCommandRepository; @Inject final JaxbService jaxbService; @Inject final MessageService messageService; @Inject final ContentMappingServiceForCommandsDto contentMappingServiceForCommandsDto; @@ -101,7 +102,7 @@ public class CommandReplayOnPrimaryService { * @param batchSize - the maximum number of commands to return. If not specified, all found will be returned. * @throws NotFoundException - if the command with specified transaction cannot be found. */ - @MemberSupport public List<? extends CommandModel> act( + @MemberSupport public List<PublishedCommand> act( @Nullable @ParameterLayout(named="Interaction Id") final UUID interactionId, @@ -140,7 +141,7 @@ public class CommandReplayOnPrimaryService { @Nullable final Integer batchSize, final String filenamePrefix) { - final List<? extends CommandModel> commands = publishedCommandRepository.findSince(interactionId, batchSize); + final List<PublishedCommand> commands = publishedCommandRepository.findSince(interactionId, batchSize); if(commands == null) { messageService.informUser("No commands found"); } diff --git a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyser.java b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyser.java index 4d6a0fe..72e7d2a 100644 --- a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyser.java +++ b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyser.java @@ -18,6 +18,8 @@ */ package org.apache.isis.extensions.commandreplay.secondary.analyser; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; + /** * @since 2.0 {@index} */ @@ -25,9 +27,9 @@ public interface CommandReplayAnalyser { /** * - * @param commandJdo + * @param publishedCommand * @return - if not <code>null</code>, indicates the reason that there was an issue replaying the command. */ - String analyzeReplay(final CommandModel commandJdo); + String analyzeReplay(final PublishedCommand publishedCommand); } diff --git a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyserException.java b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyserException.java index e0c6ed3..ac3e09a 100644 --- a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyserException.java +++ b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyserException.java @@ -30,6 +30,7 @@ import org.apache.isis.applib.services.commanddto.conmap.UserDataKeys; import org.apache.isis.applib.util.schema.CommandDtoUtils; import org.apache.isis.commons.internal.base._Strings; import org.apache.isis.core.config.IsisConfiguration; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.schema.common.v2.InteractionType; import lombok.RequiredArgsConstructor; @@ -53,12 +54,12 @@ public class CommandReplayAnalyserException implements CommandReplayAnalyser { } @Override - public String analyzeReplay(final CommandModel commandModel) { + public String analyzeReplay(final PublishedCommand publishedCommand) { if(!enabled) { return null; } - val dto = commandModel.getCommandDto(); + val dto = publishedCommand.getCommandDto(); if(dto.getMember().getInteractionType() == InteractionType.PROPERTY_EDIT) { return null; } @@ -68,7 +69,7 @@ public class CommandReplayAnalyserException implements CommandReplayAnalyser { return null; } - val replayedException = commandModel.getException(); + val replayedException = publishedCommand.getException(); val primaryExceptionTrimmed = trimmed(primaryException); val replayedExceptionTrimmed = trimmed(replayedException); diff --git a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyserResult.java b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyserResult.java index ad94192..7dd2516 100644 --- a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyserResult.java +++ b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analyser/CommandReplayAnalyserResult.java @@ -29,6 +29,7 @@ import org.springframework.stereotype.Service; import org.apache.isis.applib.services.commanddto.conmap.UserDataKeys; import org.apache.isis.applib.util.schema.CommandDtoUtils; import org.apache.isis.core.config.IsisConfiguration; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.schema.common.v2.InteractionType; import lombok.RequiredArgsConstructor; @@ -52,12 +53,12 @@ public class CommandReplayAnalyserResult implements CommandReplayAnalyser { } @Override - public String analyzeReplay(final CommandModel commandModel) { + public String analyzeReplay(final PublishedCommand publishedCommand) { if(!enabled) { return null; } - val dto = commandModel.getCommandDto(); + val dto = publishedCommand.getCommandDto(); if(dto.getMember().getInteractionType() == InteractionType.PROPERTY_EDIT) { return null; } @@ -66,7 +67,7 @@ public class CommandReplayAnalyserResult implements CommandReplayAnalyser { // ... either the same result when replayed val primaryResultStr = CommandDtoUtils.getUserData(dto, UserDataKeys.RESULT); - val secondaryResult = commandModel.getResult(); + val secondaryResult = publishedCommand.getResult(); val secondaryResultStr = secondaryResult != null ? secondaryResult.toString() : null; return Objects.equals(primaryResultStr, secondaryResultStr) diff --git a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analysis/CommandReplayAnalysisService.java b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analysis/CommandReplayAnalysisService.java index 6679cd0..ea2e678 100644 --- a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analysis/CommandReplayAnalysisService.java +++ b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/analysis/CommandReplayAnalysisService.java @@ -26,6 +26,7 @@ import javax.inject.Named; import org.apache.isis.applib.annotation.PriorityPrecedence; import org.springframework.stereotype.Service; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.extensions.commandreplay.secondary.analyser.CommandReplayAnalyser; import lombok.extern.log4j.Log4j2; @@ -44,17 +45,17 @@ public class CommandReplayAnalysisService { * as in error. * This will effectively block the running of any further commands until the administrator fixes the issue. */ - public void analyse(final CommandModel commandModel) { - final String analysis = analyseReplay(commandModel); + public void analyse(final PublishedCommand publishedCommand) { + final String analysis = analyseReplay(publishedCommand); - commandModel.saveAnalysis(analysis); + publishedCommand.saveAnalysis(analysis); } - private String analyseReplay(final CommandModel commandJdo) { + private String analyseReplay(final PublishedCommand publishedCommand) { for (final CommandReplayAnalyser analyser : analysers) { try { - String reason = analyser.analyzeReplay(commandJdo); + String reason = analyser.analyzeReplay(publishedCommand); if (reason != null) { return reason; } diff --git a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/fetch/CommandFetcher.java b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/fetch/CommandFetcher.java index 316892a..2a1c0a8 100644 --- a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/fetch/CommandFetcher.java +++ b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/fetch/CommandFetcher.java @@ -34,6 +34,7 @@ import org.springframework.stereotype.Service; import org.apache.isis.applib.services.jaxb.JaxbService; import org.apache.isis.applib.services.jaxb.JaxbService.Simple; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.extensions.commandreplay.secondary.SecondaryStatus; import org.apache.isis.extensions.commandreplay.secondary.StatusException; import org.apache.isis.extensions.commandreplay.secondary.config.SecondaryConfig; @@ -66,7 +67,7 @@ public class CommandFetcher { * @throws StatusException */ public List<CommandDto> fetchCommand( - final @Nullable CommandModel previousHwmIfAny) + final @Nullable PublishedCommand previousHwmIfAny) throws StatusException { log.debug("finding command on primary ..."); @@ -82,7 +83,7 @@ public class CommandFetcher { * @param previousHwmIfAny * @throws StatusException */ - private CommandsDto fetchCommands(final CommandModel previousHwmIfAny) + private CommandsDto fetchCommands(final PublishedCommand previousHwmIfAny) throws StatusException { final UUID transactionId = previousHwmIfAny != null ? previousHwmIfAny.getInteractionId() : null; diff --git a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/jobcallables/ReplicateAndRunCommands.java b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/jobcallables/ReplicateAndRunCommands.java index 27d0332..1ae6ecf 100644 --- a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/jobcallables/ReplicateAndRunCommands.java +++ b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/jobcallables/ReplicateAndRunCommands.java @@ -28,6 +28,7 @@ import javax.inject.Inject; import org.apache.isis.applib.services.command.CommandExecutorService; import org.apache.isis.applib.services.xactn.TransactionService; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommandRepository; import org.apache.isis.extensions.commandlog.applib.dom.ReplayState; import org.apache.isis.extensions.commandreplay.secondary.SecondaryStatus; @@ -57,8 +58,7 @@ public class ReplicateAndRunCommands implements Callable<SecondaryStatus> { @Inject CommandExecutorService commandExecutorService; @Inject TransactionService transactionService; @Inject CommandFetcher commandFetcher; - @Inject - PublishedCommandRepository<? extends CommandModel> publishedCommandRepository; + @Inject PublishedCommandRepository publishedCommandRepository; @Inject CommandReplayAnalysisService analysisService; @Inject Optional<ReplayCommandExecutionController> controller; @@ -79,7 +79,7 @@ public class ReplicateAndRunCommands implements Callable<SecondaryStatus> { return; } - List<? extends CommandModel> commandsToReplay; + List<PublishedCommand> commandsToReplay; while(isRunning()) { @@ -90,7 +90,7 @@ public class ReplicateAndRunCommands implements Callable<SecondaryStatus> { if(commandsToReplay.isEmpty()) { // look for previously replayed on secondary - CommandModel hwm = publishedCommandRepository.findMostRecentReplayed().orElse(null); + PublishedCommand hwm = publishedCommandRepository.findMostRecentReplayed().orElse(null); if (hwm != null) { // give up if there was a failure; admin will need to fix issue and retry @@ -131,16 +131,16 @@ public class ReplicateAndRunCommands implements Callable<SecondaryStatus> { * @param commandsToReplay * @apiNote could return, whether there was a command to process (and so continue) */ - private void replay(List<? extends CommandModel> commandsToReplay) { + private void replay(List<PublishedCommand> commandsToReplay) { - commandsToReplay.forEach(commandModel -> { + commandsToReplay.forEach(publishedCommand -> { - log.info("replaying {}", commandModel.getInteractionId()); + log.info("replaying {}", publishedCommand.getInteractionId()); // // run command // - val replayState = executeCommandInTranAndAnalyse(commandModel); + val replayState = executeCommandInTranAndAnalyse(publishedCommand); if(replayState.isFailed()) { // will effectively block the running of any further commands // until the issue is fixed. @@ -150,7 +150,7 @@ public class ReplicateAndRunCommands implements Callable<SecondaryStatus> { // // find child commands, and run them // - val parent = commandModel; + val parent = publishedCommand; val childCommands = transactionService.callWithinCurrentTransactionElseCreateNew( @@ -170,18 +170,18 @@ public class ReplicateAndRunCommands implements Callable<SecondaryStatus> { } - private ReplayState executeCommandInTranAndAnalyse(final CommandModel commandJdo) { + private ReplayState executeCommandInTranAndAnalyse(final PublishedCommand publishedCommand) { transactionService.runWithinCurrentTransactionElseCreateNew( () -> { commandExecutorService.executeCommand( - CommandExecutorService.InteractionContextPolicy.SWITCH_USER_AND_TIME, commandJdo.getCommandDto(), commandJdo.outcomeHandler()); + CommandExecutorService.InteractionContextPolicy.SWITCH_USER_AND_TIME, publishedCommand.getCommandDto(), publishedCommand.outcomeHandler()); }); transactionService.runWithinCurrentTransactionElseCreateNew(() -> { - analysisService.analyse(commandJdo); + analysisService.analyse(publishedCommand); }); - return commandJdo.getReplayState(); + return publishedCommand.getReplayState(); } diff --git a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/CommandModel_exclude.java b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/PublishedCommand_exclude.java similarity index 80% rename from extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/CommandModel_exclude.java rename to extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/PublishedCommand_exclude.java index 9cfcbc6..b8430aa 100644 --- a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/CommandModel_exclude.java +++ b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/PublishedCommand_exclude.java @@ -26,6 +26,7 @@ import org.apache.isis.applib.annotation.Action; import org.apache.isis.applib.annotation.ActionLayout; import org.apache.isis.applib.annotation.SemanticsOf; import org.apache.isis.extensions.commandlog.applib.IsisModuleExtCommandLogApplib; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.extensions.commandlog.applib.dom.ReplayState; import org.apache.isis.extensions.commandreplay.secondary.config.SecondaryConfig; @@ -37,21 +38,20 @@ import lombok.RequiredArgsConstructor; */ @Action( semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE, - domainEvent = CommandModel_exclude.ActionDomainEvent.class + domainEvent = PublishedCommand_exclude.ActionDomainEvent.class ) @ActionLayout(associateWith = "executeIn", sequence = "2") @RequiredArgsConstructor -//@Log4j2 -public class CommandModel_exclude { +public class PublishedCommand_exclude { public static class ActionDomainEvent - extends IsisModuleExtCommandLogApplib.ActionDomainEvent<CommandModel_exclude> { } + extends IsisModuleExtCommandLogApplib.ActionDomainEvent<PublishedCommand_exclude> { } - final CommandModel commandModel; + final PublishedCommand publishedCommand; - public CommandModel act() { - commandModel.setReplayState(ReplayState.EXCLUDED); - return commandModel; + public PublishedCommand act() { + publishedCommand.setReplayState(ReplayState.EXCLUDED); + return publishedCommand; } public boolean hideAct() { @@ -59,7 +59,7 @@ public class CommandModel_exclude { } public String disableAct() { final boolean notInError = - commandModel.getReplayState() == null || !commandModel.getReplayState().isFailed(); + publishedCommand.getReplayState() == null || !publishedCommand.getReplayState().isFailed(); return notInError ? "This command is not in error, so cannot be excluded." : null; diff --git a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/CommandJdo_replayQueue.java b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/PublishedCommand_replayQueue.java similarity index 81% rename from extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/CommandJdo_replayQueue.java rename to extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/PublishedCommand_replayQueue.java index 8b119d1..43ac934 100644 --- a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/CommandJdo_replayQueue.java +++ b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/mixins/PublishedCommand_replayQueue.java @@ -24,6 +24,7 @@ import javax.inject.Inject; import org.apache.isis.applib.annotation.Collection; import org.apache.isis.applib.annotation.CollectionLayout; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommandRepository; import org.apache.isis.extensions.commandreplay.secondary.IsisModuleExtCommandReplaySecondary; import org.apache.isis.extensions.commandreplay.secondary.config.SecondaryConfig; @@ -34,21 +35,21 @@ import lombok.RequiredArgsConstructor; * @since 2.0 {@index} */ @Collection( - domainEvent = CommandJdo_replayQueue.CollectionDomainEvent.class + domainEvent = PublishedCommand_replayQueue.CollectionDomainEvent.class ) @CollectionLayout( defaultView = "table", sequence = "100.100" ) @RequiredArgsConstructor -public class CommandJdo_replayQueue { +public class PublishedCommand_replayQueue { public static class CollectionDomainEvent - extends IsisModuleExtCommandReplaySecondary.CollectionDomainEvent<CommandJdo_replayQueue, CommandModel> { } + extends IsisModuleExtCommandReplaySecondary.CollectionDomainEvent<PublishedCommand_replayQueue, PublishedCommand> { } - final CommandModel commandModel; + final PublishedCommand publishedCommand; - public List<? extends CommandModel> coll() { + public List<PublishedCommand> coll() { return publishedCommandRepository.findReplayedOnSecondary(); } public boolean hideColl() { @@ -56,7 +57,6 @@ public class CommandJdo_replayQueue { } @Inject SecondaryConfig secondaryConfig; - @Inject - PublishedCommandRepository<? extends CommandModel> publishedCommandRepository; + @Inject PublishedCommandRepository publishedCommandRepository; } diff --git a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/ui/CommandReplayOnSecondaryService.java b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/ui/CommandReplayOnSecondaryService.java index c096938..91c8dd8 100644 --- a/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/ui/CommandReplayOnSecondaryService.java +++ b/extensions/core/command-replay/secondary/src/main/java/org/apache/isis/extensions/commandreplay/secondary/ui/CommandReplayOnSecondaryService.java @@ -28,6 +28,7 @@ import org.apache.isis.applib.annotation.*; import org.apache.isis.applib.annotation.PriorityPrecedence; import org.apache.isis.applib.services.jaxb.JaxbService; import org.apache.isis.applib.value.Clob; +import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommand; import org.apache.isis.extensions.commandlog.applib.dom.PublishedCommandRepository; import org.apache.isis.extensions.commandreplay.secondary.IsisModuleExtCommandReplaySecondary; import org.apache.isis.schema.cmd.v2.CommandDto; @@ -56,7 +57,7 @@ public class CommandReplayOnSecondaryService { public static final String LOGICAL_TYPE_NAME = IsisModuleExtCommandReplaySecondary.NAMESPACE + ".CommandReplayOnSecondaryService"; @Inject - PublishedCommandRepository<? extends CommandModel> publishedCommandRepository; + PublishedCommandRepository publishedCommandRepository; @Inject final JaxbService jaxbService; public static abstract class ActionDomainEvent<T> extends IsisModuleExtCommandReplaySecondary.ActionDomainEvent<T> { } @@ -67,7 +68,7 @@ public class CommandReplayOnSecondaryService { public class ActionEvent extends ActionDomainEvent<findMostRecentReplayed> { } - @MemberSupport public CommandModel act() { + @MemberSupport public PublishedCommand act() { return publishedCommandRepository.findMostRecentReplayed().orElse(null); } }
