diff --git a/entity-management-common/src/main/java/eu/europeana/entitymanagement/common/config/DataSource.java b/entity-management-common/src/main/java/eu/europeana/entitymanagement/common/config/DataSource.java index 11ba22b3f..914469ad7 100644 --- a/entity-management-common/src/main/java/eu/europeana/entitymanagement/common/config/DataSource.java +++ b/entity-management-common/src/main/java/eu/europeana/entitymanagement/common/config/DataSource.java @@ -9,8 +9,8 @@ public class DataSource { public static final String FREQ_STATIC = "static"; public static final String EUROPEANA_ID = "europeana"; public static final String ZOHO_ID = "zoho-crm"; - public static final String ZOHO_HOST = "crm.zoho.com"; -// public static final String ZOHO_HOST = "crm.zoho.eu"; +// public static final String ZOHO_HOST = "crm.zoho.com"; + public static final String ZOHO_HOST = "crm.zoho.eu"; @JacksonXmlProperty(isAttribute = true) private String url; diff --git a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/ZohoMapping.java b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/ZohoMapping.java index 0f940cbea..1274a797d 100644 --- a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/ZohoMapping.java +++ b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/ZohoMapping.java @@ -3,8 +3,6 @@ import static eu.europeana.entitymanagement.vocabulary.WebEntityFields.ENTITY_URI; import static eu.europeana.entitymanagement.vocabulary.WebEntityFields.WIKIDATA_URI; import static eu.europeana.entitymanagement.vocabulary.WebEntityFields.ZOHO_LABEL; -import java.util.Arrays; -import java.util.List; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -52,13 +50,13 @@ public void setWikidataUri(String wikidataUri) { this.wikidataUri = wikidataUri; } - public static String getEntityUriFromName(List list ,String name) { - for(ZohoMapping cm : list) { - List splittedAndTrimmed = Arrays.stream(cm.getZohoLabel().split(",")).map(String::trim).toList(); - if(splittedAndTrimmed.contains(name)) { - return cm.getEntityUri(); - } - } - return null; - } +// public static String getEntityUriFromName(List list ,String name) { +// for(ZohoMapping cm : list) { +// List splittedAndTrimmed = Arrays.stream(cm.getZohoLabel().split(",")).map(String::trim).toList(); +// if(splittedAndTrimmed.contains(name)) { +// return cm.getEntityUri(); +// } +// } +// return null; +// } } diff --git a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/normalization/EntityFieldsCleaner.java b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/normalization/EntityFieldsCleaner.java index b0d801a91..efd6ab9a7 100644 --- a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/normalization/EntityFieldsCleaner.java +++ b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/normalization/EntityFieldsCleaner.java @@ -89,13 +89,15 @@ public void cleanAndNormalize(Entity entity) { String[] normalized = normalizedList.toArray(new String[0]); entity.setFieldValue(field, normalized); } else if (fieldType.isAssignableFrom(List.class)) { - List fieldValueList = (List) fieldValue; - if (fieldValueList.isEmpty()) { + List fieldValueList = (List) fieldValue; + if(fieldValueList.isEmpty() || !(fieldValueList.get(0) instanceof String)) { continue; } + + List fieldValueListString = (List) fieldValue; // remove spaces from the List fields - List normalizedList = normalizeValues(field.getName(), fieldValueList); + List normalizedList = normalizeValues(field.getName(), fieldValueListString); // if Entity field is supposed to contain a single element, remove all elements // except the @@ -125,7 +127,7 @@ public void cleanAndNormalize(Entity entity) { e); } } - + private WebResource normalizeWebResource(WebResource existingFieldValue) { WebResource webResource = new WebResource(existingFieldValue); diff --git a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/vocabulary/WebEntityFields.java b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/vocabulary/WebEntityFields.java index 891ba8678..d79e1d383 100644 --- a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/vocabulary/WebEntityFields.java +++ b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/vocabulary/WebEntityFields.java @@ -9,8 +9,8 @@ public interface WebEntityFields { public static final String LANGUAGE_EN = "en"; public static final String BASE_DATA_EUROPEANA_URI = "http://data.europeana.eu/"; public static final String WIKIDATA_HOST = "www.wikidata.org"; - public static final String ZOHO_CRM_HOST = "crm.zoho.com"; -// public static final String ZOHO_CRM_HOST = "crm.zoho.eu"; +// public static final String ZOHO_CRM_HOST = "crm.zoho.com"; + public static final String ZOHO_CRM_HOST = "crm.zoho.eu"; // common fields public static final String ID = "id"; diff --git a/entity-management-mongo/src/main/java/eu/europeana/entitymanagement/mongo/repository/VocabularyRepository.java b/entity-management-mongo/src/main/java/eu/europeana/entitymanagement/mongo/repository/VocabularyRepository.java index a43e9fa92..ef58f84aa 100644 --- a/entity-management-mongo/src/main/java/eu/europeana/entitymanagement/mongo/repository/VocabularyRepository.java +++ b/entity-management-mongo/src/main/java/eu/europeana/entitymanagement/mongo/repository/VocabularyRepository.java @@ -35,4 +35,7 @@ public List saveBulk(List vocabs) { return datastore.save(vocabs); } + public void dropCollection() { + datastore.getMapper().getCollection(Vocabulary.class).drop(); + } } diff --git a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/testutils/IntegrationTestUtils.java b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/testutils/IntegrationTestUtils.java index 11c682fce..6e0812739 100644 --- a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/testutils/IntegrationTestUtils.java +++ b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/testutils/IntegrationTestUtils.java @@ -169,15 +169,15 @@ public class IntegrationTestUtils { public static final String INVALID_MIGRATION_ID = "http://www.testing.org/entity/testing"; public static final String ORGANIZATION_BNF_URI_ZOHO = - "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000002112001"; + "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000002112001"; public static final String ORGANIZATION_NATURALIS_URI_ZOHO = - "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000000370517"; + "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000000370517"; public static final String ORGANIZATION_PCCE_URI_ZOHO = - "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000000338555"; + "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000000338555"; public static final String ORGANIZATION_GFM_URI_ZOHO = - "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000004503618"; + "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000004503618"; public static final String ORGANIZATION_BERGER_MUSEUM_URI_ZOHO = - "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000004477407"; + "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000004477407"; public static final String ORGANIZATION_NATURALIS_URI_WIKIDATA_PATH_SUFFIX = "/entity/Q641676"; public static final String ORGANIZATION_NATURALIS_URI_WIKIDATA_URI = WIKIDATA_BASE_URI + ORGANIZATION_NATURALIS_URI_WIKIDATA_PATH_SUFFIX; diff --git a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/testutils/TestConfig.java b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/testutils/TestConfig.java index 145a45dff..8fe37daea 100644 --- a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/testutils/TestConfig.java +++ b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/testutils/TestConfig.java @@ -15,7 +15,7 @@ public class TestConfig { - public static final String MOCK_ZOHO_BASE_URL = "https://crm.zoho.com/crm/org51823723/tab/Accounts/"; + public static final String MOCK_ZOHO_BASE_URL = "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/"; public static final String MOCK_ZOHO_COUNTRY_MAPPING_FILE = "/zoho_country_mapping_test.json"; /** diff --git a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/BaseWebControllerTest.java b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/BaseWebControllerTest.java index 5737ce10a..e21a896ce 100644 --- a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/BaseWebControllerTest.java +++ b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/BaseWebControllerTest.java @@ -30,6 +30,7 @@ import eu.europeana.entitymanagement.definitions.model.EntityRecord; import eu.europeana.entitymanagement.definitions.model.Organization; import eu.europeana.entitymanagement.exception.ingestion.EntityUpdateException; +import eu.europeana.entitymanagement.mongo.repository.VocabularyRepository; import eu.europeana.entitymanagement.solr.exception.SolrServiceException; import eu.europeana.entitymanagement.solr.service.SolrService; import eu.europeana.entitymanagement.testutils.IntegrationTestUtils; @@ -53,6 +54,8 @@ abstract class BaseWebControllerTest extends AbstractIntegrationTest { protected SolrService emSolrService; @Autowired private WebApplicationContext webApplicationContext; + + @Autowired protected VocabularyRepository vocabRepository; @BeforeEach protected void setup() throws Exception { diff --git a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/EntityRetrievalIT.java b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/EntityRetrievalIT.java index f1e1429e0..3d61b5ff4 100644 --- a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/EntityRetrievalIT.java +++ b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/EntityRetrievalIT.java @@ -14,6 +14,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.xpath; +import java.util.List; import java.util.Map; import java.util.Optional; import org.hamcrest.Matchers; @@ -28,6 +29,7 @@ import eu.europeana.entitymanagement.batch.service.FailedTaskService; import eu.europeana.entitymanagement.definitions.batch.model.ScheduledUpdateType; import eu.europeana.entitymanagement.definitions.model.EntityRecord; +import eu.europeana.entitymanagement.definitions.model.Vocabulary; import eu.europeana.entitymanagement.testutils.IntegrationTestUtils; import eu.europeana.entitymanagement.vocabulary.EntityTypes; import eu.europeana.entitymanagement.vocabulary.FailedTaskJsonFields; @@ -490,12 +492,19 @@ public void retrievePlaceExternalSchemaOrgShouldBeSuccessful() throws Exception } @Test - public void retrieveOrganizationJsonExternalWithCountryDereference() throws Exception { + public void retrieveOrganizationJsonExternalWithCountryAndRoleDereference() throws Exception { //1. create a place "Sweden" to be used to dereference zoho country for the zoho GFM org String europeanaMetadata = loadFile(IntegrationTestUtils.PLACE_REGISTER_SWEDEN_JSON); String metisResponse = loadFile(IntegrationTestUtils.PLACE_SWEDEN_XML); createEntity(europeanaMetadata, metisResponse, IntegrationTestUtils.PLACE_SWEDEN_URI); + //2. create a vocabulary for the europeanaRole + Vocabulary vocab = new Vocabulary(); + vocab.setVocabularyUri("http://data.europeana.eu/vocabulary/role/ProvidingInstitution"); + vocab.setInScheme(List.of("http://data.europeana.eu/vocabulary/role")); + vocab.setPrefLabel(Map.of("en", "Providing Institution")); + vocabRepository.save(vocab); + // //forcefully change the country mapping uri to the right one // List countryMap= entityRecordService.getCountryMapping(); // for(CountryMapping cm : countryMap) { @@ -524,7 +533,9 @@ public void retrieveOrganizationJsonExternalWithCountryDereference() throws Exce .andExpect(jsonPath("$.type", is(EntityTypes.Organization.getEntityType()))) .andExpect(jsonPath("$.sameAs").isNotEmpty()) .andExpect(jsonPath("$.countryId", is("http://data.europeana.eu/place/1"))) - .andExpect(jsonPath("$.countryPlace.prefLabel.en", is("Sweden"))); + .andExpect(jsonPath("$.europeanaRole[0]", is("http://data.europeana.eu/vocabulary/role/ProvidingInstitution"))) + .andExpect(jsonPath("$.countryPlace.prefLabel.en", is("Sweden"))) + .andExpect(jsonPath("$.europeanaRoleVocabularies[0].prefLabel.en", is("Providing Institution"))); } @Test diff --git a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_berger_museum.json b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_berger_museum.json index 09b532f7a..c3e830395 100644 --- a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_berger_museum.json +++ b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_berger_museum.json @@ -1,4 +1,4 @@ { "type": "Organization", - "id": "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000004477407" + "id": "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000004477407" } \ No newline at end of file diff --git a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_bnf.json b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_bnf.json index 89ecf2d47..b7d3990b2 100644 --- a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_bnf.json +++ b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_bnf.json @@ -1,6 +1,6 @@ { "type": "Organization", - "id": "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000002112001", + "id": "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000002112001", "prefLabel": { "fr": "Bibliothèque nationale de France" }, diff --git a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_gfm.json b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_gfm.json index 626752a50..fe24181fc 100644 --- a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_gfm.json +++ b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_gfm.json @@ -1,4 +1,4 @@ { "type": "Organization", - "id": "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000004503618" + "id": "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000004503618" } \ No newline at end of file diff --git a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_naturalis.json b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_naturalis.json index 29ed51e0e..fa533bb39 100644 --- a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_naturalis.json +++ b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_naturalis.json @@ -1,6 +1,6 @@ { "type": "Organization", - "id": "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000000370517", + "id": "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000000370517", "prefLabel": { "fr": "Nauralis" }, diff --git a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_pcce.json b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_pcce.json index 41c3f9149..547c082a0 100644 --- a/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_pcce.json +++ b/entity-management-tests/src/integration-test/resources/content/organization_register_zoho_pcce.json @@ -1,4 +1,4 @@ { "type": "Organization", - "id": "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000000338555" + "id": "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/1482250000000338555" } \ No newline at end of file diff --git a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_berger_museum_response.json b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_berger_museum_response.json index 9fb4e205c..ad2863ae9 100644 --- a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_berger_museum_response.json +++ b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_berger_museum_response.json @@ -10,11 +10,11 @@ "DEA_Signed": true, "Account_Name": "Berger museum", "Sector": "Cultural Heritage", - "Organisation_Role2": [ + "Organisation_Role": [ "Data Provider" ], "SameAs_1": "http://www.wikidata.org/entity/Q23014463", - "Country": "Norway", + "Organisation_Country": "Norway, NO", "Tag": [], "Latitude": "-1", "Longitude": "-1" diff --git a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_bnf_response.json b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_bnf_response.json index 213cfdadd..d0137352c 100644 --- a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_bnf_response.json +++ b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_bnf_response.json @@ -13,7 +13,7 @@ "Alternative_1": "FR(French)", "City": "Paris", "Longitude": "2.3758333", - "Country": "France", + "Organisation_Country": "France, FR", "Description": "The Bibliothèque nationale de France (BnF; French: [bi.bli.jɔ.tɛk na.sjɔ.nal də fʁɑ̃s]) is the National Library of France, located in Paris. It is the national repository of all that is published in France and also holds extensive historical collections.", "Geographic_Level": [ "National" @@ -34,7 +34,7 @@ "Industry_2": [ "Library" ], - "Organisation_Role2": [ + "Organisation_Role": [ "Data Provider", "Provider" ], diff --git a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_gfm_response.json b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_gfm_response.json index a63ebe8a0..a2e1739cb 100644 --- a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_gfm_response.json +++ b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_gfm_response.json @@ -4,7 +4,7 @@ "DEA_Sent": false, "Lang_Alternative_1":"SV(Swedish)", "Image_service_Opt_in": false, - "Country": "Sweden", + "Organisation_Country": "Sweden, SE", "Geographic_Level": [], "Alternative_1":"Gotlands försvarsmuseum", "Lang_Organisation_Name": "EN(English)", @@ -13,8 +13,8 @@ "Sector": "Cultural Heritage", "SameAs_1": "http://www.wikidata.org/entity/Q28933300", "SameAs_2": "http://isni.org/isni/000000012159802X", - "Organisation_Role2": [ - "Data Provider" + "Organisation_Role": [ + "Providing Institution" ], "Latitude": "-1", "Longitude": "-1" diff --git a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_naturalis_response.json b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_naturalis_response.json index c48bc32f1..8f1af2a02 100644 --- a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_naturalis_response.json +++ b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_naturalis_response.json @@ -4,7 +4,7 @@ "DEA_Sent": true, "City": "Leiden", "Image_service_Opt_in": false, - "Country": "Netherlands", + "Organisation_Country": "Netherlands, NL", "Geographic_Level": [], "Website": "https://www.naturalis.nl/nl/", "Lang_Organisation_Name": "EN(English)", @@ -14,7 +14,7 @@ "Sector": "Cultural Heritage", "SameAs_1": "http://www.wikidata.org/entity/Q641676", "SameAs_2": "http://isni.org/isni/000000012159802X", - "Organisation_Role2": [ + "Organisation_Role": [ "Data Provider" ], "Tag": [], diff --git a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_pcce_response.json b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_pcce_response.json index 561597d04..afb844b39 100644 --- a/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_pcce_response.json +++ b/entity-management-tests/src/integration-test/resources/zoho-deref/organization_zoho_pcce_response.json @@ -10,7 +10,7 @@ "City": "Brussels", "Content_Language": "NL(Dutch)", "Image_service_Opt_in": false, - "Country": "Belgium", + "Organisation_Country": "Belgium, BE", "Geographic_Level": [ "Regional" ], @@ -22,7 +22,7 @@ "ZIP_code": "1000", "Account_Name": "PCCE (Provincial Centre for Cultural Heritage)", "Sector": "Cultural Heritage", - "Organisation_Role2": [ + "Organisation_Role": [ "Data Provider" ], "Tag": [], diff --git a/entity-management-web/src/main/java/eu/europeana/entitymanagement/web/service/EntityRecordService.java b/entity-management-web/src/main/java/eu/europeana/entitymanagement/web/service/EntityRecordService.java index 48c98ab62..d32dfe3c5 100644 --- a/entity-management-web/src/main/java/eu/europeana/entitymanagement/web/service/EntityRecordService.java +++ b/entity-management-web/src/main/java/eu/europeana/entitymanagement/web/service/EntityRecordService.java @@ -104,7 +104,7 @@ public class EntityRecordService { // Fields to be ignored during consolidation ("type" is final, so it cannot be updated) private static final Set ignoredMergeFields = Set.of("type"); - private List countryMapping; + private Map countryMapping; private ObjectMapper emJsonMapper; @Autowired @@ -130,7 +130,8 @@ private void readCountryMappingFile() throws IOException { assert inputStream != null; try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { String contents = reader.lines().collect(Collectors.joining(System.lineSeparator())); - countryMapping = emJsonMapper.readValue(contents, new TypeReference>(){}); + List countryMapList = emJsonMapper.readValue(contents, new TypeReference>(){}); + countryMapping=countryMapList.stream().collect(Collectors.toMap(ZohoMapping::getZohoLabel, ZohoMapping::getEntityUri)); } } } @@ -1285,6 +1286,7 @@ private Map deepCopyOfMap(Map input) throws Enti public void dropRepository() { this.entityRecordRepository.dropCollection(); + this.vocabRepository.dropCollection(); } /** @@ -1469,7 +1471,7 @@ public void mapZohoOrgFields(Entity entity) { //map the country field if(org.getAddress()!=null && org.getAddress().getVcardCountryName()!=null) { - String countryUri = ZohoMapping.getEntityUriFromName(countryMapping, org.getAddress().getVcardCountryName()); + String countryUri = countryMapping.get(org.getAddress().getVcardCountryName()); if(StringUtils.isBlank(countryUri)) { logger.info("The mapping for the country: {}, to the europeana uri does not exist.", org.getAddress().getVcardCountryName()); } diff --git a/entity-management-web/src/main/resources/datasources.xml b/entity-management-web/src/main/resources/datasources.xml index 61cabd9d6..2d1b7520c 100644 --- a/entity-management-web/src/main/resources/datasources.xml +++ b/entity-management-web/src/main/resources/datasources.xml @@ -10,8 +10,8 @@ - - + + \ No newline at end of file diff --git a/entity-management-web/src/main/resources/zoho_country_mapping_local.json b/entity-management-web/src/main/resources/zoho_country_mapping_local.json index 39fec9ecf..898bebbda 100644 --- a/entity-management-web/src/main/resources/zoho_country_mapping_local.json +++ b/entity-management-web/src/main/resources/zoho_country_mapping_local.json @@ -1,7 +1,7 @@ [ { - "Zoho Label": "Sweden, SE", - "Entity URI": "http://data.europeana.eu/place/4", - "Wikidata URI": "http://www.wikidata.org/entity/Q34" + "Zoho Label": "France, FR", + "Entity URI": "http://data.europeana.eu/place/5", + "Wikidata URI": "http://www.wikidata.org/entity/Q142" } ] \ No newline at end of file diff --git a/entity-management-zoho/src/main/java/eu/europeana/entitymanagement/zoho/organization/ZohoOrganizationConverter.java b/entity-management-zoho/src/main/java/eu/europeana/entitymanagement/zoho/organization/ZohoOrganizationConverter.java index f28228d9f..927bad648 100644 --- a/entity-management-zoho/src/main/java/eu/europeana/entitymanagement/zoho/organization/ZohoOrganizationConverter.java +++ b/entity-management-zoho/src/main/java/eu/europeana/entitymanagement/zoho/organization/ZohoOrganizationConverter.java @@ -29,10 +29,10 @@ public class ZohoOrganizationConverter { private static Map roleMapping ; static { roleMapping = new HashMap<>(); - roleMapping.put("Providing Institution", "http://data.europeana.eu/vocabulary/role/ProvidingInstitution"); - roleMapping.put("Aggregator", "http://data.europeana.eu/vocabulary/role/Aggregator"); - roleMapping.put("Accredited Aggregator", "http://data.europeana.eu/vocabulary/role/AccreditedAggregator"); - roleMapping.put("Potential Providing Institution", "http://data.europeana.eu/vocabulary/role/ProvidingInstitution"); + roleMapping.put("providing institution", "http://data.europeana.eu/vocabulary/role/ProvidingInstitution"); + roleMapping.put("aggregator", "http://data.europeana.eu/vocabulary/role/Aggregator"); + roleMapping.put("accredited aggregator", "http://data.europeana.eu/vocabulary/role/AccreditedAggregator"); + roleMapping.put("potential providing institution", "http://data.europeana.eu/vocabulary/role/ProvidingInstitution"); } public static Organization convertToOrganizationEntity(Record zohoRecord, String zohoBaseUrl) { @@ -65,10 +65,18 @@ public static Organization convertToOrganizationEntity(Record zohoRecord, String // ZohoUtils.createLanguageMapOfStringList( // Locale.ENGLISH.getLanguage(), organizationRoleStringList)); // } - List institutionRoleStringList = - ZohoUtils.stringListSupplier(zohoRecord.getKeyValue(ZohoConstants.INSTITUTION_ROLE_FIELD)); - if (!institutionRoleStringList.isEmpty()) { - org.setEuropeanaRole(institutionRoleStringList.stream().map(e -> roleMapping.get(e)).toList()); + List orgRoleZohoList = + ZohoUtils.stringListSupplier(zohoRecord.getKeyValue(ZohoConstants.ORGANIZATION_ROLE_FIELD)); + if (!orgRoleZohoList.isEmpty()) { + List orgRoleList = new ArrayList<>(); + for(String orgRoleZoho : orgRoleZohoList) { + if(roleMapping.containsKey(orgRoleZoho.toLowerCase())) { + orgRoleList.add(roleMapping.get(orgRoleZoho.toLowerCase())); + } + } + if(! orgRoleList.isEmpty()) { + org.setEuropeanaRole(orgRoleList); + } } Address address = new Address(); diff --git a/entity-management-zoho/src/main/java/eu/europeana/entitymanagement/zoho/utils/ZohoConstants.java b/entity-management-zoho/src/main/java/eu/europeana/entitymanagement/zoho/utils/ZohoConstants.java index 32c854b27..54ccc3ae9 100644 --- a/entity-management-zoho/src/main/java/eu/europeana/entitymanagement/zoho/utils/ZohoConstants.java +++ b/entity-management-zoho/src/main/java/eu/europeana/entitymanagement/zoho/utils/ZohoConstants.java @@ -21,8 +21,7 @@ public final class ZohoConstants { public static final String METIS_USER_FIELD = "Metis_user"; public static final String ACCOUNT_ROLE_FIELD = "Pick_List_3"; // This is the Account/Organization Role field - public static final String ORGANIZATION_ROLE_FIELD = "Organisation_Role2"; - public static final String INSTITUTION_ROLE_FIELD = "Institution_Role"; + public static final String ORGANIZATION_ROLE_FIELD = "Organisation_Role"; public static final String OFFICIAL_LANGUAGE_FIELD = "Official_Language"; public static final String LANG_ORGANIZATION_NAME_FIELD = "Lang_Organisation_Name"; public static final String LANG_ALTERNATIVE_FIELD = "Lang_Alternative"; @@ -37,7 +36,7 @@ public final class ZohoConstants { public static final String SAME_AS_FIELD = "SameAs"; public static final String STREET_FIELD = "Street"; public static final String CITY_FIELD = "City"; - public static final String COUNTRY_FIELD = "Country"; + public static final String COUNTRY_FIELD = "Organisation_Country"; public static final String ZIP_CODE_FIELD = "ZIP_code"; public static final String PO_BOX_FIELD = "PO_box"; public static final String LATITUDE_FIELD = "Latitude";