Interface StagedModelDataHandler<T extends StagedModel>
- All Known Implementing Classes:
BaseStagedModelDataHandler
public interface StagedModelDataHandler<T extends StagedModel>
- Author:
- Máté Thurzó, Daniel Kocsis, Zsolt Berentey
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteStagedModel
(String uuid, long groupId, String className, String extraData) Deletes the staged model matching the parameters.void
deleteStagedModel
(T stagedModel) Deletes the staged model.void
exportStagedModel
(PortletDataContext portletDataContext, T stagedModel) Exports the staged model and its references.fetchMissingReference
(String uuid, long groupId) Returns a reference of the staged model.fetchStagedModelByUuidAndGroupId
(String uuid, long groupId) Returns the staged model with the UUID and group.fetchStagedModelsByUuidAndCompanyId
(String uuid, long companyId) Returns the staged models with the UUID and company.String[]
Returns the class names of the models the data handler handles.getDisplayName
(T stagedModel) Returns the staged model's display name.int[]
Returns the workflow statuses that are used as filters during the export process.getReferenceAttributes
(PortletDataContext portletDataContext, T stagedModel) Returns the attributes that are automatically merged into the XML element of the staged model reference.void
importMissingReference
(PortletDataContext portletDataContext, Element referenceElement) Maps the ID of the existing staged model to the old ID in the reference element.void
importMissingReference
(PortletDataContext portletDataContext, String uuid, long groupId, long classPK) Maps the ID of the existing staged model to the old ID in the reference element.void
importStagedModel
(PortletDataContext portletDataContext, T stagedModel) Imports the staged model.default boolean
isEnabled
(long companyId) void
restoreStagedModel
(PortletDataContext portletDataContext, T stagedModel) Restores the staged model from the trash.boolean
validateReference
(PortletDataContext portletDataContext, Element referenceElement) Returnstrue
if the staged model reference validation is successful.
-
Method Details
-
deleteStagedModel
void deleteStagedModel(String uuid, long groupId, String className, String extraData) throws PortalException Deletes the staged model matching the parameters. This method is called when deletions are imported.- Parameters:
uuid
- the staged model's UUIDgroupId
- the primary key of the entity's groupclassName
- the staged model's class nameextraData
- the extra data containing useful information about the staged model. This information makes the staged model easier to identify and fetch for deletion. It is populated when a deletion system event is added, usually in the*LocalServiceImpl
class of the model.- Throws:
PortalException
- if a portal exception occurred
-
deleteStagedModel
Deletes the staged model. This method is called when deletions are imported.- Parameters:
stagedModel
- the staged model to delete- Throws:
PortalException
- if a portal exception occurred
-
exportStagedModel
void exportStagedModel(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException Exports the staged model and its references. See theexportStagedModel(PortletDataContext, T)
method for a reference implementation. Refrain from overriding this method; instead, override theBaseStagedModelDataHandler#doExportStagedModel(PortletDataContext, T)
method.- Parameters:
portletDataContext
- the portlet data context of the current processstagedModel
- the staged model to export- Throws:
PortletDataException
- if a portlet data exception occurred
-
fetchMissingReference
Returns a reference of the staged model. This method is typically used in validation and import methods.- Parameters:
uuid
- the reference's UUIDgroupId
- the primary key of the group- Returns:
- a reference of the staged model
-
fetchStagedModelByUuidAndGroupId
Returns the staged model with the UUID and group. This method is used in cases with grouped models.- Parameters:
uuid
- the staged model's UUIDgroupId
- the primary key of the group- Returns:
- the staged model with the UUID and group
-
fetchStagedModelsByUuidAndCompanyId
Returns the staged models with the UUID and company.- Parameters:
uuid
- the staged model's UUIDcompanyId
- the primary key of the company- Returns:
- the staged models with the UUID and company
-
getClassNames
String[] getClassNames()Returns the class names of the models the data handler handles.- Returns:
- the class names of the models the data handler handles
-
getDisplayName
Returns the staged model's display name. The display name is presented in the UI so users can follow the export/import process.- Parameters:
stagedModel
- the staged model from which to extract the display name- Returns:
- the staged model's display name
-
getExportableStatuses
int[] getExportableStatuses()Returns the workflow statuses that are used as filters during the export process.- Returns:
- the workflow statuses that are used as filters during the export process
-
getReferenceAttributes
Returns the attributes that are automatically merged into the XML element of the staged model reference. These attributes are available during the import process in, for example, theimportMissingReference(PortletDataContext, Element)
andvalidateReference(PortletDataContext, Element)
methods.- Parameters:
portletDataContext
- the current process's portlet data contextstagedModel
- the staged model for which to get attributes- Returns:
- the attributes for the staged model
-
importMissingReference
void importMissingReference(PortletDataContext portletDataContext, Element referenceElement) throws PortletDataException Maps the ID of the existing staged model to the old ID in the reference element. When a reference is exported as missing, the Data Handler framework calls this method during the import process and updates the new primary key map in the portlet data context.- Parameters:
portletDataContext
- the portlet data context of the current processreferenceElement
- the XML element that contains information about the staged model reference- Throws:
PortletDataException
- if a portlet data exception occurred
-
importMissingReference
void importMissingReference(PortletDataContext portletDataContext, String uuid, long groupId, long classPK) throws PortletDataException Maps the ID of the existing staged model to the old ID in the reference element. When the staged model data handler instance extendsBaseStagedModelDataHandler
, this method is called to override theBaseStagedModelDataHandler.importMissingReference(PortletDataContext, Element)
andBaseStagedModelDataHandler.doImportMissingReference(PortletDataContext, Element)
methods.- Parameters:
portletDataContext
- the portlet data context of the current processuuid
- the staged model's UUID from the reference elementgroupId
- the primary key of the entity's group from the reference elementclassPK
- the class primary key of the staged model from the reference element- Throws:
PortletDataException
- if a portlet data exception occurred- See Also:
-
importStagedModel
void importStagedModel(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException Imports the staged model. All the staged model's references must be imported before this method is called. See theBaseStagedModelDataHandler.importStagedModel(PortletDataContext, StagedModel)
method for a reference implementation. Refrain from overriding this method; instead, override theBaseStagedModelDataHandler#doImportStagedModel(PortletDataContext, T)
method.- Parameters:
portletDataContext
- the portlet data context of the current processstagedModel
- the staged model to import- Throws:
PortletDataException
- if a portlet data exception occurred
-
isEnabled
default boolean isEnabled(long companyId) -
restoreStagedModel
void restoreStagedModel(PortletDataContext portletDataContext, T stagedModel) throws PortletDataException Restores the staged model from the trash. This method is called during the import process to ensure the imported staged model is not in the trash. See theBaseStagedModelDataHandler.restoreStagedModel(PortletDataContext, StagedModel)
method for a reference implementation. Refrain from overriding this method; instead, override theBaseStagedModelDataHandler.doRestoreStagedModel(PortletDataContext, StagedModel)
method.- Parameters:
portletDataContext
- the portlet data context of the current processstagedModel
- the staged model to restore from the trash- Throws:
PortletDataException
- if a portlet data exception occurred
-
validateReference
Returnstrue
if the staged model reference validation is successful.- Parameters:
portletDataContext
- the portlet data context of the current processreferenceElement
- the XML element that contains information about the reference- Returns:
true
if the reference validation is successful;false
otherwise
-