Search in sources :

Example 6 with DatabaseInfo

use of org.jumpmind.db.platform.DatabaseInfo in project symmetric-ds by JumpMind.

the class DataGapDetectorTest 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);
    when(symmetricDialect.supportsTransactionViews()).thenReturn(false);
    when(symmetricDialect.getDatabaseTime()).thenReturn(0L);
    parameterService = mock(ParameterService.class);
    when(parameterService.getEngineName()).thenReturn(ENGINE_NAME);
    when(parameterService.getLong(ParameterConstants.ROUTING_STALE_DATA_ID_GAP_TIME)).thenReturn(60000000L);
    when(parameterService.getInt(ParameterConstants.DATA_ID_INCREMENT_BY)).thenReturn(1);
    when(parameterService.getLong(ParameterConstants.ROUTING_LARGEST_GAP_SIZE)).thenReturn(50000000L);
    when(parameterService.getLong(ParameterConstants.DBDIALECT_ORACLE_TRANSACTION_VIEW_CLOCK_SYNC_THRESHOLD_MS)).thenReturn(60000L);
    when(parameterService.getLong(ParameterConstants.ROUTING_STALE_GAP_BUSY_EXPIRE_TIME)).thenReturn(60000L);
    when(parameterService.is(ParameterConstants.ROUTING_DETECT_INVALID_GAPS)).thenReturn(true);
    when(parameterService.getInt(ParameterConstants.ROUTING_MAX_GAP_CHANGES)).thenReturn(1000);
    IExtensionService extensionService = mock(ExtensionService.class);
    ISymmetricEngine engine = mock(AbstractSymmetricEngine.class);
    when(engine.getParameterService()).thenReturn(parameterService);
    when(engine.getStatisticManager()).thenReturn(statisticManager);
    when(engine.getNodeService()).thenReturn(nodeService);
    when(engine.getDataService()).thenReturn(dataService);
    when(engine.getSymmetricDialect()).thenReturn(symmetricDialect);
    when(engine.getExtensionService()).thenReturn(extensionService);
    routerService = new RouterService(engine);
    when(engine.getRouterService()).thenReturn(routerService);
    contextService = mock(ContextService.class);
    dataService = mock(DataService.class);
    statisticManager = mock(StatisticManager.class);
    when(statisticManager.newProcessInfo((ProcessInfoKey) any())).thenReturn(new ProcessInfo());
    nodeService = mock(NodeService.class);
    when(nodeService.findIdentity()).thenReturn(new Node(NODE_ID, NODE_GROUP_ID));
    detector = newGapDetector();
    detector.setFullGapAnalysis(false);
}
Also used : RouterService(org.jumpmind.symmetric.service.impl.RouterService) IRouterService(org.jumpmind.symmetric.service.IRouterService) IDatabasePlatform(org.jumpmind.db.platform.IDatabasePlatform) IContextService(org.jumpmind.symmetric.service.IContextService) ContextService(org.jumpmind.symmetric.service.impl.ContextService) DatabaseInfo(org.jumpmind.db.platform.DatabaseInfo) IParameterService(org.jumpmind.symmetric.service.IParameterService) ParameterService(org.jumpmind.symmetric.service.impl.ParameterService) INodeService(org.jumpmind.symmetric.service.INodeService) NodeService(org.jumpmind.symmetric.service.impl.NodeService) Node(org.jumpmind.symmetric.model.Node) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) DataService(org.jumpmind.symmetric.service.impl.DataService) IDataService(org.jumpmind.symmetric.service.IDataService) ISqlTemplate(org.jumpmind.db.sql.ISqlTemplate) ISqlTransaction(org.jumpmind.db.sql.ISqlTransaction) IExtensionService(org.jumpmind.symmetric.service.IExtensionService) IStatisticManager(org.jumpmind.symmetric.statistic.IStatisticManager) StatisticManager(org.jumpmind.symmetric.statistic.StatisticManager) AbstractSymmetricDialect(org.jumpmind.symmetric.db.AbstractSymmetricDialect) Before(org.junit.Before)

Example 7 with DatabaseInfo

use of org.jumpmind.db.platform.DatabaseInfo in project symmetric-ds by JumpMind.

the class TableExtractDataReaderSource method startNewCursor.

protected void startNewCursor() {
    DatabaseInfo dbInfo = platform.getDatabaseInfo();
    String sql = String.format("select * from %s %s", table.getQualifiedTableName(dbInfo.getDelimiterToken(), dbInfo.getCatalogSeparator(), dbInfo.getSchemaSeparator()), StringUtils.isNotBlank(whereClause) ? " where " + whereClause : "");
    this.cursor = platform.getSqlTemplate().queryForCursor(sql, new ISqlRowMapper<CsvData>() {

        public CsvData mapRow(Row row) {
            return new CsvData(DataEventType.INSERT, toStringData(row, table.getPrimaryKeyColumns()), toStringData(row, table.getColumns()));
        }
    });
}
Also used : DatabaseInfo(org.jumpmind.db.platform.DatabaseInfo) Row(org.jumpmind.db.sql.Row) ISqlRowMapper(org.jumpmind.db.sql.ISqlRowMapper) CsvData(org.jumpmind.symmetric.io.data.CsvData)

