This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-3002
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/ISIS-3002 by this push:
new 1d28c9831a ISIS-3002: fleshes out ExecutionLogEntryRepository
1d28c9831a is described below
commit 1d28c9831a70d791682a279ffd5f8b08bd84048c
Author: Dan Haywood <[email protected]>
AuthorDate: Tue Jul 12 16:21:36 2022 +0100
ISIS-3002: fleshes out ExecutionLogEntryRepository
---
.../applib/dom/CommandLogEntryRepository.java | 53 ++++----
.../executionlog/applib/dom/ExecutionLogEntry.java | 19 ++-
.../applib/dom/ExecutionLogEntryPK.java | 44 +-----
.../applib/dom/ExecutionLogEntryRepository.java | 149 ++++++++++++++++++++-
.../executionlog/jdo/dom/ExecutionLogEntry.java | 116 ++++++++--------
.../jdo/dom/ExecutionLogEntryRepository.java | 58 ++++++++
6 files changed, 306 insertions(+), 133 deletions(-)
diff --git
a/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
b/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
index 380831e5c1..47b032b551 100644
---
a/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
+++
b/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
@@ -46,7 +46,6 @@ 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.Getter;
import lombok.val;
@@ -66,14 +65,14 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
@Inject Provider<RepositoryService> repositoryServiceProvider;
@Inject FactoryService factoryService;
- private final Class<C> commandLogClass;
+ private final Class<C> commandLogEntryClass;
- protected CommandLogEntryRepository(Class<C> commandLogClass) {
- this.commandLogClass = commandLogClass;
+ protected CommandLogEntryRepository(Class<C> commandLogEntryClass) {
+ this.commandLogEntryClass = commandLogEntryClass;
}
public C createEntryAndPersist(final Command command, CommandLogEntry
parentEntryIfAny) {
- C c = factoryService.detachedEntity(commandLogClass);
+ C c = factoryService.detachedEntity(commandLogEntryClass);
c.setCommandDto(command.getCommandDto());
c.setParent(parentEntryIfAny);
persist(c);
@@ -82,13 +81,13 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
public Optional<C> findByInteractionId(final UUID interactionId) {
return repositoryService().firstMatch(
- Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_BY_INTERACTION_ID)
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_INTERACTION_ID)
.withParameter("interactionId", interactionId));
}
public List<C> findByParent(final CommandLogEntry parent) {
return repositoryService().allMatches(
- Query.named(commandLogClass, CommandLogEntry.Nq.FIND_BY_PARENT)
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_PARENT)
.withParameter("parent", parent));
}
@@ -101,19 +100,19 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
final Query<C> query;
if(from != null) {
if(to != null) {
- query = Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_BY_TIMESTAMP_BETWEEN)
+ query = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_TIMESTAMP_BETWEEN)
.withParameter("from", fromTs)
.withParameter("to", toTs);
} else {
- query = Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_BY_TIMESTAMP_AFTER)
+ query = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_TIMESTAMP_AFTER)
.withParameter("from", fromTs);
}
} else {
if(to != null) {
- query = Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_BY_TIMESTAMP_BEFORE)
+ query = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_TIMESTAMP_BEFORE)
.withParameter("to", toTs);
} else {
- query = Query.named(commandLogClass, CommandLogEntry.Nq.FIND);
+ query = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND);
}
}
return repositoryService().allMatches(query);
@@ -121,12 +120,12 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
public List<C> findCurrent() {
return repositoryService().allMatches(
- Query.named(commandLogClass, CommandLogEntry.Nq.FIND_CURRENT));
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_CURRENT));
}
public List<C> findCompleted() {
return repositoryService().allMatches(
- Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_COMPLETED));
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_COMPLETED));
}
@@ -141,22 +140,22 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
final Query<C> query;
if(from != null) {
if(to != null) {
- query = Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_BY_TARGET_AND_TIMESTAMP_BETWEEN)
+ query = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_TARGET_AND_TIMESTAMP_BETWEEN)
.withParameter("target", target)
.withParameter("from", fromTs)
.withParameter("to", toTs);
} else {
- query = Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_BY_TARGET_AND_TIMESTAMP_AFTER)
+ query = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_TARGET_AND_TIMESTAMP_AFTER)
.withParameter("target", target)
.withParameter("from", fromTs);
}
} else {
if(to != null) {
- query = Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_BY_TARGET_AND_TIMESTAMP_BEFORE)
+ query = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_TARGET_AND_TIMESTAMP_BEFORE)
.withParameter("target", target)
.withParameter("to", toTs);
} else {
- query = Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_BY_TARGET)
+ query = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_TARGET)
.withParameter("target", target);
}
}
@@ -165,7 +164,7 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
public List<C> findRecentByUsername(final String username) {
return repositoryService().allMatches(
- Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_RECENT_BY_USERNAME)
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_RECENT_BY_USERNAME)
.withParameter("username", username));
}
@@ -173,7 +172,7 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
public List<C> findRecentByTarget(final Bookmark target) {
return repositoryService().allMatches(
- Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_RECENT_BY_TARGET)
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_RECENT_BY_TARGET)
.withParameter("target", target));
}
@@ -221,7 +220,7 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
private List<C> findFirst() {
Optional<C> firstCommandIfAny = repositoryService().firstMatch(
- Query.named(commandLogClass, CommandLogEntry.Nq.FIND_FIRST));
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_FIRST));
return firstCommandIfAny
.map(Collections::singletonList)
.orElse(Collections.emptyList());
@@ -238,7 +237,7 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
*/
public Optional<C> findMostRecentReplayed() {
return repositoryService().firstMatch(
- Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_MOST_RECENT_REPLAYED));
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_MOST_RECENT_REPLAYED));
}
/**
@@ -254,12 +253,12 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
*/
public Optional<C> findMostRecentCompleted() {
return repositoryService().firstMatch(
- Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_MOST_RECENT_COMPLETED));
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_MOST_RECENT_COMPLETED));
}
public List<C> findNotYetReplayed() {
return repositoryService().allMatches(
- Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_NOT_YET_REPLAYED).withLimit(10));
+ Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_NOT_YET_REPLAYED).withLimit(10));
}
@@ -274,7 +273,7 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
}
}
- final C commandJdo = factoryService.detachedEntity(commandLogClass);
+ final C commandJdo =
factoryService.detachedEntity(commandLogEntryClass);
commandJdo.setInteractionId(UUID.fromString(dto.getInteractionId()));
commandJdo.setTimestamp(JavaSqlXMLGregorianCalendarMarshalling.toTimestamp(dto.getTimestamp()));
@@ -308,7 +307,7 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
}
public void truncateLog() {
- repositoryService().removeAll(commandLogClass);
+ repositoryService().removeAll(commandLogEntryClass);
}
// --
@@ -328,7 +327,7 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
private C findByInteractionIdElseNull(final UUID interactionId) {
- val q = Query.named(commandLogClass,
CommandLogEntry.Nq.FIND_BY_INTERACTION_ID)
+ val q = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_BY_INTERACTION_ID)
.withParameter("interactionId", interactionId.toString());
return repositoryService().uniqueMatch(q).orElse(null);
}
@@ -341,7 +340,7 @@ public abstract class CommandLogEntryRepository<C extends
CommandLogEntry> {
// XXX that's a historic workaround, should rather be fixed upstream
val needsTrimFix = batchSize != null && batchSize == 1;
- val q = Query.named(commandLogClass, CommandLogEntry.Nq.FIND_SINCE)
+ val q = Query.named(commandLogEntryClass,
CommandLogEntry.Nq.FIND_SINCE)
.withParameter("timestamp", timestamp)
.withRange(QueryRange.limit(
needsTrimFix ? 2L : batchSize
diff --git
a/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntry.java
b/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntry.java
index 9fe2367ccc..14435bdfde 100644
---
a/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntry.java
+++
b/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntry.java
@@ -33,13 +33,13 @@ import javax.validation.constraints.Digits;
import org.springframework.stereotype.Service;
-import org.apache.isis.applib.Identifier;
import org.apache.isis.applib.annotation.DomainObject;
import org.apache.isis.applib.annotation.DomainObjectLayout;
import org.apache.isis.applib.annotation.Editing;
import org.apache.isis.applib.annotation.Optionality;
import org.apache.isis.applib.annotation.Parameter;
import org.apache.isis.applib.annotation.PriorityPrecedence;
+import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.annotation.Property;
import org.apache.isis.applib.annotation.PropertyLayout;
import org.apache.isis.applib.annotation.Where;
@@ -103,6 +103,18 @@ implements Comparable<ExecutionLogEntry>,
DomainChangeRecord, HasInteractionIdAn
@UtilityClass
public static class Nq {
+ public static final String FIND_BY_INTERACTION_ID =
"findByInteractionId";
+ public static final String FIND_BY_INTERACTION_ID_AND_SEQUENCE =
"findByInteractionIdAndSequence";
+ public static final String FIND_BY_TARGET_AND_TIMESTAMP_BETWEEN =
"findByTargetAndTimestampBetween";
+ public static final String FIND_BY_TARGET_AND_TIMESTAMP_AFTER =
"findByTargetAndTimestampAfter";
+ public static final String FIND_BY_TARGET_AND_TIMESTAMP_BEFORE =
"findByTargetAndTimestampBefore";
+ public static final String FIND_BY_TARGET = "findByTarget";
+ public static final String FIND_BY_TIMESTAMP_BETWEEN =
"findByTimestampBetween";
+ public static final String FIND_BY_TIMESTAMP_AFTER =
"findByTimestampAfter";
+ public static final String FIND_BY_TIMESTAMP_BEFORE =
"findByTimestampBefore";
+ public static final String FIND = "find";
+ public static final String FIND_RECENT_BY_USERNAME =
"findRecentByUsername";
+ public static final String FIND_RECENT_BY_TARGET =
"findRecentByTarget";
}
@UtilityClass
@@ -113,9 +125,12 @@ implements Comparable<ExecutionLogEntry>,
DomainChangeRecord, HasInteractionIdAn
}
-
public ExecutionLogEntry(@NonNull Execution<? extends
MemberExecutionDto,?> execution) {
+ init(execution);
+ }
+ @Programmatic
+ public void init(Execution<? extends MemberExecutionDto, ?> execution) {
val interactionId = execution.getInteraction().getInteractionId();
setInteractionId(interactionId);
diff --git
a/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryPK.java
b/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryPK.java
index ab9b5d59d4..25e97cd894 100644
---
a/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryPK.java
+++
b/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryPK.java
@@ -4,11 +4,13 @@ import java.io.Serializable;
import java.util.StringTokenizer;
import java.util.UUID;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.val;
+@EqualsAndHashCode(of = {"interactionId", "sequence"})
@NoArgsConstructor
public class ExecutionLogEntryPK implements Serializable {
@@ -17,55 +19,19 @@ public class ExecutionLogEntryPK implements Serializable {
private static final String SEPARATOR = "_";
@Getter @Setter
- public UUID transactionId;
+ public UUID interactionId;
@Getter @Setter
public int sequence;
public ExecutionLogEntryPK(final String value) {
val token = new StringTokenizer (value, SEPARATOR);
- this.transactionId = UUID.fromString(token.nextToken());
+ this.interactionId = UUID.fromString(token.nextToken());
this.sequence = Integer.parseInt(token.nextToken());
}
@Override
public String toString() {
- return transactionId + SEPARATOR + sequence;
- }
-
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((transactionId == null) ? 0 :
transactionId.hashCode());
- result = prime * result + sequence;
- return result;
- }
-
- @Override
- public boolean equals(final Object o) {
- if (this == o)
- return true;
- if (o == null)
- return false;
- if (getClass() != o.getClass())
- return false;
-
- ExecutionLogEntryPK other = (ExecutionLogEntryPK) o;
- if (transactionId == null) {
- if (other.transactionId != null) {
- return false;
- }
- } else {
- if (!transactionId.equals(other.transactionId)) {
- return false;
- }
- }
- if (sequence != other.sequence) {
- return false;
- }
- return true;
+ return interactionId + SEPARATOR + sequence;
}
}
diff --git
a/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryRepository.java
b/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryRepository.java
index 3c383098d9..474c244bb5 100644
---
a/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryRepository.java
+++
b/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryRepository.java
@@ -1,14 +1,157 @@
package org.apache.isis.extensions.executionlog.applib.dom;
+import java.sql.Timestamp;
import java.util.List;
+import java.util.Optional;
import java.util.UUID;
+import javax.inject.Inject;
+import javax.inject.Provider;
+
+import org.apache.isis.applib.exceptions.RecoverableException;
+import org.apache.isis.applib.query.Query;
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.factory.FactoryService;
import org.apache.isis.applib.services.iactn.Execution;
import org.apache.isis.applib.services.publishing.spi.ExecutionSubscriber;
+import org.apache.isis.applib.services.repository.RepositoryService;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * Provides supporting functionality for querying and persisting
+ * {@link ExecutionLogEntry command} entities.
+ */
+@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
+public abstract class ExecutionLogEntryRepository<E extends ExecutionLogEntry>
{
+
+ public static class NotFoundException extends RecoverableException {
+ private static final long serialVersionUID = 1L;
+ @Getter
+ private final UUID interactionId;
+ public NotFoundException(final UUID interactionId) {
+ super("Execution log entry not found");
+ this.interactionId = interactionId;
+ }
+ }
+
+ private final Class<E> executionLogEntryClass;
+
+ /**
+ * for testing only.
+ */
+ protected ExecutionLogEntryRepository(Class<E> executionLogEntryClass,
Provider<RepositoryService> repositoryServiceProvider, FactoryService
factoryService) {
+ this.executionLogEntryClass = executionLogEntryClass;
+ this.repositoryServiceProvider = repositoryServiceProvider;
+ this.factoryService = factoryService;
+ }
+
+ public E createEntryAndPersist(final Execution execution) {
+ E e = factoryService.detachedEntity(executionLogEntryClass);
+ e.init(execution);
+ persist(e);
+ return e;
+ }
+
+ public List<E> findByInteractionId(UUID interactionId) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_BY_INTERACTION_ID)
+ .withParameter("interactionId", interactionId));
+ }
+
+ public Optional<E> findByInteractionIdAndSequence(UUID interactionId, int
sequence) {
+ return repositoryService().firstMatch(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_BY_INTERACTION_ID_AND_SEQUENCE)
+ .withParameter("interactionId", interactionId)
+ .withParameter("sequence", sequence)
+ );
+ }
+
+ public List<E> find() {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND));
+ }
+
+ public List<E> findByTarget(Bookmark target) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_BY_TARGET)
+ .withParameter("target", target));
+ }
+
+ public List<E> findByTargetAndTimestampAfter(Bookmark target, Timestamp
timestamp) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_BY_TARGET_AND_TIMESTAMP_AFTER)
+ .withParameter("target", target)
+ .withParameter("timestamp", timestamp)
+ );
+ }
+
+ public List<E> findByTargetAndTimestampBefore(Bookmark target, Timestamp
timestamp) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_BY_TARGET_AND_TIMESTAMP_BEFORE)
+ .withParameter("target", target)
+ .withParameter("timestamp", timestamp)
+ );
+ }
+
+ public List<E> findByTargetAndTimestampBetween(Bookmark target, Timestamp
timestampFrom, Timestamp timestampTo) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_BY_TARGET_AND_TIMESTAMP_BETWEEN)
+ .withParameter("target", target)
+ .withParameter("timestampFrom", timestampFrom)
+ .withParameter("timestampTo", timestampTo)
+ );
+ }
+
+ public List<E> findByTimestampAfter(Timestamp timestamp) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_BY_TIMESTAMP_AFTER)
+ .withParameter("timestamp", timestamp)
+ );
+ }
+
+ public List<E> findByTimestampBefore(Timestamp timestamp) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_BY_TIMESTAMP_BEFORE)
+ .withParameter("timestamp", timestamp)
+ );
+ }
+
+ public List<E> findByTimestampBetween(Timestamp timestampFrom, Timestamp
timestampTo) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_BY_TIMESTAMP_BETWEEN)
+ .withParameter("timestampFrom", timestampFrom)
+ .withParameter("timestampTo", timestampTo)
+ );
+ }
+
+ public List<E> findRecentByUsername(String username) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_RECENT_BY_USERNAME)
+ .withParameter("username", username)
+ );
+ }
+
+ public List<E> findByRecentByTarget(Bookmark target) {
+ return repositoryService().allMatches(
+ Query.named(executionLogEntryClass,
ExecutionLogEntry.Nq.FIND_RECENT_BY_TARGET)
+ .withParameter("target", target)
+ );
+ }
+
+ private void persist(final E commandLogEntry) {
+ repositoryService().persist(commandLogEntry);
+ }
-public abstract class ExecutionLogEntryRepository<E extends ExecutionLogEntry>
implements ExecutionSubscriber {
+ private RepositoryService repositoryService() {
+ return repositoryServiceProvider.get();
+ }
- public abstract E createEntryAndPersist(Execution<?, ?> execution);
+ @Inject Provider<RepositoryService> repositoryServiceProvider;
+ @Inject FactoryService factoryService;
- public abstract List<E> findByInteractionId(UUID interactionId);
}
diff --git
a/extensions/core/executionlog/persistence-jdo/src/main/java/org/apache/isis/extensions/executionlog/jdo/dom/ExecutionLogEntry.java
b/extensions/core/executionlog/persistence-jdo/src/main/java/org/apache/isis/extensions/executionlog/jdo/dom/ExecutionLogEntry.java
index cc238548f7..abf888ca1b 100644
---
a/extensions/core/executionlog/persistence-jdo/src/main/java/org/apache/isis/extensions/executionlog/jdo/dom/ExecutionLogEntry.java
+++
b/extensions/core/executionlog/persistence-jdo/src/main/java/org/apache/isis/extensions/executionlog/jdo/dom/ExecutionLogEntry.java
@@ -18,8 +18,6 @@
*/
package org.apache.isis.extensions.executionlog.jdo.dom;
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
import java.util.UUID;
import javax.inject.Named;
@@ -32,18 +30,11 @@ import javax.jdo.annotations.Queries;
import javax.jdo.annotations.Query;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.isis.applib.Identifier;
import org.apache.isis.applib.annotation.DomainObject;
-import org.apache.isis.applib.annotation.DomainObjectLayout;
import org.apache.isis.applib.annotation.Editing;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.annotation.Property;
-import org.apache.isis.applib.annotation.PropertyLayout;
-import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.jaxb.PersistentEntitiesAdapter;
import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.util.TitleBuffer;
-import
org.apache.isis.extensions.executionlog.applib.IsisModuleExtExecutionLogApplib;
+import org.apache.isis.extensions.executionlog.applib.dom.ExecutionLogEntry.Nq;
import org.apache.isis.extensions.executionlog.applib.dom.ExecutionLogEntryPK;
import
org.apache.isis.extensions.executionlog.applib.dom.ExecutionLogEntryType;
import org.apache.isis.schema.ixn.v2.InteractionDto;
@@ -53,90 +44,90 @@ import lombok.Setter;
@PersistenceCapable(
identityType= IdentityType.APPLICATION,
- schema = "isispublishmq",
- table="PublishedEvent",
+ schema = ExecutionLogEntry.SCHEMA,
+ table = ExecutionLogEntry.TABLE,
objectIdClass= ExecutionLogEntryPK.class)
@Queries( {
@Query(
- name="findByTransactionId", language="JDOQL",
+ name= Nq.FIND_BY_INTERACTION_ID,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE transactionId == :transactionId "
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE interactionId == :interactionId "
+ "ORDER BY timestamp DESC, sequence DESC"),
@Query(
- name="findByTransactionIdAndSequence", language="JDOQL",
+ name= Nq.FIND_BY_INTERACTION_ID_AND_SEQUENCE,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE transactionId == :transactionId "
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE interactionId == :interactionId "
+ "&& sequence == :sequence "),
@Query(
- name="findByTargetAndTimestampBetween", language="JDOQL",
+ name= Nq.FIND_BY_TARGET_AND_TIMESTAMP_BETWEEN,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE targetStr == :targetStr "
- + "&& timestamp >= :from "
- + "&& timestamp <= :to "
- + "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC"),
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE target == :target "
+ + "&& timestamp >= :timestampFrom "
+ + "&& timestamp <= :timestampTo "
+ + "ORDER BY timestamp DESC, interactionId DESC, sequence
DESC"),
@Query(
- name="findByTargetAndTimestampAfter", language="JDOQL",
+ name= Nq.FIND_BY_TARGET_AND_TIMESTAMP_AFTER,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE targetStr == :targetStr "
- + "&& timestamp >= :from "
- + "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC"),
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE target == :target "
+ + "&& timestamp >= :timestamp "
+ + "ORDER BY timestamp DESC, interactionId DESC, sequence
DESC"),
@Query(
- name="findByTargetAndTimestampBefore", language="JDOQL",
+ name= Nq.FIND_BY_TARGET_AND_TIMESTAMP_BEFORE,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE targetStr == :targetStr "
- + "&& timestamp <= :to "
- + "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC"),
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE target == :target "
+ + "&& timestamp <= :timestamp "
+ + "ORDER BY timestamp DESC, interactionId DESC, sequence
DESC"),
@Query(
- name="findByTarget", language="JDOQL",
+ name= Nq.FIND_BY_TARGET,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE targetStr == :targetStr "
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE target == :target "
+ "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC"),
@Query(
- name="findByTimestampBetween", language="JDOQL",
+ name= Nq.FIND_BY_TIMESTAMP_BETWEEN,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE timestamp >= :from "
- + "&& timestamp <= :to "
- + "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC"),
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE timestamp >= :timestampFrom "
+ + "&& timestamp <= :timestampTo "
+ + "ORDER BY timestamp DESC, interactionId DESC, sequence
DESC"),
@Query(
- name="findByTimestampAfter", language="JDOQL",
+ name= Nq.FIND_BY_TIMESTAMP_AFTER,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE timestamp >= :from "
- + "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC"),
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE timestamp >= :timestamp "
+ + "ORDER BY timestamp DESC, interactionId DESC, sequence
DESC"),
@Query(
- name="findByTimestampBefore", language="JDOQL",
+ name= Nq.FIND_BY_TIMESTAMP_BEFORE,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE timestamp <= :to "
- + "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC"),
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE timestamp <= :timestamp "
+ + "ORDER BY timestamp DESC, interactionId DESC, sequence
DESC"),
@Query(
- name="find", language="JDOQL",
+ name= Nq.FIND,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC"),
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "ORDER BY timestamp DESC, interactionId DESC, sequence
DESC"),
@Query(
- name="findRecentByUser", language="JDOQL",
+ name= Nq.FIND_RECENT_BY_USERNAME,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE user == :user "
- + "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC "
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE username == :username "
+ + "ORDER BY timestamp DESC, interactionId DESC, sequence
DESC "
+ "RANGE 0,30"),
@Query(
- name="findRecentByTarget", language="JDOQL",
+ name= Nq.FIND_RECENT_BY_TARGET,
value="SELECT "
- + "FROM
com.ecpnv.platform.v1.extensions.executionlog.dom.jdo.events.PublishedEvent "
- + "WHERE targetStr == :targetStr "
- + "ORDER BY timestamp DESC, transactionId DESC, sequence
DESC "
+ + "FROM " + ExecutionLogEntry.FQCN + " "
+ + "WHERE target == :target "
+ + "ORDER BY timestamp DESC, interactionId DESC, sequence
DESC "
+ "RANGE 0,30")
})
-@Named("isispublishmq.PublishedEvent")
+@Named(ExecutionLogEntry.LOGICAL_TYPE_NAME)
@DomainObject(
editing = Editing.DISABLED
)
@@ -144,6 +135,7 @@ import lombok.Setter;
public class ExecutionLogEntry extends
org.apache.isis.extensions.executionlog.applib.dom.ExecutionLogEntry {
+ public static final String FQCN =
"org.apache.isis.extensions.executionlog.jdo.dom.ExecutionLogEntry";
@PrimaryKey
@InteractionId
@Column(allowsNull = InteractionId.ALLOWS_NULL,
length=InteractionId.MAX_LENGTH)
diff --git
a/extensions/core/executionlog/persistence-jdo/src/main/java/org/apache/isis/extensions/executionlog/jdo/dom/ExecutionLogEntryRepository.java
b/extensions/core/executionlog/persistence-jdo/src/main/java/org/apache/isis/extensions/executionlog/jdo/dom/ExecutionLogEntryRepository.java
new file mode 100644
index 0000000000..1106e3de20
--- /dev/null
+++
b/extensions/core/executionlog/persistence-jdo/src/main/java/org/apache/isis/extensions/executionlog/jdo/dom/ExecutionLogEntryRepository.java
@@ -0,0 +1,58 @@
+/*
+ * 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.executionlog.jdo.dom;
+
+import javax.inject.Named;
+import javax.inject.Provider;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Service;
+
+import org.apache.isis.applib.annotation.PriorityPrecedence;
+import org.apache.isis.applib.services.factory.FactoryService;
+import org.apache.isis.applib.services.repository.RepositoryService;
+import
org.apache.isis.extensions.executionlog.jdo.IsisModuleExtExecutionLogJdo;
+
+import lombok.Builder;
+
+@Service
+@Named(ExecutionLogEntryRepository.LOGICAL_TYPE_NAME)
[email protected](PriorityPrecedence.MIDPOINT)
+@Qualifier("Jdo")
+public class ExecutionLogEntryRepository
+extends
org.apache.isis.extensions.executionlog.applib.dom.ExecutionLogEntryRepository<ExecutionLogEntry>
{
+
+ public static final String LOGICAL_TYPE_NAME =
IsisModuleExtExecutionLogJdo.NAMESPACE + ".ExecutionLogEntryRepository";
+
+ public ExecutionLogEntryRepository() {
+ super(ExecutionLogEntry.class);
+ }
+
+ /**
+ * for testing only
+ */
+ @Builder
+ ExecutionLogEntryRepository(
+ Class<ExecutionLogEntry> executionLogEntryClass,
+ Provider<RepositoryService> repositoryServiceProvider,
+ FactoryService factoryService) {
+ super(executionLogEntryClass, repositoryServiceProvider,
factoryService);
+ }
+
+}