Class EntityHierarchyProperty<T extends PersistenceEntity>

  • Type Parameters:
    T - PersistenceEntity, it is entity type, not property type
    All Implemented Interfaces:
    ClientBehaviorHolder, MenuNodeActionHandler, java.io.Serializable

    public class EntityHierarchyProperty<T extends PersistenceEntity>
    extends EntityProperty<T>
    EntityHierarchyProperty whose value is Hierarchy entity.

    Its render style can be multi-level selects or input text. auto complete will be enabled by default for input text render style.

    Since:
    4.0
    See Also:
    Serialized Form
    • Constructor Detail

      • EntityHierarchyProperty

        public EntityHierarchyProperty​(PersistenceDataBackingBean<T> backingBean,
                                       java.lang.String name,
                                       java.lang.Class type,
                                       java.lang.reflect.Method readMethod,
                                       java.lang.reflect.Method writeMethod,
                                       EntityProperty<T> parent)
        Constructor.
        Parameters:
        backingBean - entity or entity list backing bean
        name - property name
        type - property type
        readMethod - read method
        writeMethod - write method
        parent - parent property
    • Method Detail

      • validate

        public void validate​(java.lang.Object value)
                      throws InvalidValueException,
                             SystemException
        Description copied from class: EntityProperty
        Validate property value including required, length, and value ranges.

        If validation is delayed, validate() is called by EntityBackingBean.validate() during Invoke Application Phase, and property value has been set during model update phase even though the value is invalid.

        Otherwise, if validation is not delayed(default), validate() is called before setting property value after data conversion during Model Update phase.

        Overrides:
        validate in class EntityProperty<T extends PersistenceEntity>
        Parameters:
        value - property value that has been converted to property type
        Throws:
        InvalidValueException - throw if the value is invalid
        SystemException - throw if any ohter error occurs
      • getValueInternal

        protected java.lang.Object getValueInternal​(T entity,
                                                    boolean convertToString)
                                             throws SystemException
        Description copied from class: EntityProperty
        Get property value. return previous invalid input value (if any) to display invalid input back to user.
        Overrides:
        getValueInternal in class EntityProperty<T extends PersistenceEntity>
        Parameters:
        entity - the entity to get value from
        convertToString - flag indicating whether the property value should be converted into a string
        Returns:
        property value
        Throws:
        SystemException - throw if an error occurs
      • getHierarchyPathAsString

        public java.lang.String getHierarchyPathAsString​(T entity)
                                                  throws SystemException
        Get hierarchy path as string.
        Parameters:
        entity - the entity to get value from
        Returns:
        path as string such as a/b/c
        Throws:
        SystemException - throw if an error occurs
        Since:
        5.17
      • getQueryCriterion

        public <Q> javax.persistence.criteria.Expression<java.lang.Boolean> getQueryCriterion​(javax.persistence.criteria.CriteriaBuilder criteriaBuilder,
                                                                                              javax.persistence.criteria.CriteriaQuery<Q> criteriaQuery)
                                                                                       throws SystemException
        Build query restriction from this hierarchy property.

        If matchType is START_WITH, match the hierarchy value or its descendants.

        Overrides:
        getQueryCriterion in class EntityProperty<T extends PersistenceEntity>
        Parameters:
        criteriaBuilder - the CriteriaBuilder instance
        criteriaQuery - the CriteriaQuery being built
        Returns:
        Predicate instance
        Throws:
        SystemException - throw if an error occurs
      • isGrouping

        public boolean isGrouping()
        If edit is enabled and render style is select, the property will be rendered as a group of select properties for multi-level hierarchy select.
        Overrides:
        isGrouping in class EntityProperty<T extends PersistenceEntity>
        Returns:
        true if grouping
      • setRenderStyle

        public void setRenderStyle​(RenderStyle renderStyle,
                                   boolean initPartialBehaviorSupportFromViewConfig)
                            throws SystemException
        Description copied from class: EntityProperty
        Set renderStyle. If openInputDialog is true, add menuNode for opening the input dialog in editing mode. Also add menu node to show/manage I18N translations if this property is I18n enabled. @see EntityI18N
        Overrides:
        setRenderStyle in class EntityProperty<T extends PersistenceEntity>
        Parameters:
        renderStyle - the renderStyle to set
        initPartialBehaviorSupportFromViewConfig - whether to initialize partialBehaviorSupport defined in the ViewConfig of its backing bean.
        Throws:
        SystemException - throw if an error occurs in checking property showing mode or adding menu ndoes
      • getChildren

        public java.util.List<EntityProperty<T>> getChildren()
        If edit is enabled and render style is select, the property will be rendered as a list of child properties for multi-level hierarchy select.
        Overrides:
        getChildren in class EntityProperty<T extends PersistenceEntity>
        Returns:
        child properties. return null or empty list if there is no child properties.
      • convert

        protected java.lang.Object convert​(java.lang.Object value)
                                    throws SystemException
        Description copied from class: EntityProperty
        Convert value to the property type if necessary, and validate property value if not delayed for model update phase. Always validate for other phases such as Invoke Application Phase.
        Overrides:
        convert in class EntityProperty<T extends PersistenceEntity>
        Parameters:
        value - user input value
        Returns:
        the converted value(if necessary) that can be invalid if not validated.
        Throws:
        InvalidValueException - throw if a data conversion error occurs
        SystemException - throw if any other error occurs
      • setValueInternal

        protected boolean setValueInternal​(T entity,
                                           java.lang.Object value)
        Description copied from class: EntityProperty
        Set property value. If the value is a string, convert the string to the property type if necessary. If the value is not a string, no type conversion.
        Overrides:
        setValueInternal in class EntityProperty<T extends PersistenceEntity>
        Parameters:
        entity - the entity of the property to set value to
        value - the property value to set
        Returns:
        true if value is changed and set successfully, false if not changed or value is invalid