Commit d1cb7a44 authored by Matija Obreza's avatar Matija Obreza Committed by Artem Hrybeniuk
Browse files

@CodeValueField: Disable CV validation for Taxonomy* entities

parent ca7a16b7
......@@ -50,4 +50,9 @@ public @interface CodeValueField {
* This CV field translated titles should be included in full-text index
*/
boolean indexed() default false;
/**
* The CV must be valid and declared. Set to false to avoid validation check.
*/
boolean strict() default true;
}
......@@ -31,12 +31,18 @@ public class CodeValueValidator implements ConstraintValidator<CodeValueField, S
*/
private String groupName;
/**
* When not strict then validation is skipped.
*/
private boolean strict;
/**
* Initializes the validator.
*/
@Override
public void initialize(CodeValueField constraintAnnotation) {
this.groupName = constraintAnnotation.value();
this.strict = constraintAnnotation.strict();
}
/**
......@@ -45,7 +51,7 @@ public class CodeValueValidator implements ConstraintValidator<CodeValueField, S
*/
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
if (StringUtils.isBlank(value)) {
if (StringUtils.isBlank(value) || !strict) {
return true; // nothing to validate here
}
......
......@@ -80,7 +80,7 @@ public class TaxonomyFamily extends CooperatorOwnedModel implements Copyable<Tax
@Basic
@Column(name = "suprafamily_rank_code", length = 20)
@CodeValueField("TAXONOMY_SUPRAFAMILY")
@CodeValueField(value = "TAXONOMY_SUPRAFAMILY", strict = false)
private String suprafamilyRankCode;
@Basic
......
......@@ -62,7 +62,7 @@ public class TaxonomyGenus extends CooperatorOwnedModel implements Copyable<Taxo
@Basic
@Column(name = "hybrid_code", length = 20)
@CodeValueField("GENUS_HYBRID")
@CodeValueField(value = "GENUS_HYBRID", strict = false)
private String hybridCode;
@Id
......@@ -81,7 +81,7 @@ public class TaxonomyGenus extends CooperatorOwnedModel implements Copyable<Taxo
@Basic
@Column(name = "qualifying_code", length = 20)
@CodeValueField("TAXONOMY_GENUS_QUALIFIER")
@CodeValueField(value = "TAXONOMY_GENUS_QUALIFIER", strict = false)
private String qualifyingCode;
@Basic
......
......@@ -70,7 +70,7 @@ public class TaxonomySpecies extends CooperatorOwnedModel implements Copyable<Ta
@Basic
@Column(name = "common_fertilization_code", length = 20)
@CodeValueField("TAXONOMY_FERTILIZATION_METHOD")
@CodeValueField(value = "TAXONOMY_FERTILIZATION_METHOD", strict = false)
private String commonFertilizationCode;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
......@@ -132,7 +132,7 @@ public class TaxonomySpecies extends CooperatorOwnedModel implements Copyable<Ta
@Basic
@Column(name = "life_form_code", length = 20)
@CodeValueField("ACCESSION_LIFE_FORM")
@CodeValueField(value = "ACCESSION_LIFE_FORM", strict = false)
private String lifeFormCode;
@Basic
......@@ -179,7 +179,7 @@ public class TaxonomySpecies extends CooperatorOwnedModel implements Copyable<Ta
@Basic
@Column(name = "restriction_code", length = 20)
@CodeValueField("TAXONOMY_RESTRICTION")
@CodeValueField(value = "TAXONOMY_RESTRICTION", strict = false)
private String restrictionCode;
@Basic
......@@ -213,7 +213,7 @@ public class TaxonomySpecies extends CooperatorOwnedModel implements Copyable<Ta
@Basic
@Column(name = "synonym_code", length = 20)
@CodeValueField("TAXONOMY_SPECIES_QUALIFIER")
@CodeValueField(value = "TAXONOMY_SPECIES_QUALIFIER", strict = false)
private String synonymCode;
@ManyToOne(fetch = FetchType.EAGER, cascade = {})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment