Revision 64254a55
Added by Andreas Müller over 2 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/CorrectRanksForCodeValidator.java | ||
---|---|---|
35 | 35 |
boolean valid = true; |
36 | 36 |
if (name.getRank() != null){ |
37 | 37 |
UUID rankUuid = name.getRank().getUuid(); |
38 |
if(rankUuid.equals(Rank.uuidCultivar) || |
|
39 |
rankUuid.equals(Rank.uuidCultivarGroup) || |
|
40 |
rankUuid.equals(Rank.uuidGrexICNCP) || |
|
41 |
rankUuid.equals(Rank.uuidGraftChimaera) || |
|
42 |
rankUuid.equals(Rank.uuidDenominationClass) |
|
43 |
) { |
|
44 |
if (!name.isCultivar()){ |
|
45 |
valid = false; |
|
46 |
} |
|
38 |
if(isCultivarUuid(rankUuid) && !name.isCultivar()){ |
|
39 |
valid = false; |
|
40 |
}else if (name.isCultivar() && !isCultivarUuid(rankUuid)){ |
|
41 |
valid = false; |
|
47 | 42 |
}else if (rankUuid.equals(Rank.uuidSectionZoology) || |
48 | 43 |
rankUuid.equals(Rank.uuidSubsectionZoology) |
49 | 44 |
) { |
... | ... | |
63 | 58 |
return valid; |
64 | 59 |
} |
65 | 60 |
|
61 |
private boolean isCultivarUuid(UUID rankUuid) { |
|
62 |
return rankUuid.equals(Rank.uuidCultivar) || |
|
63 |
rankUuid.equals(Rank.uuidCultivarGroup) || |
|
64 |
rankUuid.equals(Rank.uuidGrexICNCP) || |
|
65 |
rankUuid.equals(Rank.uuidGraftChimaera) || |
|
66 |
rankUuid.equals(Rank.uuidDenominationClass); |
|
67 |
} |
|
68 |
|
|
66 | 69 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/validation/CorrectRanksForCodeTest.java | ||
---|---|---|
66 | 66 |
constraintViolations = validator.validate(name, Level2.class, Default.class); |
67 | 67 |
assertFalse("There should be a constraint violation as this name of rank cultivar has code ICNafp", constraintViolations.isEmpty()); |
68 | 68 |
assertHasConstraintOnValidator((Set)constraintViolations, CorrectRanksForCodeValidator.class); |
69 |
|
|
70 |
name.setNameType(NomenclaturalCode.ICNCP); |
|
71 |
name.setRank(Rank.SPECIES()); |
|
72 |
assertFalse("There should be a constraint violation as this name of rank cultivar has code ICNafp", constraintViolations.isEmpty()); |
|
73 |
assertHasConstraintOnValidator((Set)constraintViolations, CorrectRanksForCodeValidator.class); |
|
69 | 74 |
} |
70 | 75 |
|
71 | 76 |
@Test |
Also available in: Unified diff
ref 6387 add some first rules for rank<->code test (cont.)