Skip to content

Commit

Permalink
update solr organization fields
Browse files Browse the repository at this point in the history
  • Loading branch information
SrdjanStevanetic committed Feb 8, 2024
1 parent 61eab5c commit 7cd1b0f
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public class Organization extends Entity {
private String countryId;
@Transient
private Place country;
@Transient
private String countryISO;


private List<String> europeanaRoleIds;
@Reference(lazy = true)
Expand Down Expand Up @@ -282,5 +285,14 @@ public List<Vocabulary> getEuropeanaRole() {
public void setEuropeanaRole(List<Vocabulary> europeanaRole) {
this.europeanaRole = europeanaRole;
}

@JsonIgnore
public String getCountryISO() {
return countryISO;
}

public void setCountryISO(String countryISO) {
this.countryISO = countryISO;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public class SolrOrganization extends SolrEntity<Organization> {
private List<String> 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<String> europeanaRole;

@Field(OrganizationSolrFields.COUNTRY)
private String country;
private List<String> country;

@Field(OrganizationSolrFields.VCARD_HAS_ADDRESS)
private String hasAddress;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -187,7 +195,7 @@ protected void setSameReferenceLinks(ArrayList<String> uris) {
this.sameAs = uris;
}

public String getCountry() {
public List<String> getCountry() {
return country;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,8 @@
<!-- TO BE DELETED IN NEXT RELEASE -->
<dynamicField name="europeanaRole.*" type="string"
indexed="true" multiValued="true" stored="true" />
<!-- TO BE ENABLED IN NEXT RELEASE
<field name="europeanaRole" type="string" indexed="true"
stored="true" multiValued="true" />
-->
<!-- DEPRECATED TO BE DELETED
<dynamicField name="edm_europeanaRole.*" type="string" indexed="true"
multiValued="true" /> <copyField source="europeanaRole.*" dest="edm_europeanaRole.*"
Expand All @@ -516,7 +514,7 @@
indexed="false" stored="true" multiValued="true" />
<!-- ISO ALPHA-2 codes -->
<field name="country" type="string" indexed="true" stored="true"
multiValued="false" />
multiValued="true" />

<!-- TODO: alias -->
<!-- <field name="edm_country" type="string" indexed="true" stored="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"Zoho Label": "Sweden, SE",
"Entity URI": "http://data.europeana.eu/place/1",
"Wikidata URI": "http://www.wikidata.org/entity/Q34"
}
},
{
"Zoho Label": "Norway, NO",
"Entity URI": "http://data.europeana.eu/place/2",
"Wikidata URI": "http://www.wikidata.org/entity/Q20"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static Organization convertToOrganizationEntity(Record zohoRecord, String
//update address country
address.setVcardCountryName(extractCountryName(zohoCountryLabel));

org.setCountryISO(StringUtils.substringAfterLast(zohoCountryLabel, ",").trim());
//update organization country id
if(countryMappings.containsKey(zohoCountryLabel)) {
//get country ID from mappings
Expand Down

0 comments on commit 7cd1b0f

Please sign in to comment.