Project

General

Profile

« Previous | Next » 

Revision bc885cc5

Added by Katja Luther almost 13 years ago

View differences:

.gitattributes
815 815
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/parser/location/CoordinateConverter.java -text
816 816
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/Level2.java -text
817 817
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/Level3.java -text
818
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/ValidationException.java -text
818 819
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/BasionymsMustShareEpithetsAndAuthors.java -text
819 820
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/ChildTaxaMustBeLowerRankThanParent.java -text
820 821
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/ChildTaxaMustDeriveNameFromParent.java -text
821 822
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/ChildTaxaMustNotSkipRanks.java -text
822 823
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/CorrectEpithetsForRank.java -text
823 824
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/HomotypicSynonymsShouldBelongToGroup.java -text
825
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/InReference.java -text
824 826
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/MustHaveAuthority.java -text
825 827
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/NamesWithHomotypicRelationshipsMustBelongToSameGroup.java -text
826 828
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/NoDuplicateNames.java -text
827 829
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/NullOrNotEmpty.java -text
830
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/ReferenceCheck.java -text
828 831
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/TaxonNameCannotBeAcceptedAndSynonym.java -text
829 832
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/BasionymsMustShareEpithetsAndAuthorsValidator.java -text
830 833
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/ChildTaxaMustBeLowerRankThanParentValidator.java -text
......
835 838
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/MustHaveAuthorityValidator.java -text
836 839
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/NamesWithHomotypicRelationshipsMustBelongToSameGroupValidator.java -text
837 840
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/NullOrNotEmptyValidator.java -text
841
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/ReferenceCheckValidation.java -text
838 842
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/StubValidator.java -text
839 843
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/TaxonNameCannotBeAcceptedAndSynonymValidator.java -text
840 844
cdmlib-model/src/main/resources/ValidationMessages.properties -text
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/ValidationException.java
1
package eu.etaxonomy.cdm.validation;
2

  
3
import javax.validation.ConstraintViolation;
4

  
5
public class ValidationException extends Exception {
6

  
7
	
8
	public ValidationException(String message){
9
		super(message);
10
		
11
	}
12
	
13
	public ValidationException(ConstraintViolation constraintViolation){
14
		super(constraintViolation.getMessage());
15
	}
16
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/InReference.java
1
package eu.etaxonomy.cdm.validation.annotation;
2

  
3
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
4
import static java.lang.annotation.ElementType.FIELD;
5
import static java.lang.annotation.ElementType.METHOD;
6
import static java.lang.annotation.ElementType.TYPE;
7
import static java.lang.annotation.RetentionPolicy.RUNTIME;
8

  
9
import java.lang.annotation.Documented;
10
import java.lang.annotation.Retention;
11
import java.lang.annotation.Target;
12

  
13
import javax.validation.Constraint;
14
import javax.validation.Payload;
15

  
16
import eu.etaxonomy.cdm.validation.constraint.InReferenceValidation;
17

  
18

  
19
@Target( { TYPE, METHOD, FIELD, ANNOTATION_TYPE})
20
@Retention(RUNTIME)
21
@Constraint(validatedBy = InReferenceValidation.class)
22
@Documented
23
public @interface InReference {
24
	String message() default "{eu.etaxonomy.cdm.validation.annotation.InReference.wrongInReferenceForReferenceType.message}";
25
	Class<? extends Payload>[] payload() default {};
26
	Class<?>[] groups() default {};
27

  
28
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/annotation/ReferenceCheck.java
1
package eu.etaxonomy.cdm.validation.annotation;
2

  
3
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
4
import static java.lang.annotation.ElementType.FIELD;
5
import static java.lang.annotation.ElementType.METHOD;
6
import static java.lang.annotation.ElementType.TYPE;
7
import static java.lang.annotation.RetentionPolicy.RUNTIME;
8

  
9
import java.lang.annotation.Documented;
10
import java.lang.annotation.Retention;
11
import java.lang.annotation.Target;
12

  
13
import javax.validation.Constraint;
14
import javax.validation.Payload;
15

  
16
import eu.etaxonomy.cdm.validation.constraint.ReferenceCheckValidation;
17

  
18

  
19
@Target( { TYPE, METHOD, FIELD, ANNOTATION_TYPE})
20
@Retention(RUNTIME)
21
@Constraint(validatedBy = ReferenceCheckValidation.class)
22
@Documented
23
public @interface ReferenceCheck {
24
	String message() default "{eu.etaxonomy.cdm.validation.annotation.ISBNe.wrongISBNForReferenceType.message}";
25
	Class<? extends Payload>[] payload() default {};
26
	Class<?>[] groups() default {};
27

  
28
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/validation/constraint/ReferenceCheckValidation.java
1
package eu.etaxonomy.cdm.validation.constraint;
2

  
3
import javax.validation.ConstraintValidator;
4
import javax.validation.ConstraintValidatorContext;
5

  
6
import eu.etaxonomy.cdm.model.reference.Reference;
7
import eu.etaxonomy.cdm.model.reference.ReferenceType;
8
import eu.etaxonomy.cdm.validation.annotation.InReference;
9
import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
10
import eu.etaxonomy.cdm.validation.annotation.ReferenceCheck;
11

  
12
public class ReferenceCheckValidation implements
13
ConstraintValidator<ReferenceCheck, Reference>{
14
	
15
	@Override
16
	public boolean isValid(Reference value,
17
			ConstraintValidatorContext constraintValidatorContext) {
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
		
26
		if ((value.getType() != ReferenceType.Book || value.getType() != ReferenceType.Proceedings) && !value.getIsbn().isEmpty()) isValid = false;
27
		
28
		return isValid;
29
	}
30

  
31
	@Override
32
	public void initialize(ReferenceCheck constraintAnnotation) {
33
		// TODO Auto-generated method stub
34
		
35
	}
36

  
37
	
38
}

Also available in: Unified diff