Search in sources :

Example 1 with ProcessDefinition

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

the class RuntimeDataServiceImpl method getProcessIds.

@Override
public Collection<String> getProcessIds(String deploymentId, QueryContext queryContext) {
    deploymentId = getLatestDeploymentId(requireNonNull(deploymentId, DEPLOYMENT_ID_MUST_NOT_BE_NULL));
    List<String> processIds = new ArrayList<String>(availableProcesses.size());
    if (deploymentId == null || deploymentId.isEmpty()) {
        return processIds;
    }
    for (ProcessDefinition procAssetDesc : availableProcesses) {
        if (((ProcessAssetDesc) procAssetDesc).getDeploymentId().equals(deploymentId) && ((ProcessAssetDesc) procAssetDesc).isActive()) {
            processIds.add(procAssetDesc.getId());
        }
    }
    return applyPaginition(processIds, queryContext);
}
Also used : ProcessAssetDesc(org.jbpm.kie.services.impl.model.ProcessAssetDesc) ArrayList(java.util.ArrayList) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition)

Example 2 with ProcessDefinition

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

the class CaseRuntimeDataServiceImplTest method testGetProcessDefinitions.

@Test
public void testGetProcessDefinitions() {
    Collection<ProcessDefinition> processes = caseRuntimeDataService.getProcessDefinitions(new QueryContext());
    assertNotNull(processes);
    assertEquals(2, processes.size());
    Map<String, ProcessDefinition> mappedProcesses = mapProcesses(processes);
    assertTrue(mappedProcesses.containsKey("UserTask"));
    assertTrue(mappedProcesses.containsKey("DataVerification"));
    processes = caseRuntimeDataService.getProcessDefinitions("User", new QueryContext());
    assertNotNull(processes);
    assertEquals(1, processes.size());
    mappedProcesses = mapProcesses(processes);
    assertTrue(mappedProcesses.containsKey("UserTask"));
    processes = caseRuntimeDataService.getProcessDefinitionsByDeployment(deploymentUnit.getIdentifier(), new QueryContext());
    assertNotNull(processes);
    assertEquals(2, processes.size());
    mappedProcesses = mapProcesses(processes);
    assertTrue(mappedProcesses.containsKey("UserTask"));
    assertTrue(mappedProcesses.containsKey("DataVerification"));
}
Also used : ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 3 with ProcessDefinition

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

the class EDefinitionTest method testBuildProcessDefinition.

@Test
public void testBuildProcessDefinition() {
    String deploymentId = "org.jboss.bpms.qa:ejb-services-single:1.0-SNAPSHOT";
    String bpmn2Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <bpmn2:definitions xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.omg.org/bpmn20\" xmlns:bpmn2=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\" xmlns:bpsim=\"http://www.bpsim.org/schemas/1.0\" xmlns:dc=\"http://www.omg.org/spec/DD/20100524/DC\" xmlns:di=\"http://www.omg.org/spec/DD/20100524/DI\" xmlns:drools=\"http://www.jboss.org/drools\" id=\"_IN4SENQhEeKMjMb8Niyi_Q\" xsi:schemaLocation=\"http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd\" expressionLanguage=\"http://www.mvel.org/2.0\" targetNamespace=\"http://www.omg.org/bpmn20\" typeLanguage=\"http://www.java.com/javaTypes\">   <bpmn2:process id=\"org.jboss.qa.bpms.ScriptTask\" drools:version=\"1.0\" drools:packageName=\"defaultPackage\" name=\"ScriptTask\" isExecutable=\"true\">     <bpmn2:startEvent id=\"_A3185DDF-23A7-48B7-A2FE-7C0FE39F6691\" drools:bgcolor=\"#9acd32\" drools:selectable=\"true\" name=\"\">       <bpmn2:outgoing>_DA0951B7-5BC8-49AE-9E35-AA855177BBB6</bpmn2:outgoing>     </bpmn2:startEvent>     <bpmn2:scriptTask id=\"_3C8F4385-5348-479C-83EE-0C2DC2004F1A\" drools:selectable=\"true\" name=\"Script Task\" scriptFormat=\"http://www.java.com/java\">       <bpmn2:incoming>_DA0951B7-5BC8-49AE-9E35-AA855177BBB6</bpmn2:incoming>       <bpmn2:outgoing>_6BF9DBC4-39E3-48DF-ABBC-896E9E534ECC</bpmn2:outgoing>       <bpmn2:script><![CDATA[System.out.println(\"Hello World!!!\");]]></bpmn2:script>     </bpmn2:scriptTask>     <bpmn2:sequenceFlow id=\"_DA0951B7-5BC8-49AE-9E35-AA855177BBB6\" drools:bgcolor=\"#000000\" drools:selectable=\"true\" sourceRef=\"_A3185DDF-23A7-48B7-A2FE-7C0FE39F6691\" targetRef=\"_3C8F4385-5348-479C-83EE-0C2DC2004F1A\"/>     <bpmn2:endEvent id=\"_DC07735C-FA99-414C-AEAC-9F4CE0CF24F9\" drools:bgcolor=\"#ff6347\" drools:selectable=\"true\" name=\"\">       <bpmn2:incoming>_6BF9DBC4-39E3-48DF-ABBC-896E9E534ECC</bpmn2:incoming>     </bpmn2:endEvent>     <bpmn2:sequenceFlow id=\"_6BF9DBC4-39E3-48DF-ABBC-896E9E534ECC\" drools:bgcolor=\"#000000\" drools:selectable=\"true\" sourceRef=\"_3C8F4385-5348-479C-83EE-0C2DC2004F1A\" targetRef=\"_DC07735C-FA99-414C-AEAC-9F4CE0CF24F9\"/>   </bpmn2:process>   <bpmndi:BPMNDiagram id=\"_IN4SEdQhEeKMjMb8Niyi_Q\">     <bpmndi:BPMNPlane id=\"_IN45INQhEeKMjMb8Niyi_Q\" bpmnElement=\"org.jboss.qa.bpms.ScriptTask\">       <bpmndi:BPMNShape id=\"_IN45IdQhEeKMjMb8Niyi_Q\" bpmnElement=\"_A3185DDF-23A7-48B7-A2FE-7C0FE39F6691\">         <dc:Bounds height=\"30.0\" width=\"30.0\" x=\"122.0\" y=\"178.0\"/>       </bpmndi:BPMNShape>       <bpmndi:BPMNShape id=\"_IN45ItQhEeKMjMb8Niyi_Q\" bpmnElement=\"_3C8F4385-5348-479C-83EE-0C2DC2004F1A\">         <dc:Bounds height=\"80.0\" width=\"100.0\" x=\"180.0\" y=\"153.0\"/>       </bpmndi:BPMNShape>       <bpmndi:BPMNEdge id=\"_IN45I9QhEeKMjMb8Niyi_Q\" bpmnElement=\"_DA0951B7-5BC8-49AE-9E35-AA855177BBB6\">         <di:waypoint xsi:type=\"dc:Point\" x=\"137.0\" y=\"193.0\"/>         <di:waypoint xsi:type=\"dc:Point\" x=\"230.0\" y=\"193.0\"/>       </bpmndi:BPMNEdge>       <bpmndi:BPMNShape id=\"_IN45JNQhEeKMjMb8Niyi_Q\" bpmnElement=\"_DC07735C-FA99-414C-AEAC-9F4CE0CF24F9\">         <dc:Bounds height=\"28.0\" width=\"28.0\" x=\"320.0\" y=\"178.0\"/>       </bpmndi:BPMNShape>       <bpmndi:BPMNEdge id=\"_IN45JdQhEeKMjMb8Niyi_Q\" bpmnElement=\"_6BF9DBC4-39E3-48DF-ABBC-896E9E534ECC\">         <di:waypoint xsi:type=\"dc:Point\" x=\"230.0\" y=\"193.0\"/>         <di:waypoint xsi:type=\"dc:Point\" x=\"334.0\" y=\"192.0\"/>       </bpmndi:BPMNEdge>     </bpmndi:BPMNPlane>   </bpmndi:BPMNDiagram>   <bpmn2:relationship id=\"_IN45JtQhEeKMjMb8Niyi_Q\" type=\"BPSimData\">     <bpmn2:extensionElements>       <bpsim:BPSimData>         <bpsim:Scenario xsi:type=\"bpsim:Scenario\" id=\"default\" name=\"Simulationscenario\">           <bpsim:ScenarioParameters xsi:type=\"bpsim:ScenarioParameters\" baseTimeUnit=\"s\"/>           <bpsim:ElementParameters xsi:type=\"bpsim:ElementParameters\" elementRef=\"_3C8F4385-5348-479C-83EE-0C2DC2004F1A\" id=\"_IN45J9QhEeKMjMb8Niyi_Q\">             <bpsim:TimeParameters xsi:type=\"bpsim:TimeParameters\">               <bpsim:ProcessingTime xsi:type=\"bpsim:Parameter\">                 <bpsim:NormalDistribution mean=\"0.0\" standardDeviation=\"0.0\"/>               </bpsim:ProcessingTime>             </bpsim:TimeParameters>             <bpsim:CostParameters xsi:type=\"bpsim:CostParameters\">               <bpsim:UnitCost xsi:type=\"bpsim:Parameter\">                 <bpsim:FloatingParameter value=\"0.0\"/>               </bpsim:UnitCost>             </bpsim:CostParameters>           </bpsim:ElementParameters>           <bpsim:ElementParameters xsi:type=\"bpsim:ElementParameters\" elementRef=\"_6BF9DBC4-39E3-48DF-ABBC-896E9E534ECC\" id=\"_IN45KNQhEeKMjMb8Niyi_Q\">             <bpsim:ControlParameters xsi:type=\"bpsim:ControlParameters\">               <bpsim:Probability xsi:type=\"bpsim:Parameter\">                 <bpsim:FloatingParameter value=\"100.0\"/>               </bpsim:Probability>             </bpsim:ControlParameters>           </bpsim:ElementParameters>           <bpsim:ElementParameters xsi:type=\"bpsim:ElementParameters\" elementRef=\"_A3185DDF-23A7-48B7-A2FE-7C0FE39F6691\" id=\"_IN45KdQhEeKMjMb8Niyi_Q\">             <bpsim:TimeParameters xsi:type=\"bpsim:TimeParameters\">               <bpsim:WaitTime xsi:type=\"bpsim:Parameter\">                 <bpsim:FloatingParameter value=\"0.0\"/>               </bpsim:WaitTime>             </bpsim:TimeParameters>           </bpsim:ElementParameters>           <bpsim:ElementParameters xsi:type=\"bpsim:ElementParameters\" elementRef=\"_DC07735C-FA99-414C-AEAC-9F4CE0CF24F9\" id=\"_IN45KtQhEeKMjMb8Niyi_Q\">             <bpsim:TimeParameters xsi:type=\"bpsim:TimeParameters\">               <bpsim:ProcessingTime xsi:type=\"bpsim:Parameter\">                 <bpsim:NormalDistribution mean=\"0.0\" standardDeviation=\"0.0\"/>               </bpsim:ProcessingTime>             </bpsim:TimeParameters>           </bpsim:ElementParameters>           <bpsim:ElementParameters xsi:type=\"bpsim:ElementParameters\" elementRef=\"_DA0951B7-5BC8-49AE-9E35-AA855177BBB6\" id=\"_IN45K9QhEeKMjMb8Niyi_Q\">             <bpsim:ControlParameters xsi:type=\"bpsim:ControlParameters\">               <bpsim:Probability xsi:type=\"bpsim:Parameter\">                 <bpsim:FloatingParameter value=\"100.0\"/>               </bpsim:Probability>             </bpsim:ControlParameters>           </bpsim:ElementParameters>         </bpsim:Scenario>       </bpsim:BPSimData>     </bpmn2:extensionElements>     <bpmn2:source>_IN4SENQhEeKMjMb8Niyi_Q</bpmn2:source>     <bpmn2:target>_IN4SENQhEeKMjMb8Niyi_Q</bpmn2:target>   </bpmn2:relationship> </bpmn2:definitions>";
    ProcessDefinition pd = definitionService.buildProcessDefinition(deploymentId, bpmn2Content, KieServices.Factory.get().getKieClasspathContainer(this.getClass().getClassLoader()), false);
    Assertions.assertThat(pd).isNotNull();
    // value from process definition
    System.out.println(pd.getId());
    // value from process definition
    System.out.println(pd.getName());
    // PROCESS - always
    System.out.println(pd.getKnowledgeType());
    // Never called so far, maybe in future
    System.out.println(pd.getOriginalPath());
    // value from process definition
    System.out.println(pd.getPackageName());
    // RuleFlow always
    System.out.println(pd.getType());
    // value from process definition
    System.out.println(pd.getVersion());
    // all remaining are empty for this process
    System.out.println(pd.getAssociatedEntities());
    System.out.println(pd.getProcessVariables());
    System.out.println(pd.getReusableSubProcesses());
    System.out.println(pd.getServiceTasks());
    Assertions.assertThat(pd.getId()).isEqualTo("org.jboss.qa.bpms.ScriptTask");
    Assertions.assertThat(pd.getName()).isEqualTo("ScriptTask");
    Assertions.assertThat(pd.getKnowledgeType()).isEqualTo("PROCESS");
    Assertions.assertThat(pd.getOriginalPath()).isNull();
    Assertions.assertThat(pd.getPackageName()).isEqualTo("defaultPackage");
    Assertions.assertThat(pd.getType()).isEqualTo("RuleFlow");
    Assertions.assertThat(pd.getVersion()).isEqualTo("1.0");
    Assertions.assertThat(pd.getAssociatedEntities()).isEmpty();
    Assertions.assertThat(pd.getProcessVariables()).isEmpty();
    Assertions.assertThat(pd.getReusableSubProcesses()).isEmpty();
    Assertions.assertThat(pd.getServiceTasks()).isEmpty();
}
Also used : ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) Test(org.junit.Test) AbstractEJBServicesTest(org.jbpm.test.container.AbstractEJBServicesTest)

Example 4 with ProcessDefinition

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

the class EDefinitionTest method testGetProcessDefinition.

@Test
public void testGetProcessDefinition() {
    DeploymentUnit basicKieJar = archive.deployBasicKieJar();
    ProcessDefinition pd = definitionService.getProcessDefinition(basicKieJar.getIdentifier(), HUMAN_TASK_PROCESS_ID);
    Assertions.assertThat(pd).isNotNull();
    System.out.println(pd.getId());
    System.out.println(pd.getName());
    System.out.println(pd.getKnowledgeType());
    System.out.println(pd.getOriginalPath());
    System.out.println(pd.getPackageName());
    System.out.println(pd.getType());
    System.out.println(pd.getVersion());
    System.out.println(pd.getAssociatedEntities());
    System.out.println(pd.getProcessVariables());
    System.out.println(pd.getReusableSubProcesses());
    System.out.println(pd.getServiceTasks());
    Assertions.assertThat(pd.getId()).isNotNull().isEqualTo(HUMAN_TASK_PROCESS_ID);
    Assertions.assertThat(pd.getName()).isNotNull().isEqualTo("HumanTask");
    Assertions.assertThat(pd.getKnowledgeType()).isNotNull();
    // Assertions.assertThat(pd.getOriginalPath()).isNotNull(); // Related to asset deployment
    Assertions.assertThat(pd.getPackageName()).isNotNull();
    Assertions.assertThat(pd.getType()).isNotNull();
    Assertions.assertThat(pd.getVersion()).isNotNull();
    Assertions.assertThat(pd.getAssociatedEntities()).isNotNull();
    Assertions.assertThat(pd.getProcessVariables()).isNotNull();
    Assertions.assertThat(pd.getReusableSubProcesses()).isNotNull();
    Assertions.assertThat(pd.getServiceTasks()).isNotNull();
}
Also used : ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) Test(org.junit.Test) AbstractEJBServicesTest(org.jbpm.test.container.AbstractEJBServicesTest)

Example 5 with ProcessDefinition

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

the class EDeploymentTest method testDeploy.

@Test
public void testDeploy() throws Exception {
    DeploymentUnit basicKieJar = archive.deployBasicKieJar();
    DeployedUnit deployed = deploymentService.getDeployedUnit(basicKieJar.getIdentifier());
    Assertions.assertThat(deployed).isNotNull();
    Assertions.assertThat(deployed.getDeploymentUnit()).isNotNull();
    Assertions.assertThat(deployed.getDeploymentUnit()).isEqualTo(basicKieJar);
    Assertions.assertThat(deployed.getRuntimeManager()).isNotNull();
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    Assertions.assertThat(processes).isNotNull().isNotEmpty();
}
Also used : DeployedUnit(org.jbpm.services.api.model.DeployedUnit) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.internal.query.QueryContext) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) Test(org.junit.Test) AbstractEJBServicesTest(org.jbpm.test.container.AbstractEJBServicesTest)

Aggregations

ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)50 Test (org.junit.Test)44 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)29 QueryContext (org.kie.api.runtime.query.QueryContext)27 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)22 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)19 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)19 HashMap (java.util.HashMap)14 ArrayList (java.util.ArrayList)12 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)12 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)9 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)7 DeployedUnitImpl (org.jbpm.kie.services.impl.DeployedUnitImpl)6 OtherPerson (org.jbpm.kie.test.objects.OtherPerson)6 Person (org.jbpm.kie.test.objects.Person)6 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)6 KieSession (org.kie.api.runtime.KieSession)4 AbstractEJBServicesTest (org.jbpm.test.container.AbstractEJBServicesTest)3 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)3 File (java.io.File)2