Commit df1e2f75 authored by Matija Obreza's avatar Matija Obreza Committed by Artem Hrybeniuk
Browse files

CV: Updated handling of ensureCodeValue and cache keys

- Geography updater: ensure CV for GEOGRAPHY_COUNTRY_CODE only if missing
- USDA updates: added log message that the transaction still needs committing to the database
- Added new CV for "Invalid" TAXONOMY_SPECIES_QUALIFIER
parent d1cb7a44
......@@ -172,9 +172,9 @@ public class CodeValueServiceImpl extends FilteredTranslatedCRUDServiceImpl<Code
}
@Override
@Transactional
@Transactional(propagation = Propagation.REQUIRES_NEW)
@PreAuthorize("hasAuthority('GROUP_ADMINS')")
@CacheEvict(allEntries = true)
@CacheEvict(key = "'codevalue-' + #groupName + '-' + #value")
public CodeValue ensureCodeValue(String groupName, String value, String title, String description) {
CodeValue codeValue = repository.getByGroupNameAndValue(groupName, value);
......@@ -189,13 +189,13 @@ public class CodeValueServiceImpl extends FilteredTranslatedCRUDServiceImpl<Code
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
@Cacheable(key = "'codevalue-' + #groupName + '-' + #value")
@Cacheable(key = "'codevalue-' + #groupName + '-' + #value", sync = true)
public boolean validate(String groupName, String value) {
return repository.existsCodeValueByGroupNameAndValue(groupName, value);
}
@Override
@Cacheable
@Cacheable(key = "'mcpdOfCode-' + #groupName + '-' + #value", sync = true)
public String findMcpdOfCodeValue(String groupName, String value) {
SysLang sl = languageService.getLanguage(MCPD_IETF_TAG);
CodeValue cv = repository.getByGroupNameAndValue(groupName, value);
......@@ -207,7 +207,7 @@ public class CodeValueServiceImpl extends FilteredTranslatedCRUDServiceImpl<Code
}
@Override
@Cacheable
@Cacheable(key = "'codeOfMcpd-' + #groupName + '-' + #mcpd", sync = true)
public String findCodeValueOfMCPD(String groupName, Integer mcpd) {
if (mcpd == null)
return null;
......
......@@ -129,8 +129,9 @@ public class UsdaGeographyUpdater {
// Add missing GEOGRAPHY_COUNTRY_CODE code values
{
ggGeo.stream().map(geo -> geo.countryCode).filter(StringUtils::isNotBlank).distinct().forEach(countryCode -> {
//codeValueService.ensureCodeValue(CommunityCodeValues.GEOGRAPHY_COUNTRY_CODE, countryCode, countryCode, null);
codeValueService.ensureCodeValue(CommunityCodeValues.GEOGRAPHY_COUNTRY_CODE, countryCode, countryCode, null);
if (! codeValueService.validate(CommunityCodeValues.GEOGRAPHY_COUNTRY_CODE, countryCode)) {
codeValueService.ensureCodeValue(CommunityCodeValues.GEOGRAPHY_COUNTRY_CODE, countryCode, countryCode, null);
}
});
}
......@@ -292,6 +293,6 @@ public class UsdaGeographyUpdater {
});
}
LOG.warn("Done.");
LOG.warn("Done. Transaction will now be committed.");
}
}
......@@ -578,7 +578,7 @@ public class UsdaTaxonomyUpdater {
toSave.clear();
}
LOG.warn("Done.");
LOG.warn("Done. Transaction will now be committed.");
}
static void downloadDataIfNeeded(File folder) throws IOException {
......
......@@ -132,6 +132,7 @@
1491 TAXONOMY_SPECIES_QUALIFIER = 2010-01-01 00:00:00 1 2016-04-19 19:11:20 48 1994-08-24 00:00:00 1
1493 TAXONOMY_SPECIES_QUALIFIER B 2010-01-01 00:00:00 1 2011-10-06 00:10:28 48 1993-09-16 00:00:00 1
1494 TAXONOMY_SPECIES_QUALIFIER S 2010-01-01 00:00:00 1 2016-04-19 19:10:42 48 1993-09-15 00:00:00 1
1495 TAXONOMY_SPECIES_QUALIFIER I 2010-01-01 00:00:00 1 2016-04-19 19:10:42 48 1993-09-15 00:00:00 1
1496 DATE_FORMAT dd/MM/yyyy 2010-01-01 00:00:00 1 2014-10-09 17:54:03 48 2005-08-17 00:00:00 1
1497 DATE_FORMAT MM/dd/yyyy 2010-01-01 00:00:00 1 2014-10-09 17:54:03 48 1993-09-21 00:00:00 1
1498 DATE_FORMAT MM/yyyy 2010-01-01 00:00:00 1 2014-10-09 17:54:03 48 1993-09-21 00:00:00 1
......
......@@ -132,6 +132,7 @@
1491 1491 1 Homotypic synonym A synonym based on the same type 2010-01-01 00:00:00 1 2019-06-18 16:09:21 48 2009-01-09 00:00:00 1
1493 1493 1 Basionym The legitimate name that provides the epithet for a new combination or new rank 2010-01-01 00:00:00 1 2019-06-18 16:09:21 48 2009-01-09 00:00:00 1
1494 1494 1 Heterotypic synonym A synonym based on a different type 2010-01-01 00:00:00 1 2019-06-18 16:09:21 48 2009-01-09 00:00:00 1
1495 1495 1 Invalid An associated designation that was not validly published 2010-01-01 00:00:00 1 2019-06-18 16:09:21 48 2009-01-09 00:00:00 1
1496 1496 1 dd/mm/yyyy \N 2010-01-01 00:00:00 1 2014-10-09 17:54:03 48 2009-01-09 00:00:00 1
1497 1497 1 mm/dd/yyyy \N 2010-01-01 00:00:00 1 2014-10-09 17:54:03 48 2009-01-09 00:00:00 1
1498 1498 1 mm/yyyy \N 2010-01-01 00:00:00 1 2014-10-09 17:54:04 48 2009-01-09 00:00:00 1
......
Supports Markdown
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