Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import org.apache.causeway.extensions.commandlog.applib.dom.replay.ReplayableCommand_excludeFromReplay;
import org.apache.causeway.extensions.commandlog.applib.dom.replay.ReplayableCommand_makeExportable;
import org.apache.causeway.extensions.commandlog.applib.dom.replay.ReplayableCommand_openCommandLogEntry;
import org.apache.causeway.extensions.commandlog.applib.dom.replay.ReplayableCommand_openTarget;
import org.apache.causeway.extensions.commandlog.applib.dom.replay.ReplayableCommand_openTargetTR;
import org.apache.causeway.extensions.commandlog.applib.dom.replay.ReplayableCommand_replayOrRetry;
import org.apache.causeway.extensions.commandlog.applib.fakescheduler.FakeScheduler;
import org.apache.causeway.extensions.commandlog.applib.job.BackgroundCommandsJobControl;
Expand Down Expand Up @@ -69,6 +71,8 @@
CommandLogEntry_siblingCommands.class,
ReplayableCommand_makeExportable.class,
ReplayableCommand_openCommandLogEntry.class,
ReplayableCommand_openTarget.class,
ReplayableCommand_openTargetTR.class,
ReplayableCommand_replayOrRetry.class,
ReplayableCommand_excludeFromReplay.class,
ReplayableCommand_delete.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Optional;

import javax.inject.Inject;
import javax.inject.Named;
Expand All @@ -32,12 +33,16 @@
import org.apache.causeway.applib.annotation.DomainService;
import org.apache.causeway.applib.annotation.DomainServiceLayout;
import org.apache.causeway.applib.annotation.MemberSupport;
import org.apache.causeway.applib.annotation.Optionality;
import org.apache.causeway.applib.annotation.Parameter;
import org.apache.causeway.applib.annotation.ParameterLayout;
import org.apache.causeway.applib.annotation.PriorityPrecedence;
import org.apache.causeway.applib.annotation.Publishing;
import org.apache.causeway.applib.annotation.RestrictTo;
import org.apache.causeway.applib.annotation.SemanticsOf;
import org.apache.causeway.applib.services.clock.ClockService;
import org.apache.causeway.applib.services.factory.FactoryService;
import org.apache.causeway.applib.value.Blob;
import org.apache.causeway.extensions.commandlog.applib.CausewayModuleExtCommandLogApplib;
import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntry;
import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntryRepository;
Expand All @@ -47,6 +52,8 @@
import org.jspecify.annotations.NonNull;
import org.springframework.lang.Nullable;

import jnr.a64asm.OP;

import lombok.RequiredArgsConstructor;

