public void checkFundingExternalIdentifiersForDuplicates(ExternalIDs newExtIds, ExternalIDs existingExtIds, Source existingSource, Source activeSource) { if (existingExtIds != null && newExtIds != null) { for (ExternalID existingId : existingExtIds.getExternalIdentifier()) { for (ExternalID newId : newExtIds.getExternalIdentifier()) { 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 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); }
if(id.getRelationship() == null) { errors.add("relationship"); if(Relationship.VERSION_OF.equals(id.getRelationship())) { hasVersionOfIdentifier = true; if(Relationship.SELF.equals(id.getRelationship())) { hasSelfIdentifier = true;
private void addExternalIdsToExistingSet(Work work, Set<ExternalID> existingExternalIDs) { if(work != null && work.getExternalIdentifiers() != null && work.getExternalIdentifiers().getExternalIdentifier() != null) { for(ExternalID extId : work.getExternalIdentifiers().getExternalIdentifier()) { //Don't include PART_OF external ids if(!Relationship.PART_OF.equals(extId.getRelationship())) { existingExternalIDs.add(extId); } } } }
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); }
/** * Return the list of existing external identifiers for the given user where the source matches the given sourceId * * @param existingWorks * The list of existing works for the current user * @param activeSource * The client id we are evaluating * @return A set of all the existing external identifiers that belongs to the given user and to the given source id * */ private Set<ExternalID> buildExistingExternalIdsSet(List<Work> existingWorks, Source activeSource) { Set<ExternalID> existingExternalIds = new HashSet<ExternalID>(); for(Work work : existingWorks) { //If it is the same source if(SourceEntityUtils.isTheSameForDuplicateChecking(activeSource, work.getSource())) { if(work.getExternalIdentifiers() != null && work.getExternalIdentifiers().getExternalIdentifier() != null) { for(ExternalID extId : work.getExternalIdentifiers().getExternalIdentifier()) { //Don't include PART_OF external ids if(!Relationship.PART_OF.equals(extId.getRelationship())) { existingExternalIds.add(extId); } } } } } return existingExternalIds; }
public GroupPojo(List<T> summaries, int id, String orcid, ExternalIDs ids){ setGroupId(id); Long maxDisplayIndex = null; setActivities(new ArrayList<T>()); for (T summary : summaries) { getActivities().add(summary); Long displayIndex = Long.parseLong(summary.getDisplayIndex()); if (maxDisplayIndex == null || displayIndex > maxDisplayIndex) { maxDisplayIndex = displayIndex; setActivePutCode(summary.getPutCode()); setActiveVisibility(summary.getVisibility().name()); setDefaultActivity(summary); } if (summary.getSource().retrieveSourcePath().equals(orcid)) { setUserVersionPresent(true); } } if (ids != null) { for (ExternalID extId : ids.getExternalIdentifier()) { if (extId.getRelationship() == null) { extId.setRelationship(Relationship.SELF); } externalIdentifiers.add(ActivityExternalIdentifier.valueOf(extId)); } } }
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); }
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); } } } } }
if(existingExternalIdentifiers.contains(extId) && Relationship.SELF.equals(extId.getRelationship())) { Map<String, String> params = new HashMap<String, String>(); params.put("clientName", SourceEntityUtils.getSourceName(activeSource));
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); }
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); } }
@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); }
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; }
List<ActivityExternalIdentifier> workExternalIdentifiersList = new ArrayList<ActivityExternalIdentifier>(); 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)) {
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; }
while(it.hasNext()) { ExternalID extId = it.next(); if(Relationship.VERSION_OF.equals(extId.getRelationship())) { it.remove();