Search in sources :

Example 1 with UserGroupCallback

use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.

the class EvaluationExample2 method getRuntimeManager.

private static RuntimeManager getRuntimeManager(String process) {
    // load up the knowledge base
    JBPMHelper.startH2Server();
    JBPMHelper.setupDataSource();
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(new UserGroupCallback() {

        public List<String> getGroupsForUser(String userId) {
            List<String> result = new ArrayList<String>();
            if ("mary".equals(userId)) {
                result.add("HR");
            } else if ("john".equals(userId)) {
                result.add("PM");
            }
            return result;
        }

        public boolean existsUser(String arg0) {
            return true;
        }

        public boolean existsGroup(String arg0) {
            return true;
        }
    }).addAsset(KieServices.Factory.get().getResources().newClassPathResource(process), ResourceType.BPMN2).get();
    return RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
}
Also used : RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) ArrayList(java.util.ArrayList) List(java.util.List) UserGroupCallback(org.kie.api.task.UserGroupCallback)

Example 2 with UserGroupCallback

use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.

the class HumanTaskExample method getRuntimeManager.

private static RuntimeManager getRuntimeManager(String process) {
    // load up the knowledge base
    JBPMHelper.startH2Server();
    JBPMHelper.setupDataSource();
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(new UserGroupCallback() {

        public List<String> getGroupsForUser(String userId) {
            List<String> result = new ArrayList<String>();
            if ("sales-rep".equals(userId)) {
                result.add("sales");
            } else if ("john".equals(userId)) {
                result.add("PM");
            }
            return result;
        }

        public boolean existsUser(String arg0) {
            return true;
        }

        public boolean existsGroup(String arg0) {
            return true;
        }
    }).addAsset(KieServices.Factory.get().getResources().newClassPathResource(process), ResourceType.BPMN2).get();
    return RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
}
Also used : RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) ArrayList(java.util.ArrayList) List(java.util.List) UserGroupCallback(org.kie.api.task.UserGroupCallback)

Example 3 with UserGroupCallback

use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.

the class MvelResolverDeploymentDescriptorManagerTest method testDeploymentDescriptorFromKieContainer.

@Test
public void testDeploymentDescriptorFromKieContainer() throws IOException {
    Map<String, String> resources = new HashMap<String, String>();
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
    String kmoduleString = IOUtils.toString(this.getClass().getResourceAsStream("/kmodule-custom-wih.xml"), "UTF-8");
    resources.put("src/main/resources/META-INF/kmodule.xml", kmoduleString);
    String processString = IOUtils.toString(this.getClass().getResourceAsStream("/BPMN2-CustomTask.bpmn2"), "UTF-8");
    resources.put("src/main/resources/BPMN2-CustomTask.bpmn2", processString);
    InternalKieModule kJar1 = createKieJar(ks, releaseId, resources);
    installKjar(releaseId, kJar1);
    Properties properties = new Properties();
    UserGroupCallback userGroupCallback = new JBossUserGroupCallbackImpl(properties);
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder(releaseId).userGroupCallback(userGroupCallback).get();
    manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
    manager.getRuntimeEngine(ProcessInstanceIdContext.get()).getKieSession().startProcess("customtask");
}
Also used : RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) HashMap(java.util.HashMap) JBossUserGroupCallbackImpl(org.jbpm.services.task.identity.JBossUserGroupCallbackImpl) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) Properties(java.util.Properties) UserGroupCallback(org.kie.api.task.UserGroupCallback) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Test(org.junit.Test)

Example 4 with UserGroupCallback

use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.

the class LDAPUserGroupCallbackImplTest method testGroupsOneLevelScopeEngContext.

@Test
public void testGroupsOneLevelScopeEngContext() {
    UserGroupCallback ldapUserGroupCallback = createLdapUserGroupCallbackWithRoleCtx(SearchScope.ONELEVEL_SCOPE, "ou=ENG,ou=Roles,dc=jbpm,dc=org");
    assertGroups(ldapUserGroupCallback, false, false, true, false);
}
Also used : UserGroupCallback(org.kie.api.task.UserGroupCallback) Test(org.junit.Test)

Example 5 with UserGroupCallback

use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.

the class LDAPUserGroupCallbackImplTest method testGroupsSubtreeScopeRolesContext.

@Test
public void testGroupsSubtreeScopeRolesContext() {
    UserGroupCallback ldapUserGroupCallback = createLdapUserGroupCallbackWithRoleCtx(SearchScope.SUBTREE_SCOPE, "ou=Roles,dc=jbpm,dc=org");
    assertGroups(ldapUserGroupCallback, true, true, true, true);
}
Also used : UserGroupCallback(org.kie.api.task.UserGroupCallback) Test(org.junit.Test)

Aggregations

UserGroupCallback (org.kie.api.task.UserGroupCallback)47 Test (org.junit.Test)41 Properties (java.util.Properties)10 ArrayList (java.util.ArrayList)8 JBossUserGroupCallbackImpl (org.jbpm.services.task.identity.JBossUserGroupCallbackImpl)8 HashMap (java.util.HashMap)7 KieSession (org.kie.api.runtime.KieSession)6 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)6 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)6 WorkflowProcessInstance (org.jbpm.workflow.instance.WorkflowProcessInstance)5 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)5 List (java.util.List)4 Status (org.kie.api.task.model.Status)4 TaskSummary (org.kie.api.task.model.TaskSummary)4 UserTransaction (javax.transaction.UserTransaction)3 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)3 DefaultProcessEventListener (org.kie.api.event.process.DefaultProcessEventListener)3 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)3 ProcessNodeLeftEvent (org.kie.api.event.process.ProcessNodeLeftEvent)3 SessionNotFoundException (org.kie.internal.runtime.manager.SessionNotFoundException)3