use of org.jumpmind.db.sql.ISqlTemplate in project symmetric-ds by JumpMind.
the class AbstractDdlTypesTest method createTable.
protected void createTable() {
ISqlTemplate sqlTemplate = platform.getSqlTemplate();
sqlTemplate.update(buildDdl());
}
use of org.jumpmind.db.sql.ISqlTemplate in project symmetric-ds by JumpMind.
the class GroupletService method getGrouplets.
public List<Grouplet> getGrouplets(boolean refreshCache) {
long maxCacheTime = parameterService.getLong(ParameterConstants.CACHE_TIMEOUT_GROUPLETS_IN_MS);
List<Grouplet> all = cache;
if (all == null || System.currentTimeMillis() - lastCacheTime >= maxCacheTime || lastCacheTime == 0 || refreshCache) {
ISqlTemplate sqlTemplate = platform.getSqlTemplate();
final Map<String, Grouplet> groupletMap = new HashMap<String, Grouplet>();
all = sqlTemplate.query(getSql("selectGroupletSql"), new ISqlRowMapper<Grouplet>() {
public Grouplet mapRow(Row rs) {
Grouplet grouplet = new Grouplet();
grouplet.setGroupletId(rs.getString("grouplet_id"));
grouplet.setDescription(rs.getString("description"));
grouplet.setGroupletLinkPolicy(GroupletLinkPolicy.valueOf(rs.getString("grouplet_link_policy")));
grouplet.setCreateTime(rs.getDateTime("create_time"));
grouplet.setLastUpdateBy(rs.getString("last_update_by"));
grouplet.setLastUpdateTime(rs.getDateTime("last_update_time"));
groupletMap.put(grouplet.getGroupletId(), grouplet);
return grouplet;
}
});
sqlTemplate.query(getSql("selectGroupletLinkSql"), new ISqlRowMapper<GroupletLink>() {
public GroupletLink mapRow(Row rs) {
GroupletLink groupletLink = new GroupletLink();
String groupletId = rs.getString("grouplet_id");
Grouplet grouplet = groupletMap.get(groupletId);
groupletLink.setExternalId(rs.getString("external_id"));
groupletLink.setCreateTime(rs.getDateTime("create_time"));
groupletLink.setLastUpdateBy(rs.getString("last_update_by"));
groupletLink.setLastUpdateTime(rs.getDateTime("last_update_time"));
if (grouplet != null) {
grouplet.getGroupletLinks().add(groupletLink);
}
return groupletLink;
}
});
sqlTemplate.query(getSql("selectTriggerRouterGroupletSql"), new ISqlRowMapper<TriggerRouterGrouplet>() {
public TriggerRouterGrouplet mapRow(Row rs) {
TriggerRouterGrouplet trGrouplet = new TriggerRouterGrouplet();
String groupletId = rs.getString("grouplet_id");
Grouplet grouplet = groupletMap.get(groupletId);
trGrouplet.setAppliesWhen(AppliesWhen.valueOf(rs.getString("applies_when")));
trGrouplet.setRouterId(rs.getString("router_id"));
trGrouplet.setTriggerId(rs.getString("trigger_id"));
trGrouplet.setCreateTime(rs.getDateTime("create_time"));
trGrouplet.setLastUpdateBy(rs.getString("last_update_by"));
trGrouplet.setLastUpdateTime(rs.getDateTime("last_update_time"));
if (grouplet != null) {
grouplet.getTriggerRouterGrouplets().add(trGrouplet);
}
return trGrouplet;
}
});
cache = all;
lastCacheTime = System.currentTimeMillis();
}
return all;
}
use of org.jumpmind.db.sql.ISqlTemplate in project symmetric-ds by JumpMind.
the class GroupletService method deleteTriggerRouterGroupletsFor.
public void deleteTriggerRouterGroupletsFor(TriggerRouter triggerRouter) {
ISqlTemplate sqlTemplate = platform.getSqlTemplate();
sqlTemplate.update(getSql("deleteTriggerRouterGroupletForSql"), new Object[] { triggerRouter.getTrigger().getTriggerId(), triggerRouter.getRouter().getRouterId() }, new int[] { Types.VARCHAR, Types.VARCHAR });
}
use of org.jumpmind.db.sql.ISqlTemplate in project symmetric-ds by JumpMind.
the class GroupletService method deleteTriggerRouterGrouplet.
public void deleteTriggerRouterGrouplet(Grouplet grouplet, TriggerRouterGrouplet triggerRouterGrouplet) {
ISqlTemplate sqlTemplate = platform.getSqlTemplate();
sqlTemplate.update(getSql("deleteTriggerRouterGroupletSql"), new Object[] { grouplet.getGroupletId(), triggerRouterGrouplet.getAppliesWhen().name(), triggerRouterGrouplet.getTriggerId(), triggerRouterGrouplet.getRouterId() }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR });
}
use of org.jumpmind.db.sql.ISqlTemplate in project symmetric-ds by JumpMind.
the class GroupletService method saveGroupletLink.
public void saveGroupletLink(Grouplet grouplet, GroupletLink link) {
ISqlTemplate sqlTemplate = platform.getSqlTemplate();
link.setLastUpdateTime(new Date());
if (sqlTemplate.update(getSql("updateGroupletLinkSql"), new Object[] { link.getCreateTime(), link.getLastUpdateBy(), link.getLastUpdateTime(), grouplet.getGroupletId(), link.getExternalId() }, new int[] { Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR }) == 0) {
link.setCreateTime(new Date());
sqlTemplate.update(getSql("insertGroupletLinkSql"), new Object[] { link.getCreateTime(), link.getLastUpdateBy(), link.getLastUpdateTime(), grouplet.getGroupletId(), link.getExternalId() }, new int[] { Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR });
}
}
Aggregations