From 657c47aacd2597787c4fde54f7ce409d64f547ae Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 21 Sep 2016 10:00:51 +0200 Subject: [PATCH] [New] Added get activity template methods on StrolchTransaction --- .../persistence/api/AbstractTransaction.java | 10 +++ .../persistence/api/StrolchTransaction.java | 65 ++++++++++++++++--- 2 files changed, 65 insertions(+), 10 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 1520981d6..88418b49e 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 @@ -421,6 +421,16 @@ public abstract class AbstractTransaction implements StrolchTransaction { return getOrderMap().getTemplate(this, type, assertExists); } + @Override + public Activity getActivityTemplate(String type) { + return getActivityMap().getTemplate(this, type); + } + + @Override + public Activity getActivityTemplate(String type, boolean assertExists) throws StrolchException { + return getActivityMap().getTemplate(this, type, assertExists); + } + @Override public Order getOrderBy(String type, String id) { return getOrderBy(type, id, false); 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 06fb0dc52..fde191333 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 @@ -457,8 +457,8 @@ public interface StrolchTransaction extends AutoCloseable { /** *

- * Returns a copy of the {@link Resource} of Type {@link StrolchConstants#TEMPLATE} with the given type as id, or null if it - * does not exist + * Returns a copy of the {@link Resource} of Type {@link StrolchConstants#TEMPLATE} with the given type as id, or + * null if it does not exist *

* *

@@ -472,7 +472,7 @@ public interface StrolchTransaction extends AutoCloseable { * @param type * the id of the {@link Resource} template * - * @return the {@link Resource} template with the given id, or null if it does not exist + * @return the copy of the {@link Resource} template with the given id, or null if it does not exist */ public Resource getResourceTemplate(String type); @@ -493,8 +493,8 @@ public interface StrolchTransaction extends AutoCloseable { * @param type * the id of the {@link Resource} template * - * @return the {@link Resource} template with the given id, or if assertExists is true, then an - * exception is thrown if the resource does not exist + * @return the copy of the {@link Resource} template with the given id, or if assertExists is true, + * then an exception is thrown if the resource does not exist * * @throws StrolchException */ @@ -502,8 +502,8 @@ public interface StrolchTransaction extends AutoCloseable { /** *

- * Returns a copy of the {@link Order} of Type {@link StrolchConstants#TEMPLATE} with the given type as id, or null if it does - * not exist + * Returns a copy of the {@link Order} of Type {@link StrolchConstants#TEMPLATE} with the given type as id, or null + * if it does not exist *

* *

@@ -517,7 +517,7 @@ public interface StrolchTransaction extends AutoCloseable { * @param type * the id of the {@link Order} template * - * @return the {@link Order} template with the given id, or null if it does not exist + * @return the copy of the {@link Order} template with the given id, or null if it does not exist */ public Order getOrderTemplate(String type); @@ -538,13 +538,58 @@ public interface StrolchTransaction extends AutoCloseable { * @param type * the id of the {@link Order} template * - * @return the {@link Order} template with the given id, or if assertExists is true, then an exception - * is thrown if the order does not exist + * @return the copy of the {@link Order} template with the given id, or if assertExists is true, then + * an exception is thrown if the order does not exist * * @throws StrolchException */ public Order getOrderTemplate(String type, boolean assertExists) throws StrolchException; + /** + *

+ * Returns a copy of the {@link Activity} of Type {@link StrolchConstants#TEMPLATE} with the given type as id, or + * null if it does not exist + *

+ * + *

+ * Templates are {@link StrolchRootElement StrolchRootElements} which have the type + * {@link StrolchConstants#TEMPLATE} and their id is the type of element for which it is a template. For instance + * when creating a {@link Activity} of type ToStock then having a template with the id + * ToStock helps creating new ToStock activities; get the activity and then create a clone: + * {@link Activity#getClone()} + *

+ * + * @param type + * the id of the {@link Activity} template + * + * @return the copy of the {@link Activity} template with the given id, or null if it does not exist + */ + public Activity getActivityTemplate(String type); + + /** + *

+ * Returns a copy of the {@link Activity} of Type {@link StrolchConstants#TEMPLATE} with the given type as id. If + * assertExists is true, then an exception is thrown if the template does not exist does not exist + *

+ * + *

+ * Templates are {@link StrolchRootElement StrolchRootElements} which have the type + * {@link StrolchConstants#TEMPLATE} and their id is the type of element for which it is a template. For instance + * when creating a {@link Activity} of type ToStock then having a template with the id + * ToStock helps creating new ToStock activities; get the activity and then create a clone: + * {@link Activity#getClone()} + *

+ * + * @param type + * the id of the {@link Activity} template + * + * @return the copy of the {@link Activity} template with the given id, or if assertExists is true, + * then an exception is thrown if the activity does not exist + * + * @throws StrolchException + */ + public Activity getActivityTemplate(String type, boolean assertExists) throws StrolchException; + /** * Returns the {@link Resource} with the given type and id, or null if it does not exist *