Workflow Asset Application

This sample demonstrates workflow enabling a model entity that is an asset.

To see the Workflow sample in action, complete the following steps:

  1. Add the sample widget to a page by navigating to Add (Add) → WidgetsSampleWorkflow Asset and dragging it to the page.

  2. Go to Control PanelWorkflowProcess BuilderConfiguration and assign a workflow to the Qux entity.

  3. Select the app’s Add button and add an entity. Do this several times to create multiple entities.

  4. Go to UserMy Workflow TasksAssigned 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 that is asset enabled.

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 Qux.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 Qux 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 _quxLocalService.updateStatus(userId, classPK, status);
}

For more information on the workflow framework, visit its dedicated documentation.

« Workflow SamplesWorkflow Application »
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0