String ksession = input.nextLine(); KModuleDeploymentUnit unit = new KModuleDeploymentUnit(groupId, artifactId, version, kbase, ksession); if (deploymentConfigService.getDeployment(unit.getIdentifier()) == null) { return "No deployment found with id " + unit.getIdentifier(); deploymentConfigService.removeDeployment(unit.getIdentifier()); result.append("Deployment " + unit.getIdentifier() + " has been successfully removed"); return result.toString();
private List<KModuleDeploymentUnitSummary> getDeployedUnits(final QueryFilter filter) { Collection<DeployedUnit> deployedUnits = deploymentService.getDeployedUnits(); List<KModuleDeploymentUnitSummary> unitsIds = new ArrayList<KModuleDeploymentUnitSummary>(deployedUnits.size()); for (DeployedUnit du : deployedUnits) { KModuleDeploymentUnit kdu = (KModuleDeploymentUnit) du.getDeploymentUnit(); KModuleDeploymentUnitSummary duSummary = new KModuleDeploymentUnitSummary(kdu.getIdentifier(), kdu.getGroupId(), kdu.getArtifactId(), kdu.getVersion(), kdu.getKbaseName(), kdu.getKsessionName(), kdu.getStrategy().toString(), kdu.getMergeMode().toString()); if(filter.getParams() == null || filter.getParams().get("textSearch") == null || ((String)filter.getParams().get("textSearch")).isEmpty()){ unitsIds.add(duSummary); }else if(kdu.getIdentifier().toLowerCase().contains((String)filter.getParams().get("textSearch"))){ unitsIds.add(duSummary); } duSummary.setActive(du.isActive()); } sort(unitsIds, filter); return unitsIds; }
unit.setKbaseName(kbaseNames.iterator().next()); unit.setKsessionName(ksessionNames.iterator().next()); unit.setStrategy(RuntimeStrategy.valueOf(runtimeStrategy)); unit.setMergeMode(MergeMode.valueOf(mergeMode)); unit.setKsessionName(ksession); String kbase = config.getConfigItemValue(KieServerConstants.PCFG_KIE_BASE); unit.setKbaseName(kbase); unit.setKieContainer(kieContainer); DeployedUnit deployedUnit = deploymentService.getDeployedUnit(unit.getIdentifier()); Set<Class<?>> customClasses = new HashSet<Class<?>>(deployedUnit.getDeployedClasses());
@Override public void deploy(DeploymentUnit unit) { KModuleDeploymentUnit kmoduleUnit = (KModuleDeploymentUnit) unit; remote.deploy(kmoduleUnit.getGroupId(), kmoduleUnit.getArtifactId(), kmoduleUnit.getVersion(), kmoduleUnit.getKbaseName(), kmoduleUnit.getKsessionName(), kmoduleUnit.getStrategy().toString()); }
private void testProcessWithStrategy(RuntimeStrategy strategy) { KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION); deploymentUnit.setStrategy(strategy); deploymentService.deploy(deploymentUnit); String userId = "john"; Long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "hiring"); List<Long> taskIdList = runtimeDataService.getTasksByProcessInstanceId(processInstanceId); Assertions.assertThat(taskIdList).hasSize(1); long taskId = taskIdList.get(0); userTaskService.claim(taskId, userId); userTaskService.start(taskId, userId); userTaskService.complete(taskId, userId, null); List<Status> taskStatus = new ArrayList<Status>(); taskStatus.add(Status.Completed); taskStatus.add(Status.Created); taskStatus.add(Status.InProgress); taskStatus.add(Status.Reserved); List<TaskSummary> taskSummaryList = runtimeDataService.getTasksByStatusByProcessInstanceId(processInstanceId, taskStatus, null); Assertions.assertThat(taskSummaryList).hasSize(1); processService.abortProcessInstance(processInstanceId); ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId); assertNotNull(pi); assertEquals(ProcessInstance.STATE_ABORTED, pi.getState().intValue()); }
KModuleDeploymentUnit kDepUnit = new KModuleDeploymentUnit("org", "jar", "1.0", "kbase", "ksession" ); kDepUnit.setStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE); JaxbDeploymentUnit depUnit = new JaxbDeploymentUnit(kDepUnit.getGroupId(), kDepUnit.getArtifactId(), kDepUnit.getArtifactId()); depUnit.setKbaseName(kDepUnit.getKbaseName()); depUnit.setKsessionName(kDepUnit.getKsessionName()); depUnit.setStrategy(kDepUnit.getStrategy()); depUnit.setStatus(JaxbDeploymentStatus.NONEXISTENT); depUnitList.getDeploymentUnitList().add(depUnit);
protected DeploymentUnit buildDeploymentUnit(String gav) { String[] elems = gav.split(":"); if (elems.length == 3) { return new KModuleDeploymentUnit(elems[0],elems[1],elems[2]); } else if (elems.length == 5) { return new KModuleDeploymentUnit(elems[0],elems[1],elems[2], elems[3], elems[4]); } else { logger.warn("Unknown deployment unit {}", gav); } return null; } }
@Test public void testGetProcessByDeploymentId() { Collection<ProcessDefinition> definitions = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext()); assertNotNull(definitions); assertEquals(3, definitions.size()); List<String> expectedProcessIds = new ArrayList<String>(); expectedProcessIds.add("org.jbpm.writedocument.empty"); expectedProcessIds.add("org.jbpm.writedocument"); expectedProcessIds.add("org.jboss.qa.bpms.HumanTask"); for (ProcessDefinition def : definitions) { assertTrue(expectedProcessIds.contains(def.getId())); } }
|| unitSummary.getId().contains("SNAPSHOT")){ if (unitSummary.getType().equals("kjar")) { unit = new KModuleDeploymentUnit(((KModuleDeploymentUnitSummary) unitSummary).getGroupId(), ((KModuleDeploymentUnitSummary) unitSummary).getArtifactId(), ((KModuleDeploymentUnitSummary) unitSummary).getVersion(), ((KModuleDeploymentUnitSummary) unitSummary).getKsessionName()); if (((KModuleDeploymentUnitSummary) unitSummary).getStrategy() != null) { ((KModuleDeploymentUnit)unit).setStrategy(RuntimeStrategy.valueOf(((KModuleDeploymentUnitSummary) unitSummary).getStrategy())); ((KModuleDeploymentUnit)unit).setMergeMode(MergeMode.valueOf(((KModuleDeploymentUnitSummary) unitSummary).getMergeMode()));
deploymentService.undeploy(new CustomIdKmoduleDeploymentUnit(id, unit.getGroupId(), unit.getArtifactId(), unit.getVersion()));
@Override protected RegisterableItemsFactory getRegisterableItemsFactory(AuditEventBuilder auditLoggerBuilder, KieContainer kieContainer, KModuleDeploymentUnit unit) { return InjectableRegisterableItemsFactory.getFactory(beanManager, auditLoggerBuilder, kieContainer, unit.getKsessionName()); } }
@SuppressWarnings("unchecked") @Override public void createContainer(String id, KieContainerInstance kieContainerInstance, Map<String, Object> parameters) { if (!initialized) { return; } List<Message> messages = (List<Message>) parameters.get(KieServerConstants.KIE_SERVER_PARAM_MESSAGES); try { DeployedUnit deployedUnit = deploymentService.getDeployedUnit(id); if(deployedUnit != null) { String kieBaseName = ((KModuleDeploymentUnit)deployedUnit.getDeploymentUnit()).getKbaseName(); KieContainer kieContainer = kieContainerInstance.getKieContainer(); imageReferences.putIfAbsent(id, new ImageReference(kieContainer, kieBaseName)); formRendererBase.indexDeploymentForms(id); } } catch (Exception e) { messages.add(new Message(Severity.WARN, "Unable to create image reference for container " + id +" by extension " + this + " due to " + e.getMessage())); logger.warn("Unable to create image reference for container {} due to {}", id, e.getMessage(), e); } }
private void testProcessWithStrategy(RuntimeStrategy strategy) { KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION); deploymentUnit.setStrategy(strategy); deploymentService.deploy(deploymentUnit); String userId = "john"; Long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "hiring"); List<Long> taskIdList = runtimeDataService.getTasksByProcessInstanceId(processInstanceId); Assertions.assertThat(taskIdList).hasSize(1); long taskId = taskIdList.get(0); userTaskService.claim(taskId, userId); userTaskService.start(taskId, userId); userTaskService.complete(taskId, userId, null); List<Status> taskStatus = new ArrayList<Status>(); taskStatus.add(Status.Completed); taskStatus.add(Status.Created); taskStatus.add(Status.InProgress); taskStatus.add(Status.Reserved); List<TaskSummary> taskSummaryList = runtimeDataService.getTasksByStatusByProcessInstanceId(processInstanceId, taskStatus, null); Assertions.assertThat(taskSummaryList).hasSize(1); processService.abortProcessInstance(processInstanceId); ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId); assertNotNull(pi); assertEquals(ProcessInstance.STATE_ABORTED, pi.getState().intValue()); }
KModuleDeploymentUnit kDepUnit = new KModuleDeploymentUnit("org", "jar", "1.0", "kbase", "ksession"); kDepUnit.setStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE); kDepUnit.getGroupId(), kDepUnit.getArtifactId(), kDepUnit.getArtifactId()); depUnit.setKbaseName(kDepUnit.getKbaseName()); depUnit.setKsessionName(kDepUnit.getKsessionName()); depUnit.setStrategy(kDepUnit.getStrategy()); depUnit.setStatus(JaxbDeploymentStatus.NONEXISTENT); depUnitList.getDeploymentUnitList().add(depUnit);
@RequestMapping(value="/deploy", method=RequestMethod.POST) public String deploy(@RequestParam("id")String id, @RequestParam(value="strategy", defaultValue="SINGLETON") String strategy) { String outcome = "Deployment " + id + " deployed successfully"; String[] gav = id.split(":"); KModuleDeploymentUnit unit = new KModuleDeploymentUnit(gav[0], gav[1], gav[2], null, null, strategy); deploymentService.deploy(unit); return outcome; }
@Test public void testGetProcessIds() { Collection<String> definitions = runtimeDataService.getProcessIds(deploymentUnit.getIdentifier(), new QueryContext()); assertNotNull(definitions); assertEquals(3, definitions.size()); assertTrue(definitions.contains("org.jbpm.writedocument.empty")); assertTrue(definitions.contains("org.jbpm.writedocument")); assertTrue(definitions.contains("org.jboss.qa.bpms.HumanTask")); }
@Override protected RegisterableItemsFactory getRegisterableItemsFactory(AuditEventBuilder auditLoggerBuilder, KieContainer kieContainer, KModuleDeploymentUnit unit) { SpringRegisterableItemsFactory factory = new SpringRegisterableItemsFactory(context, kieContainer, unit.getKsessionName()); factory.setAuditBuilder(auditLoggerBuilder); return factory; }
KModuleDeploymentUnit unit = new KModuleDeploymentUnit(groupId, artifactId, version, kbase, ksession, strategy); deploymentConfigService.addDeployment(unit.getIdentifier(), unit); result.append("Deployment " + unit.getIdentifier() + " has been successfully added"); return result.toString();
private void testProcessWithStrategy(RuntimeStrategy strategy) { KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION); deploymentUnit.setStrategy(strategy); deploymentService.deploy(deploymentUnit); String userId = "john"; Long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "hiring"); List<Long> taskIdList = runtimeDataService.getTasksByProcessInstanceId(processInstanceId); Assertions.assertThat(taskIdList).hasSize(1); long taskId = taskIdList.get(0); userTaskService.claim(taskId, userId); userTaskService.start(taskId, userId); userTaskService.complete(taskId, userId, null); List<Status> taskStatus = new ArrayList<Status>(); taskStatus.add(Status.Completed); taskStatus.add(Status.Created); taskStatus.add(Status.InProgress); taskStatus.add(Status.Reserved); List<TaskSummary> taskSummaryList = runtimeDataService.getTasksByStatusByProcessInstanceId(processInstanceId, taskStatus, null); Assertions.assertThat(taskSummaryList).hasSize(1); processService.abortProcessInstance(processInstanceId); ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId); assertNotNull(pi); assertEquals(ProcessInstance.STATE_ABORTED, pi.getState().intValue()); }
public static void main(String[] args) { ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args); if (args.length > 1) { try { System.out.println("Params available trying to deploy " + args); DeploymentService deploymentService = (DeploymentService) ctx.getBean("deploymentService"); KModuleDeploymentUnit unit = new KModuleDeploymentUnit(args[0], args[1], args[2]); deploymentService.deploy(unit); } catch (Throwable e) { System.out.println("Error when deploying = " + e.getMessage()); } } } }