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); }
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); }
private Work checkWorkAndIdentifierTypes(Work work) { if (WorkType.BOOK_CHAPTER.equals(work.getWorkType())) { for (ExternalID externalID : work.getExternalIdentifiers().getExternalIdentifier()) { if ("isbn".equals(externalID.getType())) { externalID.setRelationship(Relationship.PART_OF); } } } return work; }
/** * 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; }
public static void populateExternalIdentifiers(ExternalIDs extIds, WorkForm workForm, WorkType workType) { if (extIds != null) { List<ActivityExternalIdentifier> workExternalIdentifiersList = new ArrayList<ActivityExternalIdentifier>(); for (ExternalID extId : extIds.getExternalIdentifier()) { if(extId.getRelationship() == null) { if(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.equals(extId.getType())) { if(WorkType.BOOK.equals(workType)) { extId.setRelationship(Relationship.PART_OF); } else { extId.setRelationship(Relationship.SELF); } } else if(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISBN.equals(extId.getType())) { if(WorkType.BOOK_CHAPTER.equals(workType) || WorkType.CONFERENCE_PAPER.equals(workType)) { extId.setRelationship(Relationship.PART_OF); } else { extId.setRelationship(Relationship.SELF); } } else { extId.setRelationship(Relationship.SELF); } } workExternalIdentifiersList.add(ActivityExternalIdentifier.valueOf(extId)); } workForm.setWorkExternalIdentifiers(workExternalIdentifiersList); } }
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 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) { 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(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(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; }
id.setValue(workExternalIdentifier.getWorkExternalIdentifierId().content); id.setNormalized(new TransientNonEmptyString(norm.normalise(id.getType(), workExternalIdentifier.getWorkExternalIdentifierId().content))); if (StringUtils.isEmpty(id.getNormalized().getValue())){ id.setNormalizedError(new TransientError(localeManager.resolveMessage("transientError.normalization_failed.code"),localeManager.resolveMessage("transientError.normalization_failed.message",id.getType(),workExternalIdentifier.getWorkExternalIdentifierId().content ))); id.setNormalizedUrl(new TransientNonEmptyString(norm.generateNormalisedURL(id.getType(), workExternalIdentifier.getWorkExternalIdentifierId().content))); if (StringUtils.isEmpty(id.getNormalizedUrl().getValue())){ id.setNormalizedUrlError(new TransientError(localeManager.resolveMessage("transientError.normalization_failed.code"),localeManager.resolveMessage("transientError.normalization_failed.message",id.getType(),workExternalIdentifier.getWorkExternalIdentifierId().content )));
for (ExternalID extId : workGroup.getIdentifiers().getExternalIdentifier()) { if (extId.getRelationship() == null) { if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.equals(extId.getType())) { if (WorkType.BOOK.equals(workType)) { extId.setRelationship(Relationship.PART_OF); extId.setRelationship(Relationship.SELF); } else if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISBN.equals(extId.getType())) { if (WorkType.BOOK_CHAPTER.equals(workType) || WorkType.CONFERENCE_PAPER.equals(workType)) { extId.setRelationship(Relationship.PART_OF);
@Override public ExternalIDs convertFrom(String source, Type<ExternalIDs> destinationType) { JSONExternalIdentifiers externalIdentifiers = JsonUtils.readObjectFromJsonString(source, JSONExternalIdentifiers.class); ExternalIDs externalIDs = new ExternalIDs(); for (JSONExternalIdentifier externalIdentifier : externalIdentifiers.getExternalIdentifier()) { ExternalID id = new ExternalID(); if (externalIdentifier.getType() == null) { id.setType(FundingExternalIdentifierType.GRANT_NUMBER.value()); } else { id.setType(externalIdentifier.getType().toLowerCase()); } if (externalIdentifier.getUrl() != null && !PojoUtil.isEmpty(externalIdentifier.getUrl().getValue())) { Url url = new Url(externalIdentifier.getUrl().getValue()); id.setUrl(url); } if (!PojoUtil.isEmpty(externalIdentifier.getValue())) { id.setValue(externalIdentifier.getValue()); id.setNormalized(new TransientNonEmptyString(norm.normalise(id.getType(), externalIdentifier.getValue()))); if (StringUtils.isEmpty(id.getNormalized().getValue())){ id.setNormalizedError(new TransientError(localeManager.resolveMessage("transientError.normalization_failed.code"),localeManager.resolveMessage("transientError.normalization_failed.message", id.getType(), externalIdentifier.getValue()))); } } if (externalIdentifier.getRelationship() != null) { id.setRelationship(Relationship.fromValue(conv.convertFrom(externalIdentifier.getRelationship(), null))); } externalIDs.getExternalIdentifier().add(id); } return externalIDs; }
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; }