use of org.springframework.jdbc.core.simple.SimpleJdbcInsert in project goci by EBISPOT.
the class V2_0_1_002__Remove_duplicates_from_snp_region_table method migrate.
@Override
public void migrate(JdbcTemplate jdbcTemplate) throws Exception {
final Map<Long, Long> snpIdToRegionId = new HashMap<>();
// Go through list of exact duplicates in SNP_REGION table
jdbcTemplate.query(SELECT_DUPLICATES, (resultSet, i) -> {
Long snpId = resultSet.getLong(1);
Long regionId = resultSet.getLong(2);
// Store entry so we can recreate
snpIdToRegionId.put(snpId, regionId);
// Delete all entries
jdbcTemplate.update(DELETE_FROM_SNP_REGION, snpId, regionId);
return null;
});
// Insert statements
SimpleJdbcInsert insertSnpRegion = new SimpleJdbcInsert(jdbcTemplate).withTableName("SNP_REGION").usingColumns("SNP_ID", "REGION_ID");
for (Long snpId : snpIdToRegionId.keySet()) {
Long regionId = snpIdToRegionId.get(snpId);
Map<String, Object> snpRegionArgs = new HashMap<>();
snpRegionArgs.put("SNP_ID", snpId);
snpRegionArgs.put("REGION_ID", regionId);
insertSnpRegion.execute(snpRegionArgs);
}
}
use of org.springframework.jdbc.core.simple.SimpleJdbcInsert in project goci by EBISPOT.
the class V2_0_1_014__Migrate_entrez_ids method migrate.
@Override
public void migrate(JdbcTemplate jdbcTemplate) throws Exception {
// Query for gene IDs
jdbcTemplate.query(SELECT_ENTREZ_GENE_IDS, (resultSet, i) -> {
String geneId = resultSet.getString(1);
// Insert into new table
SimpleJdbcInsert insertEntrezId = new SimpleJdbcInsert(jdbcTemplate).withTableName("ENTREZ_GENE").usingColumns("ENTREZ_GENE_ID");
Map<String, Object> insertArgs = new HashMap<>();
insertArgs.put("ENTREZ_GENE_ID", geneId);
insertEntrezId.execute(insertArgs);
return null;
});
}
Aggregations