Skip to content

Commit

Permalink
Merge branch '3.9' of https://github.com/JumpMind/symmetric-ds.git in…
Browse files Browse the repository at this point in the history
…to 3.9
  • Loading branch information
jumpmind-josh committed Apr 12, 2019
2 parents ffa714e + 7881fc3 commit 400b285
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 114 deletions.
5 changes: 5 additions & 0 deletions symmetric-assemble/src/asciidoc/configuration/ldap.ad
Expand Up @@ -6,6 +6,11 @@ Configuring a <<Users>> authentication on SymmetricDS using LDAP is as simple as
console.auth.ldap.baseDN:: The LDAP base DN to search for a user.
[&#xA0;Default:&#xA0;]


A list of base DNs can be specified by separating each entry by a pipe ("|") symbol. +
For example: +
ou=Users,o=IT,c=US,dc=corp,dc=local|ou=Users,o=Tech,c=US,dc=corp,dc=local

console.auth.ldap.host:: The LDAP server host name.
[&#xA0;Default:&#xA0;]

Expand Down
Expand Up @@ -63,6 +63,7 @@
import org.jumpmind.symmetric.db.informix.InformixSymmetricDialect;
import org.jumpmind.symmetric.db.interbase.InterbaseSymmetricDialect;
import org.jumpmind.symmetric.db.mariadb.MariaDBSymmetricDialect;
import org.jumpmind.symmetric.db.mssql.MsSql2008SymmetricDialect;
import org.jumpmind.symmetric.db.mssql.MsSqlSymmetricDialect;
import org.jumpmind.symmetric.db.mssql2000.MsSql2000SymmetricDialect;
import org.jumpmind.symmetric.db.mysql.MySqlSymmetricDialect;
Expand Down Expand Up @@ -108,7 +109,7 @@ public ISymmetricDialect create() {
} else if (platform instanceof OracleDatabasePlatform) {
dialect = new OracleSymmetricDialect(parameterService, platform);
} else if (platform instanceof MsSql2008DatabasePlatform) {
dialect = new MsSqlSymmetricDialect(parameterService, platform);
dialect = new MsSql2008SymmetricDialect(parameterService, platform);
} else if (platform instanceof MsSql2005DatabasePlatform) {
dialect = new MsSqlSymmetricDialect(parameterService, platform);
} else if (platform instanceof MsSql2000DatabasePlatform) {
Expand Down
Expand Up @@ -9,8 +9,8 @@ public Db2As400TriggerTemplate(ISymmetricDialect symmetricDialect) {
super(symmetricDialect);

stringColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' || replace(replace($(tableAlias).\"$(columnName)\",'\\','\\\\'),'\"','\\\"') || '\"' end" ;
datetimeColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' || rtrim(char(year(timestamp_iso($(tableAlias).\"$(columnName)\"))))||'-'||substr(digits(month(timestamp_iso($(tableAlias).\"$(columnName)\"))),9)||'-'||substr(digits(day(timestamp_iso($(tableAlias).\"$(columnName)\"))),9)||' '||substr(digits(hour(timestamp_iso($(tableAlias).\"$(columnName)\"))),9)||':'||substr(digits(minute(timestamp_iso($(tableAlias).\"$(columnName)\"))),9)||':'||substr(digits(second(timestamp_iso($(tableAlias).\"$(columnName)\"))),9)||'.'||RIGHT(REPEAT('0',6)||rtrim(char(microsecond(timestamp_iso($(tableAlias).\"$(columnName)\")))),6) || '\"' end";
String castClobTo = symmetricDialect.getParameterService().getString(ParameterConstants.AS400_CAST_CLOB_TO, "DCLOB");

clobColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' || replace(replace(cast($(tableAlias).\"$(columnName)\" as "+castClobTo+"),'\\','\\\\'),'\"','\\\"') || '\"' end" ;

sqlTemplates.put("insertTriggerTemplate" ,
Expand Down
@@ -0,0 +1,22 @@
package org.jumpmind.symmetric.db.mssql;

import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.symmetric.model.Trigger;
import org.jumpmind.symmetric.service.IParameterService;

public class MsSql2008SymmetricDialect extends MsSqlSymmetricDialect {
public MsSql2008SymmetricDialect() {
super();
}

public MsSql2008SymmetricDialect(IParameterService parameterService, IDatabasePlatform platform) {
super(parameterService, platform);
this.triggerTemplate = new MsSql2008TriggerTemplate(this);
}

@Override
protected String getDbSpecificDataHasChangedCondition(Trigger trigger) {
/* gets filled/replaced by trigger template as it will compare by each column */
return "$(anyColumnChanged)";
}
}
@@ -0,0 +1,50 @@
package org.jumpmind.symmetric.db.mssql;

import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Table;
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.io.data.DataEventType;
import org.jumpmind.symmetric.model.Channel;
import org.jumpmind.symmetric.model.Trigger;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.jumpmind.util.FormatUtils;

public class MsSql2008TriggerTemplate extends MsSqlTriggerTemplate {
public MsSql2008TriggerTemplate(ISymmetricDialect symmetricDialect) {
super(symmetricDialect);
}

@Override
protected String replaceTemplateVariables(DataEventType dml, Trigger trigger,
TriggerHistory history, Channel channel, String tablePrefix, Table originalTable, Table table,
String defaultCatalog, String defaultSchema, String ddl) {
ddl = super.replaceTemplateVariables(dml, trigger, history, channel, tablePrefix, originalTable, table, defaultCatalog, defaultSchema, ddl);
ddl = FormatUtils.replace("anyColumnChanged",
buildColumnsAreNotEqualString(table, newTriggerValue, oldTriggerValue), ddl);
return ddl;
}

private String buildColumnsAreNotEqualString(Table table, String table1Name, String table2Name){
StringBuilder builder = new StringBuilder();

for(Column column : table.getColumns()){
if (builder.length() > 0) {
builder.append(" or ");
}

if(isNotComparable(column)) {
// Can't compare the value.
// Let's use the UPDATE() function to see if it showed up in the SET list of the update statement
builder.append(String.format("UPDATE(\"%1$s\")", column.getName()));
} else {
builder.append(String.format("((%1$s.\"%2$s\" IS NOT NULL AND %3$s.\"%2$s\" IS NOT NULL AND %1$s.\"%2$s\"<>%3$s.\"%2$s\") or "
+ "(%1$s.\"%2$s\" IS NULL AND %3$s.\"%2$s\" IS NOT NULL) or "
+ "(%1$s.\"%2$s\" IS NOT NULL AND %3$s.\"%2$s\" IS NULL))", table1Name, column.getName(), table2Name));
}
}
if (builder.length() == 0) {
builder.append("1=1");
}
return builder.toString();
}
}
Expand Up @@ -284,7 +284,7 @@ protected String replaceTemplateVariables(DataEventType dml, Trigger trigger,
return ddl;
}

private boolean isNotComparable(Column column) {
protected boolean isNotComparable(Column column) {
String columnType = column.getJdbcTypeName();
return StringUtils.equalsIgnoreCase(columnType, "IMAGE")
|| StringUtils.equalsIgnoreCase(columnType, "TEXT")
Expand Down
Expand Up @@ -77,6 +77,10 @@ protected void buildSqlReplacementTokens() {
if (parameterService.is(ParameterConstants.DBDIALECT_ORACLE_USE_HINTS, true)) {
sqlReplacementTokens.put("selectDataUsingGapsSqlHint", "/*+ index(d " + parameterService.getTablePrefix() + "_IDX_D_CHANNEL_ID) */");
}
if (parameterService.is(ParameterConstants.DBDIALECT_ORACLE_USE_SELECT_START_DATA_ID_HINT, false)) {
sqlReplacementTokens.put("selectDataUsingStartDataIdHint", "/*+ full (d) */");
}

}

@Override
Expand Down
Expand Up @@ -228,6 +228,7 @@ private ParameterConstants() {
public final static String DBDIALECT_ORACLE_USE_TRANSACTION_VIEW = "oracle.use.transaction.view";
public final static String DBDIALECT_ORACLE_TEMPLATE_NUMBER_SPEC = "oracle.template.precision";
public final static String DBDIALECT_ORACLE_USE_HINTS = "oracle.use.hints";
public final static String DBDIALECT_ORACLE_USE_SELECT_START_DATA_ID_HINT = "oracle.use.select.data.using.start.data.id.hint";
public final static String DBDIALECT_ORACLE_SEQUENCE_NOORDER = "oracle.sequence.noorder";
public final static String DBDIALECT_ORACLE_SEQUENCE_NOORDER_NEXTVALUE_DB_URLS = "oracle.sequence.noorder.nextvalue.db.urls";

Expand Down
Expand Up @@ -73,7 +73,6 @@ public class ChannelRouterContext extends SimpleRouterContext {
private long maxPeekAheadQueueSize;
private long dataRereadCount;
private List<DataGap> dataGaps = new ArrayList<DataGap>();
private Set<String> transactions = new HashSet<String>();
private long lastDataId = -1;
private List<Long> dataIds = new ArrayList<Long>();

Expand Down Expand Up @@ -153,7 +152,7 @@ synchronized public void logStats(Logger log, long totalTimeInMs) {
if (log.isDebugEnabled()) {
log.debug(channel.getChannelId() + ", startDataId=" + startDataId + ", endDataId=" + endDataId +
", dataReadCount=" + dataReadCount + ", peekAheadFillCount=" + peekAheadFillCount +
", transactions=" + transactions.toString() + ", dataGaps=" + dataGaps.toString());
", dataGaps=" + dataGaps.toString());
}
}

Expand Down Expand Up @@ -264,16 +263,6 @@ public List<DataGap> getDataGaps() {
public void setDataGaps(List<DataGap> dataGaps) {
this.dataGaps = dataGaps;
}

public Set<String> getTransactions() {
return transactions;
}

public void addTransaction(String transactionId) {
if (isNotBlank(transactionId)) {
this.transactions.add(transactionId);
}
}

public void setOnlyDefaultRoutersAssigned(boolean onlyDefaultRoutersAssigned) {
this.onlyDefaultRoutersAssigned = onlyDefaultRoutersAssigned;
Expand Down

0 comments on commit 400b285

Please sign in to comment.