intcount=this.jdbcTemplate.update("UPDATE `accession` A inner join `faoinstitute` FI on FI.code=A.instCode set A.instituteId=FI.id;");
LOG.info("Institute references updated: "+count);
LOG.info("Updating institute accession count");
count=this.jdbcTemplate
.update("UPDATE faoinstitute FI inner join (select instituteId, count(*) X from accession group by instituteId) A on A.instituteId=FI.id set FI.accessionCount=A.X;");
// public void updateInstituteAccessionCount(long instituteId) {
// LOG.debug("Updating institute accession count for instituteId=" +
// instituteId);
// // int count = jdbcTemplate
// //
// .update("UPDATE faoinstitute FI inner join (select instituteId, count(*) X from accession where instituteId= ? group by instituteId) A on A.instituteId=FI.id set FI.accessionCount=A.X where FI.id = ?;",
// // instituteId, instituteId);
// jdbcTemplate.update("UPDATE faoinstitute SET accessionCount = (select count(*) from accession where instituteId=?) where id = ?;",
// instituteId, instituteId);
// LOG.info("Institute accession count updated for " + instituteId);
// }
@Override
@PreAuthorize("hasRole('ADMINISTRATOR')")
@Transactional(readOnly=false)
publicvoidupdateCountryRefs(){
LOG.info("Updating country references");
finalintcount=this.jdbcTemplate
.update("UPDATE `accession` A inner join `country` C on C.code3=A.orgCty set A.orgCtyId=C.id WHERE A.orgCty IS NOT NULL;");
LOG.info("Country references updated: "+count);
}
@Override
@PreAuthorize("hasRole('ADMINISTRATOR')")
@Transactional(readOnly=false)
publicvoidupdateFaoInstituteCountries(){
LOG.info("Updating country references");
finalintcount=this.jdbcTemplate.update("UPDATE `faoinstitute` I inner join `country` C on C.code3=left(I.code, 3) set I.countryId=C.id;");
LOG.info("Country references updated: "+count);
}
@Override
publicvoidensureMethodTable(finalMethodmethod){
LOG.info("Ensuring method table for "+method);
try{
LOG.info("Checking for table with name "+method.getId().toString());
.prepareStatement("select distinct a.id, a.instCode, a.acceNumb, t.genus from accessiontrait at inner join accession a on a.id=at.accessionId left outer join taxonomy2 t on t.id=a.taxonomyId2 where at.metadataId = ?");