/**
Expand Down Expand Up @@ -189,15 +196,21 @@ public class replayManager {
public class DomainEvent extends ActionDomainEvent<replayManager> { }

@MemberSupport public CommandReplayManager act(
@ParameterLayout(describedAs = "Limits the commands shown; only commands since this timestamp are available for replay. Set to a time immediately before the commands to be replayed.")
final java.sql.Timestamp since
@Parameter(
optionality = Optionality.OPTIONAL,
fileAccept = ".yml,.yaml"
)
final Blob commandsYaml
) {
return new CommandReplayManager(since, replayContext);
final var now = clockService.getClock().nowAsJavaSqlTimestamp();
final var commandReplayManager = new CommandReplayManager(now, replayContext);
return Optional.ofNullable(commandsYaml)
.map(yaml -> importCommands(commandReplayManager).act(yaml, true))
.orElse(commandReplayManager);
}

@MemberSupport public java.sql.Timestamp defaultSince() {
final var now = clockService.getClock().nowAsJavaSqlTimestamp();
return truncatedTo(now, ChronoUnit.HOURS);
private CommandReplayManager.importCommands importCommands(CommandReplayManager commandReplayManager) {
return factoryService.mixin(CommandReplayManager.importCommands.class, commandReplayManager);
}
}

Expand All @@ -208,4 +221,6 @@ public class DomainEvent extends ActionDomainEvent<replayManager> { }
private LocalDate now() {
return clockService.getClock().nowAsLocalDate(ZoneId.systemDefault());
}

@Inject private FactoryService factoryService;
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@ private static Timestamp addSeconds(Timestamp ts, int secondsToAdd) {
)
@ActionLayout(
sequence = "1.1",
associateWith = "pendingOrFailed",
cssClass = "btn-secondary",
describedAs = "Imports commands from yaml format, then persists them with replayState=PENDING."
describedAs = "Imports commands from yaml format, then persists them with a replayState of PENDING."
)
public class importCommands {
public class DomainEvent extends ActionDomainEvent<importCommands> { }
Expand Down Expand Up @@ -239,8 +238,8 @@ private long sizePendingOrFailed() {
)
@ActionLayout(
associateWith = "pendingOrFailed", sequence = "1.2",
cssClass = "btn-primary",
cssClassFa = "solid circle-play",
cssClass = "btn-secondary",
cssClassFa = "solid forward",
describedAs = "Executes the list of commands in sequence, after having sorted them by their timestamp. "
+ "If any of the given commands fails, "
+ "its surrounding transaction is rolled back, but any successful commands so far are marked OK). "
Expand Down Expand Up @@ -289,7 +288,7 @@ public List<ReplayableCommand> choicesSelected() {
executionPublishing = Publishing.DISABLED
)
@ActionLayout(
associateWith = "pendingOrFailed", sequence = "1.3",
associateWith = "pendingOrFailed", sequence = "1.1",
cssClassFa = "solid circle-play",
cssClass = "btn-primary",
describedAs = "Executes the oldest command.")
Expand Down Expand Up @@ -319,7 +318,7 @@ public String disableAct() {
executionPublishing = Publishing.DISABLED
)
@ActionLayout(
associateWith = "pendingOrFailed", sequence = "1.4",
associateWith = "pendingOrFailed", sequence = "1.3",
cssClass = "btn-secondary",
describedAs = "Marks selected Commands to be EXCLUDED from replay"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.causeway.extensions.commandlog.applib.dom.replay;

import lombok.RequiredArgsConstructor;

import javax.inject.Inject;

import org.apache.causeway.applib.annotation.*;
import org.apache.causeway.applib.services.bookmark.Bookmark;
import org.apache.causeway.applib.services.bookmark.BookmarkService;
import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntry;

@Action(
semantics = SemanticsOf.SAFE,
commandPublishing = Publishing.DISABLED,
domainEvent = ReplayableCommand_openTarget.DomainEvent.class,
executionPublishing = Publishing.DISABLED
)
@ActionLayout(
sequence = "0.3", associateWith = "target",
describedAs = "Opens the underlying Target"
)
@RequiredArgsConstructor
public class ReplayableCommand_openTarget {

public static class DomainEvent extends ReplayableCommand.ActionDomainEvent<ReplayableCommand_openTarget> {
}

private final ReplayableCommand replayableCommand;

@MemberSupport
public Object act() {
return replayableCommand.commandLogEntry()
.map(CommandLogEntry::getTarget)
.flatMap(bookmark -> bookmarkService.lookup(bookmark))
.orElse(null);
}

@MemberSupport
public String disableAct() {
return replayableCommand.commandLogEntry().isEmpty() ? "No corresponding CommandLogEntry" : null;
}

@Inject private BookmarkService bookmarkService;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.causeway.extensions.commandlog.applib.dom.replay;

import lombok.RequiredArgsConstructor;

import javax.inject.Inject;

import org.apache.causeway.applib.annotation.*;
import org.apache.causeway.applib.services.bookmark.BookmarkService;
import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntry;

@Action(
semantics = SemanticsOf.SAFE,
commandPublishing = Publishing.DISABLED,
domainEvent = ReplayableCommand_openTargetTR.DomainEvent.class,
executionPublishing = Publishing.DISABLED
)
@ActionLayout(
named = "Open Target",
describedAs = "Opens the underlying Target",
hidden = Where.OBJECT_FORMS // table row action.
)
@RequiredArgsConstructor
public class ReplayableCommand_openTargetTR {

public static class DomainEvent extends ReplayableCommand.ActionDomainEvent<ReplayableCommand_openTargetTR> {
}

private final ReplayableCommand replayableCommand;

@MemberSupport
public Object act() {
return replayableCommand.commandLogEntry()
.map(CommandLogEntry::getTarget)
.flatMap(bookmark -> bookmarkService.lookup(bookmark))
.orElse(null);
}

@MemberSupport
public String disableAct() {
return replayableCommand.commandLogEntry().isEmpty() ? "No corresponding CommandLogEntry" : null;
}

@Inject private BookmarkService bookmarkService;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public ReplayableCommand act() {

@MemberSupport
public String disableAct() {
return replayableCommand.disableReplayOrRetry();
// previously we restricted this, but there are cases where a
// retry of a command that succeeded may be warranted
// return replayableCommand.disableReplayOrRetry();

return null;
}
}
Loading