Class AUniqueEntityFieldValidator<TEntity extends de.xima.cmn.dao.interfaces.IEntity<Long>,​TField>

  • Type Parameters:
    TEntity - Type of the entity owning the field.
    TField - Type of the field to which the validator applies.
    All Implemented Interfaces:
    Serializable, EventListener, javax.faces.validator.Validator
    Direct Known Subclasses:
    AUniqueStringFieldValidator

    public abstract class AUniqueEntityFieldValidator<TEntity extends de.xima.cmn.dao.interfaces.IEntity<Long>,​TField>
    extends AUniqueBeanFieldValidator<TEntity,​TField>
    Abstract base class for faces validators that check whether a certain field of an entity is unique amongst all existing entities within a certain scope.
    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    See Also:
    Serialized Form
    • Constructor Detail

      • AUniqueEntityFieldValidator

        protected AUniqueEntityFieldValidator​(Class<TEntity> entityClass,
                                              Class<TField> fieldClass)
    • Method Detail

      • addScope

        protected void addScope​(de.xima.cmn.criteria.QueryCriteriaManager qcm,
                                TEntity entity)
        Use this method to restrict the scope of entities considered for the duplicate search, such as to a certain client, version, project etc.

        By default, the client and project scope is set if the entity implements IMandantDependent or IProjektDependent.

        Parameters:
        qcm - Query criteria manager that will be used to check for existing duplicates.
        entity - Entity that is validated.
      • addSearch

        protected abstract void addSearch​(de.xima.cmn.criteria.QueryCriteriaManager qcm,
                                          TField value)
        Adds the criteria an entity must match to be considered a duplicate.
        Parameters:
        qcm - Query criteria manager that will be used to check for existing duplicates.
        value - Field to search.
      • hasDuplicates

        protected boolean hasDuplicates​(TEntity entity,
                                        TField fieldValue)
        Description copied from class: AUniqueBeanFieldValidator
        Checks if any duplicates exists for the given bean with the given field value.
        Specified by:
        hasDuplicates in class AUniqueBeanFieldValidator<TEntity extends de.xima.cmn.dao.interfaces.IEntity<Long>,​TField>
        Parameters:
        entity - Bean to check for existing duplicates.
        fieldValue - Field value to check for duplicates.