public void validateWorkOrPeerReview(ExternalID id) { if (id == null) return; List<String> errors = Lists.newArrayList(); if (id.getType() == null || !identifierTypeManager.fetchIdentifierTypesByAPITypeName(null).containsKey(id.getType())) { errors.add("type"); } if(PojoUtil.isEmpty(id.getValue())) { errors.add("value"); } if(requireRelationshipOnExternalIdentifier) { if(id.getRelationship() == null) { errors.add("relationship"); } } checkAndThrow(errors); }
public void validateFunding(ExternalIDs ids) { if (ids == null) // urgh return; List<String> errors = Lists.newArrayList(); for (ExternalID id : ids.getExternalIdentifier()) { if (id.getType() == null || !identifierTypeManager.fetchIdentifierTypesByAPITypeName(null).containsKey(id.getType())) { errors.add(id.getType()); } if(PojoUtil.isEmpty(id.getValue())) { errors.add("value"); } if(requireRelationshipOnExternalIdentifier) { if(id.getRelationship() == null) { errors.add("relationship"); } } } checkAndThrow(errors); }
/** * Merges in the DOI from a work into a CSLItemdata (if found and not * already present) * * @param work * @param item */ private String extractID(Work work, WorkExternalIdentifierType type) { if (work.getExternalIdentifiers() != null && work.getExternalIdentifiers().getExternalIdentifier() != null && work.getExternalIdentifiers().getExternalIdentifier().size() > 0) { for (ExternalID id : work.getExternalIdentifiers().getExternalIdentifier()) { if (id.getType().equalsIgnoreCase(type.value())) { return id.getValue(); } } } return null; }
/** * Merges in the DOI from a work into a CSLItemdata (if found and not * already present) * * @param work * @param item */ private String extractID(Work work, WorkExternalIdentifierType type) { if (work.getExternalIdentifiers() != null && work.getExternalIdentifiers().getExternalIdentifier() != null && work.getExternalIdentifiers().getExternalIdentifier().size() > 0) { for (ExternalID id : work.getExternalIdentifiers().getExternalIdentifier()) { if (id.getType().equalsIgnoreCase(type.value())) { return id.getValue(); } } } return null; }
if(PojoUtil.isEmpty(id.getValue())) { errors.add("value");
public void checkExternalIdentifiersForDuplicates(ExternalIDs newExtIds, ExternalIDs existingExtIds, Source existingSource, Source activeSource) { if (existingExtIds != null && newExtIds != null) { for (ExternalID existingId : existingExtIds.getExternalIdentifier()) { for (ExternalID newId : newExtIds.getExternalIdentifier()) { // normalize the ids before checking equality newId.setNormalized(new TransientNonEmptyString(norm.normalise(newId.getType(), newId.getValue()))); if (existingId.getNormalized() == null) existingId.setNormalized(new TransientNonEmptyString(norm.normalise(existingId.getType(), existingId.getValue()))); if (areRelationshipsSameAndSelf(existingId.getRelationship(), newId.getRelationship()) && newId.equals(existingId) && SourceEntityUtils.isTheSameForDuplicateChecking(activeSource,existingSource)) { Map<String, String> params = new HashMap<String, String>(); params.put("clientName", SourceEntityUtils.getSourceName(activeSource)); throw new OrcidDuplicatedActivityException(params); } } } } }
public void validateNotificationItems(Items items) { if (items == null) return; List<String> errors = Lists.newArrayList(); for (Item i : items.getItems()) { if (i.getExternalIdentifier() != null && i.getExternalIdentifier().getType() != null) { ExternalID extId = i.getExternalIdentifier(); if (extId.getType() == null || !identifierTypeManager.fetchIdentifierTypesByAPITypeName(null).containsKey(extId.getType())) { errors.add(i.getExternalIdentifier().getType()); } if(PojoUtil.isEmpty(extId.getValue())) { errors.add("value"); } if(requireRelationshipOnExternalIdentifier) { if(extId.getRelationship() == null) { errors.add("relationship"); } } } } checkAndThrow(errors); }
if ((externalIdentifiers.getExternalIdentifier().get(0).getValue() == null && externalIdentifiers.getExternalIdentifier().get(0) .getType() == null)) { return false;
for(ExternalID extId : work.getExternalIdentifiers().getExternalIdentifier()) { extId.setNormalized(new TransientNonEmptyString(norm.normalise(extId.getType(), extId.getValue())));
public static FundingExternalIdentifierForm valueOf(ExternalID fundingExternalIdentifier) { FundingExternalIdentifierForm result = new FundingExternalIdentifierForm(); if (fundingExternalIdentifier.getType() != null) result.setType(Text.valueOf(fundingExternalIdentifier.getType())); if (fundingExternalIdentifier.getUrl() != null && !PojoUtil.isEmpty(fundingExternalIdentifier.getUrl().getValue())) result.setUrl(Text.valueOf(fundingExternalIdentifier.getUrl().getValue())); if (!PojoUtil.isEmpty(fundingExternalIdentifier.getValue())) result.setValue(Text.valueOf(fundingExternalIdentifier.getValue())); if(fundingExternalIdentifier.getRelationship() != null) result.setRelationship(Text.valueOf(fundingExternalIdentifier.getRelationship().value())); return result; }
@Override public String convertTo(ExternalIDs source, Type<String> destinationType) { JSONFundingExternalIdentifiers jsonFundingExternalIdentifiers = new JSONFundingExternalIdentifiers(); for (ExternalID externalID : source.getExternalIdentifier()) { JSONExternalIdentifier jsonExternalIdentifier = new JSONExternalIdentifier(); if (externalID.getType() != null) { jsonExternalIdentifier.setType(conv.convertTo(externalID.getType(), null)); } if (externalID.getUrl() != null) { jsonExternalIdentifier.setUrl(new JSONUrl(externalID.getUrl().getValue())); } if (!PojoUtil.isEmpty(externalID.getValue())) { jsonExternalIdentifier.setValue(externalID.getValue()); } if (externalID.getRelationship() != null) { jsonExternalIdentifier.setRelationship(conv.convertTo(externalID.getRelationship().value(), null)); } jsonFundingExternalIdentifiers.getFundingExternalIdentifier().add(jsonExternalIdentifier); } return JsonUtils.convertToJsonString(jsonFundingExternalIdentifiers); }
@Override public String convertTo(ExternalIDs source, Type<String> destinationType) { JSONExternalIdentifiers jsonExternalIdentifiers = new JSONExternalIdentifiers(); for (ExternalID externalID : source.getExternalIdentifier()) { JSONExternalIdentifier jsonExternalIdentifier = new JSONExternalIdentifier(); if (externalID.getType() != null) { jsonExternalIdentifier.setType(conv.convertTo(externalID.getType(), null)); } if (externalID.getUrl() != null) { jsonExternalIdentifier.setUrl(new JSONUrl(externalID.getUrl().getValue())); } if (!PojoUtil.isEmpty(externalID.getValue())) { jsonExternalIdentifier.setValue(externalID.getValue()); } if (externalID.getRelationship() != null) { jsonExternalIdentifier.setRelationship(conv.convertTo(externalID.getRelationship().value(), null)); } jsonExternalIdentifiers.getExternalIdentifier().add(jsonExternalIdentifier); } return JsonUtils.convertToJsonString(jsonExternalIdentifiers); }
@Override public String convertTo(ExternalID source, Type<String> destinationType) { JSONWorkExternalIdentifier jsonWorkExternalIdentifier = new JSONWorkExternalIdentifier(); if (source.getType() != null) { jsonWorkExternalIdentifier.setWorkExternalIdentifierType(conv.convertTo(source.getType(), null)); } if (source.getUrl() != null) { jsonWorkExternalIdentifier.setUrl(new JSONUrl(source.getUrl().getValue())); } if (!PojoUtil.isEmpty(source.getValue())) { jsonWorkExternalIdentifier.setWorkExternalIdentifierId(new WorkExternalIdentifierId(source.getValue())); } if (source.getRelationship() != null) { jsonWorkExternalIdentifier.setRelationship(conv.convertTo(source.getRelationship().value(), null)); } return JsonUtils.convertToJsonString(jsonWorkExternalIdentifier); }
@Override public String convertTo(ExternalIDs source, Type<String> destinationType) { JSONWorkExternalIdentifiers jsonWorkExternalIdentifiers = new JSONWorkExternalIdentifiers(); for (ExternalID externalID : source.getExternalIdentifier()) { JSONWorkExternalIdentifier jsonWorkExternalIdentifier = new JSONWorkExternalIdentifier(); if (externalID.getType() != null) { jsonWorkExternalIdentifier.setWorkExternalIdentifierType(conv.convertTo(externalID.getType(), null)); } if (externalID.getUrl() != null) { jsonWorkExternalIdentifier.setUrl(new JSONUrl(externalID.getUrl().getValue())); } if (!PojoUtil.isEmpty(externalID.getValue())) { jsonWorkExternalIdentifier.setWorkExternalIdentifierId(new WorkExternalIdentifierId(externalID.getValue())); } if (externalID.getRelationship() != null) { jsonWorkExternalIdentifier.setRelationship(conv.convertTo(externalID.getRelationship().value(), null)); } jsonWorkExternalIdentifiers.getWorkExternalIdentifier().add(jsonWorkExternalIdentifier); } return JsonUtils.convertToJsonString(jsonWorkExternalIdentifiers); }
private SchemaOrgAffiliation createFundingOrg(FundingGroup fundingGroup) { SchemaOrgAffiliation a = new SchemaOrgAffiliation(); a.name = fundingGroup.getFundingSummary().get(0).getOrganization().getName(); a.alternateName = fundingGroup.getFundingSummary().get(0).getTitle().getTitle().getContent(); //add org ids for (FundingSummary s : fundingGroup.getFundingSummary()){ if (s.getOrganization().getDisambiguatedOrganization() !=null){ if (!StringUtils.isEmpty(s.getOrganization().getDisambiguatedOrganization().getDisambiguationSource()) && !StringUtils.isEmpty(s.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier())) addIdToAffiliation(s.getOrganization().getDisambiguatedOrganization().getDisambiguationSource(),s.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier(), a); if (s.getOrganization().getDisambiguatedOrganization().getExternalIdentifiers() != null) for (DisambiguatedOrganizationExternalIdentifier i : s.getOrganization().getDisambiguatedOrganization().getExternalIdentifiers()) { addIdToAffiliation(i.getIdentifierType(),i.getIdentifier(), a); } } } //add grant ids if (fundingGroup.getIdentifiers() != null && fundingGroup.getIdentifiers().getExternalIdentifier() != null) for (ExternalID id : fundingGroup.getIdentifiers().getExternalIdentifier()) a.identifier.add(new SchemaOrgExternalID(id.getType(), norm.normalise(id.getType(), id.getValue()))); return a; }
public static ActivityExternalIdentifier valueOf(ExternalID externalIdentifier) { ActivityExternalIdentifier wi = new ActivityExternalIdentifier(); if (externalIdentifier != null) { if (externalIdentifier.getValue() != null) wi.setExternalIdentifierId(Text.valueOf(externalIdentifier.getValue())); if (externalIdentifier.getType() != null) wi.setExternalIdentifierType(Text.valueOf(externalIdentifier.getType())); if(externalIdentifier.getRelationship() != null) wi.setRelationship(Text.valueOf(externalIdentifier.getRelationship().value())); if(externalIdentifier.getUrl() != null) wi.setUrl(Text.valueOf(externalIdentifier.getUrl().getValue())); if(externalIdentifier.getNormalized() != null){ wi.setNormalized(Text.valueOf(externalIdentifier.getNormalized().getValue())); wi.getNormalized().setRequired(false); } if(externalIdentifier.getNormalizedUrl() != null){ wi.setNormalizedUrl(Text.valueOf(externalIdentifier.getNormalizedUrl().getValue())); wi.getNormalizedUrl().setRequired(false); } } return wi; }
public ExternalID clone() { ExternalID id = new ExternalID(); id.type = this.getType(); id.value = this.getValue(); if (this.getNormalized() != null) id.setNormalized(this.getNormalized()); if (this.getNormalizedError() != null) id.setNormalizedError(this.getNormalizedError()); if (this.getUrl() != null) id.url = new Url(this.getUrl().getValue()); if (this.getRelationship() != null) id.relationship = this.getRelationship(); if (this.getNormalizedUrl() != null) id.setNormalizedUrl(this.getNormalizedUrl()); if (this.getNormalizedUrlError() != null) id.setNormalizedUrlError(this.getNormalizedUrlError()); return id; }