Revert last commit (taxon node handling is done in taxeditor)
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / IEntityValidationService.java
1 // $Id: IEntityConstraintViolationService.java 22374 2014-12-10 23:02:58Z ayco_holleman $
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.cdm.api.service;
12
13 import java.util.List;
14 import java.util.Set;
15
16 import javax.validation.ConstraintValidator;
17 import javax.validation.ConstraintViolation;
18
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;
25
26 /**
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).
30 *
31 * @author ayco_holleman
32 *
33 */
34 public interface IEntityValidationService extends IService<EntityValidation>,
35 IEntityValidationCrud {
36
37 /**
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
42 * @param errors
43 * All constraints violated by the specified entity
44 * @param crudEventType
45 * The CRUD operation triggering the validation
46 */
47 @Override
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);
54
55
56 /**
57 * Delete validation result for the specified entity, presumably because it has become
58 * obsolete.
59 *
60 * @param validatedEntityClass
61 * The fully qualified class name of the entity's class.
62 * @param validatedEntityId
63 * The id of the entity
64 */
65 @Override
66 // This method should not be exposed via cdmlib-services.
67 void deleteEntityValidation(String validatedEntityClass, int validatedEntityId);
68
69
70 /**
71 * Get the validation result for a particular entity.
72 *
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
78 * validated yet
79 *
80 */
81 EntityValidation getValidationResult(String validatedEntityClass, int validatedEntityId);
82
83
84 /**
85 * Get all validation results for all validated entities. The results are sorted
86 * according the type and id of the validated entities.
87 *
88 * @return The {@code EntityValidation}s
89 */
90 List<EntityValidation> getValidationResults();
91
92
93 /**
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.
96 *
97 * @param validatedEntityClass
98 * The fully qualified class name of the entity class
99 *
100 * @return The {@code EntityValidation}s
101 */
102 List<EntityValidation> getEntityValidations(String validatedEntityClass);
103
104
105 /**
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.
112 *
113 * @param validatorClass
114 * The fully qualified class name of the {@link ConstraintValidator}.
115 *
116 * @return The {@code EntityValidation}s
117 */
118 List<EntityValidation> getEntitiesViolatingConstraint(String validatorClass);
119
120
121 /**
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.
125 *
126 * @param validatedEntityClass
127 * The fully qualified class name of the entity class.
128 * @param severity
129 * The severity of the {@link EntityConstraintViolation}s associated with
130 * the {@code EntityValidation}
131 *
132 * @return The {@code EntityValidation}s
133 */
134 List<EntityValidation> getValidationResults(String validatedEntityClass, Severity severity);
135
136
137 /**
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.
141 *
142 * @param severity
143 * The severity of the {@link EntityConstraintViolation}s associated with
144 * the {@code EntityValidation}
145 *
146 * @return The {@code EntityValidation}s
147 */
148 List<EntityValidation> getValidationResults(Severity severity);
149
150 }