The
basic
sample demonstrates workflow enabling an entity that is not an asset.
To see the Workflow sample in action, complete the following steps:
-
Add the sample widget to a page by navigating to Add (
) → Widgets → Sample → Workflow Basic and dragging it to the page.
-
Go to Control Panel → Workflow → Process Builder → Configuration and assign a workflow to the
Baz
entity. -
Select the app’s Add button and add an entity. Do this several times to create multiple entities.
-
Go to User → My Workflow Tasks → Assigned to My Roles and assigned the task to me and Approve the Task.
Now you’ve taken the entity and successfully run it through a workflow.
What API(s) and/or code components does this sample highlight?
This sample demonstrates Liferay DXP’s Workflow Handler API. Specifically, it
demonstrates how to create a WorkflowHandler
for your custom entity.
How does this sample leverage the API(s) and/or code component?
The basic implementation of WorkflowHandler
is done via extension of the
BaseWorkflowHandler
class. This is where the sample leverages the basic
methods required for the entity’s WorkflowHandler
.
@Override
public String getClassName() {
return Baz.class.getName();
}
@Override
public String getTitle(long classPK, Locale locale) {
return String.valueOf(classPK);
}
@Override
public String getType(Locale locale) {
return ResourceActionsUtil.getModelResource(locale, getClassName());
}
@Override
public Baz updateStatus(
int status, Map<String, Serializable> workflowContext)
throws PortalException {
long userId = GetterUtil.getLong(
(String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
long classPK = GetterUtil.getLong(
(String)workflowContext.get(
WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
return _bazLocalService.updateStatus(userId, classPK, status);
}
For more information on the workflow framework, visit its dedicated documentation.