Search in sources :

Example 66 with Row

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

the class JdbcPersistenceManagerTest method testSave.

@Test
public void testSave() {
    Date date = new Date();
    A a = new A(1, date, "Hello");
    assertTrue(manager.save(a));
    date = new Date();
    a.setLastUpdateTime(date);
    assertFalse(manager.save(a));
    Row row = getRow(1);
    assertEquals(date, row.get("last_update_time"));
}
Also used : Row(org.jumpmind.db.sql.Row) Date(java.util.Date) Test(org.junit.Test)

Example 67 with Row

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

the class AbstractXmlPublisherExtensionPoint method readData.

protected List<String[]> readData(final Table table, String[] args) {
    final IDatabasePlatform platform = engine.getDatabasePlatform();
    List<String[]> rows = new ArrayList<String[]>();
    final String[] columnNames = table.getColumnNames();
    if (columnNames != null && columnNames.length > 0) {
        StringBuilder builder = new StringBuilder("select ");
        for (int i = 0; i < columnNames.length; i++) {
            String columnName = columnNames[i];
            if (i > 0) {
                builder.append(",");
            }
            builder.append(columnName);
        }
        builder.append(" from ").append(table.getName()).append(" where ");
        for (int i = 0; i < groupByColumnNames.size(); i++) {
            String columnName = groupByColumnNames.get(i);
            if (i > 0 && i < groupByColumnNames.size()) {
                builder.append(" and ");
            }
            builder.append(columnName).append("=?");
        }
        ISqlTemplate template = platform.getSqlTemplate();
        Object[] argObjs = platform.getObjectValues(engine.getSymmetricDialect().getBinaryEncoding(), args, table.getColumnsWithName(groupByColumnNames.toArray(new String[groupByColumnNames.size()])));
        rows = template.query(builder.toString(), new ISqlRowMapper<String[]>() {

            @Override
            public String[] mapRow(Row row) {
                return platform.getStringValues(engine.getSymmetricDialect().getBinaryEncoding(), table.getColumns(), row, false, false);
            }
        }, argObjs);
    }
    return rows;
}
Also used : IDatabasePlatform(org.jumpmind.db.platform.IDatabasePlatform) ISqlTemplate(org.jumpmind.db.sql.ISqlTemplate) ArrayList(java.util.ArrayList) Row(org.jumpmind.db.sql.Row) IExtensionPoint(org.jumpmind.extension.IExtensionPoint) INodeGroupExtensionPoint(org.jumpmind.symmetric.ext.INodeGroupExtensionPoint) ISqlRowMapper(org.jumpmind.db.sql.ISqlRowMapper)

Example 68 with Row

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

the class AndroidSqlReadCursor method getMapForRow.

protected Row getMapForRow() {
    int columnCount = this.cursor.getColumnCount();
    Row mapOfColValues = new Row(columnCount);
    for (int i = 0; i < columnCount; i++) {
        String name = this.cursor.getColumnName(i);
        mapOfColValues.put(name, this.cursor.getString(i));
    }
    return mapOfColValues;
}
Also used : Row(org.jumpmind.db.sql.Row)

Example 69 with Row

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

the class AndroidSqlReadCursor method next.

public T next() {
    try {
        if (this.cursor.moveToNext()) {
            Row row = getMapForRow();
            rowNumber++;
            if (this.mapper != null) {
                return this.mapper.mapRow(row);
            }
        }
        return null;
    } catch (Exception ex) {
        throw this.sqlTemplate.translate(ex);
    }
}
Also used : Row(org.jumpmind.db.sql.Row)

Example 70 with Row

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

the class ConfigurationService method getChannels.

public Map<String, Channel> getChannels(boolean refreshCache) {
    long channelCacheTimeoutInMs = parameterService.getLong(ParameterConstants.CACHE_TIMEOUT_CHANNEL_IN_MS, 60000);
    Map<String, Channel> channels = channelsCache;
    if (System.currentTimeMillis() - channelCacheTime >= channelCacheTimeoutInMs || channels == null || refreshCache) {
        synchronized (this) {
            channels = channelsCache;
            if (System.currentTimeMillis() - channelCacheTime >= channelCacheTimeoutInMs || channels == null || refreshCache) {
                channels = new HashMap<String, Channel>();
                List<Channel> list = sqlTemplate.query(getSql("selectChannelsSql"), new ISqlRowMapper<Channel>() {

                    public Channel mapRow(Row row) {
                        Channel channel = new Channel();
                        channel.setChannelId(row.getString("channel_id"));
                        channel.setProcessingOrder(row.getInt("processing_order"));
                        channel.setMaxBatchSize(row.getInt("max_batch_size"));
                        channel.setEnabled(row.getBoolean("enabled"));
                        channel.setMaxBatchToSend(row.getInt("max_batch_to_send"));
                        channel.setMaxDataToRoute(row.getInt("max_data_to_route"));
                        channel.setUseOldDataToRoute(row.getBoolean("use_old_data_to_route"));
                        channel.setUseRowDataToRoute(row.getBoolean("use_row_data_to_route"));
                        channel.setUsePkDataToRoute(row.getBoolean("use_pk_data_to_route"));
                        channel.setContainsBigLob(row.getBoolean("contains_big_lob"));
                        channel.setBatchAlgorithm(row.getString("batch_algorithm"));
                        channel.setExtractPeriodMillis(row.getLong("extract_period_millis"));
                        channel.setDataLoaderType(row.getString("data_loader_type"));
                        channel.setCreateTime(row.getDateTime("create_time"));
                        channel.setLastUpdateBy(row.getString("last_update_by"));
                        channel.setLastUpdateTime(row.getDateTime("last_update_time"));
                        channel.setReloadFlag(row.getBoolean("reload_flag"));
                        channel.setFileSyncFlag(row.getBoolean("file_sync_flag"));
                        return channel;
                    }
                });
                for (Channel channel : list) {
                    channels.put(channel.getChannelId(), channel);
                }
                channelsCache = channels;
                channelCacheTime = System.currentTimeMillis();
            }
        }
    }
    return channels;
}
Also used : NodeChannel(org.jumpmind.symmetric.model.NodeChannel) Channel(org.jumpmind.symmetric.model.Channel) Row(org.jumpmind.db.sql.Row)

Aggregations

Row (org.jumpmind.db.sql.Row)78 ArrayList (java.util.ArrayList)31 ISqlRowMapper (org.jumpmind.db.sql.ISqlRowMapper)23 Trigger (org.jumpmind.db.model.Trigger)19 DmlStatement (org.jumpmind.db.sql.DmlStatement)19 JdbcSqlTemplate (org.jumpmind.db.sql.JdbcSqlTemplate)19 Column (org.jumpmind.db.model.Column)15 Table (org.jumpmind.db.model.Table)12 Date (java.util.Date)11 SqlException (org.jumpmind.db.sql.SqlException)9 ISqlTemplate (org.jumpmind.db.sql.ISqlTemplate)8 Test (org.junit.Test)8 HashMap (java.util.HashMap)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 IDatabasePlatform (org.jumpmind.db.platform.IDatabasePlatform)3 IoException (org.jumpmind.exception.IoException)3 NetworkedNode (org.jumpmind.symmetric.model.NetworkedNode)3 Node (org.jumpmind.symmetric.model.Node)3