Hi everyone, it's been a long time since I wrote the first part of this blog. In the previous part, we discussed the fundamentals of workflows, their types and applications.
Today, we are going to discuss the most widely used Workflow step - the process step. This is generally used when we want our application to execute a certain logic.
It executes an ECMA script or an OSGi service to perform automatic processing. A process can be implemented using the following steps -
Please make note of the process.label property that defines the identifier by which this process step will be listed among many process steps (this is explained in the below section).
Here, we are implementing WorkflowProcess interface and our business logic is written in the execute() method. Here we are getting the type of payload from the WorkflowData object and then also getting the process arguments that a user might pass while using this process step.
Today, we are going to discuss the most widely used Workflow step - the process step. This is generally used when we want our application to execute a certain logic.
It executes an ECMA script or an OSGi service to perform automatic processing. A process can be implemented using the following steps -
- Create an OSGi service implementing the interface com.adobe.granite.workflow.exec.WorkflowProcess.
- Set the property process.label. This is the String value by which our workflow needs to be listed.
- Implement the execute(WorkItem, WorkflowSession, MetaDataMap) method with the implementation code.
The execute() method has three parameters -
- WorkItem - It is the unit that is passed through a Workflow instance of a WorkflowModel. It contains the WorkflowData. The instances act on and a reference to the WorkflowNode that describes the underlying workflow step.
- WorkflowSession - This class provides all functionality (depending on the users' rights) for managing WorkflowModels, Workflow instances and their execution.
- MetaDataMap - A value map for generic access to meta data values.
Following is the sample implementation of a process step -
Please make note of the process.label property that defines the identifier by which this process step will be listed among many process steps (this is explained in the below section).
Configuring the workflow
- Navigate to - http://<host>:<port>/libs/cq/workflow/admin/console/content/models.html and click on "Create" button.
![]() |
Workflow models |
- Now click on "Create Model" and enter the workflow details and "Done".
![]() |
Create workflow model |
- Select workflow model created and click on "Edit"
![]() |
Edit workflow model |
- Click on drag components here and select process step from the list. Before that, delete step 1 which is created automatically.
![]() |
Select process step |
- Edit the process step using the following configuration. Note that we selected the process which is similar to the value we have given in the process.label property.
![]() |
Configure process step |
- After saving the dialog, click on "Sync" in top right corner to save the workflow. Thus our workflow model is ready. Now, we can run it for any operation we want. The simplest example is to run this workflow model for a page.
- When you run it, you will find the following messages in the logs -
2019-09-24 22:40:35.268 INFO [org.redquark.demo.core.workflows.ProcessStepExample] Payload type: JCR_PATH
2019-09-24 22:40:35.268 INFO [org.redquark.demo.core.workflows.ProcessStepExample] Payload path: /content/we-retail/language-masters/en/men
2019-09-24 22:40:35.269 INFO [org.redquark.demo.core.workflows.ProcessStepExample] Process args: [a=1, b=2, c=3]
Conclusion
In this post, we looked into creating a custom workflow process steps and how to configure it. You can find the code to this in my GitHub repository.
can u help me on custom process step On page creation a property must be added.
ReplyDelete