Class ProgramItemHierarchyValidator

All Implemented Interfaces:
ContentValidator, Configurable, LogEnabled, Serviceable

Global validator for ProgramItem content. Check that structure to not create an infinite loop
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager smanager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • validate

      public void validate(Content content, Errors errors)
      Description copied from interface: ContentValidator
      Validates a content.
      Specified by:
      validate in interface ContentValidator
      Parameters:
      content - the content to validate
      errors - the structure to populate if the validation failed.
    • configure

      public void configure(Configuration configuration) throws ConfigurationException
      Specified by:
      configure in interface Configurable
      Throws:
      ConfigurationException
    • validate

      public void validate(Content content, Map<String,Object> values, View view, Errors errors)
      Description copied from interface: ContentValidator
      Validates a content being edited
      Specified by:
      validate in interface ContentValidator
      Parameters:
      content - the content to validate
      values - the values being set
      view - the view
      errors - the structure to populate if the validation failed.
    • getChildMetadataNames

      Get the names of child metadata to be checked
      Returns:
      the child metadata's names
    • getParentMetadataNames

      Get the names of parent metadata to be checked
      Returns:
      the parent metadata's names
    • checkAncestors

      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. Return false if the ProgramItem to add is in the hierarchy of the given ProgramItem
      Parameters:
      programItem - The content to start search
      childProgramItem - The child program item to search in ancestors
      Returns:
      true if child program item is already part of the hierarchy (ascendant search)
    • checkAncestors

      protected boolean checkAncestors(ProgramItem childProgramItem, List<? extends ProgramItem> parentProgramItems)
      Check if the hierarchy of a program item will be still valid if adding the given program item as child. Return false if the ProgramItem to add is in the hierarchy of the given ProgramItem
      Parameters:
      childProgramItem - The child program item to add
      parentProgramItems - The parent program items of the target
      Returns:
      true if child program item is already part of the hierarchy (ascendant search)
    • _addError

      protected void _addError(Errors errors, ElementDefinition childDefinition, Content content, Content childContent, String catalog, String i18nKey)
      Add an error
      Parameters:
      errors - The list of errors
      childDefinition - The child metadata definition
      content - The content being edited
      childContent - The content to add as child content
      catalog - the i18n catalog
      i18nKey - the i18n key for the error message