-
1. Re: query TasksAssignedAsPotentialOwner doesn't work with MySql db
swiderski.maciej Mar 31, 2014 1:26 AM (in response to cescobar)so what's the user assignment, user or group? since actual owner is null then it must be a group or multi user assignment or your user group callback instructs task service to skip users/groups as the do not exists. Please provide more details on your case as it's hard to diagnose on the current information.
HTH
-
2. Re: query TasksAssignedAsPotentialOwner doesn't work with MySql db
cescobar Mar 31, 2014 1:46 AM (in response to swiderski.maciej)Hi Maciej
I am using a ApplicationScoped class like this.
WFApplicationScopedProducer.java
@ApplicationScoped
public class WFApplicationScopedProducer {
@Inject
private InjectableRegisterableItemsFactory factory;
@Inject
private UserGroupCallback usergroupCallback;
@PersistenceUnit(unitName = "org.jbpm.workflow.financial-web")
private EntityManagerFactory emf;
@Produces
public EntityManagerFactory produceEntityManagerFactory() {
if (this.emf == null) {
this.emf = Persistence.createEntityManagerFactory("org.jbpm.workflow.financial-web");
}
return this.emf;
}
@EJB AccountService acctService;
@Produces
@Singleton
@PerProcessInstance
@PerRequest
public RuntimeEnvironment produceEnvironment(EntityManagerFactory emf) {
Collection<Account> list = acctService.getAccounts();
HashMap<String, Object> map = new HashMap<String, Object>();
for(Account acct : list){
String entityId = acct.getDepartment().getDepartmentcode();
//String entityValue = acct.getEmail()+":en-UK:"+acct.getDepartment().getDepartmentcode();
String entityValue = acct.getDepartment().getDepartmentcode();
map.put(entityId, entityValue);
}
Properties properties= new Properties();
properties.putAll(map);
System.out.println("Entities values::::: "+properties);
usergroupCallback = new JBossUserGroupCallbackImpl(properties);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
.newDefaultBuilder()
.entityManagerFactory(emf)
.userGroupCallback(usergroupCallback)
.registerableItemsFactory(factory)
.addAsset(
ResourceFactory.newClassPathResource("requisition.bpmn"),
ResourceType.BPMN2).get();
return environment;
}
-----
AppUserGroupCallback.java
@Alternative
public class AppUserGroupCallback implements UserGroupCallback {
public boolean existsUser(String userId) {
System.out.println("AppUserGroupCallback.userId ::::::::::::::::::::: "+ userId);
return userId.equals("ADMIN") || userId.equals("COMPRAS") || userId.equals("Administrator");
}
public boolean existsGroup(String groupId) {
return groupId.equals("ADMIN") || groupId.equals("COMPRAS");
}
public List<String> getGroupsForUser(String userId, List<String> groupIds, List<String> allExistingGroupIds)
{
List<String> groups = new ArrayList<String>();
if (userId.equals("ADMIN"))
groups.add("ADMIN");
else if (userId.equals("COMPRAS"))
groups.add("COMPRAS");
System.out.println("AppUserGroupCallback.groups ::::::::::::::::::::: "+ groups);
return groups;
}
}
And then, I need to populate usergroupCallback from my db tables instead of an file properties. I have the following beans.xml file content
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd
http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
<alternatives>
<class>org.jbpm.workflow.util.AppUserGroupCallback</class>
<class>org.jbpm.kie.services.cdi.producer.DefaultUserGroupInfoProducer</class>
</alternatives>
<interceptors>
<class>org.jboss.seam.transaction.TransactionInterceptor</class>
</interceptors>
</beans>
When the application is deploy in console appears.
00:12:52,043 INFO [stdout] (ServerService Thread Pool -- 86) Entities values::::: {ADMIN=ADMIN, CIENCIA=CIENCIA}
That says to me what my db table is being read to populate my usergroupCallback.
But When I go to my SQL tables I see this:
SELECT * FROM mysqlinnodb.OrganizationalEntity;
DTYPE id
User Administrator
Group Administrators
Group Crusaders
User john
Group "Knights Templer"
My processInstaceId is generated and I see it into SELECT * FROM mysqlinnodb.Task; But
id,archived,allowedToDelegate,formName,priority,subTaskStrategy,activationTime,createdOn,deploymentId,documentAccessType,documentContentId,documentType,expirationTime,faultAccessType,faultContentId,faultName,faultType,outputAccessType,outputContentId,outputType,parentId,previousStatus,processId,processInstanceId,processSessionId,skipable,status,workItemId,taskType,OPTLOCK,taskInitiator_id,actualOwner_id,createdBy_id
16,0,NULL,"APROBACION POR DIRECTOR",0,NoAction,"2014-03-31 00:13:18","2014-03-31 00:13:18",default-singleton,0,16,java.util.HashMap,NULL,NULL,-1,NULL,NULL,NULL,-1,NULL,-1,2,com.sample.requisition,16,1,1,Ready,16,NULL,0,NULL,NULL,NULL
When actualOwner_Id and createdBy_Id both are null
And into my ProcessDefinition diagram I have actorId: ADMIN for the first task when the process starts.
and the rest with their respective actorId
So I am very confused how to solve that
Thanks for your reply
-
3. Re: query TasksAssignedAsPotentialOwner doesn't work with MySql db
liuyi08f Mar 31, 2014 11:47 AM (in response to cescobar)I have encounted the same problem, I hope it could be solved soon. the intertested thing is that the user krisv, john and mary does work, but the other user does not work.
-
4. Re: query TasksAssignedAsPotentialOwner doesn't work with MySql db
liuyi08f Apr 1, 2014 3:21 AM (in response to cescobar)May be you miss the following code in your WFApplicationScopedProducer
@Produces public UserGroupCallback produceUserGroupCallback() { return usergroupCallback; } -
5. Re: query TasksAssignedAsPotentialOwner doesn't work with MySql db
cescobar Apr 1, 2014 3:26 AM (in response to liuyi08f)Thank you Yi, Let me try it and I will come back to comment you.
-
6. Re: query TasksAssignedAsPotentialOwner doesn't work with MySql db
swiderski.maciej Apr 2, 2014 3:47 AM (in response to cescobar)if you would like to use users and groups from your own data base table you can use DBUserGroupCallback implementation that will directly use your tables to find out if user/group exists.
HTH
-
7. Re: query TasksAssignedAsPotentialOwner doesn't work with MySql db
cescobar Apr 9, 2014 3:04 AM (in response to swiderski.maciej)Thanks!
By the way do you know how can I get the Process Variables by using the Kie API in jbpm6 ? I see in the rewards-basic example it set an input paramenter named recipient, but there is no example of how to retreive that data.