Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Commit

Permalink
Releasing 3.6.0 - Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
  • Loading branch information
kovax committed Jan 5, 2019
2 parents 7b36a67 + 1cb92d7 commit 73ec82c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 43 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<name>CRISTAL-iSE JOOQ Storage</name>
<groupId>org.cristalise</groupId>
<artifactId>cristalise-jooqdb</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<description>CRISTAL-iSE JOOQ Storage Module</description>
<url>https://github.com/cristal-ise/jooqdb</url>
<licenses>
Expand Down Expand Up @@ -186,7 +186,7 @@
<dependency>
<groupId>org.cristalise</groupId>
<artifactId>cristalise-kernel</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
Expand Down
35 changes: 17 additions & 18 deletions src/main/java/org/cristalise/storage/jooqdb/JooqClusterStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,7 +36,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;
Expand Down Expand Up @@ -63,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();
}
Expand All @@ -88,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;
Expand All @@ -104,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
Expand Down Expand Up @@ -271,17 +276,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) {
domainHandler.put(context, uuid, (Outcome)obj);
} else if (Gateway.getProperties().getBoolean("DomainHandler.enableFullTrigger", false)) {
domainHandler.put(context, uuid, obj);
}
}


// Trigger all registered handlers to update domain specific tables
for (JooqDomainHandler domainHandler : domainHandlers) domainHandler.put(context, uuid, obj, locker);
}

@Override
Expand All @@ -303,11 +302,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);
}
}
26 changes: 8 additions & 18 deletions src/main/java/org/cristalise/storage/jooqdb/JooqDomainHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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 outcome the Outcome object beeing stored
* @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;

/**
* 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) 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.
* 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;
}
6 changes: 5 additions & 1 deletion src/main/java/org/cristalise/storage/jooqdb/JooqHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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> UUID_TYPE = SQLDataType.UUID;
public static final DataType<String> NAME_TYPE = SQLDataType.VARCHAR.length(64);
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/cristalise/lookup/LookupSearchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 73ec82c

Please sign in to comment.