public BPMNProcess read(InputStream inputStream) { Definitions definitions = BPMN2Utils.getDefinitions(inputStream); Optional<Process> processOptional = findProcess(definitions); if(!processOptional.isPresent()) { throw new RuntimeException("Cannot find Process on definitions"); } Process process = processOptional.get(); BusinessProcessFormModel formModel = new BusinessProcessFormModel(process.getId(), process.getName(), new ArrayList<>()); BPMNProcess bpmmProcess = new BPMNProcess(formModel); readContainerUserTasks(process, bpmmProcess::addTaskFormModel); return bpmmProcess; }
public ProcessPropertyReader of(Process el) { return new ProcessPropertyReader(el, diagram, definitionResolver.getShape(el.getId()), definitionResolver.getResolutionFactor()); } }
public void updateIDs(Definitions def) { // data object id update List<RootElement> rootElements = def.getRootElements(); for (RootElement root : rootElements) { if (root instanceof Process) { Process process = (Process) root; if (process.getId() != null) { String processId = process.getId().trim(); processId = processId.replaceAll("\\s", ""); process.setId(processId); } List<FlowElement> flowElements = process.getFlowElements(); for (FlowElement fe : flowElements) { if (fe instanceof DataObject) { DataObject da = (DataObject) fe; if (da.getName() != null) { String daId = da.getName().trim(); daId = daId.replaceAll("\\W", ""); da.setId(daId); } } } } } }
public void setCaseFileVariables(CaseFileVariables caseFileVariables) { String value = caseFileVariables.getValue(); DeclarationList declarationList = DeclarationList.fromString(value); List<Property> properties = process.getProperties(); declarationList.getDeclarations().forEach(decl -> { VariableScope.Variable variable = variableScope.declare(this.process.getId(), CaseFileVariables.CASE_FILE_PREFIX + decl.getIdentifier(), decl.getType()); properties.add(variable.getTypedIdentifier()); this.itemDefinitions.add(variable.getTypeDeclaration()); }); }
public ProcessPropertyWriter(Process process, VariableScope variableScope) { super(process, variableScope); this.process = process; this.bpmnDiagram = di.createBPMNDiagram(); bpmnDiagram.setId(process.getId()); this.bpmnPlane = di.createBPMNPlane(); bpmnDiagram.setPlane(bpmnPlane); }
@Override public JBPMProcessModel getModelForProcess(final String processId, final Path path) { GenerationConfig<Optional<JBPMProcessModel>> operations = new GenerationConfig<>(Optional.empty()); operations.setPredicate(definitions -> { if (definitions.isPresent()) { if (!operations.getValue().isPresent()) { Optional<Process> optional = Optional.of(bpmnFormModelGenerator.getProcess(definitions.get())); return optional.isPresent() && optional.get().getId().equals(processId); } } return false; }); operations.setConsumer(processModel -> operations.setValue(Optional.ofNullable(processModel))); Path rootPath = moduleService.resolveModule(path).getRootPath(); scannProcessesForType(rootPath, "bpmn2", operations); if (!operations.getValue().isPresent()) { scannProcessesForType(rootPath, "bpmn", operations); } return operations.getValue().orElse(null); }
public void setProcessVariables(ProcessVariables processVariables) { String value = processVariables.getValue(); DeclarationList declarationList = DeclarationList.fromString(value); List<Property> properties = process.getProperties(); declarationList.getDeclarations().forEach(decl -> { VariableScope.Variable variable = variableScope.declare(this.process.getId(), decl.getIdentifier(), decl.getType()); properties.add(variable.getTypedIdentifier()); this.itemDefinitions.add(variable.getTypeDeclaration()); }); }
@Test public void setIdWithWhitespace() { p.setId("some weird id \t"); Process process = p.getProcess(); assertThat(process.getId()).isEqualTo("someweirdid"); }
@Override public BusinessProcessFormModel generateProcessFormModel(Definitions source, Path path) { Process process = getProcess(source); if (process != null) { final ClassLoader projectClassLoader = projectClassLoaderHelper.getModuleClassLoader(moduleService.resolveModule(path)); List<ModelProperty> properties = process.getProperties().stream().map(property -> { String varName = property.getId(); String varType = BPMNVariableUtils.getRealTypeForInput(property.getItemSubjectRef().getStructureRef()); Variable variable = new Variable(varName, varType); variable.setInput(true); variable.setOutput(true); return createModelProperty(variable, projectClassLoader); }).filter(modelProperty -> modelProperty != null) .sorted((property1, property2) -> property1.getName().compareToIgnoreCase(property2.getName())).collect(Collectors.toList()); return new BusinessProcessFormModel(process.getId(), process.getName(), properties); } return null; }
@Test public void testUpdateIDs() { Definitions defs = mock(Definitions.class); Process process = mock(Process.class); DataObject flowElement = mock(DataObject.class); final Value<String> processId = new Value<>("Project:Bad Id"); final Value<String> flowElementId = new Value<>("Bad Flow Id!"); when(process.getId()).thenAnswer((m) -> processId.get()); doAnswer((m) -> { processId.set(m.getArgumentAt(0, String.class)); return null; }).when(process).setId(anyString()); when(flowElement.getId()).thenAnswer((m) -> flowElementId.get()); when(flowElement.getName()).thenAnswer((m) -> flowElementId.get()); doAnswer((m) -> { flowElementId.set(m.getArgumentAt(0, String.class)); return null; }).when(flowElement).setId(anyString()); when(process.getFlowElements()).thenReturn(Arrays.asList(flowElement)); when(defs.getRootElements()).thenReturn(Arrays.asList(process)); tested.updateIDs(defs); assertEquals("Project:BadId", processId.get()); assertEquals("BadFlowId", flowElementId.get()); }
process.getId()); assertEquals("BPSimple", process.getName());
process.getId()); assertEquals("BPSimple", process.getName());
private BpmnNode convertProcessNode(String id, Process process) { Node<View<D>, Edge> diagramNode = delegate.factoryManager.newNode(id, getDiagramClass()); D definition = diagramNode.getContent().getDefinition(); ProcessPropertyReader e = delegate.propertyReaderFactory.of(process); definition.setDiagramSet(new DiagramSet(new Name(process.getName()), new Documentation(e.getDocumentation()), new Id(process.getId()), new Package(e.getPackage()), new Version(e.getVersion()), new AdHoc(e.isAdHoc()), new ProcessInstanceDescription(e.getDescription()), new Executable(process.isIsExecutable())) ); definition.setCaseManagementSet(new CaseManagementSet(new CaseIdPrefix(e.getCaseIdPrefix()), new CaseRoles(e.getCaseRoles()), new CaseFileVariables(e.getCaseFileVariables()) )); definition.setProcessData(new ProcessData(new ProcessVariables(e.getProcessVariables()))); diagramNode.getContent().setBounds(e.getBounds()); definition.setFontSet(e.getFontSet()); definition.setBackgroundSet(e.getBackgroundSet()); return BpmnNode.of(diagramNode); }