Search in sources :

Example 91 with DeploymentUnit

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

the class DeploymentSynchronizer method onDeploy.

@Override
public void onDeploy(DeploymentEvent event) {
    if (event == null || event.getDeployedUnit() == null) {
        return;
    }
    DeploymentUnit unit = event.getDeployedUnit().getDeploymentUnit();
    if (!entries.containsKey(unit.getIdentifier()) && event.getDeployedUnit().isActive()) {
        try {
            deploymentStore.enableDeploymentUnit(unit);
            // when successfully stored add it to local store
            entries.put(unit.getIdentifier(), unit);
            logger.info("Deployment unit {} stored successfully", unit.getIdentifier());
        } catch (Exception e) {
            if (isCausedByConstraintViolation(e)) {
                logger.info("Deployment {} already stored in deployment store", unit);
            } else {
                logger.error("Unable to store deployment {} in deployment store due to {}", unit, e.getMessage());
            }
        }
    }
}
Also used : DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException)

Example 92 with DeploymentUnit

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

the class DeploymentStoreTest method testEnableAndGetAndDisableActiveDeployments.

@Test
public void testEnableAndGetAndDisableActiveDeployments() {
    Collection<DeploymentUnit> enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(0, enabled.size());
    KModuleDeploymentUnit unit = new KModuleDeploymentUnit("org.jbpm", "test", "1.0");
    store.enableDeploymentUnit(unit);
    enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(1, enabled.size());
    store.disableDeploymentUnit(unit);
    enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(0, enabled.size());
}
Also used : KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 93 with DeploymentUnit

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

the class DeploymentStoreTest method testEnableAndGetByDateActiveDeployments.

@Test
public void testEnableAndGetByDateActiveDeployments() {
    Collection<DeploymentUnit> enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(0, enabled.size());
    Date date = new Date();
    KModuleDeploymentUnit unit = new KModuleDeploymentUnit("org.jbpm", "test", "1.0");
    store.enableDeploymentUnit(unit);
    unit = new KModuleDeploymentUnit("org.jbpm", "prod", "1.0");
    store.enableDeploymentUnit(unit);
    Collection<DeploymentUnit> unitsEnabled = new HashSet<DeploymentUnit>();
    Collection<DeploymentUnit> unitsDisabled = new HashSet<DeploymentUnit>();
    Collection<DeploymentUnit> unitsActivated = new HashSet<DeploymentUnit>();
    Collection<DeploymentUnit> unitsDeactivated = new HashSet<DeploymentUnit>();
    store.getDeploymentUnitsByDate(date, unitsEnabled, unitsDisabled, unitsActivated, unitsDeactivated);
    assertNotNull(unitsEnabled);
    assertEquals(2, unitsEnabled.size());
    assertNotNull(unitsDisabled);
    assertEquals(0, unitsDisabled.size());
    date = new Date();
    store.disableDeploymentUnit(unit);
    // verify
    unitsEnabled.clear();
    unitsDisabled.clear();
    unitsActivated.clear();
    unitsDeactivated.clear();
    store.getDeploymentUnitsByDate(date, unitsEnabled, unitsDisabled, unitsActivated, unitsDeactivated);
    assertNotNull(unitsEnabled);
    assertEquals(0, unitsEnabled.size());
    assertNotNull(unitsDisabled);
    assertEquals(1, unitsDisabled.size());
}
Also used : KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) Date(java.util.Date) HashSet(java.util.HashSet) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 94 with DeploymentUnit

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

the class ClientEjbTimerServiceTest method cleanup.

@After
public void cleanup() {
    if (processInstanceId != null) {
        // let's abort process instance to leave the system in clear state
        processService.abortProcessInstance(processInstanceId);
    }
    cleanupSingletonSessionId();
    if (units != null && !units.isEmpty()) {
        for (DeploymentUnit unit : units) {
            deploymentService.undeploy(unit);
        }
        units.clear();
    }
    close();
}
Also used : DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) After(org.junit.After)

Example 95 with DeploymentUnit

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