Example 8 with DatabaseInfo

use of org.jumpmind.db.platform.DatabaseInfo in project symmetric-ds by JumpMind.

the class ExtractDataReader method buildSelect.

protected String buildSelect(Table table, Column lobColumn, Column[] pkColumns) {
    StringBuilder sql = new StringBuilder("select ");
    DatabaseInfo dbInfo = platform.getDatabaseInfo();
    String quote = platform.getDdlBuilder().isDelimitedIdentifierModeOn() ? dbInfo.getDelimiterToken() : "";
    sql.append(quote);
    sql.append(lobColumn.getName());
    sql.append(quote);
    sql.append(",");
    sql.delete(sql.length() - 1, sql.length());
    sql.append(" from ");
    sql.append(table.getQualifiedTableName(quote, dbInfo.getCatalogSeparator(), dbInfo.getSchemaSeparator()));
    sql.append(" where ");
    for (Column col : pkColumns) {
        sql.append(quote);
        sql.append(col.getName());
        sql.append(quote);
        sql.append("=? and ");
    }
    sql.delete(sql.length() - 5, sql.length());
    return sql.toString();
}
Also used : DatabaseInfo(org.jumpmind.db.platform.DatabaseInfo) Column(org.jumpmind.db.model.Column)

Example 9 with DatabaseInfo

use of org.jumpmind.db.platform.DatabaseInfo in project symmetric-ds by JumpMind.

the class RouterServiceTest method setup.

@Before
public void setup() {
    ISymmetricEngine engine = mock(ISymmetricEngine.class);
    IParameterService parameterService = mock(IParameterService.class);
    ISymmetricDialect symmetricDialect = mock(ISymmetricDialect.class);
    IDatabasePlatform databasePlatform = mock(IDatabasePlatform.class);
    IExtensionService extensionService = mock(IExtensionService.class);
    when(databasePlatform.getDatabaseInfo()).thenReturn(new DatabaseInfo());
    when(symmetricDialect.getPlatform()).thenReturn(databasePlatform);
    when(engine.getDatabasePlatform()).thenReturn(databasePlatform);
    when(engine.getParameterService()).thenReturn(parameterService);
    when(engine.getSymmetricDialect()).thenReturn(symmetricDialect);
    when(engine.getExtensionService()).thenReturn(extensionService);
    routerService = new RouterService(engine);
}
Also used : ISymmetricDialect(org.jumpmind.symmetric.db.ISymmetricDialect) IDatabasePlatform(org.jumpmind.db.platform.IDatabasePlatform) DatabaseInfo(org.jumpmind.db.platform.DatabaseInfo) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) IExtensionService(org.jumpmind.symmetric.service.IExtensionService) IParameterService(org.jumpmind.symmetric.service.IParameterService) Before(org.junit.Before)

Example 10 with DatabaseInfo

use of org.jumpmind.db.platform.DatabaseInfo in project symmetric-ds by JumpMind.

the class DefaultDatabaseWriter method allowInsertIntoAutoIncrementColumns.

@Override
protected void allowInsertIntoAutoIncrementColumns(boolean value, Table table) {
    DatabaseInfo dbInfo = platform.getDatabaseInfo();
    String quote = dbInfo.getDelimiterToken();
    String catalogSeparator = dbInfo.getCatalogSeparator();
    String schemaSeparator = dbInfo.getSchemaSeparator();
    transaction.allowInsertIntoAutoIncrementColumns(value, table, quote, catalogSeparator, schemaSeparator);
}
Also used : DatabaseInfo(org.jumpmind.db.platform.DatabaseInfo)

Aggregations

DatabaseInfo (org.jumpmind.db.platform.DatabaseInfo)18 IDatabasePlatform (org.jumpmind.db.platform.IDatabasePlatform)6 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)5 ISymmetricEngine (org.jumpmind.symmetric.ISymmetricEngine)5 IExtensionService (org.jumpmind.symmetric.service.IExtensionService)5 IParameterService (org.jumpmind.symmetric.service.IParameterService)5 Column (org.jumpmind.db.model.Column)4 Before (org.junit.Before)4 ISqlTemplate (org.jumpmind.db.sql.ISqlTemplate)3 ISymmetricDialect (org.jumpmind.symmetric.db.ISymmetricDialect)3 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 Table (org.jumpmind.db.model.Table)2 JdbcSqlTransaction (org.jumpmind.db.sql.JdbcSqlTransaction)2 Row (org.jumpmind.db.sql.Row)2 AbstractSymmetricDialect (org.jumpmind.symmetric.db.AbstractSymmetricDialect)2 Node (org.jumpmind.symmetric.model.Node)2 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)2 IDataService (org.jumpmind.symmetric.service.IDataService)2