Search in sources :

Example 1 with RuntimeEngine

use of org.kie.api.runtime.manager.RuntimeEngine in project camel by apache.

the class JBPMEndpoint method createProducer.

public Producer createProducer() throws Exception {
    RemoteRestRuntimeEngineBuilder engineBuilder = RemoteRuntimeEngineFactory.newRestBuilder();
    if (configuration.getUserName() != null) {
        engineBuilder.addUserName(configuration.getUserName());
    }
    if (configuration.getPassword() != null) {
        engineBuilder.addPassword(configuration.getPassword());
    }
    if (configuration.getDeploymentId() != null) {
        engineBuilder.addDeploymentId(configuration.getDeploymentId());
    }
    if (configuration.getConnectionURL() != null) {
        engineBuilder.addUrl(configuration.getConnectionURL());
    }
    if (configuration.getProcessInstanceId() != null) {
        engineBuilder.addProcessInstanceId(configuration.getProcessInstanceId());
    }
    if (configuration.getTimeout() != null) {
        engineBuilder.addTimeout(configuration.getTimeout());
    }
    if (configuration.getExtraJaxbClasses() != null) {
        engineBuilder.addExtraJaxbClasses(configuration.getExtraJaxbClasses());
    }
    RuntimeEngine runtimeEngine = engineBuilder.build();
    return new JBPMProducer(this, runtimeEngine);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RemoteRestRuntimeEngineBuilder(org.kie.remote.client.api.RemoteRestRuntimeEngineBuilder)

Example 2 with RuntimeEngine

use of org.kie.api.runtime.manager.RuntimeEngine in project jbpm by kiegroup.

the class DefaultChecklistManager method selectOptionalTask.

public void selectOptionalTask(String taskName, long processInstanceId) {
    RuntimeEngine runtime = getRuntime();
    runtime.getKieSession().signalEvent(taskName, null, processInstanceId);
    manager.disposeRuntimeEngine(runtime);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine)

Example 3 with RuntimeEngine

use of org.kie.api.runtime.manager.RuntimeEngine in project jbpm by kiegroup.

the class DefaultChecklistManager method addTask.

public ChecklistItem addTask(String userId, String[] actorIds, String[] groupIds, String name, String orderingId, long processInstanceId) {
    RuntimeEngine runtime = getRuntime();
    InternalTask task = (InternalTask) TaskModelProvider.getFactory().newTask();
    ;
    setTaskName(task, name);
    setTaskDescription(task, orderingId);
    // task.setPriority(priority);
    InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
    taskData.setProcessInstanceId(processInstanceId);
    // taskData.setProcessSessionId(sessionId);
    taskData.setSkipable(false);
    taskData.setDeploymentId("default-singleton");
    User cuser = TaskModelProvider.getFactory().newUser();
    ((InternalOrganizationalEntity) cuser).setId(userId);
    taskData.setCreatedBy(cuser);
    task.setTaskData(taskData);
    InternalPeopleAssignments peopleAssignments = (InternalPeopleAssignments) task.getPeopleAssignments();
    if (peopleAssignments == null) {
        peopleAssignments = (InternalPeopleAssignments) TaskModelProvider.getFactory().newPeopleAssignments();
        peopleAssignments.setPotentialOwners(new ArrayList<OrganizationalEntity>());
        peopleAssignments.setBusinessAdministrators(new ArrayList<OrganizationalEntity>());
        peopleAssignments.setExcludedOwners(new ArrayList<OrganizationalEntity>());
        peopleAssignments.setRecipients(new ArrayList<OrganizationalEntity>());
        peopleAssignments.setTaskStakeholders(new ArrayList<OrganizationalEntity>());
        task.setPeopleAssignments(peopleAssignments);
    }
    List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
    for (String actorId : actorIds) {
        User user = TaskModelProvider.getFactory().newUser();
        ((InternalOrganizationalEntity) user).setId(actorId);
        potentialOwners.add(user);
    }
    for (String groupId : groupIds) {
        Group group = TaskModelProvider.getFactory().newGroup();
        ((InternalOrganizationalEntity) group).setId(groupId);
        potentialOwners.add(group);
    }
    setTaskPotentialOwners(task, potentialOwners);
    List<OrganizationalEntity> businessAdministrators = peopleAssignments.getBusinessAdministrators();
    User administrator = TaskModelProvider.getFactory().newUser();
    ((InternalOrganizationalEntity) administrator).setId("Administrator");
    businessAdministrators.add(administrator);
    TaskService taskService = runtime.getTaskService();
    long taskId = taskService.addTask(task, (Map<String, Object>) null);
    manager.disposeRuntimeEngine(runtime);
    return ChecklistItemFactory.createChecklistItem(taskService.getTaskById(taskId));
}
Also used : Group(org.kie.api.task.model.Group) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) InternalTask(org.kie.internal.task.api.model.InternalTask) InternalTaskService(org.kie.internal.task.api.InternalTaskService) TaskService(org.kie.api.task.TaskService) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) ArrayList(java.util.ArrayList) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments)

Example 4 with RuntimeEngine

use of org.kie.api.runtime.manager.RuntimeEngine in project jbpm by kiegroup.

the class DefaultChecklistManager method updateTaskDescription.

public void updateTaskDescription(long taskId, String description) {
    RuntimeEngine runtime = getRuntime();
    List<I18NText> descriptions = new ArrayList<I18NText>();
    I18NText text = TaskModelProvider.getFactory().newI18NText();
    ((InternalI18NText) text).setLanguage("en-UK");
    ((InternalI18NText) text).setText(description);
    descriptions.add(text);
    ((InternalTaskService) runtime.getTaskService()).setDescriptions(taskId, descriptions);
    manager.disposeRuntimeEngine(runtime);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) ArrayList(java.util.ArrayList) InternalTaskService(org.kie.internal.task.api.InternalTaskService)

Example 5 with RuntimeEngine

use of org.kie.api.runtime.manager.RuntimeEngine in project jbpm by kiegroup.

the class DefaultChecklistManager method completeTask.

public void completeTask(String userId, long taskId) {
    RuntimeEngine runtime = getRuntime();
    runtime.getTaskService().start(taskId, userId);
    runtime.getTaskService().complete(taskId, userId, null);
    manager.disposeRuntimeEngine(runtime);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine)

Aggregations

RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)388 Test (org.junit.Test)269 KieSession (org.kie.api.runtime.KieSession)265 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)229 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)149 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)116 TaskService (org.kie.api.task.TaskService)111 HashMap (java.util.HashMap)110 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)105 TaskSummary (org.kie.api.task.model.TaskSummary)86 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)82 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)67 ArrayList (java.util.ArrayList)59 InternalTaskService (org.kie.internal.task.api.InternalTaskService)59 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)58 AbstractExecutorBaseTest (org.jbpm.test.util.AbstractExecutorBaseTest)49 DefaultRegisterableItemsFactory (org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory)43 WorkItemHandler (org.kie.api.runtime.process.WorkItemHandler)40 UserTaskService (org.jbpm.services.api.UserTaskService)36 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)34