05-10-2018 12:39 AM
The issue is pretty similar to the below one that was discussed many years ago and I'm unable to refer to the fixes provided to that issue.
GroupManager.findGroupsByUser called twice
-----------------------------------------------------------------------------------------------------------------------------
GroupEntityManager.findGroupsByUser() is invoked 5 times on taskQuery execution. I'm using SpringBoot along with Activiti, I have provided the code snippets below. Please advise if I'm missing anything for the query to function correctly.
Query:
List<Task> tasks = taskQuery.taskCandidateOrAssigned(userId)
.list();
Config:
@Override
public ProcessEngineFactoryBean processEngine(SpringProcessEngineConfiguration configuration) throws Exception{
configuration.setIdGenerator(new StrongUuidGenerator());
GroupManagerFactory groupManagerFactory = new GroupManagerFactory(customGroupEntityManager);
configuration.setCustomSessionFactories(CollectionUtil.createListOfOne(groupManagerFactory));
configuration.setGroupEntityManager(customGroupEntityManager);
configuration.setDbIdentityUsed(false);
return super.processEngine(configuration);
}
GroupEntityManager:
@Component
public class CustomGroupEntityManager implements GroupEntityManager, Session{
@Override
public List<Group> findGroupsByUser(String userId) {
//ACTUAL IMPLEMENTATION AND THIS METHOD IS GETTING INVOKED "FIVE" TIMES
}
@Override
public Group createNewGroup(String groupId) {
return null;
}
@Override
public GroupQuery createNewGroupQuery() {
return null;
}
@Override
public List<Group> findGroupByQueryCriteria(GroupQueryImpl query, Page page) {
return null;
}
@Override
public long findGroupCountByQueryCriteria(GroupQueryImpl query) {
return 0;
}
@Override
public List<Group> findGroupsByNativeQuery(Map<String, Object> parameterMap, int firstResult, int maxResults) {
return null;
}
@Override
public long findGroupCountByNativeQuery(Map<String, Object> parameterMap) {
return 0;
}
@Override
public boolean isNewGroup(Group group) {
return false;
}
@Override
public GroupEntity create() {
return null;
}
@Override
public GroupEntity findById(String entityId) {
return null;
}
@Override
public void insert(GroupEntity entity) {
}
@Override
public void insert(GroupEntity entity, boolean fireCreateEvent) {
}
@Override
public GroupEntity update(GroupEntity entity) {
return null;
}
@Override
public GroupEntity update(GroupEntity entity, boolean fireUpdateEvent) {
return null;
}
@Override
public void delete(String id) {
}
@Override
public void delete(GroupEntity entity) {
}
@Override
public void delete(GroupEntity entity, boolean fireDeleteEvent) {
}
@Override
public void flush() {
}
@Override
public void close() {
}
// CLOVER:ON
}
05-15-2018 12:26 PM
Any input on this issue is appreciated.
05-25-2018 06:12 AM
This is being called by mybatis as mentioned in the other thread. Did you try setting the candidate groups in the query? If you provide the candidate groups in query GroupEntityManager.findGroupsByUser will not be invoked (see Activiti/TaskQueryImpl.java at 6.x · Activiti/Activiti · GitHub). Your query might look like this.
List<Task> tasks = taskQuery.taskCandidateOrAssigned(userId)
.or()
.taskCandidateGroupIn(groups)
.endOr()
.list();
Hope this helps.
Explore our Alfresco products with the links below. Use labels to filter content by product module.