From bacf17b1a74783907039fcfb3f6a74e4d709bc54 Mon Sep 17 00:00:00 2001
From: Robert von Burg
Date: Tue, 20 Jan 2015 19:47:49 +0100
Subject: [PATCH] [New] Added tx.auditFrom() - this allows to quickly create a
new Audit which uses the details from the current TX. This TX can then be
added to the auditTrail for persisting
---
.../persistence/api/AbstractTransaction.java | 3 +-
.../persistence/api/StrolchTransaction.java | 187 +++++++-----------
2 files changed, 71 insertions(+), 119 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 1f348b8c5..84ed70181 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
@@ -687,7 +687,8 @@ public abstract class AbstractTransaction implements StrolchTransaction {
}
}
- private Audit auditFrom(AccessType accessType, String elementType, String id) {
+ @Override
+ public Audit auditFrom(AccessType accessType, String elementType, String id) {
Audit audit = new Audit();
audit.setId(StrolchAgent.getUniqueIdLong());
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 8f526d624..188d64103 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
@@ -29,6 +29,7 @@ import li.strolch.model.Resource;
import li.strolch.model.ResourceVisitor;
import li.strolch.model.StrolchElement;
import li.strolch.model.StrolchRootElement;
+import li.strolch.model.audit.AccessType;
import li.strolch.model.audit.Audit;
import li.strolch.model.audit.AuditQuery;
import li.strolch.model.audit.AuditVisitor;
@@ -77,14 +78,15 @@ public interface StrolchTransaction extends AutoCloseable {
public void addCommand(Command command);
+ public Audit auditFrom(AccessType accessType, String elementType, String id);
+
public List doQuery(OrderQuery query);
public List doQuery(OrderQuery query, OrderVisitor orderVisitor);
public List doQuery(ResourceQuery query);
- public List doQuery(ResourceQuery query,
- ResourceVisitor resourceVisitor);
+ public List doQuery(ResourceQuery query, ResourceVisitor resourceVisitor);
public List doQuery(AuditQuery query);
@@ -96,233 +98,182 @@ public interface StrolchTransaction extends AutoCloseable {
*
*
*
- * A Locator has the form
- * <ObjectClassType>/<Type>/<Id> - this is the
- * least amount of path elements to find an object. Thus to query a
- * {@link Resource} of type "MyType" and the id "@1" use the following path:
- * Resourcee/MyType/@1
+ * A Locator has the form <ObjectClassType>/<Type>/<Id> - this is the least amount of path
+ * elements to find an object. Thus to query a {@link Resource} of type "MyType" and the id "@1" use the following
+ * path: Resourcee/MyType/@1
*
*
*
- * This method can also be used to find a deeper element, e.g. a specific
- * {@link Parameter} on an {@link ParameterBag} on an {@link Order}. This
- * would be done as follows: Order/MyType/@1/myParam
+ * This method can also be used to find a deeper element, e.g. a specific {@link Parameter} on an
+ * {@link ParameterBag} on an {@link Order}. This would be done as follows: Order/MyType/@1/myParam
*
*
* @param locator
- * the locator defining the path to the element which is to be
- * found
+ * the locator defining the path to the element which is to be found
*
* @return the element described by the locator
*
* @throws StrolchException
* if the element could not be found
* @throws ClassCastException
- * if the querying code is not asking for the correct instance.
- * Do not query a {@link Parameter} if the variable to which the
- * result is to be is stored is a {@link Resource}, etc.
+ * if the querying code is not asking for the correct instance. Do not query a {@link Parameter} if the
+ * variable to which the result is to be is stored is a {@link Resource}, etc.
*/
- public T findElement(Locator locator)
- throws StrolchException, ClassCastException;
+ public T findElement(Locator locator) throws StrolchException, ClassCastException;
/**
- * Returns the {@link Resource} with the given type and id, or null if it
- * does not exist
+ * Returns the {@link Resource} with the given type and id, or null if it does not exist
*
* @param type
* the type of the {@link Resource}
* @param id
* the id of the {@link Resource}
*
- * @return the {@link Resource} with the given type and id, or null if it
- * does not exist
+ * @return the {@link Resource} with the given type and id, or null if it does not exist
*/
public Resource getResourceBy(String type, String id);
/**
- * Returns the {@link Resource} with the given type and id, or null if it
- * does not exist
+ * Returns the {@link Resource} with the given type and id, or null if it does not exist
*
* @param type
* the type of the {@link Resource}
* @param id
* the id of the {@link Resource}
* @param assertExists
- * if true, and resource does not exist, then a
- * {@link StrolchException} is thrown
+ * if true, and resource does not exist, then a {@link StrolchException} is thrown
*
- * @return the {@link Resource} with the given type and id, or null if it
- * does not exist
+ * @return the {@link Resource} with the given type and id, or null if it does not exist
*
* @throws StrolchException
* if the resource does not exist, and assertExists is true
*/
- public Resource getResourceBy(String type, String id, boolean assertExists)
- throws StrolchException;
+ public Resource getResourceBy(String type, String id, boolean assertExists) throws StrolchException;
/**
- * Returns the {@link Resource} which is referenced by the given
- * {@link StringParameter}. A reference {@link Parameter} must have its
- * interpretation set to
- * {@link StrolchConstants#INTERPRETATION_RESOURCE_REF} and the UOM must be
- * set to the resource's type and the value is the id of the resource
+ * Returns the {@link Resource} which is referenced by the given {@link StringParameter}. A reference
+ * {@link Parameter} must have its interpretation set to {@link StrolchConstants#INTERPRETATION_RESOURCE_REF} and
+ * the UOM must be set to the resource's type and the value is the id of the resource
*
* @param refP
- * the {@link StringParameter} which references a
- * {@link Resource}
+ * the {@link StringParameter} which references a {@link Resource}
*
- * @return the resource referenced by the parameter, or null if it does not
- * exist
+ * @return the resource referenced by the parameter, or null if it does not exist
*
* @throws StrolchException
- * if the {@link StringParameter} is not a properly configured
- * as a reference parameter
+ * if the {@link StringParameter} is not a properly configured as a reference parameter
*/
public Resource getResourceBy(StringParameter refP) throws StrolchException;
/**
- * Returns the {@link Resource} which is referenced by the given
- * {@link StringParameter}. A reference {@link Parameter} must have its
- * interpretation set to
- * {@link StrolchConstants#INTERPRETATION_RESOURCE_REF} and the UOM must be
- * set to the resource's type and the value is the id of the resource
+ * Returns the {@link Resource} which is referenced by the given {@link StringParameter}. A reference
+ * {@link Parameter} must have its interpretation set to {@link StrolchConstants#INTERPRETATION_RESOURCE_REF} and
+ * the UOM must be set to the resource's type and the value is the id of the resource
*
* @param refP
- * the {@link StringParameter} which references a
- * {@link Resource}
+ * the {@link StringParameter} which references a {@link Resource}
* @param assertExists
- * if true, and resource does not exist, then a
- * {@link StrolchException} is thrown
+ * if true, and resource does not exist, then a {@link StrolchException} is thrown
*
- * @return the resource referenced by the parameter, or null if it does not
- * exist
+ * @return the resource referenced by the parameter, or null if it does not exist
*
* @throws StrolchException
- * if the {@link StringParameter} is not a properly configured
- * as a reference parameter, or if the resource does not exist,
- * and assertExists is true
+ * if the {@link StringParameter} is not a properly configured as a reference parameter, or if the
+ * resource does not exist, and assertExists is true
*/
- public Resource getResourceBy(StringParameter refP, boolean assertExists)
- throws StrolchException;
+ public Resource getResourceBy(StringParameter refP, boolean assertExists) throws StrolchException;
/**
- * Returns all {@link Resource Resources} which are referenced by the given
- * {@link StringListParameter}. A reference {@link Parameter} must have its
- * interpretation set to
- * {@link StrolchConstants#INTERPRETATION_RESOURCE_REF} and the UOM must be
- * set to the resource's type and the value is the id of the resource
+ * Returns all {@link Resource Resources} which are referenced by the given {@link StringListParameter}. A reference
+ * {@link Parameter} must have its interpretation set to {@link StrolchConstants#INTERPRETATION_RESOURCE_REF} and
+ * the UOM must be set to the resource's type and the value is the id of the resource
*
* @param refP
- * the {@link StringListParameter} which references a list of
- * {@link Resource Resources}
+ * the {@link StringListParameter} which references a list of {@link Resource Resources}
*
- * @return the resources referenced by the parameter, or the empty list if
- * they do not exist. Note: Any missing resources are not
- * returned!
+ * @return the resources referenced by the parameter, or the empty list if they do not exist. Note: Any
+ * missing resources are not returned!
*
* @throws StrolchException
- * if the {@link StringListParameter} is not a properly
- * configured as a reference parameter
+ * if the {@link StringListParameter} is not a properly configured as a reference parameter
*/
- public List getResourcesBy(StringListParameter refP)
- throws StrolchException;
+ public List getResourcesBy(StringListParameter refP) throws StrolchException;
/**
- * Returns the {@link Order} with the given type and id, or null if it does
- * not exist
+ * Returns the {@link Order} with the given type and id, or null if it does not exist
*
* @param type
* the type of the {@link Order}
* @param id
* the id of the {@link Order}
*
- * @return the {@link Order} with the given type and id, or null if it does
- * not exist
+ * @return the {@link Order} with the given type and id, or null if it does not exist
*/
public Order getOrderBy(String type, String id);
/**
- * Returns the {@link Order} with the given type and id, or null if it does
- * not exist
+ * Returns the {@link Order} with the given type and id, or null if it does not exist
*
* @param type
* the type of the {@link Order}
* @param id
* the id of the {@link Order}
* @param assertExists
- * if true, and order does not exist, then a
- * {@link StrolchException} is thrown
+ * if true, and order does not exist, then a {@link StrolchException} is thrown
*
- * @return the {@link Order} with the given type and id, or null if it does
- * not exist
+ * @return the {@link Order} with the given type and id, or null if it does not exist
*
* @throws StrolchException
* if the order does not exist, and assertExists is true
*/
- public Order getOrderBy(String type, String id, boolean assertExists)
- throws StrolchException;
+ public Order getOrderBy(String type, String id, boolean assertExists) throws StrolchException;
/**
- * Returns the {@link Order} which is referenced by the given
- * {@link StringParameter}. A reference {@link Parameter} must have its
- * interpretation set to {@link StrolchConstants#INTERPRETATION_ORDER_REF}
- * and the UOM must be set to the order's type and the value is the id of
- * the order
+ * Returns the {@link Order} which is referenced by the given {@link StringParameter}. A reference {@link Parameter}
+ * must have its interpretation set to {@link StrolchConstants#INTERPRETATION_ORDER_REF} and the UOM must be set to
+ * the order's type and the value is the id of the order
*
* @param refP
* the {@link StringParameter} which references an {@link Order}
*
- * @return the order referenced by the parameter, or null if it does not
- * exist
+ * @return the order referenced by the parameter, or null if it does not exist
*
* @throws StrolchException
- * if the {@link StringParameter} is not a properly configured
- * as a reference parameter
+ * if the {@link StringParameter} is not a properly configured as a reference parameter
*/
public Order getOrderBy(StringParameter refP) throws StrolchException;
/**
- * Returns the {@link Order} which is referenced by the given
- * {@link StringParameter}. A reference {@link Parameter} must have its
- * interpretation set to {@link StrolchConstants#INTERPRETATION_ORDER_REF}
- * and the UOM must be set to the order's type and the value is the id of
- * the order
+ * Returns the {@link Order} which is referenced by the given {@link StringParameter}. A reference {@link Parameter}
+ * must have its interpretation set to {@link StrolchConstants#INTERPRETATION_ORDER_REF} and the UOM must be set to
+ * the order's type and the value is the id of the order
*
* @param refP
* the {@link StringParameter} which references an {@link Order}
* @param assertExists
- * if true, and order does not exist, then a
- * {@link StrolchException} is thrown
+ * if true, and order does not exist, then a {@link StrolchException} is thrown
*
- * @return the order referenced by the parameter, or null if it does not
- * exist
+ * @return the order referenced by the parameter, or null if it does not exist
*
* @throws StrolchException
- * if the {@link StringParameter} is not a properly configured
- * as a reference parameter, or if the order does not exist, and
- * assertExists is true
+ * if the {@link StringParameter} is not a properly configured as a reference parameter, or if the order
+ * does not exist, and assertExists is true
*/
- public Order getOrderBy(StringParameter refP, boolean assertExists)
- throws StrolchException;
+ public Order getOrderBy(StringParameter refP, boolean assertExists) throws StrolchException;
/**
- * Returns all {@link Order Orders} which are referenced by the given
- * {@link StringListParameter}. A reference {@link Parameter} must have its
- * interpretation set to {@link StrolchConstants#INTERPRETATION_ORDER_REF}
- * and the UOM must be set to the order's type and the value is the id of
- * the order
+ * Returns all {@link Order Orders} which are referenced by the given {@link StringListParameter}. A reference
+ * {@link Parameter} must have its interpretation set to {@link StrolchConstants#INTERPRETATION_ORDER_REF} and the
+ * UOM must be set to the order's type and the value is the id of the order
*
* @param refP
- * the {@link StringListParameter} which references a list of
- * {@link Order Orders}
+ * the {@link StringListParameter} which references a list of {@link Order Orders}
*
- * @return the orders referenced by the parameter, or the empty list if they
- * do not exist. Note: Any missing orders are not returned!
+ * @return the orders referenced by the parameter, or the empty list if they do not exist. Note: Any missing
+ * orders are not returned!
*
* @throws StrolchException
- * if the {@link StringListParameter} is not a properly
- * configured as a reference parameter
+ * if the {@link StringListParameter} is not a properly configured as a reference parameter
*/
- public List getOrdersBy(StringListParameter refP)
- throws StrolchException;
+ public List getOrdersBy(StringListParameter refP) throws StrolchException;
}