Skip to content

Commit

Permalink
zoho fields changed to comply with zoho eu
Browse files Browse the repository at this point in the history
  • Loading branch information
SrdjanStevanetic committed Feb 1, 2024
1 parent d4222ac commit 1fb2901
Show file tree
Hide file tree
Showing 29 changed files with 154 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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.eu";

@JacksonXmlProperty(isAttribute = true)
private String url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ public interface OrganizationSolrFields extends EntitySolrFields {
public static final String FOAF_MBOX = "foaf_mbox";
public static final String EUROPEANA_ROLE = "europeanaRole";
public static final String EUROPEANA_ROLE_ALL = EUROPEANA_ROLE + EXTENSION_ALL;
public static final String COUNTRY_ID = "countryId";
public static final String COUNTRY_PREF_LABEL_ALL = "countryPrefLabel.*";
public static final String COUNTRY_PREF_LABEL = "countryPrefLabel";
public static final String COUNTRY_LAT = "countryLatitude";
public static final String COUNTRY_LONG = "countryLongitude";
public static final String COUNTRY = "country";
public static final String VCARD_HAS_ADDRESS = "vcard_hasAddress.1";
public static final String VCARD_STREET_ADDRESS = "vcard_streetAddress.1";
public static final String VCARD_LOCALITY = "vcard_locality.1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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";

// common fields
public static final String ID = "id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.apache.solr.client.solrj.beans.Field;
import eu.europeana.entitymanagement.definitions.model.Address;
import eu.europeana.entitymanagement.definitions.model.Organization;
import eu.europeana.entitymanagement.definitions.model.Place;
import eu.europeana.entitymanagement.solr.SolrUtils;
import eu.europeana.entitymanagement.utils.EntityUtils;
import eu.europeana.entitymanagement.vocabulary.EntitySolrFields;
Expand Down Expand Up @@ -40,17 +39,8 @@ public class SolrOrganization extends SolrEntity<Organization> {
@Field(OrganizationSolrFields.EUROPEANA_ROLE_ALL)
private Map<String, List<String>> europeanaRole;

@Field(OrganizationSolrFields.COUNTRY_ID)
private String countryId;

@Field(OrganizationSolrFields.COUNTRY_PREF_LABEL_ALL)
private Map<String, String> countryPrefLabel;

@Field(OrganizationSolrFields.COUNTRY_LAT)
private Float countryLatitude;

@Field(OrganizationSolrFields.COUNTRY_LONG)
private Float countryLongitude;
@Field(OrganizationSolrFields.COUNTRY)
private String country;

@Field(OrganizationSolrFields.VCARD_HAS_ADDRESS)
private String hasAddress;
Expand Down Expand Up @@ -93,12 +83,7 @@ public SolrOrganization(Organization organization) {
if (organization.getMbox() != null) this.mbox = new ArrayList<>(organization.getMbox());
setEuropeanaRole(organization.getEuropeanaRole());

if(organization.getCountry()!=null) {
this.countryId = organization.getCountry().getEntityId();
this.setCountryPrefLabel(organization.getCountry().getPrefLabel());
this.countryLatitude = ((Place) organization.getCountry()).getLatitude();
this.countryLongitude = ((Place) organization.getCountry()).getLongitude();
}
this.country=organization.getCountryId();

if (organization.getSameReferenceLinks() != null) {
this.sameAs = new ArrayList<>(organization.getSameReferenceLinks());
Expand Down Expand Up @@ -145,16 +130,6 @@ private void setEuropeanaRole(Map<String, List<String>> europeanaRole) {
}
}

private void setCountryPrefLabel(Map<String, String> prefLabel) {
if (MapUtils.isNotEmpty(prefLabel)) {
this.countryPrefLabel =
new HashMap<>(
SolrUtils.normalizeStringMapByAddingPrefix(
OrganizationSolrFields.COUNTRY_PREF_LABEL + EntitySolrFields.DYNAMIC_FIELD_SEPARATOR,
prefLabel));
}
}

public Map<String, String> getDescription() {
return description;
}
Expand Down Expand Up @@ -220,19 +195,7 @@ protected void setSameReferenceLinks(ArrayList<String> uris) {
this.sameAs = uris;
}

public String getCountryId() {
return countryId;
}

public Map<String, String> getCountryPrefLabel() {
return countryPrefLabel;
}

public Float getCountryLatitude() {
return countryLatitude;
}

public Float getCountryLongitude() {
return countryLongitude;
public String getCountry() {
return country;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public abstract class AbstractIntegrationTest {
@Autowired protected ConceptSchemeService emConceptSchemeService;
@Autowired protected EntityManagementConfiguration emConfig;
@Autowired protected ZohoConfiguration zohoConfiguration;

static {
MONGO_CONTAINER =
new MongoContainer("entity-management", "job-repository", "enrichment")
Expand All @@ -78,6 +78,8 @@ public abstract class AbstractIntegrationTest {
.withLogConsumer(new WaitingConsumer().andThen(new ToStringConsumer()));

SOLR_CONTAINER.start();


}

/** MockWebServer needs to be static, so we can inject its port into the Spring context. */
Expand All @@ -101,6 +103,7 @@ public static void setupAll() throws IOException {
mockSearchAndRecord = new MockWebServer();
mockSearchAndRecord.setDispatcher(setupSearchAndRecordDispatcher());
mockSearchAndRecord.start();

}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public void zohoOrganizationDereferenceTest() throws Exception {
Assertions.assertNotNull(org.getLogo());
Assertions.assertNotNull(org.getAddress().getVcardStreetAddress());
Assertions.assertNotNull(org.getAddress().getVcardCountryName());
Assertions.assertTrue(org.getHiddenLabel().contains("BN Paris (blíže neurčeno)"));
Assertions.assertTrue(org.getHiddenLabel().contains("Bibliothèque nationale"));
Assertions.assertTrue(org.getHiddenLabel().contains("Bibliothèque nationale Francaise"));
Assertions.assertTrue(org.getHiddenLabel().contains("French National Library"));
Assertions.assertTrue(org.getHiddenLabel().contains("Bibliothèque nationale Francaise French National Library"));
}

// @Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ public class IntegrationTestUtils {
public static final String ORGANIZATION_BNF_URI_ZOHO =
"https://crm.zoho.eu/crm/org20085137532/tab/Accounts/486281000000938399";
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/486281000000923816";
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/486281000000923271";
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/486281000000940433";
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/486281000000939337";

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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";

@Autowired
Expand All @@ -32,7 +32,7 @@ public ZohoConfiguration configureZoho() throws Exception {
ZohoConfiguration zohoConfiguration = Mockito.mock(ZohoConfiguration.class);
ZohoAccessClient zohoClient = Mockito.mock(ZohoAccessClient.class);
Mockito.when(zohoConfiguration.getZohoAccessClient()).thenReturn(zohoClient);
Mockito.when(zohoConfiguration.getZohoBaseUrl()).thenReturn(zohoConfiguration.getZohoBaseUrl());
Mockito.when(zohoConfiguration.getZohoBaseUrl()).thenReturn(MOCK_ZOHO_BASE_URL);

// find matching JSON file based on zohoId argument, then create a Record object for it
Mockito.doAnswer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.LOGO_LINK_TO_WIKIMEDIACOMMONS_FIELD;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.LONGITUDE_FIELD;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.OFFICIAL_LANGUAGE_FIELD;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.ORGANIZATION_COUNTRY_FIELD;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.ORGANIZATION_ROLE_FIELD;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.PO_BOX_FIELD;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.SAME_AS_CODE_LENGTH;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.SAME_AS_FIELD;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.STREET_FIELD;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.WEBSITE_FIELD;
import static eu.europeana.entitymanagement.zoho.utils.ZohoConstants.ZIP_CODE_FIELD;
import java.io.IOException;
Expand Down Expand Up @@ -57,7 +57,7 @@ public class ZohoRecordTestDeserializer extends StdDeserializer<Record> {
ACRONYM_FIELD,
LOGO_LINK_TO_WIKIMEDIACOMMONS_FIELD,
WEBSITE_FIELD,
ORGANIZATION_COUNTRY_FIELD,
STREET_FIELD,
CITY_FIELD,
COUNTRY_FIELD,
ZIP_CODE_FIELD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void registerZohoOrganizationBergerShouldBeSuccessful() throws Exception
Matchers.hasItems(
IntegrationTestUtils.ORGANIZATION_BERGER_MUSEUM_WIKIDATA_URI,
IntegrationTestUtils.ORGANIZATION_BERGER_MUSEUM_URI_ZOHO)))
.andExpect(jsonPath("$.prefLabel[*]", hasSize(1)))
.andExpect(jsonPath("$.prefLabel[*]", hasSize(2)))
// should have Europeana, Zoho and Wikidata proxies
.andExpect(jsonPath("$.proxies", hasSize(3)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,7 @@ public void retrieveOrganizationJsonExternalWithCountryDereference() throws Exce
.andExpect(jsonPath("$.id", is(entityId)))
.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("$.country.prefLabel.en", is("Sweden")));
}

@Test
Expand All @@ -547,7 +546,7 @@ public void retrieveOrganizationJsonExternal() throws Exception {
.andExpect(jsonPath("$.id", is(entityId)))
.andExpect(jsonPath("$.type", is(EntityTypes.Organization.getEntityType())))
.andExpect(jsonPath("$.sameAs").isNotEmpty())
.andExpect(jsonPath("$.countryId").isNotEmpty())
.andExpect(jsonPath("$.hasAddress.countryName").isNotEmpty())
.andExpect(jsonPath("$.countryPlace").doesNotExist());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ ZohoDereferenceService getZohoDereferenceService() {
public void generateBNFJson() throws Exception {
//get original zoho record
Optional<Record> zohoOrganization =
zohoConfiguration.getZohoAccessClient().getZohoRecordOrganizationById(IntegrationTestUtils.ORGANIZATION_BNF_URI_ZOHO);
zohoConfiguration.getZohoAccessClient().getZohoRecordOrganizationById(IntegrationTestUtils.ORGANIZATION_PCCE_URI_ZOHO);
String zohoRecord = getZohoDereferenceService().serialize(zohoOrganization.get());
//if you need to see original enable : System.out.println(zohoRecord);
// System.out.println(zohoRecord);
System.out.println(zohoRecord);

//deserialize data with the test deserializer
ZohoRecordTestDeserializer zohoRecordDeserializer = new ZohoRecordTestDeserializer();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@context": "http://www.europeana.eu/schemas/context/entity.jsonld",
"id": "http://data.europeana.eu/organization/1482250000000370517",
"id": "http://data.europeana.eu/organization/1",
"type": "Organization",
"depiction": {
"id": "http://commons.wikimedia.org/wiki/Special:FilePath/WLANL%20-%20thedogg%20-%20Mammoet%20%282%29.jpg",
Expand Down
Original file line number Diff line number Diff line change
@@ -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/486281000000939337"
}
Original file line number Diff line number Diff line change
@@ -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/486281000000938399",
"prefLabel": {
"fr": "Bibliothèque nationale de France"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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/486281000000940433"
}
Original file line number Diff line number Diff line change
@@ -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/486281000000923816",
"prefLabel": {
"fr": "Nauralis"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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/486281000000923271"
}
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,8 @@
<dynamicField name="edm_acronym.*" type="string"
indexed="false" stored="true" multiValued="true" />
<!-- ISO ALPHA-2 codes -->
<field name="countryId" type="string" indexed="true" stored="true"
<field name="country" type="string" indexed="true" stored="true"
multiValued="false" />
<dynamicField name="countryPrefLabel.*" type="string"
indexed="true" stored="true" multiValued="false" />
<field name="countryLatitude" type="float" indexed="false"
stored="true" multiValued="false" />
<field name="countryLongitude" type="float" indexed="false"
stored="true" multiValued="false" />

<!-- TODO: alias -->
<!-- <field name="edm_country" type="string" indexed="true" stored="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
{
"Last_Activity_Time": "2021-11-23T14:08:03+01:00",
"id": "1482250000004477407",
"Industry": "Museum",
"Working_Language": "NO(NORSK)",
"DEA_Sent": true,
"Content_Language": "NO(NORSK)",
"Image_service_Opt_in": false,
"Lang_Organisation_Name": "NO(NORSK)",
"DEA_Signed": true,
"Account_Name": "Berger museum",
"Sector": "Cultural Heritage",
"Organisation_Role2": [
"Data Provider"
"Organisation_Role" : [
"Providing institution"
],
"SameAs_1": "http://www.wikidata.org/entity/Q23014463",
"Country": "Norway",
"Tag": [],
"Latitude": "-1",
"Longitude": "-1"
}
"Organisation_Country" : "Norway, NO",
"id" : 486281000000939337,
"Lang_Alternative_1" : "NO(Norwegian)",
"Subsector" : "Museum",
"Alternative_1" : "Berger museum",
"Website" : "https://vestfoldmuseene.no/berger-museum/",
"Lang_Organisation_Name" : "EN(English)",
"Zoho_ID" : "zcrm_1482250000004477407",
"Account_Name" : "Berger museum",
"Official_language" : "NO(Norwegian)",
"Sector" : "Cultural heritage",
"SameAs_1" : "http://www.wikidata.org/entity/Q23014463",
"Continent" : "Europe",
"Tag" : [ ]
}
Loading

0 comments on commit 1fb2901

Please sign in to comment.