/** * 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; }
activityValidator.checkExternalIdentifiersForDuplicates(work.getExternalIdentifiers(), existing.getExternalIdentifiers(), existing.getSource(), activeSource);
activityValidator.checkExternalIdentifiersForDuplicates(work.getExternalIdentifiers(), existing.getExternalIdentifiers(), existing.getSource(), activeSource);