Commit 2c544cbc authored by Matija Obreza's avatar Matija Obreza
Browse files

Fixed PDCI loading bug with accessionId==null

parent e1c0f82b
......@@ -27,7 +27,7 @@ import org.springframework.data.jpa.repository.Query;
public interface PDCIRepository extends JpaRepository<PDCI, Long> {
@Query("select pdci from PDCI pdci where pdci.accession.id=?1")
PDCI findByAccessionId(Long accessionId);
PDCI findByAccessionId(long accessionId);
@Query("select pdci from PDCI pdci where pdci.accession.id in (?1)")
List<PDCI> findByAccessionId(Collection<Long> accessionIds);
......
......@@ -174,7 +174,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Autowired
private FaoInstituteRepository instituteRepository;
@Autowired
@Qualifier("genesysLowlevelRepositoryCustomImpl")
@Qualifier("genesysLowlevelRepositoryCustomImpl")
private GenesysLowlevelRepository genesysLowlevelRepository;
@Autowired
private SvalbardRepository svalbardRepository;
......@@ -1067,7 +1067,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
zos.putNextEntry(metaEntry);
final BufferedWriter osw = new BufferedWriter(new OutputStreamWriter(zos));
osw.write("<?xml version='1.0' encoding='utf-8'?>\n");
osw.write("<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n");
osw.write(
"<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n");
osw.write("<core encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\"&quot;\" ignoreHeaderLines=\"0\">\n");
osw.write("\t<files><location>core.csv</location></files>\n");
osw.write("\t<id index=\"0\" />\n");
......@@ -1334,7 +1335,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
zos.putNextEntry(metaEntry);
final BufferedWriter osw = new BufferedWriter(new OutputStreamWriter(zos));
osw.write("<?xml version='1.0' encoding='utf-8'?>\n");
osw.write("<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n");
osw.write(
"<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n");
osw.write("<core encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\"&quot;\" ignoreHeaderLines=\"0\">\n");
osw.write("\t<files><location>core.csv</location></files>\n");
osw.write("\t<id index=\"0\" />\n");
......@@ -1346,7 +1348,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
for (int i = 0; i < metadataMethods.size(); i++) {
final Method method = metadataMethods.get(i);
osw.write("<extension encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\"&quot;\" ignoreHeaderLines=\"0\">\n");
osw.write(
"<extension encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\"&quot;\" ignoreHeaderLines=\"0\">\n");
osw.write("\t<files><location>");
osw.write(method.getFieldName().toLowerCase());
osw.write(".csv</location></files>\n");
......@@ -1557,7 +1560,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public PDCI loadPDCI(Long accessionId) {
return repoPdci.findByAccessionId(accessionId);
return accessionId==null ? null : repoPdci.findByAccessionId(accessionId);
}
@Override
......@@ -1599,7 +1602,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Transactional
@CacheEvict(value = "statistics", allEntries = true)
public PDCI updatePDCI(Long accessionId) {
if (pdciCalculator == null) {
if (pdciCalculator == null || accessionId == null) {
return null;
}
......@@ -1757,15 +1760,13 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
LOG.info("Regenerating sequential numbers " + counter);
else
LOG.debug("Regenerating sequential numbers " + counter);
genesysLowlevelRepository.updateAccessionSequentialNumber(batch);
batch.clear();
}
}
});
genesysLowlevelRepository.updateAccessionSequentialNumber(batch);
}
}
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