DbMapSqlParameterSource params = new DbMapSqlParameterSource();
// this assumes that _searchKey2StatusEntry has already been populated
// in getStatus()
Pair<Long, Long> key = Pair.of(calcConfId, computationTargetId);
StatusEntry statusEntry = statusCache.get(key);
if (statusEntry != null) {
statusEntry.setStatus(status);
params.addValue("id", statusEntry.getId());
params.addValue("run_id", runId);
params.addValue("status", statusEntry.getStatus().ordinal());
updates.add(params);
} else {
final long statusId = nextId(RSK_SEQUENCE_NAME);
final DbMapSqlParameterSource insertArgs = new DbMapSqlParameterSource();
insertArgs.addValue("ID", statusId);
statusEntry = new StatusEntry();
statusEntry.setId(statusId);
statusEntry.setRunId(runId);
statusEntry.setStatus(status);
statusEntry.setCalculationConfigurationId(calcConfId);
statusEntry.setComputationTargetId(computationTargetId);
statusCache.put(key, statusEntry);
params.addValue("id", statusId);
params.addValue("run_id", runId);
params.addValue("calculation_configuration_id", calcConfId);
params.addValue("computation_target_id", computationTargetId);
params.addValue("status", statusEntry.getStatus().ordinal());
inserts.add(params);
}
}