[New] Added StrolchTransaction.getStatistics()
This commit is contained in:
parent
2fdc7118e4
commit
9c4ac3e7a4
|
@ -34,6 +34,7 @@ import li.strolch.utils.collections.MapOfMaps;
|
|||
import li.strolch.utils.dbc.DBC;
|
||||
import li.strolch.utils.helper.StringHelper;
|
||||
import li.strolch.utils.objectfilter.ObjectFilter;
|
||||
import li.strolch.utils.objectfilter.ObjectFilterStatistics;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -62,6 +63,7 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
|||
private final TransactionResult txResult;
|
||||
|
||||
private final ObjectFilter objectFilter;
|
||||
private ObjectFilterStatistics objectFilterStatistics;
|
||||
private final MapOfMaps<String, String, Resource> resourceCache;
|
||||
private final MapOfMaps<String, String, Order> orderCache;
|
||||
private final MapOfMaps<String, String, Activity> activityCache;
|
||||
|
@ -285,6 +287,13 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
|||
return (!this.objectFilter.isEmpty()) || !this.commands.isEmpty() || !this.flushedCommands.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectFilterStatistics getStatistics() {
|
||||
if (this.objectFilterStatistics == null)
|
||||
return this.objectFilter.toStatistics();
|
||||
return this.objectFilterStatistics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLock(Locator locator) throws StrolchLockException {
|
||||
return this.lockedElements.contains(locator);
|
||||
|
@ -1484,6 +1493,13 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
|||
add(cmd);
|
||||
}
|
||||
|
||||
if (this.objectFilterStatistics == null) {
|
||||
this.objectFilterStatistics = this.objectFilter.toStatistics();
|
||||
} else {
|
||||
ObjectFilterStatistics statistics = this.objectFilter.toStatistics();
|
||||
this.objectFilterStatistics = this.objectFilterStatistics.merge(statistics);
|
||||
}
|
||||
|
||||
// clear, so that we don't do it twice in case of a flush()
|
||||
this.objectFilter.clearCache();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import li.strolch.privilege.model.PrivilegeContext;
|
|||
import li.strolch.privilege.model.Restrictable;
|
||||
import li.strolch.runtime.StrolchConstants;
|
||||
import li.strolch.service.api.Command;
|
||||
import li.strolch.utils.objectfilter.ObjectFilterStatistics;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -1891,4 +1892,9 @@ public interface StrolchTransaction extends AutoCloseable {
|
|||
* if the session for this TX does not have any of the given roles
|
||||
*/
|
||||
void assertHasAnyRole(String... roleNames) throws AccessDeniedException;
|
||||
|
||||
/**
|
||||
* Returns the statistics of this TX, i.e. the number of elements added, updated and removed in this TX
|
||||
*/
|
||||
ObjectFilterStatistics getStatistics();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue