private Builder() { timerDefinition = new TimerDefinition(); }
public Builder id(Long id) { timerDefinition.setId(id); return this; }
public Builder nodeId(Long nodeId) { timerDefinition.setNodeId(nodeId); return this; }
@Override public ProcessSummary apply(final ProcessDefinition definition) { if (definition == null) { return null; } final ProcessSummary summary = new ProcessSummary(definition.getId(), definition.getName(), definition.getContainerId(), definition.getVersion(), definition.isDynamic()); summary.setAssociatedEntities(definition.getAssociatedEntities()); summary.setProcessVariables(definition.getProcessVariables()); summary.setReusableSubProcesses(definition.getReusableSubProcesses()); summary.setServiceTasks(definition.getServiceTasks()); summary.setDynamicFormsEnabled(KieServerUtils.isKieServerRendererEnabled()); summary.setNodes(definition.getNodes() == null ? emptyList() : definition.getNodes().stream().map(node -> new ProcessNodeSummary(node.getId(), node.getName(), node.getType(), node.getUniqueId())).collect(toList())); summary.setTimers(definition.getTimers() == null ? emptyList() : definition.getTimers().stream().map(timer -> new TimerSummary(timer.getId(), timer.getNodeId(), timer.getNodeName(), timer.getUniqueId())).collect(toList())); return summary; } }
public org.kie.server.api.model.definition.ProcessDefinition getProcessDefinition(String containerId, String processId) { containerId = context.getContainerId(containerId, ContainerLocatorProvider.get().getLocator()); ProcessDefinition procDef = findProcessDefinition(containerId, processId); org.kie.server.api.model.definition.ProcessDefinition responseObject = org.kie.server.api.model.definition.ProcessDefinition.builder() .id(procDef.getId()) .name(procDef.getName()) .version(procDef.getVersion()) .packageName(procDef.getPackageName()) .containerId(procDef.getDeploymentId()) .entitiesAsCollection(procDef.getAssociatedEntities()) .serviceTasks(procDef.getServiceTasks()) .subprocesses(procDef.getReusableSubProcesses()) .variables(procDef.getProcessVariables()) .dynamic(procDef.isDynamic()) .nodes(procDef.getNodes().stream().map(node -> NodeDefinition.builder().id(node.getId()).name(node.getName()).type(node.getNodeType()).uniqueId(node.getUniqueId()).build()).collect(toSet())) .timers(procDef.getTimers().stream().map(timer -> TimerDefinition.builder().id(timer.getId()).nodeId(timer.getNodeId()).nodeName(timer.getNodeName()).uniqueId(timer.getUniqueId()).build()).collect(toSet())) .build(); return responseObject; }
public Builder uniqueId(String uniqueId) { timerDefinition.setUniqueId(uniqueId); return this; }
public Builder nodeName(String nodeName) { timerDefinition.setNodeName(nodeName); return this; }
@Override public ProcessSummary apply(final ProcessDefinition definition) { if (definition == null) { return null; } final ProcessSummary summary = new ProcessSummary(definition.getId(), definition.getName(), definition.getContainerId(), definition.getVersion(), definition.isDynamic()); summary.setAssociatedEntities(definition.getAssociatedEntities()); summary.setProcessVariables(definition.getProcessVariables()); summary.setReusableSubProcesses(definition.getReusableSubProcesses()); summary.setServiceTasks(definition.getServiceTasks()); summary.setDynamicFormsEnabled(KieServerUtils.isKieServerRendererEnabled()); summary.setNodes(definition.getNodes() == null ? emptyList() : definition.getNodes().stream().map(node -> new ProcessNodeSummary(node.getId(), node.getName(), node.getType(), node.getUniqueId())).collect(toList())); summary.setTimers(definition.getTimers() == null ? emptyList() : definition.getTimers().stream().map(timer -> new TimerSummary(timer.getId(), timer.getNodeId(), timer.getNodeName(), timer.getUniqueId())).collect(toList())); return summary; } }
@Test public void testProcessSummaryMapper_mapProcessSummary() { final ProcessDefinition pd = new ProcessDefinition(); pd.setName("definitionName"); pd.setId("definitionId"); pd.setDynamic(true); pd.setContainerId("containerId"); pd.setVersion("1.0"); pd.setAssociatedEntities(singletonMap("e1", new String[0])); pd.setProcessVariables(singletonMap("initiator", "String")); pd.setReusableSubProcesses(singletonList("processOne")); pd.setServiceTasks(singletonMap("email", "org.jbpm")); pd.setNodes(singletonList(NodeDefinition.builder().id(1l).build())); pd.setTimers(singletonList(TimerDefinition.builder().id(1l).build())); assertProcessSummary(pd, new ProcessSummaryMapper().apply(pd)); }
@Test public void testTimerProcessDefinition() { ProcessDefinition result = processClient.getProcessDefinition(CONTAINER_ID, PROCESS_ID_TIMER); assertNotNull(result); assertEquals(PROCESS_ID_TIMER, result.getId()); assertEquals("Timer Process", result.getName()); assertEquals("com.sample", result.getPackageName()); assertEquals("1", result.getVersion()); assertEquals(CONTAINER_ID, result.getContainerId()); assertNotNull(result.getNodes()); assertEquals(3, result.getNodes().size()); assertNotNull(result.getTimers()); assertEquals(1, result.getTimers().size()); TimerDefinition timer = result.getTimers().iterator().next(); assertEquals(0, timer.getId().longValue()); assertEquals(2l, timer.getNodeId().longValue()); assertEquals("timer", timer.getNodeName()); assertEquals("_2", timer.getUniqueId()); }
@Test public void testProcessSummaryMapper_mapProcessSummary() { final ProcessDefinition pd = new ProcessDefinition(); pd.setName("definitionName"); pd.setId("definitionId"); pd.setDynamic(true); pd.setContainerId("containerId"); pd.setVersion("1.0"); pd.setAssociatedEntities(singletonMap("e1", new String[0])); pd.setProcessVariables(singletonMap("initiator", "String")); pd.setReusableSubProcesses(singletonList("processOne")); pd.setServiceTasks(singletonMap("email", "org.jbpm")); pd.setNodes(singletonList(NodeDefinition.builder().id(1l).build())); pd.setTimers(singletonList(TimerDefinition.builder().id(1l).build())); assertProcessSummary(pd, new ProcessSummaryMapper().apply(pd)); }