Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change zoho mapping for Europe and avoid NPEs if country is #300

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
},
{
"Zoho Label": "Europe, EU",
"Entity URI": "",
"Wikidata URI": ""
"Entity URI": null,
"Wikidata URI": null
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,18 @@ private boolean validateAddressField(
addConstraint(context, "Field '" + fieldName + "' has an invalid or empty id value.");
isValid = false;
}
if (address.getVcardCountryName() == null
|| address.getVcardCountryName().isBlank()
|| !validateStringValue(
context,
fieldName,
EntityFieldsTypes.getFieldType(fieldName),
address.getVcardCountryName(),
null)) {
addConstraint(context, "Field '" + fieldName + "' has an invalid or empty country name.");
isValid = false;
}
//SG: EA-3720 temporarily disable until a new rule will be defined
// if (address.getVcardCountryName() == null
// || address.getVcardCountryName().isBlank()
// || !validateStringValue(
// context,
// fieldName,
// EntityFieldsTypes.getFieldType(fieldName),
// address.getVcardCountryName(),
// null)) {
// addConstraint(context, "Field '" + fieldName + "' has an invalid or empty country name.");
// isValid = false;
// }
return isValid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public enum EntityFieldsTypes {
europeanaRoleRefs(
EntityFieldsTypes.FIELD_TYPE_VOCABULARY, false, EntityFieldsTypes.FIELD_CARDINALITY_0_INFINITE),
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),
homepage(EntityFieldsTypes.FIELD_TYPE_URI, false, EntityFieldsTypes.FIELD_CARDINALITY_0_1),
phone(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ public XmlOrganizationImpl(Organization organization) {
this.europeanaRole=orgXmlRole;
}

this.country = new XmlPlaceImpl(organization.getCountry());
if(organization.getCountry() != null) {
this.country = new XmlPlaceImpl(organization.getCountry());
}

if (organization.getHomepage() != null) {
this.homepage = new LabelledResource(organization.getHomepage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ public void wikidataOrganizationGFMDereferenceTest() throws ZohoException, Excep
// GFM
dereferenceWikidataOrganization(IntegrationTestUtils.ORGANIZATION_GFM_URI_WIKIDATA_URI);
}

// @Test
// (not available in test data)
public void wikidataOrganizationSNHDereferenceTest() throws ZohoException, Exception {
// SNH
dereferenceWikidataOrganization("https://crm.zoho.eu/crm/org20085137532/tab/Accounts/486281000000938800");
}



Organization dereferenceWikidataOrganization(String organizationId) throws Exception {
Dereferencer dereferencer =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.europeana.entitymanagement.web.model;

import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import com.zoho.crm.api.record.Record;
import eu.europeana.api.commons.web.model.vocabulary.Operations;
import eu.europeana.entitymanagement.definitions.model.EntityRecord;
Expand All @@ -17,7 +18,11 @@ public class Operation implements Comparable<Operation> {

public Operation(
String zohoEuropeanaId, String action, Record zohoRecord, EntityRecord entityRecord) {
this.zohoEuropeanaId = zohoEuropeanaId;

if(! StringUtils.isBlank(zohoEuropeanaId)) {
//avoid using empty strings which might have been manually entered in Zoho
this.zohoEuropeanaId = zohoEuropeanaId;
}
this.action = action;
this.zohoRecord = zohoRecord;
if (zohoRecord != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ boolean shouldDisable(boolean hasDpsOwner, boolean markedForDeletion) {

private boolean skipNoZohoEuropeanaId(String zohoRecordEuropeanaID,
boolean organizationIdGenerationEnabled) {
return zohoRecordEuropeanaID == null && !organizationIdGenerationEnabled;
return StringUtils.isBlank(zohoRecordEuropeanaID) && !organizationIdGenerationEnabled;
}

boolean skipNonExisting(boolean hasDpsOwner, boolean markedForDeletion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public final class ZohoConstants {
public static final String LOGO_LINK_TO_WIKIMEDIACOMMONS_FIELD = "Logo";
public static final String WEBSITE_FIELD = "Website";
public static final String SECTOR_FIELD = "Sector";
public static final String SUBSECTOR_FIELD = "Subsector";
public static final String SCOPE_FIELD = "Scope";
public static final String SAME_AS_FIELD = "SameAs";
public static final String STREET_FIELD = "Street";
Expand All @@ -50,7 +51,7 @@ public final class ZohoConstants {
public static final String HIDDEN_LABEL_FIELD = "Hidden_names";

public static final String INDUSTRY_FIELD = "Industry_2";
public static final String EUROPEANA_ID_FIELD = "Europeana_ID";
public static final String EUROPEANA_ID_FIELD = "Europeana_org_ID";

// Operations
public static final String EQUALS_OPERATION = "equals";
Expand Down
Loading