本文主要是介绍springBoot + activiti6+在线编辑器 整合 附带flowable的demo,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
首先项目地址放在前头:activiti仓库github克隆地址
flowable的demo:flowable的demo仓库github地址 只有一个在线编辑器的整合
项目只贴核心代码,因为没写完后续还会慢慢边学边写,也算是自己的学习笔记,具体需要可以挡下来看。
配置:
@Beanpublic SpringProcessEngineConfiguration springProcessEngineConfiguration(DataSource dataSource, DataSourceTransactionManager transactionManager) {SpringProcessEngineConfiguration spec = new SpringProcessEngineConfiguration();spec.setDataSource(dataSource);//实现业务与流程事务的统一管理transactionManager.setDataSource(dataSource);spec.setTransactionManager(transactionManager);spec.setDatabaseSchemaUpdate("true");Resource[] resources = null;// 启动自动部署流程 放在资源根目录processes文件夹底下的流程文件try {resources = new PathMatchingResourcePatternResolver().getResources("classpath*:processes/*.bpmn");} catch (IOException e) {e.printStackTrace();}spec.setDeploymentResources(resources);return spec;}
//app-cfg.js 路径可以改自己的 代码里editor文件夹底下的三个负责编辑的类的请求跟路径保持和这里一致
ACTIVITI.CONFIG = {'contextRoot' : '/activityService',
};
流程追踪器控制层,一个基类三个分别查图片和追踪图片的类,下面是Activiti 5.x的源码:
public class BaseProcessDefinitionDiagramLayoutResource {@Resourceprivate RuntimeService runtimeService;@Resourceprivate RepositoryService repositoryService;@Resourceprivate HistoryService historyService;public ObjectNode getDiagramNode(String processInstanceId, String processDefinitionId) {List<String> highLightedFlows = Collections.<String> emptyList();List<String> highLightedActivities = Collections.<String> emptyList();Map<String, ObjectNode> subProcessInstanceMap = new HashMap<String, ObjectNode>();ProcessInstance processInstance = null;if (processInstanceId != null) {processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();if (processInstance == null) {throw new ActivitiObjectNotFoundException("Process instance could not be found");}processDefinitionId = processInstance.getProcessDefinitionId();List<ProcessInstance> subProcessInstances = runtimeService.createProcessInstanceQuery().superProcessInstanceId(processInstanceId).list();for (ProcessInstance subProcessInstance : subProcessInstances) {String subDefId = subProcessInstance.getProcessDefinitionId();String superExecutionId = ((ExecutionEntity) subProcessInstance).getSuperExecutionId();ProcessDefinitionEntity subDef = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(subDefId);ObjectNode processInstanceJSON = new ObjectMapper().createObjectNode();processInstanceJSON.put("processInstanceId", subProcessInstance.getId());processInstanceJSON.put("superExecutionId", superExecutionId);processInstanceJSON.put("processDefinitionId", subDef.getId());processInstanceJSON.put("processDefinitionKey", subDef.getKey());processInstanceJSON.put("processDefinitionName", subDef.getName());subProcessInstanceMap.put(superExecutionId, processInstanceJSON);}}if (processDefinitionId == null) {throw new ActivitiObjectNotFoundException("No process definition id provided");}ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId);if (processDefinition == null) {throw new ActivitiException("Process definition " + processDefinitionId + " could not be found");}ObjectNode responseJSON = new ObjectMapper().createObjectNode();// Process definitionJsonNode pdrJSON = getProcessDefinitionResponse(processDefinition);if (pdrJSON != null) {responseJSON.put("processDefinition", pdrJSON);}// Highlighted activitiesif (processInstance != null) {ArrayNode activityArray = new ObjectMapper().createArrayNode();ArrayNode flowsArray = new ObjectMapper().createArrayNode();highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);highLightedFlows = getHighLightedFlows(processInstanceId, processDefinition);for (String activityName : highLightedActivities) {activityArray.add(activityName);}for (String flow : highLightedFlows)flowsArray.add(flow);responseJSON.put("highLightedActivities", activityArray);responseJSON.put("highLightedFlows", flowsArray);}// Pool shape, if process is participant in collaborationif (processDefinition.getParticipantProcess() != null) {ParticipantProcess pProc = processDefinition.getParticipantProcess();ObjectNode participantProcessJSON = new ObjectMapper().createObjectNode();participantProcessJSON.put("id", pProc.getId());if (StringUtils.isNotEmpty(pProc.getName())) {participantProcessJSON.put("name", pProc.getName());} else {participantProcessJSON.put("name", "");}participantProcessJSON.put("x", pProc.getX());participantProcessJSON.put("y", pProc.getY());participantProcessJSON.put("width", pProc.getWidth());participantProcessJSON.put("height", pProc.getHeight());responseJSON.put("participantProcess", participantProcessJSON);}// Draw lanesif (processDefinition.getLaneSets() != null && !processDefinition.getLaneSets().isEmpty()) {ArrayNode laneSetArray = new ObjectMapper().createArrayNode();for (LaneSet laneSet : processDefinition.getLaneSets()) {ArrayNode laneArray = new ObjectMapper().createArrayNode();if (laneSet.getLanes() != null && !laneSet.getLanes().isEmpty()) {for (Lane lane : laneSet.getLanes()) {ObjectNode laneJSON = new ObjectMapper().createObjectNode();laneJSON.put("id", lane.getId());if (StringUtils.isNotEmpty(lane.getName())) {laneJSON.put("name", lane.getName());} else {laneJSON.put("name", "");}laneJSON.put("x", lane.getX());laneJSON.put("y", lane.getY());laneJSON.put("width", lane.getWidth());laneJSON.put("height", lane.getHeight());List<String> flowNodeIds = lane.getFlowNodeIds();ArrayNode flowNodeIdsArray = new ObjectMapper().createArrayNode();for (String flowNodeId : flowNodeIds) {flowNodeIdsArray.add(flowNodeId);}laneJSON.put("flowNodeIds", flowNodeIdsArray);laneArray.add(laneJSON);}}ObjectNode laneSetJSON = new ObjectMapper().createObjectNode();laneSetJSON.put("id", laneSet.getId());if (StringUtils.isNotEmpty(laneSet.getName())) {laneSetJSON.put("name", laneSet.getName());} else {laneSetJSON.put("name", "");}laneSetJSON.put("lanes", laneArray);laneSetArray.add(laneSetJSON);}if (laneSetArray.size() > 0)responseJSON.put("laneSets", laneSetArray);}ArrayNode sequenceFlowArray = new ObjectMapper().createArrayNode();ArrayNode activityArray = new ObjectMapper().createArrayNode();// Activities and their sequence-flowsfor (ActivityImpl activity : processDefinition.getActivities()) {getActivity(processInstanceId, activity, activityArray, sequenceFlowArray,processInstance, highLightedFlows, subProcessInstanceMap);}responseJSON.put("activities", activityArray);responseJSON.put("sequenceFlows", sequenceFlowArray);return responseJSON;}private List<String> getHighLightedFlows(String processInstanceId, ProcessDefinitionEntity processDefinition) {List<String> highLightedFlows = new ArrayList<String>();List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).orderByHistoricActivityInstanceStartTime().asc().list();List<String> historicActivityInstanceList = new ArrayList<String>();for (HistoricActivityInstance hai : historicActivityInstances) {historicActivityInstanceList.add(hai.getActivityId());}// add current activities to listList<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);historicActivityInstanceList.addAll(highLightedActivities);// activities and their sequence-flowsfor (ActivityImpl activity : processDefinition.getActivities()) {int index = historicActivityInstanceList.indexOf(activity.getId());if (index >= 0 && index + 1 < historicActivityInstanceList.size()) {List<PvmTransition> pvmTransitionList = activity.getOutgoingTransitions();for (PvmTransition pvmTransition : pvmTransitionList) {String destinationFlowId = pvmTransition.getDestination().getId();if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) {highLightedFlows.add(pvmTransition.getId());}}}}return highLightedFlows;}private void getActivity(String processInstanceId, ActivityImpl activity, ArrayNode activityArray,ArrayNode sequenceFlowArray, ProcessInstance processInstance, List<String> highLightedFlows,Map<String, ObjectNode> subProcessInstanceMap) {ObjectNode activityJSON = new ObjectMapper().createObjectNode();// Gather info on the multi instance markerString multiInstance = (String) activity.getProperty("multiInstance");if (multiInstance != null) {if (!"sequential".equals(multiInstance)) {multiInstance = "parallel";}}ActivityBehavior activityBehavior = activity.getActivityBehavior();// Gather info on the collapsed markerBoolean collapsed = (activityBehavior instanceof CallActivityBehavior);Boolean expanded = (Boolean) activity.getProperty(BpmnParse.PROPERTYNAME_ISEXPANDED);if (expanded != null) {collapsed = !expanded;}Boolean isInterrupting = null;if (activityBehavior instanceof BoundaryEventActivityBehavior) {isInterrupting = ((BoundaryEventActivityBehavior) activityBehavior).isInterrupting();}// Outgoing transitions of activityfor (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) {String flowName = (String) sequenceFlow.getProperty("name");boolean isHighLighted = (highLightedFlows.contains(sequenceFlow.getId()));boolean isConditional = sequenceFlow.getProperty(BpmnParse.PROPERTYNAME_CONDITION) != null &&!((String) activity.getProperty("type")).toLowerCase().contains("gateway");boolean isDefault = sequenceFlow.getId().equals(activity.getProperty("default"))&& ((String) activity.getProperty("type")).toLowerCase().contains("gateway");List<Integer> waypoints = ((TransitionImpl) sequenceFlow).getWaypoints();ArrayNode xPointArray = new ObjectMapper().createArrayNode();ArrayNode yPointArray = new ObjectMapper().createArrayNode();for (int i = 0; i < waypoints.size(); i += 2) { // waypoints.size()// minimally 4: x1, y1,// x2, y2xPointArray.add(waypoints.get(i));yPointArray.add(waypoints.get(i + 1));}ObjectNode flowJSON = new ObjectMapper().createObjectNode();flowJSON.put("id", sequenceFlow.getId());flowJSON.put("name", flowName);flowJSON.put("flow", "(" + sequenceFlow.getSource().getId() + ")--"+ sequenceFlow.getId() + "-->("+ sequenceFlow.getDestination().getId() + ")");if (isConditional)flowJSON.put("isConditional", isConditional);if (isDefault)flowJSON.put("isDefault", isDefault);if (isHighLighted)flowJSON.put("isHighLighted", isHighLighted);flowJSON.put("xPointArray", xPointArray);flowJSON.put("yPointArray", yPointArray);sequenceFlowArray.add(flowJSON);}// Nested activities (boundary events)ArrayNode nestedActivityArray = new ObjectMapper().createArrayNode();for (ActivityImpl nestedActivity : activity.getActivities()) {nestedActivityArray.add(nestedActivity.getId());}Map<String, Object> properties = activity.getProperties();ObjectNode propertiesJSON = new ObjectMapper().createObjectNode();for (String key : properties.keySet()) {Object prop = properties.get(key);if (prop instanceof String)propertiesJSON.put(key, (String) properties.get(key));else if (prop instanceof Integer)propertiesJSON.put(key, (Integer) properties.get(key));else if (prop instanceof Boolean)propertiesJSON.put(key, (Boolean) properties.get(key));else if ("initial".equals(key)) {ActivityImpl act = (ActivityImpl) properties.get(key);propertiesJSON.put(key, act.getId());} else if ("timerDeclarations".equals(key)) {ArrayList<TimerDeclarationImpl> timerDeclarations = (ArrayList<TimerDeclarationImpl>) properties.get(key);ArrayNode timerDeclarationArray = new ObjectMapper().createArrayNode();if (timerDeclarations != null)for (TimerDeclarationImpl timerDeclaration : timerDeclarations) {ObjectNode timerDeclarationJSON = new ObjectMapper().createObjectNode();timerDeclarationJSON.put("isExclusive", timerDeclaration.isExclusive());if (timerDeclaration.getRepeat() != null)timerDeclarationJSON.put("repeat", timerDeclaration.getRepeat());timerDeclarationJSON.put("retries", String.valueOf(timerDeclaration.getRetries()));timerDeclarationJSON.put("type", timerDeclaration.getJobHandlerType());timerDeclarationJSON.put("configuration", timerDeclaration.getJobHandlerConfiguration());//timerDeclarationJSON.put("expression", timerDeclaration.getDescription());timerDeclarationArray.add(timerDeclarationJSON);}if (timerDeclarationArray.size() > 0)propertiesJSON.put(key, timerDeclarationArray);// TODO: implement getting description} else if ("eventDefinitions".equals(key)) {ArrayList<EventSubscriptionDeclaration> eventDefinitions = (ArrayList<EventSubscriptionDeclaration>) properties.get(key);ArrayNode eventDefinitionsArray = new ObjectMapper().createArrayNode();if (eventDefinitions != null) {for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) {ObjectNode eventDefinitionJSON = new ObjectMapper().createObjectNode();if (eventDefinition.getActivityId() != null)eventDefinitionJSON.put("activityId",eventDefinition.getActivityId());eventDefinitionJSON.put("eventName", eventDefinition.getEventName());eventDefinitionJSON.put("eventType", eventDefinition.getEventType());eventDefinitionJSON.put("isAsync", eventDefinition.isAsync());eventDefinitionJSON.put("isStartEvent", eventDefinition.isStartEvent());eventDefinitionsArray.add(eventDefinitionJSON);}}if (eventDefinitionsArray.size() > 0)propertiesJSON.put(key, eventDefinitionsArray);// TODO: implement it} else if ("errorEventDefinitions".equals(key)) {ArrayList<ErrorEventDefinition> errorEventDefinitions = (ArrayList<ErrorEventDefinition>) properties.get(key);ArrayNode errorEventDefinitionsArray = new ObjectMapper().createArrayNode();if (errorEventDefinitions != null) {for (ErrorEventDefinition errorEventDefinition : errorEventDefinitions) {ObjectNode errorEventDefinitionJSON = new ObjectMapper().createObjectNode();if (errorEventDefinition.getErrorCode() != null)errorEventDefinitionJSON.put("errorCode", errorEventDefinition.getErrorCode());elseerrorEventDefinitionJSON.putNull("errorCode");errorEventDefinitionJSON.put("handlerActivityId",errorEventDefinition.getHandlerActivityId());errorEventDefinitionsArray.add(errorEventDefinitionJSON);}}if (errorEventDefinitionsArray.size() > 0)propertiesJSON.put(key, errorEventDefinitionsArray);}}if ("callActivity".equals(properties.get("type"))) {CallActivityBehavior callActivityBehavior = null;if (activityBehavior instanceof CallActivityBehavior) {callActivityBehavior = (CallActivityBehavior) activityBehavior;}if (callActivityBehavior != null) {propertiesJSON.put("processDefinitonKey", callActivityBehavior.getProcessDefinitonKey());// get processDefinitonId from execution or get last processDefinitonId// by keyArrayNode processInstanceArray = new ObjectMapper().createArrayNode();if (processInstance != null) {List<Execution> executionList = runtimeService.createExecutionQuery().processInstanceId(processInstanceId).activityId(activity.getId()).list();if (!executionList.isEmpty()) {for (Execution execution : executionList) {ObjectNode processInstanceJSON = subProcessInstanceMap.get(execution.getId());processInstanceArray.add(processInstanceJSON);}}}// If active activities nas no instance of this callActivity then add// last definitionif (processInstanceArray.size() == 0 && StringUtils.isNotEmpty(callActivityBehavior.getProcessDefinitonKey())) {// Get last definition by keyProcessDefinition lastProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(callActivityBehavior.getProcessDefinitonKey()).latestVersion().singleResult();// TODO: unuseful fields there are processDefinitionName, processDefinitionKeyif (lastProcessDefinition != null) {ObjectNode processInstanceJSON = new ObjectMapper().createObjectNode();processInstanceJSON.put("processDefinitionId", lastProcessDefinition.getId());processInstanceJSON.put("processDefinitionKey", lastProcessDefinition.getKey());processInstanceJSON.put("processDefinitionName", lastProcessDefinition.getName());processInstanceArray.add(processInstanceJSON);}}if (processInstanceArray.size() > 0) {propertiesJSON.put("processDefinitons", processInstanceArray);}}}activityJSON.put("activityId", activity.getId());activityJSON.put("properties", propertiesJSON);if (multiInstance != null)activityJSON.put("multiInstance", multiInstance);if (collapsed)activityJSON.put("collapsed", collapsed);if (nestedActivityArray.size() > 0)activityJSON.put("nestedActivities", nestedActivityArray);if (isInterrupting != null)activityJSON.put("isInterrupting", isInterrupting);activityJSON.put("x", activity.getX());activityJSON.put("y", activity.getY());activityJSON.put("width", activity.getWidth());activityJSON.put("height", activity.getHeight());activityArray.add(activityJSON);// Nested activities (boundary events)for (ActivityImpl nestedActivity : activity.getActivities()) {getActivity(processInstanceId, nestedActivity, activityArray, sequenceFlowArray,processInstance, highLightedFlows, subProcessInstanceMap);}}private JsonNode getProcessDefinitionResponse(ProcessDefinitionEntity processDefinition) {ObjectMapper mapper = new ObjectMapper();ObjectNode pdrJSON = mapper.createObjectNode();pdrJSON.put("id", processDefinition.getId());pdrJSON.put("name", processDefinition.getName());pdrJSON.put("key", processDefinition.getKey());pdrJSON.put("version", processDefinition.getVersion());pdrJSON.put("deploymentId", processDefinition.getDeploymentId());pdrJSON.put("isGraphicNotationDefined", isGraphicNotationDefined(processDefinition));return pdrJSON;}private boolean isGraphicNotationDefined(ProcessDefinitionEntity processDefinition) {return ((ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinition.getId())).isGraphicalNotationDefined();}
}@RestController
public class ProcessDefinitionDiagramLayoutResource extends BaseProcessDefinitionDiagramLayoutResource {@RequestMapping(value="/process-definition/{processDefinitionId}/diagram-layout", method = RequestMethod.GET, produces = "application/json")public ObjectNode getDiagram(@PathVariable String processDefinitionId) {return getDiagramNode(null, processDefinitionId);}
}@RestController
public class ProcessInstanceDiagramLayoutResource extends BaseProcessDefinitionDiagramLayoutResource {@RequestMapping(value="/process-instance/{processInstanceId}/diagram-layout", method = RequestMethod.GET, produces = "application/json")public ObjectNode getDiagram(@PathVariable String processInstanceId) {return getDiagramNode(processInstanceId, null);}
}@RestController
public class ProcessInstanceHighlightsResource {@Resourceprivate RuntimeService runtimeService;@Resourceprivate RepositoryService repositoryService;@Resourceprivate HistoryService historyService;protected ObjectMapper objectMapper = new ObjectMapper();@RequestMapping(value="/process-instance/{processInstanceId}/highlights", method = RequestMethod.GET, produces = "application/json")public ObjectNode getHighlighted(@PathVariable String processInstanceId) {ObjectNode responseJSON = objectMapper.createObjectNode();responseJSON.put("processInstanceId", processInstanceId);ArrayNode activitiesArray = objectMapper.createArrayNode();ArrayNode flowsArray = objectMapper.createArrayNode();try {ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());responseJSON.put("processDefinitionId", processInstance.getProcessDefinitionId());List<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);List<String> highLightedFlows = getHighLightedFlows(processDefinition, processInstanceId);for (String activityId : highLightedActivities) {activitiesArray.add(activityId);}for (String flow : highLightedFlows) {flowsArray.add(flow);}} catch (Exception e) {e.printStackTrace();}responseJSON.put("activities", activitiesArray);responseJSON.put("flows", flowsArray);return responseJSON;}/*** getHighLightedFlows** @param processDefinition* @param processInstanceId* @return*/private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) {List<String> highLightedFlows = new ArrayList<String>();List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId)//order by startime asc is not correct. use default order is correct.//.orderByHistoricActivityInstanceStartTime().asc()/*.orderByActivityId().asc()*/.list();LinkedList<HistoricActivityInstance> hisActInstList = new LinkedList<HistoricActivityInstance>();hisActInstList.addAll(historicActivityInstances);getHighlightedFlows(processDefinition.getActivities(), hisActInstList, highLightedFlows);return highLightedFlows;}/*** getHighlightedFlows** code logic:* 1. Loop all activities by id asc order;* 2. Check each activity's outgoing transitions and eventBoundery outgoing transitions, if outgoing transitions's destination.id is in other executed activityIds, add this transition to highLightedFlows List;* 3. But if activity is not a parallelGateway or inclusiveGateway, only choose the earliest flow.** @param activityList* @param hisActInstList* @param highLightedFlows*/private void getHighlightedFlows(List<ActivityImpl> activityList, LinkedList<HistoricActivityInstance> hisActInstList, List<String> highLightedFlows){//check out startEvents in activityListList<ActivityImpl> startEventActList = new ArrayList<ActivityImpl>();Map<String, ActivityImpl> activityMap = new HashMap<String, ActivityImpl>(activityList.size());for(ActivityImpl activity : activityList){activityMap.put(activity.getId(), activity);String actType = (String) activity.getProperty("type");if (actType != null && actType.toLowerCase().indexOf("startevent") >= 0){startEventActList.add(activity);}}//These codes is used to avoid a bug://ACT-1728 If the process instance was started by a callActivity, it will be not have the startEvent activity in ACT_HI_ACTINST table//Code logic://Check the first activity if it is a startEvent, if not check out the startEvent's highlight outgoing flow.HistoricActivityInstance firstHistActInst = hisActInstList.getFirst();String firstActType = (String) firstHistActInst.getActivityType();if (firstActType != null && firstActType.toLowerCase().indexOf("startevent") < 0){PvmTransition startTrans = getStartTransaction(startEventActList, firstHistActInst);if (startTrans != null){highLightedFlows.add(startTrans.getId());}}while (!hisActInstList.isEmpty()) {HistoricActivityInstance histActInst = hisActInstList.removeFirst();ActivityImpl activity = activityMap.get(histActInst.getActivityId());if (activity != null) {boolean isParallel = false;String type = histActInst.getActivityType();if ("parallelGateway".equals(type) || "inclusiveGateway".equals(type)){isParallel = true;} else if ("subProcess".equals(histActInst.getActivityType())){getHighlightedFlows(activity.getActivities(), hisActInstList, highLightedFlows);}List<PvmTransition> allOutgoingTrans = new ArrayList<PvmTransition>();allOutgoingTrans.addAll(activity.getOutgoingTransitions());allOutgoingTrans.addAll(getBoundaryEventOutgoingTransitions(activity));List<String> activityHighLightedFlowIds = getHighlightedFlows(allOutgoingTrans, hisActInstList, isParallel);highLightedFlows.addAll(activityHighLightedFlowIds);}}}/*** Check out the outgoing transition connected to firstActInst from startEventActList** @param startEventActList* @param firstActInst* @return*/private PvmTransition getStartTransaction(List<ActivityImpl> startEventActList, HistoricActivityInstance firstActInst){for (ActivityImpl startEventAct: startEventActList) {for (PvmTransition trans : startEventAct.getOutgoingTransitions()) {if (trans.getDestination().getId().equals(firstActInst.getActivityId())) {return trans;}}}return null;}/*** getBoundaryEventOutgoingTransitions** @param activity* @return*/private List<PvmTransition> getBoundaryEventOutgoingTransitions(ActivityImpl activity){List<PvmTransition> boundaryTrans = new ArrayList<PvmTransition>();for(ActivityImpl subActivity : activity.getActivities()){String type = (String)subActivity.getProperty("type");if(type!=null && type.toLowerCase().indexOf("boundary")>=0){boundaryTrans.addAll(subActivity.getOutgoingTransitions());}}return boundaryTrans;}/*** find out single activity's highlighted flowIds** @param pvmTransitionList* @param hisActInstList* @param isParallel if true only return one flowId(Such as exclusiveGateway, BoundaryEvent On Task)* @return*/private List<String> getHighlightedFlows(List<PvmTransition> pvmTransitionList, LinkedList<HistoricActivityInstance> hisActInstList, boolean isParallel){List<String> highLightedFlowIds = new ArrayList<String>();PvmTransition earliestTrans = null;HistoricActivityInstance earliestHisActInst = null;for (PvmTransition pvmTransition : pvmTransitionList) {String destActId = pvmTransition.getDestination().getId();HistoricActivityInstance destHisActInst = findHisActInst(hisActInstList, destActId);if (destHisActInst != null) {if (isParallel) {highLightedFlowIds.add(pvmTransition.getId());} else if (earliestHisActInst == null || (earliestHisActInst.getId().compareTo(destHisActInst.getId()) > 0)) {earliestTrans = pvmTransition;earliestHisActInst = destHisActInst;}}}if ((!isParallel) && earliestTrans!=null){highLightedFlowIds.add(earliestTrans.getId());}return highLightedFlowIds;}private HistoricActivityInstance findHisActInst(LinkedList<HistoricActivityInstance> hisActInstList, String actId){for (HistoricActivityInstance hisActInst : hisActInstList){if (hisActInst.getActivityId().equals(actId)){return hisActInst;}}return null;}
}
前端在线编辑器:
//toolbar-default-actions.js 编辑完成跳转前进后退页面来自这三个方法可以根据需要改写closeEditor: function(services) {},$scope.saveAndClose = function () {};$scope.save(function() {window.location.href = "./";
});//toolbar.js 使用工具栏的拷贝剪切功能键 剪切cut是默认 拷贝copy是放开的写法{"type" : "button","title" : "TOOLBAR.ACTION.CUT","cssClass" : "editor-icon editor-icon-cut","action" : "KISBPM.TOOLBAR.ACTIONS.cut","enabled" : false,"enabledAction" : "element"},{"type" : "button","title" : "TOOLBAR.ACTION.COPY","cssClass" : "editor-icon editor-icon-copy","action" : "KISBPM.TOOLBAR.ACTIONS.copy","enabled" : true,//"enabledAction" : "element"},
前端流程追踪器:
//项目结构具体代码里查看
// ActivitiRest.js里的查所有流程组件的所有ajax查询datatype注释掉
$.ajax({url: url,//datatype: 'jsop'cache: false,async: true,
})// index.html请求去掉 /servcie和根目录
ActivitiRest.options = {processInstanceHighLightsUrl: "/process-instance/{processInstanceId}/highlights?callback=?",processDefinitionUrl: "/process-definition/{processDefinitionId}/diagram-layout?callback=?",processDefinitionByKeyUrl: "/process-definition/{processDefinitionKey}/diagram-layout?callback=?"};
贴几张图
这篇关于springBoot + activiti6+在线编辑器 整合 附带flowable的demo的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!