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