Package org.ametys.odf.ose.enumeration
Class DegreesInCategoryConsistencyValidator
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.cms.contenttype.validation.AbstractContentValidator
-
- org.ametys.odf.ose.enumeration.DegreesInCategoryConsistencyValidator
-
- All Implemented Interfaces:
ContentValidator
,LogEnabled
,Serviceable
public class DegreesInCategoryConsistencyValidator extends AbstractContentValidator implements Serviceable
Global validator for a Degree Category (entry of reference table), which checks that all its degrees are only binded to this category.
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__DEGREES_ATTRIBUTE_NAME
private static String
__DEGREES_CATEGORY_CONTENT_TYPE
protected AmetysObjectResolver
_resolver
The Ametys object resolver
-
Constructor Summary
Constructors Constructor Description DegreesInCategoryConsistencyValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected I18nizableText
_getErrorLabel(Content degree, Content degreeCategory)
Get the error label corresponding to the given degree and category.protected String
_getXPathQuery(Content degree, Content currentDegreeCategory)
Returns the XPath query to execute to obtain the list of categories except the current category in which the degree appears.protected boolean
_isInAnotherCategory(Content degree, Content degreeCategory)
Check if the current degree is in another category than the current category.void
service(ServiceManager manager)
void
validate(Content degreeCategory, Map<String,Object> values, View view, Errors errors)
Validates a content being editedvoid
validate(Content content, Errors errors)
Validates a content.-
Methods inherited from class org.ametys.cms.contenttype.validation.AbstractContentValidator
getContentType, setContentType
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__DEGREES_CATEGORY_CONTENT_TYPE
private static final String __DEGREES_CATEGORY_CONTENT_TYPE
- See Also:
- Constant Field Values
-
__DEGREES_ATTRIBUTE_NAME
private static final String __DEGREES_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
-
Constructor Detail
-
DegreesInCategoryConsistencyValidator
public DegreesInCategoryConsistencyValidator()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
validate
public void validate(Content content, Errors errors)
Description copied from interface:ContentValidator
Validates a content.- Specified by:
validate
in interfaceContentValidator
- Parameters:
content
- the content to validateerrors
- the structure to populate if the validation failed.
-
validate
public void validate(Content degreeCategory, Map<String,Object> values, View view, Errors errors)
Description copied from interface:ContentValidator
Validates a content being edited- Specified by:
validate
in interfaceContentValidator
- Parameters:
degreeCategory
- the content to validatevalues
- the values being setview
- the viewerrors
- the structure to populate if the validation failed.
-
_isInAnotherCategory
protected boolean _isInAnotherCategory(Content degree, Content degreeCategory)
Check if the current degree is in another category than the current category.- Parameters:
degree
- The current degreedegreeCategory
- The current category- Returns:
true
if it's in another degree category
-
_getXPathQuery
protected String _getXPathQuery(Content degree, Content currentDegreeCategory)
Returns the XPath query to execute to obtain the list of categories except the current category in which the degree appears.- Parameters:
degree
- The degreecurrentDegreeCategory
- The current degree category- Returns:
- An XPath query
-
_getErrorLabel
protected I18nizableText _getErrorLabel(Content degree, Content degreeCategory)
Get the error label corresponding to the given degree and category.- Parameters:
degree
- The degreedegreeCategory
- The degree category- Returns:
- The error label as i18n
-
-