1 // $Id: IEntityConstraintViolationService.java 22374 2014-12-10 23:02:58Z ayco_holleman $
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.cdm
.api
.service
;
13 import java
.util
.List
;
16 import javax
.validation
.ConstraintValidator
;
17 import javax
.validation
.ConstraintViolation
;
19 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
20 import eu
.etaxonomy
.cdm
.model
.validation
.CRUDEventType
;
21 import eu
.etaxonomy
.cdm
.model
.validation
.EntityConstraintViolation
;
22 import eu
.etaxonomy
.cdm
.model
.validation
.EntityValidation
;
23 import eu
.etaxonomy
.cdm
.model
.validation
.Severity
;
24 import eu
.etaxonomy
.cdm
.persistence
.dao
.validation
.IEntityValidationCrud
;
27 * A service that provides several retrieval methods for entity validation outcomes. The
28 * focus is on the entities rather than on the constraint violations being validated
29 * (irrespective of the entities that violated them).
31 * @author ayco_holleman
34 public interface IEntityValidationService
extends IService
<EntityValidation
>,
35 IEntityValidationCrud
{
38 * Save the result of an entity validation to the error tables. Previous validation
39 * results of the same entity will be cleared first.
40 * @param validatedEntity
41 * The validated entity
43 * All constraints violated by the specified entity
44 * @param crudEventType
45 * The CRUD operation triggering the validation
48 // Note that this method should not
49 // * be exposed via cdmlib-services, because this is a backend-only affair. Populating
50 // * the error tables is done by the CVI (more particularly by an
51 // * {@link EntityValidationTaskBase}). External software like the TaxEditor can and should
52 // * not have access to this method.
53 <T
extends ICdmBase
> void saveEntityValidation(T validatedEntity
, Set
<ConstraintViolation
<T
>> errors
, CRUDEventType crudEventType
, Class
<?
>[] validationGroups
);
57 * Delete validation result for the specified entity, presumably because it has become
60 * @param validatedEntityClass
61 * The fully qualified class name of the entity's class.
62 * @param validatedEntityId
63 * The id of the entity
66 // This method should not be exposed via cdmlib-services.
67 void deleteEntityValidation(String validatedEntityClass
, int validatedEntityId
);
71 * Get the validation result for a particular entity.
73 * @param validatedEntityClass
74 * The fully qualified class name of the entity's class.
75 * @param validatedEntityId
76 * The id of the entity
77 * @return The {@code EntityValidation} or null if the entity has not been
81 EntityValidation
getValidationResult(String validatedEntityClass
, int validatedEntityId
);
85 * Get all validation results for all validated entities. The results are sorted
86 * according the type and id of the validated entities.
88 * @return The {@code EntityValidation}s
90 List
<EntityValidation
> getValidationResults();
94 * Get all validation results for all validated entities of the specified type. The
95 * results are sorted according to the type and id of the validated entities.
97 * @param validatedEntityClass
98 * The fully qualified class name of the entity class
100 * @return The {@code EntityValidation}s
102 List
<EntityValidation
> getEntityValidations(String validatedEntityClass
);
106 * Get all entities that violated a particular constraint. The results are sorted
107 * according to the type and id of the validated entities. Note that the
108 * {@code validatorClass} argument is a {@code String} (like all the {@code ***Class}
109 * arguments). This is because it is stored as such in the database, and also because
110 * the {@code Class} object itself may not be on the caller's classpath - e.g. when
111 * called from the TaxEditor.
113 * @param validatorClass
114 * The fully qualified class name of the {@link ConstraintValidator}.
116 * @return The {@code EntityValidation}s
118 List
<EntityValidation
> getEntitiesViolatingConstraint(String validatorClass
);
122 * Get all validation results for all entities of the specified type. Only constraint
123 * violations of the specified severity are returned as part of the validation result.
124 * The results are sorted according to the type and id of the validated entities.
126 * @param validatedEntityClass
127 * The fully qualified class name of the entity class.
129 * The severity of the {@link EntityConstraintViolation}s associated with
130 * the {@code EntityValidation}
132 * @return The {@code EntityValidation}s
134 List
<EntityValidation
> getValidationResults(String validatedEntityClass
, Severity severity
);
138 * Get all validation results. Only constraint violations of the specified severity
139 * are returned as part of the validation result. The results are sorted according the
140 * type and id of the validated entities.
143 * The severity of the {@link EntityConstraintViolation}s associated with
144 * the {@code EntityValidation}
146 * @return The {@code EntityValidation}s
148 List
<EntityValidation
> getValidationResults(Severity severity
);