2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import java
.util
.List
;
15 import javax
.validation
.ConstraintValidator
;
16 import javax
.validation
.ConstraintViolation
;
18 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
19 import eu
.etaxonomy
.cdm
.model
.validation
.CRUDEventType
;
20 import eu
.etaxonomy
.cdm
.model
.validation
.EntityConstraintViolation
;
21 import eu
.etaxonomy
.cdm
.model
.validation
.EntityValidation
;
22 import eu
.etaxonomy
.cdm
.model
.validation
.Severity
;
23 import eu
.etaxonomy
.cdm
.persistence
.dao
.validation
.IEntityValidationCrud
;
26 * A service that provides several retrieval methods for entity validation outcomes. The
27 * focus is on the entities rather than on the constraint violations being validated
28 * (irrespective of the entities that violated them).
30 * @author ayco_holleman
33 public interface IEntityValidationService
extends IService
<EntityValidation
>,
34 IEntityValidationCrud
{
37 * Save the result of an entity validation to the error tables. Previous validation
38 * results of the same entity will be cleared first.
39 * @param validatedEntity
40 * The validated entity
42 * All constraints violated by the specified entity
43 * @param crudEventType
44 * The CRUD operation triggering the validation
47 // Note that this method should not
48 // * be exposed via cdmlib-services, because this is a backend-only affair. Populating
49 // * the error tables is done by the CVI (more particularly by an
50 // * {@link EntityValidationTaskBase}). External software like the TaxEditor can and should
51 // * not have access to this method.
52 <T
extends ICdmBase
> void saveEntityValidation(T validatedEntity
, Set
<ConstraintViolation
<T
>> errors
, CRUDEventType crudEventType
, Class
<?
>[] validationGroups
);
56 * Delete validation result for the specified entity, presumably because it has become
59 * @param validatedEntityClass
60 * The fully qualified class name of the entity's class.
61 * @param validatedEntityId
62 * The id of the entity
65 // This method should not be exposed via cdmlib-services.
66 void deleteEntityValidation(String validatedEntityClass
, int validatedEntityId
);
70 * Get the validation result for a particular entity.
72 * @param validatedEntityClass
73 * The fully qualified class name of the entity's class.
74 * @param validatedEntityId
75 * The id of the entity
76 * @return The {@code EntityValidation} or null if the entity has not been
80 EntityValidation
getValidationResult(String validatedEntityClass
, int validatedEntityId
);
84 * Get all validation results for all validated entities. The results are sorted
85 * according the type and id of the validated entities.
87 * @return The {@code EntityValidation}s
89 List
<EntityValidation
> getValidationResults();
93 * Get all validation results for all validated entities of the specified type. The
94 * results are sorted according to the type and id of the validated entities.
96 * @param validatedEntityClass
97 * The fully qualified class name of the entity class
99 * @return The {@code EntityValidation}s
101 List
<EntityValidation
> getEntityValidations(String validatedEntityClass
);
105 * Get all entities that violated a particular constraint. The results are sorted
106 * according to the type and id of the validated entities. Note that the
107 * {@code validatorClass} argument is a {@code String} (like all the {@code ***Class}
108 * arguments). This is because it is stored as such in the database, and also because
109 * the {@code Class} object itself may not be on the caller's classpath - e.g. when
110 * called from the TaxEditor.
112 * @param validatorClass
113 * The fully qualified class name of the {@link ConstraintValidator}.
115 * @return The {@code EntityValidation}s
117 List
<EntityValidation
> getEntitiesViolatingConstraint(String validatorClass
);
121 * Get all validation results for all entities of the specified type. Only constraint
122 * violations of the specified severity are returned as part of the validation result.
123 * The results are sorted according to the type and id of the validated entities.
125 * @param validatedEntityClass
126 * The fully qualified class name of the entity class.
128 * The severity of the {@link EntityConstraintViolation}s associated with
129 * the {@code EntityValidation}
131 * @return The {@code EntityValidation}s
133 List
<EntityValidation
> getValidationResults(String validatedEntityClass
, Severity severity
);
137 * Get all validation results. Only constraint violations of the specified severity
138 * are returned as part of the validation result. The results are sorted according the
139 * type and id of the validated entities.
142 * The severity of the {@link EntityConstraintViolation}s associated with
143 * the {@code EntityValidation}
145 * @return The {@code EntityValidation}s
147 List
<EntityValidation
> getValidationResults(Severity severity
);