Skip to content

Commit 4e8e31e

Browse files
committed
CAUSEWAY-3989: simplify by not requiring bookmark service
1 parent a631ca3 commit 4e8e31e

5 files changed

Lines changed: 16 additions & 28 deletions

File tree

extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/CausewayModuleExtCommandLogApplib.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.context.annotation.Configuration;
2323
import org.springframework.context.annotation.Import;
2424

25-
import org.apache.causeway.applib.services.bookmark.BookmarkService;
2625
import org.apache.causeway.applib.services.command.CommandExecutorService;
2726
import org.apache.causeway.applib.services.iactn.InteractionService;
2827
import org.apache.causeway.applib.services.repository.RepositoryService;
@@ -118,12 +117,11 @@ public static void honorSystemEnvironment() {
118117
}
119118

120119
@Bean ReplayContext replayContext(
121-
final BookmarkService bookmarkService,
122120
final RepositoryService repositoryService,
123121
final InteractionService interactionService,
124122
final CommandLogEntryRepository commandLogEntryRepository,
125123
final CommandExecutorService commandExecutorService) {
126-
return new ReplayContext(bookmarkService, repositoryService, interactionService,
124+
return new ReplayContext(repositoryService, interactionService,
127125
commandLogEntryRepository, commandExecutorService);
128126
}
129127

extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandExportManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public List<ReplayableCommand> getNotYetExported() {
8080
return commandLogEntryRepository().findAll().stream()
8181
.filter(entry->ReplayState.canExport(entry.getReplayState()))
8282
.map(entry->new ReplayableCommand(
83-
replayContext.bookmarkService().bookmarkFor(entry).get().identifier(),
83+
entry.getInteractionId(),
8484
replayContext))
8585
.toList();
8686
}
@@ -136,7 +136,7 @@ public List<ReplayableCommand> getExported() {
136136
return commandLogEntryRepository().findAll().stream()
137137
.filter(entry->ReplayState.isExported(entry.getReplayState()))
138138
.map(entry->new ReplayableCommand(
139-
replayContext.bookmarkService().bookmarkFor(entry).get().identifier(),
139+
entry.getInteractionId(),
140140
replayContext))
141141
.toList();
142142
}

extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandReplayManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public CommandReplayManager deleteAll() {
9494
public List<ReplayableCommand> getPendingOrFailed() {
9595
return commandLogEntryRepository().findReplayPendingOrFailed().stream()
9696
.map(entry->new ReplayableCommand(
97-
replayContext.bookmarkService().bookmarkFor(entry).get().identifier(),
97+
entry.getInteractionId(),
9898
replayContext))
9999
.toList();
100100
}
@@ -147,7 +147,7 @@ public CommandReplayManager deleteSelected(final List<ReplayableCommand> selecte
147147
public List<ReplayableCommand> getSucceededOrExcluded() {
148148
return commandLogEntryRepository().findReplaySucceededOrExcluded().stream()
149149
.map(entry->new ReplayableCommand(
150-
replayContext.bookmarkService().bookmarkFor(entry).get().identifier(),
150+
entry.getInteractionId(),
151151
replayContext))
152152
.toList();
153153
}

extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayContext.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.apache.causeway.extensions.commandlog.applib.dom.replay;
2020

21-
import org.apache.causeway.applib.services.bookmark.BookmarkService;
2221
import org.apache.causeway.applib.services.command.CommandExecutorService;
2322
import org.apache.causeway.applib.services.iactn.InteractionService;
2423
import org.apache.causeway.applib.services.repository.RepositoryService;
@@ -28,7 +27,6 @@
2827
* Bundles dependencies for the replay logic.
2928
*/
3029
public record ReplayContext(
31-
BookmarkService bookmarkService,
3230
RepositoryService repositoryService,
3331
InteractionService interactionService,
3432
CommandLogEntryRepository commandLogEntryRepository,

extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayableCommand.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@
4242
import org.apache.causeway.applib.annotation.Where;
4343
import org.apache.causeway.applib.fa.FontAwesomeLayers;
4444
import org.apache.causeway.applib.jaxb.JavaTimeXMLGregorianCalendarMarshalling;
45-
import org.apache.causeway.applib.services.bookmark.Bookmark;
4645
import org.apache.causeway.applib.services.command.CommandExecutorService.InteractionContextPolicy;
4746
import org.apache.causeway.commons.functional.Try;
4847
import org.apache.causeway.commons.internal.base._Refs.ObjectReference;
4948
import org.apache.causeway.commons.internal.base._Strings;
50-
import org.apache.causeway.commons.internal.exceptions._Exceptions;
5149
import org.apache.causeway.commons.io.JsonUtils;
5250
import org.apache.causeway.commons.io.TextUtils;
5351
import org.apache.causeway.commons.io.YamlUtils;
@@ -69,7 +67,7 @@
6967
@DomainObjectLayout(cssClassFa = "terminal")
7068
@Named(ReplayableCommand.LOGICAL_TYPE_NAME)
7169
public record ReplayableCommand(
72-
String commandLogEntryId,
70+
UUID interactionId,
7371
ReplayContext replayContext,
7472
ObjectReference<CommandRecord> recordRef) implements ViewModel, Comparable<ReplayableCommand> {
7573

@@ -102,7 +100,13 @@ public String faQuickIcon() {
102100
public ReplayableCommand(
103101
final String memento,
104102
final ReplayContext replayContext) {
105-
this(memento, replayContext, new ObjectReference<>(null));
103+
this(UUID.fromString(memento), replayContext);
104+
}
105+
106+
ReplayableCommand(
107+
final UUID interactionId,
108+
final ReplayContext replayContext) {
109+
this(interactionId, replayContext, new ObjectReference<>(null));
106110
}
107111

108112
@ObjectSupport public String title() {
@@ -123,11 +127,7 @@ public ReplayableCommand(
123127
fieldSetId = "details",
124128
describedAs = "UUID of the original (replayabel) Command")
125129
public UUID getInteractionId() {
126-
return commandRecord()
127-
.map(CommandRecord::commandDto)
128-
.map(CommandDto::getInteractionId)
129-
.map(UUID::fromString)
130-
.orElse(null);
130+
return interactionId();
131131
}
132132

133133
@Property
@@ -323,7 +323,7 @@ public int compareTo(final ReplayableCommand other) {
323323

324324
@Override
325325
public String viewModelMemento() {
326-
return commandLogEntryId;
326+
return interactionId.toString();
327327
}
328328

329329
// -- UTIL
@@ -370,15 +370,7 @@ private Optional<CommandRecord> commandRecord() {
370370
}
371371

372372
Optional<CommandLogEntry> commandLogEntry() {
373-
return replayContext.bookmarkService().lookup(commandLogEntryBookmark(), CommandLogEntry.class);
374-
}
375-
376-
private Bookmark commandLogEntryBookmark() {
377-
return replayContext.bookmarkService()
378-
.bookmarkFor(CommandLogEntry.class, commandLogEntryId)
379-
.orElseThrow(()->_Exceptions.unrecoverable(
380-
"framework error: cannot create bookmark for CommandLogEntry using id '%s'",
381-
commandLogEntryId));
373+
return replayContext.commandLogEntryRepository().findByInteractionId(interactionId());
382374
}
383375

384376
private static boolean canReplayOrRetryOrMarkForExclusion(final CommandLogEntry commandLogEntry) {

0 commit comments

Comments
 (0)