Interface StagedModelRepository<T extends com.liferay.portal.kernel.model.StagedModel>

Type Parameters:
T - the staged model type on which this staged model repository operates

public interface StagedModelRepository<T extends com.liferay.portal.kernel.model.StagedModel>
Provides an interface for CRUD operations for a given staged model. This interface simplifies staged model data handlers because the CRUD operations and code logic related to those operations can be managed here instead. The get and fetch methods are typically used during an export process to query/find staged models.

The staged model parameter can be either

  • the old staged model that was serialized at export time and deserialized at import time. This means it is more like a POJO and its key attributes (primary key and foreign keys) should not be used during the CRUD operations.
  • the new staged model currently being called from the portal. This means the staged model can be used as a regular entity.
  • Method Summary

    Modifier and Type
    Method
    Description
    addStagedModel(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext, T stagedModel)
    Persists a new staged model.
    void
    deleteStagedModel(String uuid, long groupId, String className, String extraData)
     
    void
    deleteStagedModel(T stagedModel)
     
    void
    deleteStagedModels(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext)
    Deletes all the staged models this repository handles.
    default T
    fetchMissingReference(String uuid, long groupId)
    Fetches the model being handled by this repository as a missing reference.
     
     
    com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery
    getExportActionableDynamicQuery(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext)
    Returns a dynamic query that queries the entities from the database based on the parameters in the portlet data context.
    default T
    getStagedModel(long classPK)
     
    default void
    restoreStagedModel(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext, T stagedModel)
    Restores the staged model from the portal instance's trash.
    saveStagedModel(T stagedModel)
     
    updateStagedModel(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext, T stagedModel)
    Returns the updated staged model.
  • Method Details

    • addStagedModel

      T addStagedModel(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext, T stagedModel) throws com.liferay.portal.kernel.exception.PortalException
      Persists a new staged model. When setting the staged model parameter, the primary key attribute should not be used. Foreign keys should be set before calling this method. For example, suppose a bookmarks entry is being imported. It has a group ID and a folder ID as foreign keys which are required by the local service. These keys should be set on the staged model before calling this method because this method will forward these values to the service method like this:

       
       _bookmarksEntryLocalService.addEntry(userId, bookmarksEntry.getGroupId(),
               bookmarksEntry.getFolderId(), bookmarksEntry.getName(),
               bookmarksEntry.getUrl(), bookmarksEntry.getDescription(),
               serviceContext);
       
       

      Parameters:
      portletDataContext - the portlet data context
      stagedModel - the old staged model being copied
      Returns:
      the newly persisted staged model
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • deleteStagedModel

      void deleteStagedModel(String uuid, long groupId, String className, String extraData) throws com.liferay.portal.kernel.exception.PortalException
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • deleteStagedModel

      void deleteStagedModel(T stagedModel) throws com.liferay.portal.kernel.exception.PortalException
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • deleteStagedModels

      void deleteStagedModels(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext) throws com.liferay.portal.kernel.exception.PortalException
      Deletes all the staged models this repository handles. This usually includes the data from the portlet data context's scope group.
      Parameters:
      portletDataContext - the portlet data context
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • fetchMissingReference

      default T fetchMissingReference(String uuid, long groupId)
      Fetches the model being handled by this repository as a missing reference. If possible, use StagedModelRepositoryHelper.fetchMissingReference(String, long, StagedModelRepository) as the implementation. This method does not just fetch a staged model matching the UUID and group ID; it also has a set of rules defining where to find the missing reference. It searches sites in the following order:
      1. Importing site
      2. Importing site's parent sites
      3. Global site
      Parameters:
      uuid - the universal unique ID
      groupId - the importing group's ID
      Returns:
      the missing reference entity, or null if it is not found
    • fetchStagedModelByUuidAndGroupId

      T fetchStagedModelByUuidAndGroupId(String uuid, long groupId)
    • fetchStagedModelsByUuidAndCompanyId

      List<T> fetchStagedModelsByUuidAndCompanyId(String uuid, long companyId)
    • getExportActionableDynamicQuery

      com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery getExportActionableDynamicQuery(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext)
      Returns a dynamic query that queries the entities from the database based on the parameters in the portlet data context. This method is a wrapper for the same method in the Service Builder generated local service. If possible, use the local service's getExportActionableDynamicQuery(PortletDataContext) as the implementation.

      The ActionableDynamicQuery.getPerformActionMethod() is an API call (uses StagedModelDataHandlerUtil.exportStagedModel(PortletDataContext, StagedModel)) to export each entity that is returned.

      Parameters:
      portletDataContext - the portlet data context
      Returns:
      returns the export actionable dynamic query
    • getStagedModel

      default T getStagedModel(long classPK) throws com.liferay.portal.kernel.exception.PortalException
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • restoreStagedModel

      default void restoreStagedModel(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext, T stagedModel) throws com.liferay.exportimport.kernel.lar.PortletDataException
      Restores the staged model from the portal instance's trash.
      Parameters:
      portletDataContext - the portlet data context
      stagedModel - the old staged model restored from the trash
      Throws:
      com.liferay.exportimport.kernel.lar.PortletDataException - if a portlet data exception occurred
    • saveStagedModel

      T saveStagedModel(T stagedModel) throws com.liferay.portal.kernel.exception.PortalException
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • updateStagedModel

      T updateStagedModel(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext, T stagedModel) throws com.liferay.portal.kernel.exception.PortalException
      Returns the updated staged model.
      Parameters:
      portletDataContext - the portlet data context
      stagedModel - the new staged model currently being called from the portal
      Returns:
      returns the updated staged model
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred