Search in sources :

Example 56 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class DeploymentServiceWithSyncTest method testDeploymentOfProcessesBySync.

@Test
public void testDeploymentOfProcessesBySync() throws Exception {
    CoundDownDeploymentListener countDownListener = configureListener(1, true, false, false, false);
    Collection<DeployedUnit> deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(0, deployed.size());
    KModuleDeploymentUnit unit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    store.enableDeploymentUnit(unit);
    units.add(unit);
    countDownListener.waitTillCompleted(10000);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(1, deployed.size());
}
Also used : CoundDownDeploymentListener(org.jbpm.kie.services.test.objects.CoundDownDeploymentListener) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 57 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class DeploymentServiceWithSyncTest method testUndeploymentOfProcessesBySync.

@Test
public void testUndeploymentOfProcessesBySync() throws Exception {
    CoundDownDeploymentListener countDownListener = configureListener(1, false, true, false, false);
    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());
    countDownListener.waitTillCompleted(1000);
    store.disableDeploymentUnit(unit);
    countDownListener.waitTillCompleted(10000);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(0, deployed.size());
}
Also used : CoundDownDeploymentListener(org.jbpm.kie.services.test.objects.CoundDownDeploymentListener) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 58 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class DeploymentStore method getEnabledDeploymentUnits.

public Collection<DeploymentUnit> getEnabledDeploymentUnits() {
    List<DeploymentUnit> activeDeployments = new ArrayList<DeploymentUnit>();
    Map<String, Object> params = new HashMap<String, Object>();
    List<Integer> states = new ArrayList<Integer>();
    states.add(STATE_ENABLED);
    states.add(STATE_ACTIVATED);
    states.add(STATE_DEACTIVATED);
    params.put("state", states);
    List<DeploymentStoreEntry> deployments = commandService.execute(new QueryNameCommand<List<DeploymentStoreEntry>>("getDeploymentUnitsByState", params));
    for (DeploymentStoreEntry entry : deployments) {
        String sync = getEntryAttributes(entry.getAttributes()).get("sync");
        // add to the deployable list only sync flag is set to true or does not exists (default)
        if (sync == null || sync.equalsIgnoreCase("true")) {
            DeploymentUnit unit = (DeploymentUnit) xstream.fromXML(entry.getDeploymentUnit());
            if (entry.getState() == STATE_DEACTIVATED) {
                ((KModuleDeploymentUnit) unit).setActive(false);
            }
            activeDeployments.add(unit);
        }
    }
    return activeDeployments;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) ArrayList(java.util.ArrayList) List(java.util.List) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit)

Example 59 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class DeploymentStore method getDeploymentUnitsByDate.

public void getDeploymentUnitsByDate(Date date, Collection<DeploymentUnit> enabled, Collection<DeploymentUnit> disabled, Collection<DeploymentUnit> activated, Collection<DeploymentUnit> deactivated) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("ludate", date);
    List<DeploymentStoreEntry> deployments = commandService.execute(new QueryNameCommand<List<DeploymentStoreEntry>>("getDeploymentUnitsByDate", params));
    for (DeploymentStoreEntry entry : deployments) {
        String sync = getEntryAttributes(entry.getAttributes()).get("sync");
        // add to the deployable list only sync flag is set to true or does not exists (default)
        if (sync == null || sync.equalsIgnoreCase("true")) {
            DeploymentUnit unit = (DeploymentUnit) xstream.fromXML(entry.getDeploymentUnit());
            if (entry.getState() == STATE_ENABLED) {
                enabled.add(unit);
            } else if (entry.getState() == STATE_DISABLED) {
                disabled.add(unit);
            } else if (entry.getState() == STATE_ACTIVATED) {
                activated.add(unit);
            } else if (entry.getState() == STATE_DEACTIVATED) {
                ((KModuleDeploymentUnit) unit).setActive(false);
                deactivated.add(unit);
            } else {
                logger.warn("Unknown state of deployment store entry {} for {} will be ignored", entry.getId(), entry);
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit)

Example 60 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class ProcessServiceEJBIntegrationTest method testStartProcess.

@Test
public void testStartProcess() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    assertNotNull(processService);
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "customtask");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(processInstanceId);
    assertNull(pi);
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Test(org.junit.Test)

Aggregations

KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)170 Test (org.junit.Test)131 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)97 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)83 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)55 HashMap (java.util.HashMap)46 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)42 ArrayList (java.util.ArrayList)34 QueryContext (org.kie.api.runtime.query.QueryContext)34 ReleaseId (org.kie.api.builder.ReleaseId)29 KieServices (org.kie.api.KieServices)26 File (java.io.File)22 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)22 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)21 DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)19 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)19 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)19 Before (org.junit.Before)18 FileOutputStream (java.io.FileOutputStream)17 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)17