From 7cd1b0fbddc869f1edf355bb78a79d7ef1d9bf7d Mon Sep 17 00:00:00 2001 From: SrdjanStevanetic Date: Thu, 8 Feb 2024 13:24:22 +0100 Subject: [PATCH] update solr organization fields --- .../definitions/model/Organization.java | 12 ++++++++++++ .../vocabulary/EntityFieldsTypes.java | 1 + .../solr/model/SolrOrganization.java | 16 ++++++++++++---- .../entitymanagement/solr/SolrServiceIT.java | 6 ------ .../web/EntityRegistrationIT.java | 3 +++ .../resources/content/organization.json | 11 ++++++++++- .../resources/solr-docker/conf/schema.xml | 4 +--- .../resources/zoho_country_mapping_test.json | 7 ++++++- .../organization/ZohoOrganizationConverter.java | 1 + 9 files changed, 46 insertions(+), 15 deletions(-) diff --git a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Organization.java b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Organization.java index 335f267f..634ab504 100644 --- a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Organization.java +++ b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Organization.java @@ -71,6 +71,9 @@ public class Organization extends Entity { private String countryId; @Transient private Place country; + @Transient + private String countryISO; + private List europeanaRoleIds; @Reference(lazy = true) @@ -282,5 +285,14 @@ public List getEuropeanaRole() { public void setEuropeanaRole(List europeanaRole) { this.europeanaRole = europeanaRole; } + + @JsonIgnore + public String getCountryISO() { + return countryISO; + } + + public void setCountryISO(String countryISO) { + this.countryISO = countryISO; + } } diff --git a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/vocabulary/EntityFieldsTypes.java b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/vocabulary/EntityFieldsTypes.java index dfe9c955..46292f12 100644 --- a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/vocabulary/EntityFieldsTypes.java +++ b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/vocabulary/EntityFieldsTypes.java @@ -108,6 +108,7 @@ public enum EntityFieldsTypes { countryId(EntityFieldsTypes.FIELD_TYPE_URI, false, EntityFieldsTypes.FIELD_CARDINALITY_0_1), country(EntityFieldsTypes.FIELD_TYPE_PLACE, false, EntityFieldsTypes.FIELD_CARDINALITY_0_1), countryRef(EntityFieldsTypes.FIELD_TYPE_ENTITY_RECORD, false, EntityFieldsTypes.FIELD_CARDINALITY_0_1), + countryISO(EntityFieldsTypes.FIELD_TYPE_TEXT, false, EntityFieldsTypes.FIELD_CARDINALITY_1_1), homepage(EntityFieldsTypes.FIELD_TYPE_URI, false, EntityFieldsTypes.FIELD_CARDINALITY_0_1), phone( EntityFieldsTypes.FIELD_TYPE_KEYWORD, false, EntityFieldsTypes.FIELD_CARDINALITY_0_INFINITE), diff --git a/entity-management-solr/src/main/java/eu/europeana/entitymanagement/solr/model/SolrOrganization.java b/entity-management-solr/src/main/java/eu/europeana/entitymanagement/solr/model/SolrOrganization.java index 669f1bb5..dfa4c47a 100644 --- a/entity-management-solr/src/main/java/eu/europeana/entitymanagement/solr/model/SolrOrganization.java +++ b/entity-management-solr/src/main/java/eu/europeana/entitymanagement/solr/model/SolrOrganization.java @@ -37,11 +37,11 @@ public class SolrOrganization extends SolrEntity { private List mbox; //MAPPING TO BE ENABLED BACK IN THE NEXT VERSION - requires schema and ENtity API UPDATE - //@Field(OrganizationSolrFields.EUROPEANA_ROLE) + @Field(OrganizationSolrFields.EUROPEANA_ROLE) private List europeanaRole; @Field(OrganizationSolrFields.COUNTRY) - private String country; + private List country; @Field(OrganizationSolrFields.VCARD_HAS_ADDRESS) private String hasAddress; @@ -85,7 +85,15 @@ public SolrOrganization(Organization organization) { if(organization.getEuropeanaRoleIds()!=null) this.europeanaRole=new ArrayList<>(organization.getEuropeanaRoleIds()); - this.country=organization.getCountryId(); + this.country=new ArrayList<>(); + String orgCountryId=organization.getCountryId(); + String orgCoutryISO=organization.getCountryISO(); + if(orgCountryId!=null) { + this.country.add(orgCountryId); + } + if(orgCoutryISO!=null) { + this.country.add(orgCoutryISO); + } if (organization.getSameReferenceLinks() != null) { this.sameAs = new ArrayList<>(organization.getSameReferenceLinks()); @@ -187,7 +195,7 @@ protected void setSameReferenceLinks(ArrayList uris) { this.sameAs = uris; } - public String getCountry() { + public List getCountry() { return country; } } diff --git a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/solr/SolrServiceIT.java b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/solr/SolrServiceIT.java index a9b93ef9..ed424e34 100644 --- a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/solr/SolrServiceIT.java +++ b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/solr/SolrServiceIT.java @@ -41,7 +41,6 @@ import eu.europeana.entitymanagement.solr.service.SolrService; import eu.europeana.entitymanagement.testutils.IntegrationTestUtils; import eu.europeana.entitymanagement.utils.EntityRecordUtils; -import eu.europeana.entitymanagement.vocabulary.EntityTypes; @SpringBootTest public class SolrServiceIT extends AbstractIntegrationTest { @@ -79,11 +78,6 @@ void verifyPayload(SolrEntity entity) { // mandatory fields assertThat(payload, Matchers.containsString("\"prefLabel\"")); assertThat(payload, Matchers.containsString("\"type\"")); - - // for organizations verify country - if (EntityTypes.Organization.getEntityType().equals(entity.getType())) { - assertThat(payload, Matchers.containsString("\"country\"")); - } } void verifyIsShownBy(String payload) { diff --git a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/EntityRegistrationIT.java b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/EntityRegistrationIT.java index df989645..dec6aa8b 100644 --- a/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/EntityRegistrationIT.java +++ b/entity-management-tests/src/integration-test/java/eu/europeana/entitymanagement/web/EntityRegistrationIT.java @@ -7,6 +7,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.matchesRegex; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -280,6 +281,8 @@ public void registerZohoOrganizationBergerShouldBeSuccessful() throws Exception // check if indexing is successfull by searching the organization in solr SolrOrganization org = emSolrService.searchById(SolrOrganization.class, WebEntityFields.BASE_DATA_EUROPEANA_URI + "organization/1"); assertNotNull(org.getHasAddress()); + assertNotNull(org.getEuropeanaRole()); + assertTrue(org.getCountry().size()==2); } @Test diff --git a/entity-management-tests/src/integration-test/resources/content/organization.json b/entity-management-tests/src/integration-test/resources/content/organization.json index 41462810..b553ac5d 100644 --- a/entity-management-tests/src/integration-test/resources/content/organization.json +++ b/entity-management-tests/src/integration-test/resources/content/organization.json @@ -88,7 +88,16 @@ "en": "Netherlands" } }, - + "europeanaRole": { + "type" : "Vocabulary", + "vocabularyUri" : "http://data.europeana.eu/vocabulary/role/ProvidingInstitution", + "inScheme" : [ + "http://data.europeana.eu/vocabulary/role" + ], + "prefLabel" : { + "en" : "Providing Institution" + } + }, "homepage": "https://www.naturalis.nl/nl/", "phone": [ "+31-71-751-9600" diff --git a/entity-management-tests/src/integration-test/resources/solr-docker/conf/schema.xml b/entity-management-tests/src/integration-test/resources/solr-docker/conf/schema.xml index 720ed19c..f4b51cfd 100644 --- a/entity-management-tests/src/integration-test/resources/solr-docker/conf/schema.xml +++ b/entity-management-tests/src/integration-test/resources/solr-docker/conf/schema.xml @@ -488,10 +488,8 @@ - + multiValued="true" />