Search in sources :

Example 1 with StringMapper

use of org.jumpmind.db.sql.mapper.StringMapper in project symmetric-ds by JumpMind.

the class MsSqlDdlReader method getTableNames.

@Override
public List<String> getTableNames(final String catalog, final String schema, final String[] tableTypes) {
    StringBuilder sql = new StringBuilder("select \"TABLE_NAME\" from \"INFORMATION_SCHEMA\".\"TABLES\" where \"TABLE_TYPE\"='BASE TABLE'");
    List<Object> args = new ArrayList<Object>(2);
    if (isNotBlank(catalog)) {
        sql.append(" and \"TABLE_CATALOG\"=?");
        args.add(catalog);
    }
    if (isNotBlank(schema)) {
        sql.append(" and \"TABLE_SCHEMA\"=?");
        args.add(schema);
    }
    return platform.getSqlTemplate().queryWithHandler(sql.toString(), new StringMapper(), new ChangeCatalogConnectionHandler(catalog), args.toArray(new Object[args.size()]));
}
Also used : StringMapper(org.jumpmind.db.sql.mapper.StringMapper) ChangeCatalogConnectionHandler(org.jumpmind.db.sql.ChangeCatalogConnectionHandler) ArrayList(java.util.ArrayList)

Example 2 with StringMapper

use of org.jumpmind.db.sql.mapper.StringMapper in project symmetric-ds by JumpMind.

the class OutgoingBatchService method areAllLoadBatchesComplete.

public boolean areAllLoadBatchesComplete(String nodeId) {
    NodeSecurity security = nodeService.findNodeSecurity(nodeId);
    if (security == null || security.isInitialLoadEnabled()) {
        return false;
    }
    List<String> statuses = (List<String>) sqlTemplate.query(getSql("initialLoadStatusSql"), new StringMapper(), nodeId, 1);
    if (statuses == null || statuses.size() == 0) {
        throw new RuntimeException("The initial load has not been started for " + nodeId);
    }
    for (String status : statuses) {
        if (!Status.OK.name().equals(status)) {
            return false;
        }
    }
    return true;
}
Also used : StringMapper(org.jumpmind.db.sql.mapper.StringMapper) NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with StringMapper

use of org.jumpmind.db.sql.mapper.StringMapper in project symmetric-ds by JumpMind.

the class InterbaseSymmetricDialect method cleanupTriggers.

@Override
public void cleanupTriggers() {
    List<String> names = platform.getSqlTemplate().query("select rdb$trigger_name from rdb$triggers where rdb$trigger_name like '" + parameterService.getTablePrefix().toUpperCase() + "_%'", new StringMapper());
    for (String name : names) {
        platform.getSqlTemplate().update("drop trigger " + name);
        log.info("Dropped trigger {}", name);
    }
}
Also used : StringMapper(org.jumpmind.db.sql.mapper.StringMapper)

Example 4 with StringMapper

use of org.jumpmind.db.sql.mapper.StringMapper in project symmetric-ds by JumpMind.

the class FirebirdSymmetricDialect method cleanupTriggers.

@Override
public void cleanupTriggers() {
    List<String> names = platform.getSqlTemplate().query("select rdb$trigger_name from rdb$triggers where rdb$trigger_name like '" + parameterService.getTablePrefix().toUpperCase() + "_%'", new StringMapper());
    int count = 0;
    for (String name : names) {
        count += platform.getSqlTemplate().update("drop trigger " + name);
    }
    if (count > 0) {
        log.info("Remove {} triggers", count);
    }
}
Also used : StringMapper(org.jumpmind.db.sql.mapper.StringMapper)

Example 5 with StringMapper

use of org.jumpmind.db.sql.mapper.StringMapper in project symmetric-ds by JumpMind.

the class H2SymmetricDialect method cleanupTriggers.

@Override
public void cleanupTriggers() {
    List<String> names = platform.getSqlTemplate().query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = SCHEMA() AND TABLE_NAME LIKE '" + parameterService.getTablePrefix().toUpperCase() + "_%_CONFIG'", new StringMapper());
    for (String name : names) {
        platform.getSqlTemplate().update("drop table " + name);
        log.info("Dropped table {}", name);
    }
}
Also used : StringMapper(org.jumpmind.db.sql.mapper.StringMapper)

Aggregations

StringMapper (org.jumpmind.db.sql.mapper.StringMapper)7 ArrayList (java.util.ArrayList)2 List (java.util.List)1 Table (org.jumpmind.db.model.Table)1 ChangeCatalogConnectionHandler (org.jumpmind.db.sql.ChangeCatalogConnectionHandler)1 ISqlTemplate (org.jumpmind.db.sql.ISqlTemplate)1 InvalidSqlException (org.jumpmind.db.sql.InvalidSqlException)1 Node (org.jumpmind.symmetric.model.Node)1 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)1 Trigger (org.jumpmind.symmetric.model.Trigger)1 TriggerRouter (org.jumpmind.symmetric.model.TriggerRouter)1 IParameterService (org.jumpmind.symmetric.service.IParameterService)1 ITriggerRouterService (org.jumpmind.symmetric.service.ITriggerRouterService)1 Test (org.junit.Test)1