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"));
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations