use of org.jumpmind.db.platform.IDatabasePlatform in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method execute.
protected void execute(final String sql, final String node2disable) {
ISymmetricDialect dialect = getDbDialect();
IDatabasePlatform platform = dialect.getPlatform();
ISqlTransaction transaction = null;
try {
transaction = platform.getSqlTemplate().startSqlTransaction();
if (node2disable != null) {
dialect.disableSyncTriggers(transaction, node2disable);
}
transaction.prepareAndExecute(sql);
if (node2disable != null) {
dialect.enableSyncTriggers(transaction);
}
transaction.commit();
} finally {
if (transaction != null) {
transaction.close();
}
}
}
use of org.jumpmind.db.platform.IDatabasePlatform in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method update.
protected void update(String tableName, String value) {
IDatabasePlatform platform = getDbDialect().getPlatform();
String columnName = platform.alterCaseToMatchDatabaseDefaultCase("ROUTING_VARCHAR");
getSqlTemplate().update(String.format("insert into %s (%s) values(?)", tableName, columnName), value);
}
use of org.jumpmind.db.platform.IDatabasePlatform in project symmetric-ds by JumpMind.
the class DataServiceTest method setUp.
@Before
public void setUp() throws Exception {
sqlTemplate = mock(ISqlTemplate.class);
sqlTransaction = mock(ISqlTransaction.class);
when(sqlTemplate.startSqlTransaction()).thenReturn(sqlTransaction);
IDatabasePlatform platform = mock(IDatabasePlatform.class);
when(platform.getDatabaseInfo()).thenReturn(new DatabaseInfo());
when(platform.getSqlTemplate()).thenReturn(sqlTemplate);
symmetricDialect = mock(AbstractSymmetricDialect.class);
when(symmetricDialect.getPlatform()).thenReturn(platform);
parameterService = mock(ParameterService.class);
when(parameterService.getLong(ParameterConstants.ROUTING_LARGEST_GAP_SIZE)).thenReturn(50000000L);
IExtensionService extensionService = mock(ExtensionService.class);
ISymmetricEngine engine = mock(AbstractSymmetricEngine.class);
when(engine.getParameterService()).thenReturn(parameterService);
when(engine.getSymmetricDialect()).thenReturn(symmetricDialect);
dataService = new DataService(engine, extensionService);
}
use of org.jumpmind.db.platform.IDatabasePlatform in project symmetric-ds by JumpMind.
the class JavaColumnTransformTest method setUp.
@Before
public void setUp() throws Exception {
ISqlTransaction sqlTransaction = mock(ISqlTransaction.class);
platform = mock(IDatabasePlatform.class);
ISymmetricEngine engine = mock(ISymmetricEngine.class);
IParameterService parameterService = mock(IParameterService.class);
IDatabasePlatform platform = mock(IDatabasePlatform.class);
ISymmetricDialect dialect = mock(ISymmetricDialect.class);
when(dialect.getPlatform()).thenReturn(platform);
when(platform.getDatabaseInfo()).thenReturn(new DatabaseInfo());
when(engine.getParameterService()).thenReturn(parameterService);
when(engine.getSymmetricDialect()).thenReturn(dialect);
extensionService = new ExtensionService(engine);
when(engine.getExtensionService()).thenReturn(extensionService);
context = mock(DataContext.class);
when(context.findTransaction()).thenReturn(sqlTransaction);
}
use of org.jumpmind.db.platform.IDatabasePlatform in project symmetric-ds by JumpMind.
the class AbstractXmlPublisherExtensionPoint method resend.
@ManagedOperation(description = "Looks up rows in the database and resends them to the publisher")
@ManagedOperationParameters({ @ManagedOperationParameter(name = "args", description = "A pipe deliminated list of key values to use to look up the tables to resend") })
public boolean resend(String args) {
try {
String[] argArray = args != null ? args.split("\\|") : new String[0];
DataContext context = new DataContext();
IDatabasePlatform platform = engine.getDatabasePlatform();
for (String tableName : tableNamesToPublishAsGroup) {
Table table = platform.getTableFromCache(tableName, false);
List<String[]> dataRowsForTable = readData(table, argArray);
for (String[] values : dataRowsForTable) {
Batch batch = new Batch();
batch.setBinaryEncoding(engine.getSymmetricDialect().getBinaryEncoding());
batch.setSourceNodeId("republish");
context.setBatch(batch);
CsvData data = new CsvData(DataEventType.INSERT);
data.putParsedData(CsvData.ROW_DATA, values);
Element xml = getXmlFromCache(context, context.getBatch().getBinaryEncoding(), table.getColumnNames(), data.getParsedData(CsvData.ROW_DATA), table.getPrimaryKeyColumnNames(), data.getParsedData(CsvData.PK_DATA));
if (xml != null) {
toXmlElement(data.getDataEventType(), xml, table.getCatalog(), table.getSchema(), table.getName(), table.getColumnNames(), data.getParsedData(CsvData.ROW_DATA), table.getPrimaryKeyColumnNames(), data.getParsedData(CsvData.PK_DATA));
}
}
}
if (doesXmlExistToPublish(context)) {
finalizeXmlAndPublish(context);
return true;
} else {
log.warn(String.format("Failed to resend message for tables %s, columns %s, and args %s", tableNamesToPublishAsGroup, groupByColumnNames, args));
}
} catch (RuntimeException ex) {
log.error(String.format("Failed to resend message for tables %s, columns %s, and args %s", tableNamesToPublishAsGroup, groupByColumnNames, args), ex);
}
return false;
}
Aggregations