Commit c2229e34 authored by Matija Obreza's avatar Matija Obreza

Signature of findOneSGSV fixed

SGSVUpdater should not check instCode (because of #codeSGSV)
parent c6cf9274
......@@ -107,8 +107,8 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
Accession findByInstituteCodeAndAccessionName(String instCode, String accessionName);
@Query("select a from Accession a where a.accessionName=?1 and (a.institute.code=?2 or a.institute.codeSGSV=?2) and a.taxonomy.genus=?3")
Accession findOneSGSV(String acceNumb, String instCode, String genus);
@Query("select a from Accession a where a.accessionName=?2 and (a.institute.code=?1 or a.institute.codeSGSV=?1) and a.taxonomy.genus=?3")
Accession findOneSGSV(String instCode, String acceNumb, String genus);
@Query("select a from Accession a where a.institute.code=:instCode and a.accessionName=:acceNumb and a.taxonomy.genus=:genus")
Accession findOne(@Param("instCode") String holdingInstitute, @Param("acceNumb") String accessionName, @Param("genus") String genus);
......
......@@ -225,7 +225,14 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
public List<Accession> listAccessionsSGSV(List<? extends AccessionIdentifier3> accns) {
final List<Accession> result = new ArrayList<Accession>(accns.size());
for (final AccessionIdentifier3 aid3 : accns) {
final Accession accn = accessionRepository.findOneSGSV(aid3.getHoldingInstitute(), aid3.getAccessionName(), aid3.getGenus());
Accession accn = null;
try {
accn = accessionRepository.findOneSGSV(aid3.getHoldingInstitute(), aid3.getAccessionName(), aid3.getGenus());
} catch (IncorrectResultSizeDataAccessException e) {
LOG.warn("Duplicate entry for " + aid3);
}
if (accn != null) {
result.add(accn);
......
......@@ -215,13 +215,15 @@ public class SGSVUpdate {
void workIt(final List<String[]> bulk) {
// Need copy!
final ArrayList<String[]> bulkCopy = new ArrayList<String[]>(bulk);
LOG.trace("Queueing job size=" + bulkCopy.size());
taskExecutor.execute(new Runnable() {
@Override
public void run() {
final List<SGSVEntry> accns = bulkToList(bulkCopy);
LOG.trace("Got " + accns.size() + " entries");
if (LOG.isTraceEnabled())
LOG.trace("Got SGVS entries size=" + accns.size());
for (int retry = 5; retry > 0; retry--) {
if (retry < 5) {
......@@ -261,6 +263,8 @@ public class SGSVUpdate {
}
void updateSvalbards(List<SGSVEntry> accns) {
// LOG.info("Updating SGSV size="+ accns.size());
// Find accessions based on holdingInstitute and
// accession
// name
......@@ -282,17 +286,19 @@ public class SGSVUpdate {
final SGSVEntry entry = accns.get(i);
if (accn == null) {
LOG.debug("No such accession in the database. Skipping " + entry);
// LOG.info("No such accession in the database. Skipping " +
// entry);
continue;
} else {
LOG.info("Updating " + accn);
if (LOG.isTraceEnabled())
LOG.trace("Updating " + accn);
}
// NOTE Removed acceNumb check because of aliases
// if (accn.getAccessionName().equalsIgnoreCase(entry.acceNumb) &&
// accn.getInstituteCode().equals(entry.instCode)) {
if (accn.getInstituteCode().equals(entry.instCode)) {
{
if (!Boolean.TRUE.equals(accn.getInSvalbard())) {
accn.setInSvalbard(true);
updateAccession = true;
......@@ -312,8 +318,6 @@ public class SGSVUpdate {
if (updateAccession) {
matching.add(accn);
}
} else {
LOG.warn("This should not be");
}
}
......@@ -325,6 +329,7 @@ public class SGSVUpdate {
}
if (svalbards.size() > 0) {
try {
LOG.info("Saving svalbards size=" + svalbards.size());
genesysService.saveSvalbards(svalbards);
} catch (final ConstraintViolationException e) {
LOG.warn(e.getMessage());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment