Class BaseModelUADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>

java.lang.Object
com.liferay.user.associated.data.display.BaseModelUADDisplay<T>
All Implemented Interfaces:
UADComponent<T>, UADDisplay<T>

public abstract class BaseModelUADDisplay<T extends com.liferay.portal.kernel.model.BaseModel> extends Object implements UADDisplay<T>
Provides the base implementation of UADDisplay for entities generated with Service Builder. The count and retrieval are based on a dynamic query, which is available in the service generated by Service Builder.
  • Constructor Details

    • BaseModelUADDisplay

      public BaseModelUADDisplay()
  • Method Details

    • count

      public long count(long userId)
      Description copied from interface: UADDisplay
      Returns the number of type T entities associated with the the user.
      Specified by:
      count in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      Parameters:
      userId - the primary key of the user whose data to count
      Returns:
      the number of entities associated with the user
    • getFieldValues

      public Map<String,Object> getFieldValues(T t, String[] fieldNames, Locale locale)
      Description copied from interface: UADDisplay
      Returns a map of field names and values to display in the UI.
      Specified by:
      getFieldValues in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      Parameters:
      t - the type T entity
      fieldNames - the field names for getting values from the entity
      locale - the current locale
      Returns:
      a map of values to display in the UI
    • getPrimaryKey

      public Serializable getPrimaryKey(T baseModel)
      Description copied from interface: UADDisplay
      Returns the primary key of the type T entity.
      Specified by:
      getPrimaryKey in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      Parameters:
      baseModel - the entity whose primary key to retrieve
      Returns:
      the primary key of the entity
    • getRange

      public List<T> getRange(long userId, int start, int end)
      Description copied from interface: UADDisplay
      Returns type T entities in the given range associated with a user.
      Specified by:
      getRange in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      start - the starting index of the result set, for pagination
      end - the ending index of the result set, for pagination
      Returns:
      the paginated entities related to the user ID
    • getSortingFieldNames

      public String[] getSortingFieldNames()
      Description copied from interface: UADDisplay
      Returns the field names to be used as table column headers when sorting type T entities.
      Specified by:
      getSortingFieldNames in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      Returns:
      the field names used for column headers when sorting
    • getTypeName

      public String getTypeName(Locale locale)
      Description copied from interface: UADDisplay
      Returns the localized string representing type T.
      Specified by:
      getTypeName in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      Parameters:
      locale - the current locale
      Returns:
      the localized string representing type T
    • isInTrash

      public boolean isInTrash(T t) throws IllegalAccessException, InvocationTargetException
      Specified by:
      isInTrash in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      Throws:
      IllegalAccessException
      InvocationTargetException
    • isSiteScoped

      public boolean isSiteScoped()
      Description copied from interface: UADDisplay
      Returns true if type T entities are scoped by site.
      Specified by:
      isSiteScoped in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      Returns:
      true if type T entities are scoped by site; false otherwise
    • search

      public List<T> search(long userId, long[] groupIds, String keywords, String orderByField, String orderByType, int start, int end)
      Description copied from interface: UADDisplay
      Returns paginated sorted type T entities related to the user, optionally filtered by groups and/or keywords.
      Specified by:
      search in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      Parameters:
      userId - the primary key of the user
      groupIds - the primary keys of the groups that the entities are associated with
      keywords - the keywords which may occur in the entity's fields
      orderByField - the field to sort the entities by
      orderByType - the direction to sort the entities by (ascending or descending)
      start - the result set's starting index
      end - the result set's ending index
      Returns:
      the paginated, sorted, and filtered entities associated with the user
    • searchCount

      public long searchCount(long userId, long[] groupIds, String keywords)
      Description copied from interface: UADDisplay
      Returns the number of type T entities related to the user, optionally filtered by groups and/or keywords.
      Specified by:
      searchCount in interface UADDisplay<T extends com.liferay.portal.kernel.model.BaseModel>
      Parameters:
      userId - the primary key of the user
      groupIds - the primary keys of the groups that the entities are associated with
      keywords - the keywords which may occur in the entity's fields
      Returns:
      the number of filtered entities associated with the user
    • doCount

      protected abstract long doCount(com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery)
      Returns the number of type T entities associated with the user using the dynamic query.
      Parameters:
      dynamicQuery - the dynamic query to pass to the service layer
      Returns:
      the number of type T entities associated with the user using the dynamic query
    • doGetDynamicQuery

      protected abstract com.liferay.portal.kernel.dao.orm.DynamicQuery doGetDynamicQuery()
      Returns a new DynamicQuery from the relevant service for type T.
      Returns:
      a new DynamicQuery to be used by the service layer
    • doGetRange

      protected abstract List<T> doGetRange(com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start, int end)
      Returns type T entities in the given range associated with a user using a dynamic query.
      Parameters:
      dynamicQuery - the dynamic query to pass to the service layer
      start - the starting index of the result set, for pagination
      end - the ending index of the result set, for pagination
      Returns:
      a paginated list of type T entities
    • doGetUserIdFieldNames

      protected abstract String[] doGetUserIdFieldNames()
      Returns names identifying fields on the type T entity that contain the primary key of a user.
      Returns:
      the fields that contain the primary key of a user
    • getDynamicQuery

      protected com.liferay.portal.kernel.dao.orm.DynamicQuery getDynamicQuery(long userId)
      Returns a dynamic query for type T. It should be populated with criteria and ready for use by the service.
      Parameters:
      userId - the primary key of the user used to pre-filter the dynamic query
      Returns:
      a pre-filtered dynamic query
    • getOrderByComparator

      protected com.liferay.portal.kernel.util.OrderByComparator<T> getOrderByComparator(String orderByField, String orderByType)
      Returns an OrderByComparator for type T used to sort search results. If this returns null, the default dynamic query ordering is used.
      Parameters:
      orderByField - the name of the field to use for ordering
      orderByType - the type of ordering
      Returns:
      an OrderByComparator for type T
    • getSearchableFields

      protected String[] getSearchableFields()
      Returns:
      the field names to be queried
    • getSearchDynamicQuery

      protected com.liferay.portal.kernel.dao.orm.DynamicQuery getSearchDynamicQuery(long userId, long[] groupIds, String keywords, String orderByField, String orderByType)
      Returns a dynamic query that can be used to perform a database search for type T entities that are associated with the user.
      Parameters:
      userId - the primary key of the user whose data to search
      groupIds - the optional group primary keys to filter by
      keywords - the optional search terms to filter by
      orderByField - the name of the field to use for ordering
      orderByType - the type of ordering
      Returns:
      a dynamic query to be used by the doGetRange(com.liferay.portal.kernel.dao.orm.DynamicQuery, int, int) and doCount(com.liferay.portal.kernel.dao.orm.DynamicQuery) methods