Revision dd995e9b
Added by Katja Luther almost 13 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/ReferenceCheckValidation.java | ||
---|---|---|
16 | 16 |
public boolean isValid(Reference value, |
17 | 17 |
ConstraintValidatorContext constraintValidatorContext) { |
18 | 18 |
boolean isValid = true; |
19 |
// oder besser andersherum, bestimmte Referenzen d?rfen keine ISBN haben? |
|
20 |
/* |
|
21 |
* if (value.getType() == ReferenceType.Article || value.getType() == ReferenceType.Journal || value.getType() == ReferenceType.BookSection || value.getType() == ReferenceType.WebPage || value.getType() == ReferenceType.InProceedings ){ |
|
22 |
* if (!value.getIsbn().isEmpty()) isValid = false; |
|
23 |
* } |
|
24 |
*/ |
|
25 | 19 |
|
26 |
if ((value.getType() != ReferenceType.Book || value.getType() != ReferenceType.Proceedings) && !value.getIsbn().isEmpty()) isValid = false; |
|
20 |
isValid &= validIsbn(value, constraintValidatorContext); |
|
21 |
if (value.getType() == ReferenceType.Journal ) { |
|
22 |
isValid = false; |
|
23 |
constraintValidatorContext.buildErrorWithMessageTemplate("{eu.etaxonomy.cdm.validation.annotation.InReference.JournalShouldNotHaveDatePublished.message}"); |
|
24 |
} |
|
27 | 25 |
|
28 | 26 |
return isValid; |
29 | 27 |
} |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
private boolean validIsbn(Reference value, ConstraintValidatorContext constraintValidatorContext){ |
|
32 |
boolean isValid = true; |
|
33 |
if ((value.getType() != ReferenceType.Book && value.getType() != ReferenceType.Proceedings) ) { |
|
34 |
if (value.getIsbn()!= null){ |
|
35 |
isValid = false; |
|
36 |
constraintValidatorContext.buildErrorWithMessageTemplate("{eu.etaxonomy.cdm.validation.annotation.InReference.ReferenceShouldNotHaveIsbn.message}"); |
|
37 |
} |
|
38 |
} |
|
39 |
return isValid; |
|
40 |
} |
|
41 |
|
|
42 |
|
|
30 | 43 |
|
31 | 44 |
@Override |
32 | 45 |
public void initialize(ReferenceCheck constraintAnnotation) { |
... | ... | |
34 | 47 |
|
35 | 48 |
} |
36 | 49 |
|
50 |
|
|
51 |
|
|
52 |
|
|
37 | 53 |
|
38 | 54 |
} |
Also available in: Unified diff