the class SupportProcessBaseTest method testSupportProcess.

@Test
public void testSupportProcess() {
    DeploymentUnit deploymentUnitSupport = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnitSupport);
    units.add(deploymentUnitSupport);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("customer", "polymita");
    RuntimeManager managerSupport = deploymentService.getRuntimeManager(deploymentUnitSupport.getIdentifier());
    assertNotNull(managerSupport);
    int currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
    assertEquals(0, currentNumberOfEvents);
    RuntimeEngine engine = managerSupport.getRuntimeEngine(EmptyContext.get());
    assertNotNull(engine);
    ProcessInstance pI = engine.getKieSession().startProcess("support.process", params);
    assertNotNull(pI);
    TaskService taskService = engine.getTaskService();
    currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
    assertEquals(2, currentNumberOfEvents);
    // Configure Release
    List<TaskSummary> tasksAssignedToSalaboy = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
    assertEquals(1, tasksAssignedToSalaboy.size());
    assertEquals("Create Support", tasksAssignedToSalaboy.get(0).getName());
    TaskSummary createSupportTask = tasksAssignedToSalaboy.get(0);
    taskService.start(createSupportTask.getId(), "salaboy");
    currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
    assertEquals(4, currentNumberOfEvents);
    Map<String, Object> taskContent = ((InternalTaskService) taskService).getTaskContent(createSupportTask.getId());
    assertEquals("polymita", taskContent.get("input_customer"));
    Map<String, String> taskOutputMappings = bpmn2Service.getTaskOutputMappings(deploymentUnitSupport.getIdentifier(), "support.process", createSupportTask.getName());
    assertEquals(1, taskOutputMappings.size());
    assertEquals("output_customer", taskOutputMappings.keySet().iterator().next());
    Map<String, Object> output = new HashMap<String, Object>();
    output.put("output_customer", "polymita/redhat");
    taskService.complete(createSupportTask.getId(), "salaboy", output);
    currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
    assertEquals(8, currentNumberOfEvents);
    tasksAssignedToSalaboy = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
    assertEquals(1, tasksAssignedToSalaboy.size());
    assertEquals("Resolve Support", tasksAssignedToSalaboy.get(0).getName());
    TaskSummary resolveSupportTask = tasksAssignedToSalaboy.get(0);
    taskService.start(resolveSupportTask.getId(), "salaboy");
    currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
    assertEquals(10, currentNumberOfEvents);
    taskService.complete(resolveSupportTask.getId(), "salaboy", null);
    currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
    assertEquals(14, currentNumberOfEvents);
    tasksAssignedToSalaboy = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
    assertEquals(1, tasksAssignedToSalaboy.size());
    assertEquals("Notify Customer", tasksAssignedToSalaboy.get(0).getName());
    TaskSummary notifySupportTask = tasksAssignedToSalaboy.get(0);
    taskService.start(notifySupportTask.getId(), "salaboy");
    currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
    assertEquals(16, currentNumberOfEvents);
    output = new HashMap<String, Object>();
    output.put("output_solution", "solved today");
    taskService.complete(notifySupportTask.getId(), "salaboy", output);
    currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
    assertEquals(18, currentNumberOfEvents);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) HashMap(java.util.HashMap) InternalTaskService(org.kie.internal.task.api.InternalTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalTaskService(org.kie.internal.task.api.InternalTaskService) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)104 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)88 Test (org.junit.Test)53 After (org.junit.After)35 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)34 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)28 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)25 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)19 HashMap (java.util.HashMap)16 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)15 ArrayList (java.util.ArrayList)14 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)13 QueryContext (org.kie.api.runtime.query.QueryContext)13 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)12 KieServices (org.kie.api.KieServices)10 ReleaseId (org.kie.api.builder.ReleaseId)10 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)9 AbstractEJBServicesTest (org.jbpm.test.container.AbstractEJBServicesTest)8 Collection (java.util.Collection)6 DeployedUnitImpl (org.jbpm.kie.services.impl.DeployedUnitImpl)6