Skip to content

Commit

Permalink
table names
Browse files Browse the repository at this point in the history
  • Loading branch information
southeo committed Dec 5, 2023
1 parent d7f0b58 commit 918c901
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/main/java/eu/dissco/core/translator/service/DwcaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,13 @@ private List<String> generateTableNames(Archive archive) {

private String getTableName(ArchiveFile archiveFile) {
var fullSourceSystemId = webClientProperties.getSourceSystemId();
var minifiedSourceSystemId = fullSourceSystemId.substring(fullSourceSystemId.indexOf('/') + 1);
minifiedSourceSystemId = minifiedSourceSystemId.replace("-", "_");
return (minifiedSourceSystemId + "_" + archiveFile.getRowType().prefixedName()).toLowerCase().replace(":","_");
var minifiedSourceSystemId = fullSourceSystemId.substring(fullSourceSystemId.indexOf('/') + 1)
.replace("-", "_");
var tableName = (minifiedSourceSystemId + "_" + archiveFile.getRowType()
.prefixedName()).toLowerCase()
.replace(":", "_");
tableName = tableName.replace("/", "_");
return tableName.replace(".", "_");
}

private void createTempTables(List<String> tableNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void testCopyTableFails() throws Exception {
// Given
givenDWCA("/dwca-rbins.zip");
doThrow(new DisscoRepositoryException("", new Exception())).when(dwcaRepository)
.postRecords(eq("ABC-DDD-ASD_dwc:Occurrence"), anyList());
.postRecords(eq("abc_ddd_asd_dwc_occurrence"), anyList());

// When
service.retrieveData();
Expand Down Expand Up @@ -229,9 +229,9 @@ void testRetrieveDataWithGbifMedia() throws Exception {
// Given
givenDWCA("/dwca-kew-gbif-media.zip");
given(dwcaRepository.getCoreRecords(anyList(), anyString())).willReturn(givenSpecimenMap(19));
given(dwcaRepository.getRecords(anyList(), eq("ABC-DDD-ASD_dwc:Identification"))).willReturn(
given(dwcaRepository.getRecords(anyList(), eq("abc_ddd_asd_dwc_identification"))).willReturn(
Map.of());
given(dwcaRepository.getRecords(anyList(), eq("ABC-DDD-ASD_gbif:Multimedia"))).willReturn(
given(dwcaRepository.getRecords(anyList(), eq("abc_ddd_asd_gbif_multimedia"))).willReturn(
givenImageMap(19));
given(digitalSpecimenDirector.assembleDigitalSpecimenTerm(any(JsonNode.class), anyBoolean()))
.willReturn(givenDigitalSpecimen());
Expand Down Expand Up @@ -267,8 +267,7 @@ void testRetrieveDataWithAcMedia() throws Exception {
// Given
givenDWCA("/dwca-naturalis-ac-media.zip");
given(dwcaRepository.getCoreRecords(anyList(), anyString())).willReturn(givenSpecimenMap(14));
given(dwcaRepository.getRecords(anyList(),
eq("ABC-DDD-ASD_http://rs.tdwg.org/ac/terms/Multimedia"))).willReturn(givenImageMap(14));
given(dwcaRepository.getRecords(anyList(), eq("abc_ddd_asd_http___rs_tdwg_org_ac_terms_multimedia"))).willReturn(givenImageMap(14));
given(digitalSpecimenDirector.assembleDigitalSpecimenTerm(any(JsonNode.class), anyBoolean()))
.willReturn(givenDigitalSpecimen());
given(digitalSpecimenDirector.assembleDigitalMediaObjects(anyBoolean(), any(JsonNode.class),
Expand All @@ -293,7 +292,7 @@ void testRetrieveDataWithInvalidAcMedia() throws Exception {
givenDWCA("/dwca-invalid-ac-media.zip");
given(dwcaRepository.getCoreRecords(anyList(), anyString())).willReturn(givenSpecimenMap(1));
given(dwcaRepository.getRecords(anyList(),
eq("ABC-DDD-ASD_http://rs.tdwg.org/ac/terms/Multimedia"))).willReturn(givenImageMap(1));
eq("abc_ddd_asd_http___rs_tdwg_org_ac_terms_multimedia"))).willReturn(givenImageMap(1));
given(digitalSpecimenDirector.assembleDigitalSpecimenTerm(any(JsonNode.class), anyBoolean()))
.willReturn(givenDigitalSpecimen());
given(digitalSpecimenDirector.assembleDigitalMediaObjects(anyBoolean(), any(JsonNode.class),
Expand Down

0 comments on commit 918c901

Please sign in to comment.