Navigation Menu

Skip to content

Commit

Permalink
0001713: Add initial.load.before.sql and initial.load.after.sql which…
Browse files Browse the repository at this point in the history
… can contain sql that runs on the client before and after a load
  • Loading branch information
chenson42 committed May 8, 2014
1 parent 281a369 commit 86bcd22
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Expand Up @@ -99,6 +99,8 @@ private ParameterConstants() {
public final static String AUTO_CONFIGURE_EXTRA_TABLES = "auto.config.extra.tables.ddlutil.xml";
public final static String AUTO_UPDATE_NODE_VALUES = "auto.update.node.values.from.properties";

public final static String INITIAL_LOAD_BEFORE_SQL = "initial.load.before.sql";
public final static String INITIAL_LOAD_AFTER_SQL = "initial.load.after.sql";
public final static String INITIAL_LOAD_DELETE_BEFORE_RELOAD = "initial.load.delete.first";
public final static String INITIAL_LOAD_DELETE_FIRST_SQL = "initial.load.delete.first.sql";
public final static String INITIAL_LOAD_CREATE_SCHEMA_BEFORE_RELOAD = "initial.load.create.first";
Expand Down
Expand Up @@ -20,6 +20,8 @@
*/
package org.jumpmind.symmetric.service.impl;

import static org.apache.commons.lang.StringUtils.isNotBlank;

import java.sql.DataTruncation;
import java.sql.Types;
import java.util.ArrayList;
Expand Down Expand Up @@ -368,8 +370,13 @@ public void insertReloadEvents(Node targetNode, boolean reverse) {
insertLoadBatchesForReload(targetNode, loadId, createBy, triggerHistories,
triggerRoutersByHistoryId, transactional, transaction);

insertFileSyncBatchForReload(targetNode, loadId, createBy, transactional, transaction);
String afterSql = parameterService.getString(ParameterConstants.INITIAL_LOAD_AFTER_SQL);
if (isNotBlank(afterSql)) {
insertSqlEvent(transaction, targetNode, afterSql, true, loadId, createBy);
}

insertFileSyncBatchForReload(targetNode, loadId, createBy, transactional, transaction);

callReloadListeners(false, targetNode, transactional, transaction);

if (!reverse) {
Expand Down Expand Up @@ -451,6 +458,15 @@ private void insertSqlEventsPriorToReload(Node targetNode, String nodeIdRecord,
tablePrefix, engine.getNodeService().findIdentityNodeId()), true,
loadId, createBy);
}

String beforeSql = parameterService.getString(ParameterConstants.INITIAL_LOAD_BEFORE_SQL);
if (isNotBlank(beforeSql)) {
insertSqlEvent(
transaction,
targetNode,
beforeSql, true,
loadId, createBy);
}
}

private void insertCreateBatchesForReload(Node targetNode, long loadId, String createBy,
Expand Down
12 changes: 12 additions & 0 deletions symmetric-core/src/main/resources/symmetric-default.properties
Expand Up @@ -479,6 +479,18 @@ initial.load.extract.timeout.ms=7200000
# Type: boolean
initial.load.concat.csv.in.sql.enabled=false

# This is SQL that will run on the client before an initial load starts.
#
# DatabaseOverridable: true
# Tags: load
initial.load.before.sql=

# This is SQL that will run on the client after an initial load finishes.
#
# DatabaseOverridable: true
# Tags: load
initial.load.after.sql=

# If this is true, registration is opened automatically for nodes requesting it.
#
# DatabaseOverridable: true
Expand Down

0 comments on commit 86bcd22

Please sign in to comment.