@RequestMapping(value = "/rest/process-definitions/{processDefinitionId}/model-json", method = RequestMethod.GET, produces = "application/json") public JsonNode getModelJSONForProcessDefinition(@PathVariable String processDefinitionId) { BpmnModel pojoModel = repositoryService.getBpmnModel(processDefinitionId); if (pojoModel == null || pojoModel.getLocationMap().isEmpty()) { throw new InternalServerErrorException("Process definition could not be found with id " + processDefinitionId); } return processProcessElements(pojoModel, null, null, Collections.EMPTY_LIST, ""); }
public void execute() { // Reset any previous DI information bpmnModel.getLocationMap().clear(); bpmnModel.getFlowLocationMap().clear(); // Generate DI for each process for (Process process : bpmnModel.getProcesses()) { layout(process); // Operations that can only be done after all elements have received DI translateNestedSubprocesses(process); } }
@RequestMapping(value = "/rest/admin/process-definitions/{processDefinitionId}/model-json", method = RequestMethod.GET, produces = "application/json") public JsonNode getProcessDefinitionModelJSON(@PathVariable String processDefinitionId) { ServerConfig config = retrieveServerConfig(EndpointType.PROCESS); ObjectNode displayNode = objectMapper.createObjectNode(); BpmnModel pojoModel = clientService.getProcessDefinitionModel(config, processDefinitionId); if (!pojoModel.getLocationMap().isEmpty()) { try { GraphicInfo diagramInfo = new GraphicInfo(); processProcessElements(config, pojoModel, displayNode, diagramInfo, null, null); displayNode.put("diagramBeginX", diagramInfo.getX()); displayNode.put("diagramBeginY", diagramInfo.getY()); displayNode.put("diagramWidth", diagramInfo.getWidth()); displayNode.put("diagramHeight", diagramInfo.getHeight()); } catch (Exception e) { LOGGER.error("Error creating model JSON", e); } } return displayNode; }
BpmnModel pojoModel = clientService.getProcessDefinitionModel(config, processDefinitionId); if (!pojoModel.getLocationMap().isEmpty()) {
BpmnModel pojoModel = clientService.getProcessDefinitionModel(config, processDefinitionId); if (!pojoModel.getLocationMap().isEmpty()) {
/** * Look up the process definition by key. For example, this is <A href="http://localhost:8080/activiti/processes/fulfillmentProcess">process-diagram for</A> a process definition named * {@code fulfillmentProcess}. */ @RequestMapping(value = "/processes/{processDefinitionKey:.*}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE) @ResponseBody public ResponseEntity processDefinitionDiagram(@PathVariable String processDefinitionKey) { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(processDefinitionKey) .latestVersion() .singleResult(); if (processDefinition == null) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); } ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator(); BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); if (bpmnModel.getLocationMap().size() == 0) { BpmnAutoLayout autoLayout = new BpmnAutoLayout(bpmnModel); autoLayout.execute(); } InputStream is = processDiagramGenerator.generateJpgDiagram(bpmnModel); return ResponseEntity.ok(new InputStreamResource(is)); }
protected void translateNestedSubprocessElements(SubProcess subProcess) { GraphicInfo subProcessGraphicInfo = bpmnModel.getLocationMap().get(subProcess.getId()); double subProcessX = subProcessGraphicInfo.getX(); double subProcessY = subProcessGraphicInfo.getY(); List<SubProcess> nestedSubProcesses = new ArrayList<>(); for (FlowElement flowElement : subProcess.getFlowElements()) { if (flowElement instanceof SequenceFlow) { List<GraphicInfo> graphicInfos = bpmnModel.getFlowLocationMap().get(flowElement.getId()); for (GraphicInfo graphicInfo : graphicInfos) { graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin); graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin); } } else if (!(flowElement instanceof DataObject)) { // Regular element GraphicInfo graphicInfo = bpmnModel.getLocationMap().get(flowElement.getId()); graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin); graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin); } if (flowElement instanceof SubProcess) { nestedSubProcesses.add((SubProcess) flowElement); } } // Continue for next level of nested subprocesses for (SubProcess nestedSubProcess : nestedSubProcesses) { translateNestedSubprocessElements(nestedSubProcess); } }
if (!bpmnModel.getLocationMap().isEmpty()) { for (String bpmnReference : bpmnModel.getLocationMap().keySet()) { if (bpmnModel.getFlowElement(bpmnReference) == null) {
public void processDI() { if (!bpmnModel.getLocationMap().isEmpty()) { for (String bpmnReference : bpmnModel.getLocationMap().keySet()) { if (bpmnModel.getFlowElement(bpmnReference) == null) { if (processDefinition != null) { processDefinition.setGraphicalNotationDefined(true); for (String shapeId : bpmnModel.getLocationMap().keySet()) { if (processDefinition.findActivity(shapeId) != null) { createBPMNShape(shapeId, bpmnModel.getGraphicInfo(shapeId), processDefinition);
Map<String, String> collapsedSubProcessChildren = new HashMap<>(); for (String elementId : model.getLocationMap().keySet()) { FlowElement flowElement = model.getFlowElement(elementId); xtw.writeAttribute(ATTRIBUTE_ID, "BPMNPlane_" + processId); for (String elementId : model.getLocationMap().keySet()) {
@RequestMapping(value = "/rest/process-instances/history/{processInstanceId}/model-json", method = RequestMethod.GET, produces = "application/json") public JsonNode getModelHistoryJSON(@PathVariable String processInstanceId) { User currentUser = SecurityUtils.getCurrentUserObject(); if (!permissionService.hasReadPermissionOnProcessInstance(currentUser, processInstanceId)) { throw new NotPermittedException(); } HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if (processInstance == null) { throw new BadRequestException("No process instance found with id " + processInstanceId); } BpmnModel pojoModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId()); if (pojoModel == null || pojoModel.getLocationMap().isEmpty()) { throw new InternalServerErrorException("Process definition could not be found with id " + processInstance.getProcessDefinitionId()); } // Fetch process-instance activities List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list(); Set<String> completedActivityInstances = new HashSet<>(); Set<String> currentActivityinstances = new HashSet<>(); if (CollectionUtils.isNotEmpty(activityInstances)) { for (HistoricActivityInstance activityInstance : activityInstances) { if (activityInstance.getEndTime() != null) { completedActivityInstances.add(activityInstance.getActivityId()); } else { currentActivityinstances.add(activityInstance.getActivityId()); } } } ObjectNode displayNode = processProcessElements(pojoModel, completedActivityInstances, currentActivityinstances, Collections.EMPTY_LIST, processInstanceId); return displayNode; }
@Override public void validate(BpmnModel bpmnModel, List<ValidationError> errors) { if (!bpmnModel.getLocationMap().isEmpty()) { for (String bpmnReference : bpmnModel.getLocationMap().keySet()) { if (bpmnModel.getFlowElement(bpmnReference) == null) {
if (pojoModel == null || pojoModel.getLocationMap().isEmpty()) { throw new InternalServerErrorException("Process definition could not be found with id " + processInstance.getProcessDefinitionId());
protected void processProcessElements(ServerConfig config, BpmnModel pojoModel, ObjectNode displayNode, GraphicInfo diagramInfo, Set<String> completedElements, Set<String> currentElements) throws Exception { if (pojoModel.getLocationMap().isEmpty()) return;
double maxX = 0.0; double maxY = 0.0; for (GraphicInfo flowInfo : model.getLocationMap().values()) { if ((flowInfo.getX() + flowInfo.getWidth()) > maxX) { maxX = flowInfo.getX() + flowInfo.getWidth();
Map<String, GraphicInfo> locationMap = bpmnModel.getLocationMap(); for (String locationId : locationMap.keySet()) { if (initialStartEvent.getId().equals(locationId)) {
Map<String, GraphicInfo> locationMap = bpmnModel.getLocationMap(); for (String locationId : locationMap.keySet()) { if (initialStartEvent.getId().equals(locationId)) {