From c828620f3473c59c0ca2994e64e6f963d5cdcf78 Mon Sep 17 00:00:00 2001 From: Zsolt Kovacs Date: Tue, 18 Dec 2018 21:23:08 +0100 Subject: [PATCH 1/8] Starting 3.6.0 snapshot --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 46ce9ed..6e1f6a6 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ CRISTAL-iSE JOOQ Storage org.cristalise cristalise-jooqdb - 3.5.0-SNAPSHOT + 3.6.0-SNAPSHOT CRISTAL-iSE JOOQ Storage Module https://github.com/cristal-ise/jooqdb @@ -186,7 +186,7 @@ org.cristalise cristalise-kernel - 3.5.0-SNAPSHOT + 3.6.0-SNAPSHOT mysql From bd46e16005075981b22c14b5fb0f9b17ec35a2ea Mon Sep 17 00:00:00 2001 From: Aldrin Cunanan Date: Wed, 19 Dec 2018 16:16:13 +0800 Subject: [PATCH 2/8] Issue #39 add locker to domainhandler put methods --- .../java/org/cristalise/storage/jooqdb/JooqClusterStorage.java | 2 +- .../java/org/cristalise/storage/jooqdb/JooqDomainHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java index 29f3e7f..fbf32a7 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java @@ -276,7 +276,7 @@ public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws Per for (JooqDomainHandler domainHandler : domainHandlers) { if (ClusterType.OUTCOME == cluster) { - domainHandler.put(context, uuid, (Outcome)obj); + domainHandler.put(context, uuid, (Outcome)obj, locker); } else if (Gateway.getProperties().getBoolean("DomainHandler.enableFullTrigger", false)) { domainHandler.put(context, uuid, obj); } diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java index 47048c7..44a7b09 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java @@ -51,7 +51,7 @@ public interface JooqDomainHandler { * @return the number of rows created/updated * @throws PersistencyException throw this exception in case of any error that requires to abort a transaction */ - public int put(DSLContext context, UUID uuid, Outcome outcome) throws PersistencyException; + public int put(DSLContext context, UUID uuid, Outcome outcome, Object locker) throws PersistencyException; /** * This method is called each time anything but an Outcome is stored. From bf970e625eb6b4a26ba4d4c8cbe8d33009f44ad1 Mon Sep 17 00:00:00 2001 From: Aldrin Cunanan Date: Thu, 20 Dec 2018 09:14:15 +0800 Subject: [PATCH 3/8] Issue #39 add put in missed put methods --- .../java/org/cristalise/storage/jooqdb/JooqClusterStorage.java | 2 +- .../java/org/cristalise/storage/jooqdb/JooqDomainHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java index fbf32a7..6b783e9 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java @@ -278,7 +278,7 @@ public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws Per if (ClusterType.OUTCOME == cluster) { domainHandler.put(context, uuid, (Outcome)obj, locker); } else if (Gateway.getProperties().getBoolean("DomainHandler.enableFullTrigger", false)) { - domainHandler.put(context, uuid, obj); + domainHandler.put(context, uuid, obj, locker); } } diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java index 44a7b09..aa71cc6 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java @@ -62,7 +62,7 @@ public interface JooqDomainHandler { * @return the number of rows created/updated * @throws PersistencyException throw this exception in case of any error that requires to abort a transaction */ - public int put(DSLContext context, UUID uuid, C2KLocalObject obj) throws PersistencyException; + public int put(DSLContext context, UUID uuid, C2KLocalObject obj, Object locker) throws PersistencyException; /** * This method is called each time an Outcome is deleted. From 61619d1d7a5b45b9b9d03d5595dfec676d017549 Mon Sep 17 00:00:00 2001 From: Aldrin Cunanan Date: Fri, 28 Dec 2018 11:23:58 +0800 Subject: [PATCH 4/8] Issue #39 use schema name for put with cluster type outcome --- .../org/cristalise/storage/jooqdb/JooqClusterStorage.java | 3 ++- .../java/org/cristalise/storage/jooqdb/JooqDomainHandler.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java index 6b783e9..03d73c4 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java @@ -276,7 +276,8 @@ public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws Per for (JooqDomainHandler domainHandler : domainHandlers) { if (ClusterType.OUTCOME == cluster) { - domainHandler.put(context, uuid, (Outcome)obj, locker); + String schemaName = ((Outcome) obj).getSchema().getName(); + domainHandler.put(context, uuid, schemaName, locker, true); } else if (Gateway.getProperties().getBoolean("DomainHandler.enableFullTrigger", false)) { domainHandler.put(context, uuid, obj, locker); } diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java index aa71cc6..727cd7b 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java @@ -47,11 +47,11 @@ public interface JooqDomainHandler { * * @param context The configured DSLContext of jooq * @param uuid the Item's UUID - * @param outcome the Outcome object beeing stored + * @param schemaName the schema name of the item * @return the number of rows created/updated * @throws PersistencyException throw this exception in case of any error that requires to abort a transaction */ - public int put(DSLContext context, UUID uuid, Outcome outcome, Object locker) throws PersistencyException; + public int put(DSLContext context, UUID uuid, String schemaName, Object locker, Boolean isInsert) throws PersistencyException; /** * This method is called each time anything but an Outcome is stored. From 0d8de69c223387b5abbd764cf4781efca74eff3e Mon Sep 17 00:00:00 2001 From: Aldrin Cunanan Date: Fri, 28 Dec 2018 11:46:21 +0800 Subject: [PATCH 5/8] Issue #39 remove extra parameter for put --- .../java/org/cristalise/storage/jooqdb/JooqClusterStorage.java | 2 +- .../java/org/cristalise/storage/jooqdb/JooqDomainHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java index 03d73c4..6e13d6c 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java @@ -277,7 +277,7 @@ public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws Per for (JooqDomainHandler domainHandler : domainHandlers) { if (ClusterType.OUTCOME == cluster) { String schemaName = ((Outcome) obj).getSchema().getName(); - domainHandler.put(context, uuid, schemaName, locker, true); + domainHandler.put(context, uuid, schemaName, locker); } else if (Gateway.getProperties().getBoolean("DomainHandler.enableFullTrigger", false)) { domainHandler.put(context, uuid, obj, locker); } diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java index 727cd7b..5a11fd3 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java @@ -51,7 +51,7 @@ public interface JooqDomainHandler { * @return the number of rows created/updated * @throws PersistencyException throw this exception in case of any error that requires to abort a transaction */ - public int put(DSLContext context, UUID uuid, String schemaName, Object locker, Boolean isInsert) throws PersistencyException; + public int put(DSLContext context, UUID uuid, String schemaName, Object locker) throws PersistencyException; /** * This method is called each time anything but an Outcome is stored. From 0d667bdb397712968a5ebafa7abde59c64622828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Kov=C3=A1cs?= Date: Sat, 29 Dec 2018 15:14:24 +0100 Subject: [PATCH 6/8] #39: fixing unit tests --- src/test/java/org/cristalise/lookup/LookupSearchTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/cristalise/lookup/LookupSearchTest.java b/src/test/java/org/cristalise/lookup/LookupSearchTest.java index 80ca000..7caadf6 100644 --- a/src/test/java/org/cristalise/lookup/LookupSearchTest.java +++ b/src/test/java/org/cristalise/lookup/LookupSearchTest.java @@ -58,10 +58,10 @@ public void setUp() throws Exception { lookup.add( new DomainPath("empty/nothing") ); lookup.add( new DomainPath("empty/something/uuid0", lookup.getItemPath(uuid0.toString())) ); //lookup.add( new DomainPath("empty.old/something/uuid1", lookup.getItemPath(uuid1.toString())) ); - lookup.add( new RolePath(new RolePath(), "User") ); - lookup.add( new RolePath(new RolePath(), "User/SubUser") ); - lookup.add( new RolePath(new RolePath(), "User/SubUser/DummyUser") ); - lookup.add( new RolePath(new RolePath(), "User/LowerUser") ); + lookup.add( new RolePath(new RolePath(), "User") ); + lookup.add( new RolePath(new RolePath("User"), "SubUser") ); + lookup.add( new RolePath(new RolePath("User/SubUser"), "DummyUser") ); + lookup.add( new RolePath(new RolePath("User"), "LowerUser") ); } @Test From baf825c60cf80c911548edcf30fa6fbe524e7b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Kov=C3=A1cs?= Date: Sat, 29 Dec 2018 15:49:46 +0100 Subject: [PATCH 7/8] =?UTF-8?q?#39:=20Simplified=20J=C3=BC=C3=BCqDomainHan?= =?UTF-8?q?dler=20interface=20(not=20backward=20compatible)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage/jooqdb/JooqClusterStorage.java | 24 +++++++------------ .../storage/jooqdb/JooqDomainHandler.java | 24 ++++++------------- 2 files changed, 15 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java index 6e13d6c..ddb2ca9 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java @@ -32,7 +32,6 @@ import org.cristalise.kernel.lookup.ItemPath; import org.cristalise.kernel.persistency.ClusterType; import org.cristalise.kernel.persistency.TransactionalClusterStorage; -import org.cristalise.kernel.persistency.outcome.Outcome; import org.cristalise.kernel.process.Gateway; import org.cristalise.kernel.process.auth.Authenticator; import org.cristalise.kernel.querying.Query; @@ -271,18 +270,11 @@ public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws Per handler.put(context, uuid, obj); } else { - throw new PersistencyException("Write is not supported for cluster:'"+cluster+"'"); + throw new PersistencyException("Write is not supported for cluster:'"+cluster+"'"); } - - for (JooqDomainHandler domainHandler : domainHandlers) { - if (ClusterType.OUTCOME == cluster) { - String schemaName = ((Outcome) obj).getSchema().getName(); - domainHandler.put(context, uuid, schemaName, locker); - } else if (Gateway.getProperties().getBoolean("DomainHandler.enableFullTrigger", false)) { - domainHandler.put(context, uuid, obj, locker); - } - } - + + // Trigger all registered handlers to update domain specific tables + for (JooqDomainHandler domainHandler : domainHandlers) domainHandler.put(context, uuid, obj, locker); } @Override @@ -304,11 +296,11 @@ public void delete(ItemPath itemPath, String path, Object locker) throws Persist Logger.msg(5, "JooqClusterStorage.delete() - uuid:"+uuid+" cluster:"+cluster+" primaryKeys"+Arrays.toString(primaryKeys)); handler.delete(context, uuid, primaryKeys); } - else + else { throw new PersistencyException("No handler found for cluster:'"+cluster+"'"); - - if (ClusterType.OUTCOME == cluster) { - for (JooqDomainHandler domainHandler : domainHandlers) domainHandler.delete(context, uuid, primaryKeys); } + + // Trigger all registered handlers to update domain specific tables + for (JooqDomainHandler domainHandler : domainHandlers) domainHandler.delete(context, uuid, locker, primaryKeys); } } diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java index 5a11fd3..1927354 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java @@ -24,12 +24,11 @@ import org.cristalise.kernel.common.PersistencyException; import org.cristalise.kernel.entity.C2KLocalObject; -import org.cristalise.kernel.persistency.outcome.Outcome; import org.jooq.DSLContext; /** - * Provides mechanism to update application(domain) specific table(s) during the transaction - * of storing an Outcome. + * Provides mechanism to update application(domain) specific table(s) during the transaction. + * @since 3.6.0 */ public interface JooqDomainHandler { @@ -43,35 +42,26 @@ public interface JooqDomainHandler { public void createTables(DSLContext context) throws PersistencyException; /** - * This method is called each time an Outcome is stored. - * - * @param context The configured DSLContext of jooq - * @param uuid the Item's UUID - * @param schemaName the schema name of the item - * @return the number of rows created/updated - * @throws PersistencyException throw this exception in case of any error that requires to abort a transaction - */ - public int put(DSLContext context, UUID uuid, String schemaName, Object locker) throws PersistencyException; - - /** - * This method is called each time anything but an Outcome is stored. + * This method is called each time a C2KLocalObject is stored. * * @param context The configured DSLContext of jooq * @param uuid the Item's UUID * @param obj Object that is being stored + * @param locker transaction key * @return the number of rows created/updated * @throws PersistencyException throw this exception in case of any error that requires to abort a transaction */ public int put(DSLContext context, UUID uuid, C2KLocalObject obj, Object locker) throws PersistencyException; /** - * This method is called each time an Outcome is deleted. + * This method is called each time a C2KLocalObject is deleted. * * @param context The configured DSLContext of jooq * @param uuid the Item's UUID + * @param locker transaction key * @param primaryKeys the identifiers of the Outcome withing the Item * @return the number of rows deleted * @throws PersistencyException throw this exception in case of any error that requires to abort a transaction */ - public int delete(DSLContext context, UUID uuid, String...primaryKeys) throws PersistencyException; + public int delete(DSLContext context, UUID uuid, Object locker, String...primaryKeys) throws PersistencyException; } From 1cb92d738c6b711250302ea8ecab9e38e6d2f14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Kov=C3=A1cs?= Date: Sun, 30 Dec 2018 22:32:15 +0100 Subject: [PATCH 8/8] #41: disable calling DomainHandler.createTable() --- .../storage/jooqdb/JooqClusterStorage.java | 12 +++++++++--- .../org/cristalise/storage/jooqdb/JooqHandler.java | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java index ddb2ca9..ed803f5 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java @@ -20,6 +20,10 @@ */ package org.cristalise.storage.jooqdb; +import static org.cristalise.storage.jooqdb.JooqHandler.JOOQ_DOMAIN_HANDLERS; +import static org.cristalise.storage.jooqdb.JooqHandler.JOOQ_AUTOCOMMIT; +import static org.cristalise.storage.jooqdb.JooqHandler.JOOQ_DISABLE_DOMAIN_CREATE; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -62,7 +66,7 @@ public class JooqClusterStorage extends TransactionalClusterStorage { public void open(Authenticator auth) throws PersistencyException { context = JooqHandler.connect(); - autoCommit = Gateway.getProperties().getBoolean(JooqHandler.JOOQ_AUTOCOMMIT, false); + autoCommit = Gateway.getProperties().getBoolean(JOOQ_AUTOCOMMIT, false); initialiseHandlers(); } @@ -87,7 +91,7 @@ public void initialiseHandlers() throws PersistencyException { for (JooqHandler handler: jooqHandlers.values()) handler.createTables(context); try { - String handlers = Gateway.getProperties().getString(JooqHandler.JOOQ_DOMAIN_HANDLERS, ""); + String handlers = Gateway.getProperties().getString(JOOQ_DOMAIN_HANDLERS, ""); for(String handlerClass: StringUtils.split(handlers, ",")) { if (!handlerClass.contains(".")) handlerClass = "org.cristalise.storage."+handlerClass; @@ -103,7 +107,9 @@ public void initialiseHandlers() throws PersistencyException { throw new PersistencyException("JooqClusterStorage could not instantiate domain handler:"+ex.getMessage()); } - for (JooqDomainHandler handler: domainHandlers) handler.createTables(context); + if (! Gateway.getProperties().getBoolean(JOOQ_DISABLE_DOMAIN_CREATE, false)) { + for (JooqDomainHandler handler: domainHandlers) handler.createTables(context); + } } @Override diff --git a/src/main/java/org/cristalise/storage/jooqdb/JooqHandler.java b/src/main/java/org/cristalise/storage/jooqdb/JooqHandler.java index 1f5520a..338c9f1 100644 --- a/src/main/java/org/cristalise/storage/jooqdb/JooqHandler.java +++ b/src/main/java/org/cristalise/storage/jooqdb/JooqHandler.java @@ -23,7 +23,6 @@ import static org.jooq.impl.DSL.select; import static org.jooq.impl.DSL.using; -import java.sql.Blob; import java.sql.DriverManager; import java.sql.Timestamp; import java.util.Arrays; @@ -74,6 +73,11 @@ public abstract class JooqHandler { * fully qualified class names implementing the {@link JooqDomainHandler} interface. */ public static final String JOOQ_DOMAIN_HANDLERS = "JOOQ.domainHandlers"; + /** + * Defines the key (value:{@value}) to retrieve the boolean value to disable the invocation of + * {@link JooqDomainHandler#createTables(DSLContext)}. Default is 'false' + */ + public static final String JOOQ_DISABLE_DOMAIN_CREATE = "JOOQ.disableDomainCreateTables"; public static final DataType UUID_TYPE = SQLDataType.UUID; public static final DataType NAME_TYPE = SQLDataType.VARCHAR.length(64);