[jBPM] - jBPM 5.4 : how to forward / reassign a task to a group ?
by gonzalad
gonzalad [https://community.jboss.org/people/gonzalad] created the discussion
"jBPM 5.4 : how to forward / reassign a task to a group ?"
To view the discussion, visit: https://community.jboss.org/message/798550#798550
--------------------------------------------------------------
As mentioned in https://community.jboss.org/thread/221465 https://community.jboss.org/thread/221465, I need to reassign a task to a group.
This isn't normally possible via taskService.forward as per the spec WS-Huma,Task 1.0 chapter 4.7.3 Delegating or Forwarding a Human Task :
Forwarding is possible if the task has a set of individually assigned potential owners, not if its potential owners are assigned using one or many groups.
Is there a good way to do it with jBPM ?
For the moment, here's my working code, but it's kind of ugly :
public void reassign(TaskSummary taskSummary, String username,
String targetGroupname) {
Task task = taskService.getTask(taskSummary.getId());
// check if username is in potentialOwners
boolean userInPotentialOwners = false;
for (OrganizationalEntity entity : task.getPeopleAssignments()
.getPotentialOwners()) {
if (entity.getId().equals(username)) {
userInPotentialOwners = true;
break;
}
}
if (!userInPotentialOwners) {
org.jbpm.task.User actualOwner = task.getTaskData()
.getActualOwner();
// we claim the task just to set actualOwner to current user
if (taskSummary.getStatus() == Status.Ready
&& (actualOwner == null || !actualOwner.getId().equals(
username))) {
taskService.claim(task.getId(), username);
actualOwner = task.getTaskData().getActualOwner();
}
// if actualOwner is current user, we add it to potentialOwnersn,
// just to call forward - see
// https://community.jboss.org/thread/221465?tstart=0
task.getPeopleAssignments().getPotentialOwners().add(actualOwner);
}
taskService.forward(taskSummary.getId(), username, targetGroupname);
// forward reassigns the task.
// if the task was already assigned to other groups / users, those groups / users are not removed from potentialOwners
// we must do it explicitly
PeopleAssignments peopleAssignments = task.getPeopleAssignments();
List<OrganizationalEntity> clonedList = peopleAssignments
.getPotentialOwners();
for (OrganizationalEntity entity : clonedList) {
if (!entity.getId().equals(targetGroupname)
&& !entity.getId().equals("Administrator")) {
peopleAssignments.getPotentialOwners().remove(entity);
}
}
}
Thanks !
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/798550#798550]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 10 months
[jBPM] - jBPM skips my rule task nodes except for the last rule task
by John Joel Boss
John Joel Boss [https://community.jboss.org/people/jjsaguit] created the discussion
"jBPM skips my rule task nodes except for the last rule task"
To view the discussion, visit: https://community.jboss.org/message/798514#798514
--------------------------------------------------------------
using jbpm 5.4 with drools 5.5.0 and eclipse juno
I have a test project with a workflow that goes :
[start] --> [script printing "Hello 1"] --> [rule task node to print "Rule 1"] --> [script printing "Hello 2"] --> [rule task node to print "Rule 2"] --> [END]
The output is:
Hello 1
Hello 2
Rule 2
I used AgendaEventListener added to my ksession to fire the rules and I think it works just fine. Full post at https://community.jboss.org/thread/221486 https://community.jboss.org/thread/221486.
I built the KnowledgeBuilder as the following:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// adding my workflow
kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);
// adding my first rule with ruleflow-group "test1"
kbuilder.add(ResourceFactory.newClassPathResource("test.xls"), ResourceType.DTABLE);
// adding my second rule with ruleflow-group "test2"
kbuilder.add(ResourceFactory.newClassPathResource("test1.xls"), ResourceType.DTABLE);
Funny thing because if I comment out my second rule the output would be:
Hello 1
Rule 1
Hello 2
It seems like its only firing the last rule in the list.
Any idea whats wrong?
Test project attached
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/798514#798514]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 10 months
[jBPM] - Drools/jBPM integration problem - firing drools rules from rule task node
by John Joel Boss
John Joel Boss [https://community.jboss.org/people/jjsaguit] created the discussion
"Drools/jBPM integration problem - firing drools rules from rule task node"
To view the discussion, visit: https://community.jboss.org/message/798470#798470
--------------------------------------------------------------
Hi all,
I have read from https://community.jboss.org/message/627263#627263 https://community.jboss.org/message/627263 that to fire the rule, I must call fireAllRules() before the rule task node and so I added the listener sugested in the same thread:
final org.drools.event.AgendaEventListener agendaEventListener = new org.drools.event.AgendaEventListener() {
public void activationCreated(ActivationCreatedEvent event,
WorkingMemory workingMemory){
}
public void activationCancelled(ActivationCancelledEvent event,
WorkingMemory workingMemory){
}
public void beforeActivationFired(BeforeActivationFiredEvent event,
WorkingMemory workingMemory) {
}
public void afterActivationFired(AfterActivationFiredEvent event,
WorkingMemory workingMemory) {
}
public void agendaGroupPopped(AgendaGroupPoppedEvent event,
WorkingMemory workingMemory) {
}
public void agendaGroupPushed(AgendaGroupPushedEvent event,
WorkingMemory workingMemory) {
}
public void beforeRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,
WorkingMemory workingMemory) {
}
public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,
WorkingMemory workingMemory) {
workingMemory.fireAllRules();
}
public void beforeRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event,
WorkingMemory workingMemory) {
}
public void afterRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event,
WorkingMemory workingMemory) {
}
};
((StatefulKnowledgeSessionImpl) ((KnowledgeCommandContext) ((CommandBasedStatefulKnowledgeSession) ksession)
.getCommandService().getContext()).getStatefulKnowledgesession() )
.session.addEventListener(agendaEventListener);
However, I am getting the following cast error:
Exception in thread "main" java.lang.ClassCastException: org.drools.impl.StatefulKnowledgeSessionImpl cannot be cast to org.drools.command.impl.CommandBasedStatefulKnowledgeSession
at com.sample.ProcessMain.main(ProcessMain.java:79)
Can anyone help please? I'm using jBPM 5.4 with Drools 5.5.0
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/798470#798470]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 10 months