Do we have an example of OR split in workflow using a process step instead of an ecma script ?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @vishwanath881
Unfortunately , I am not able to locate the dependency, I thought It would be part of uber jar.
However, I have also not tried it by myself.
you can try different approach
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowData;
import com.adobe.granite.workflow.exec.WorkflowProcess;
public class MyCustomProcessStep implements WorkflowProcess {
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, WorkflowData workflowData) throws WorkflowException {
// Your OR split logic here
String condition1 = "your condition 1"; // Replace with your actual conditions
String condition2 = "your condition 2";
if (condition1.equals("true") || condition2.equals("true")) {
// Route the workflow to the appropriate path based on the OR split conditions
workflowSession.complete(workItem, "YOUR_NEXT_WORKFLOW_STEP");
} else {
// Handle the case when neither condition is met
workflowSession.complete(workItem, "ANOTHER_NEXT_WORKFLOW_STEP");
}
}
}
package com.example.workflow;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.split.SplitResult;
import com.adobe.granite.workflow.split.impl.AbstractSplitter;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(service = AbstractSplitter.class, immediate = true)
public class OrSplitter extends AbstractSplitter {
private static final Logger LOGGER = LoggerFactory.getLogger(OrSplitter.class);
@Override
public SplitResult doSplit(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
// Retrieve the workflow variable "conditionVariable"
String conditionVariable = (String) workItem.getWorkflowData().getMetaDataMap().get("conditionVariable");
// Check the condition
boolean conditionMet = "someValue".equals(conditionVariable);
if (conditionMet) {
LOGGER.info("Condition met. Proceeding along path A.");
return new SplitResult("A");
} else {
LOGGER.info("Condition not met. Proceeding along path B.");
return new SplitResult("B");
}
}
}
Thanks Arun, let me try and get back.
Hi @arunpatidar , Thanks for your response. However, I am unable to resolve dependencies for com.adobe.granite.workflow.split.* while compiling. Can you please share the dependency you are using?
Hi @vishwanath881
Unfortunately , I am not able to locate the dependency, I thought It would be part of uber jar.
However, I have also not tried it by myself.
you can try different approach
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowData;
import com.adobe.granite.workflow.exec.WorkflowProcess;
public class MyCustomProcessStep implements WorkflowProcess {
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, WorkflowData workflowData) throws WorkflowException {
// Your OR split logic here
String condition1 = "your condition 1"; // Replace with your actual conditions
String condition2 = "your condition 2";
if (condition1.equals("true") || condition2.equals("true")) {
// Route the workflow to the appropriate path based on the OR split conditions
workflowSession.complete(workItem, "YOUR_NEXT_WORKFLOW_STEP");
} else {
// Handle the case when neither condition is met
workflowSession.complete(workItem, "ANOTHER_NEXT_WORKFLOW_STEP");
}
}
}
@vishwanath881 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies