From 4fe7bc9106c972badcfdf878ae4f38967a1230b9 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Mon, 15 Mar 2021 11:44:56 +0100 Subject: [PATCH] [New] Added tx.get*Count() --- .../persistence/api/AbstractTransaction.java | 30 ++++++++++++ .../persistence/api/StrolchTransaction.java | 47 +++++++++++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java index 952462234..3c34e74cd 100644 --- a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java +++ b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java @@ -374,6 +374,36 @@ public abstract class AbstractTransaction implements StrolchTransaction { return this.activityMap; } + @Override + public long getResourceCount() { + return getResourceMap().querySize(this); + } + + @Override + public long getResourceCount(String type) { + return getResourceMap().querySize(this, type); + } + + @Override + public long getOrderCount() { + return getOrderMap().querySize(this); + } + + @Override + public long getOrderCount(String type) { + return getOrderMap().querySize(this, type); + } + + @Override + public long getActivityCount() { + return getActivityMap().querySize(this); + } + + @Override + public long getActivityCount(String type) { + return getActivityMap().querySize(this, type); + } + @Override public AuditTrail getAuditTrail() { if (this.auditTrail == null) { diff --git a/li.strolch.agent/src/main/java/li/strolch/persistence/api/StrolchTransaction.java b/li.strolch.agent/src/main/java/li/strolch/persistence/api/StrolchTransaction.java index 8bf3c2dc1..d40be21f1 100644 --- a/li.strolch.agent/src/main/java/li/strolch/persistence/api/StrolchTransaction.java +++ b/li.strolch.agent/src/main/java/li/strolch/persistence/api/StrolchTransaction.java @@ -171,6 +171,48 @@ public interface StrolchTransaction extends AutoCloseable { */ ActivityMap getActivityMap(); + /** + * Returns the count of all resources + * + * @return the count of all resources + */ + long getResourceCount(); + + /** + * Returns the count of resources by the given type + * + * @return the count of resources by the given type + */ + long getResourceCount(String type); + + /** + * Returns the count of all orders + * + * @return the count of all orders + */ + long getOrderCount(); + + /** + * Returns the count of orders by the given type + * + * @return the count of orders by the given type + */ + long getOrderCount(String type); + + /** + * Returns the count of all activities + * + * @return the count of all activities + */ + long getActivityCount(); + + /** + * Returns the count of activities by the given type + * + * @return the count of activities by the given type + */ + long getActivityCount(String type); + /** * Returns the {@link PersistenceHandler}. If the {@link StrolchRealm} is not running in {@link * DataStoreMode#TRANSIENT} mode, then the {@link PersistenceHandler} will be a {@link StrolchComponent}, otherwise @@ -631,9 +673,8 @@ public interface StrolchTransaction extends AutoCloseable { throws StrolchModelException, ClassCastException; /** - *

Finds a parameter with the {@link StrolchConstants#BAG_PARAMETERS} and @paramKey on the given @element, but if - * it does not exists - * on the element, then it retrieves the elements parent by using the bag {@link + *

Finds a parameter with the {@link StrolchConstants#BAG_PARAMETERS} and @paramKey on the given @element, but + * if it does not exists on the element, then it retrieves the elements parent by using the bag {@link * StrolchModelConstants#BAG_RELATIONS} and the param @parentParamKey.

* *

In Strolch relationships are usually defined on the parameter bag with the id {@link