Search in sources :

Example 66 with DeployedUnit

use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.

the class ProcessServiceImpl method setProcessVariables.

@Override
public void setProcessVariables(String deploymentId, Long processInstanceId, Map<String, Object> variables) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    variables = process(variables, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
    try {
        KieSession ksession = engine.getKieSession();
        ProcessInstance pi = ksession.getProcessInstance(processInstanceId);
        if (pi == null) {
            throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found");
        }
        ksession.execute(new SetProcessInstanceVariablesCommand(processInstanceId, variables));
    } catch (SessionNotFoundException e) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) SetProcessInstanceVariablesCommand(org.drools.core.command.runtime.process.SetProcessInstanceVariablesCommand) KieSession(org.kie.api.runtime.KieSession) RuleFlowProcessInstance(org.jbpm.ruleflow.instance.RuleFlowProcessInstance) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException)

Example 67 with DeployedUnit

use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.

the class FormProviderServiceImpl method getMarshallerContext.

protected ContentMarshallerContext getMarshallerContext(String deploymentId, String processId) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        return new ContentMarshallerContext();
    }
    InternalRuntimeManager manager = (InternalRuntimeManager) deployedUnit.getRuntimeManager();
    return new ContentMarshallerContext(manager.getEnvironment().getEnvironment(), manager.getEnvironment().getClassLoader());
}
Also used : InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) ContentMarshallerContext(org.kie.internal.task.api.ContentMarshallerContext)

Example 68 with DeployedUnit

use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.

the class DeploymentServiceEJBIntegrationTest method testDeploymentOfMultipleVersions.

@Test
public void testDeploymentOfMultipleVersions() {
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    DeploymentUnit deploymentUnit3 = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, "1.1.0-SNAPSHOT");
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    deploymentService.deploy(deploymentUnit3);
    units.add(deploymentUnit3);
    DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertEquals(0, ((DeployedUnitImpl) deployed).getDeployedClasses().size());
    DeployedUnit deployed3 = deploymentService.getDeployedUnit(deploymentUnit3.getIdentifier());
    assertNotNull(deployed3);
    assertNotNull(deployed3.getDeploymentUnit());
    assertNotNull(deployed3.getRuntimeManager());
    assertEquals(0, ((DeployedUnitImpl) deployed3).getDeployedClasses().size());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(10, processes.size());
    DeployedUnit deployedLatest = deploymentService.getDeployedUnit(GROUP_ID + ":" + ARTIFACT_ID + ":LATEST");
    assertNotNull(deployedLatest);
    assertNotNull(deployedLatest.getDeploymentUnit());
    assertNotNull(deployedLatest.getRuntimeManager());
    assertEquals(deploymentUnit3.getIdentifier(), deployedLatest.getDeploymentUnit().getIdentifier());
}
Also used : DeployedUnit(org.jbpm.services.api.model.DeployedUnit) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeployedUnitImpl(org.jbpm.kie.services.impl.DeployedUnitImpl) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Test(org.junit.Test)

Example 69 with DeployedUnit

use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.

the class DeploymentServiceEJBWithSyncIntegrationTest method testDeactivateAndActivateOfProcessesBySync.

@Test
public void testDeactivateAndActivateOfProcessesBySync() throws Exception {
    CoundDownDeploymentListener countDownListener = configureListener(2);
    DeploymentStore store = new DeploymentStore();
    store.setCommandService(commandService);
    Collection<DeployedUnit> deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(0, deployed.size());
    KModuleDeploymentUnit unit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(unit);
    units.add(unit);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(1, deployed.size());
    assertTrue(deployed.iterator().next().isActive());
    store.deactivateDeploymentUnit(unit);
    countDownListener.waitTillCompleted(10000);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(1, deployed.size());
    assertFalse(deployed.iterator().next().isActive());
    store.activateDeploymentUnit(unit);
    countDownListener.reset(1);
    countDownListener.waitTillCompleted(10000);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(1, deployed.size());
    assertTrue(deployed.iterator().next().isActive());
}
Also used : DeploymentStore(org.jbpm.kie.services.impl.store.DeploymentStore) CoundDownDeploymentListener(org.jbpm.kie.services.test.objects.CoundDownDeploymentListener) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Test(org.junit.Test)

Aggregations

DeployedUnit (org.jbpm.services.api.model.DeployedUnit)69 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)42 Test (org.junit.Test)41 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)38 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)37 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)32 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)30 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)28 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)20 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)19 QueryContext (org.kie.api.runtime.query.QueryContext)19 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)18 KieSession (org.kie.api.runtime.KieSession)17 HashMap (java.util.HashMap)16 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)13 SessionNotFoundException (org.kie.internal.runtime.manager.SessionNotFoundException)13 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)10 ArrayList (java.util.ArrayList)8 CoundDownDeploymentListener (org.jbpm.kie.services.test.objects.CoundDownDeploymentListener)8 File (java.io.File)7