Revision 12411f3e
Added by Andreas Müller over 3 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/validation/constraint/NoDuplicateNamesValidator.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.util.HashSet; |
12 | 12 |
import java.util.List; |
13 |
import java.util.Objects; |
|
13 | 14 |
import java.util.Set; |
15 |
import java.util.stream.Collectors; |
|
14 | 16 |
|
15 | 17 |
import javax.validation.ConstraintValidator; |
16 | 18 |
import javax.validation.ConstraintValidatorContext; |
... | ... | |
33 | 35 |
includeProperties.add("specificEpithet"); |
34 | 36 |
includeProperties.add("infraSpecificEpithet"); |
35 | 37 |
includeProperties.add("rank"); |
36 |
includeProperties.add("nomenclaturalSource"); //TODO still correct after #6851? |
|
37 |
// includeProperties.add("nomenclaturalSource.citation"); //TODO still correct after #6851? |
|
38 |
// includeProperties.add("nomenclaturalSource.citationMicroReference"); //TODO still correct after #6851? |
|
38 |
// includeProperties.add("nomenclaturalSource.citation"); //handled in method now since #6581 |
|
39 |
// includeProperties.add("nomenclaturalSource.citationMicroReference"); //handled in method now since #6581 |
|
39 | 40 |
includeProperties.add("basionymAuthorship"); |
40 | 41 |
includeProperties.add("exBasionymAuthorship"); |
41 | 42 |
includeProperties.add("combinationAuthorship"); |
... | ... | |
57 | 58 |
if(name == null) { |
58 | 59 |
return true; |
59 | 60 |
} else { |
60 |
List<TaxonName> matchingNonViralNames = nameService.list(name, includeProperties, null, null, null, null); |
|
61 |
if(matchingNonViralNames.size() > 0) { |
|
62 |
if(matchingNonViralNames.size() == 1 && matchingNonViralNames.get(0).equals(name)) { |
|
61 |
List<TaxonName> matchingNames = nameService.list(name, includeProperties, null, null, null, null); |
|
62 |
matchingNames = matchingNames.stream().filter(existing-> |
|
63 |
Objects.equals(existing.getNomenclaturalReference(),name.getNomenclaturalReference()) |
|
64 |
&& Objects.equals(existing.getNomenclaturalMicroReference(), name.getNomenclaturalMicroReference()) |
|
65 |
&& !existing.equals(name) |
|
66 |
).collect(Collectors.toList()); |
|
67 |
|
|
68 |
if(matchingNames.size() > 0) { |
|
69 |
if(matchingNames.size() == 1 && matchingNames.get(0).equals(name)) { |
|
63 | 70 |
return true; |
64 | 71 |
} else { |
65 | 72 |
return false; |
Also available in: Unified diff
ref #9225 fix ValidationTest / 3rd Level duplicate validation for taxon names