public class ProgramItemHierarchyValidator extends AbstractContentValidator implements Serviceable, Configurable
ProgramItem
content.
Check that structure to not create an infinite loopModifier and Type | Field and Description |
---|---|
private Set<String> |
_childMetadataNames |
protected ODFHelper |
_odfHelper
The ODF helper
|
Constructor and Description |
---|
ProgramItemHierarchyValidator() |
Modifier and Type | Method and Description |
---|---|
protected void |
addHierarchyError(Errors errors,
MetadataDefinition childDefinition,
Content content,
Content childContent)
Add an error the ascendant hierarchy is invalid (infinite loop)
|
protected boolean |
checkAncestors(ProgramItem programItem,
ProgramItem childProgramItem)
Check if the hierarchy of a program item will be still valid if adding the given program item as child.
|
void |
configure(Configuration configuration) |
protected Set<String> |
getChildMetadataNames()
Get the names of child metadata to be checked
|
void |
service(ServiceManager smanager) |
void |
validate(Content content,
Errors errors)
Validates a content.
|
void |
validate(Content content,
Form form,
MetadataSet metadataSet,
Errors errors)
Validates a content with the edited form.
|
getContentType, setContentType
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
protected ODFHelper _odfHelper
private Set<String> _childMetadataNames
public ProgramItemHierarchyValidator()
public void service(ServiceManager smanager) throws ServiceException
service
in interface Serviceable
ServiceException
public void validate(Content content, Errors errors)
ContentValidator
validate
in interface ContentValidator
content
- the content to validateerrors
- the structure to populate if the validation failed.public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
public void validate(Content content, Form form, MetadataSet metadataSet, Errors errors)
ContentValidator
validate
in interface ContentValidator
content
- the content to validateform
- the form to validatemetadataSet
- the edited metadata seterrors
- the structure to populate if the validation failed.protected Set<String> getChildMetadataNames()
protected boolean checkAncestors(ProgramItem programItem, ProgramItem childProgramItem)
ProgramItem
to add is in the hierarchy of the given ProgramItem
programItem
- The content to start searchchildProgramItem
- The child program item to search in ancestorsprotected void addHierarchyError(Errors errors, MetadataDefinition childDefinition, Content content, Content childContent)
errors
- The list of errorschildDefinition
- The child metadata definitioncontent
- The content being editedchildContent
- The content to add as child content