首页 > 代码库 > 去哪网实习总结:递归构建“流程运行顺序”的XML文件(JavaWeb)
去哪网实习总结:递归构建“流程运行顺序”的XML文件(JavaWeb)
本来是以做数据挖掘的目的进去哪网的,结构却成了系统开发。。。
只是还是比較认真的做了三个月,老师非常认同我的工作态度和成果。。
。
实习立即就要结束了,总结一下几点之前没有注意过的变成习惯和问题。分享给大家。
同一时候打个广告:去哪网内审部招JavaWeb开发实习生,时间很自由。每周一天、周六周日甚至都能够,时间充裕的小伙伴给我留言啊,挣个零花钱,还能长点经验。
。。。(保研的、想工作的大四狗最合适只是了。。。
)
map的结构为(thisProcessID, thisProcessType;nextProcessID1,nextProcessType1;...;nextProcessIDk,nextProcessTypek;),假设processType部位start、end、split、join,则type和id同样。。。。
跑一下代码就知道是怎么回事了。直接上代码:
<span style="white-space:pre"> </span>public String XMLhead = ""; @SuppressWarnings({ "rawtypes", "unchecked" }) public void formXMLfile(Map nodeMap){ /*穿行没问题 nodeMap.put("1", "start;2,2"); nodeMap.put("2", "2;3,3"); nodeMap.put("3", "3;4,end"); nodeMap.put("4", "end"); */ /* 简单并行没问题,但须要去重处理 nodeMap.put("1", "start;2,split"); nodeMap.put("2", "split;3,3;4,4"); nodeMap.put("3", "3;5,join"); nodeMap.put("4", "4;5,join"); nodeMap.put("5", "join;6,end"); nodeMap.put("6", "end"); */ nodeMap.put("1", "start;2,split"); nodeMap.put("2", "split;3,3;4,split;5,5"); nodeMap.put("3", "3;6,6"); nodeMap.put("4", "split;7,7;8,8"); nodeMap.put("5", "5;9,join"); nodeMap.put("6", "6;9,join"); nodeMap.put("7", "7;10,join"); nodeMap.put("8", "8;10,join"); nodeMap.put("9", "join;11,end"); nodeMap.put("10", "join;9,join"); nodeMap.put("11", "end"); /*简单并行没问题。但须要去重处理 nodeMap.put("1", "start;2,split"); nodeMap.put("2", "split;3,3;4,4"); nodeMap.put("3", "3;5,join"); nodeMap.put("4", "4;5,join"); nodeMap.put("5", "join;6,split"); nodeMap.put("6", "split;7,7;8,8"); nodeMap.put("7", "7;9,join"); nodeMap.put("8", "8;9,join"); nodeMap.put("9", "join;10,end"); nodeMap.put("10", "end"); */ XMLhead = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+"\n"; XMLhead += "<definitions xmlns=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:activiti=\"http://activiti.org/bpmn\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\" xmlns:omgdc=\"http://www.omg.org/spec/DD/20100524/DC\" xmlns:omgdi=\"http://www.omg.org/spec/DD/20100524/DI\" typeLanguage=\"http://www.w3.org/2001/XMLSchema\" expressionLanguage=\"http://www.w3.org/1999/XPath\" targetNamespace=\"http://www.activiti.org/test\">"+"\n"; String XMLtail = "</definitions>"; XMLhead += "<process id=\"processID\" name=\"processNAME\" isExecutable=\"true\">"+"\n"; XMLtail = "</process>\n"+XMLtail; String this_id = "1";//start String this_type = "start"; RECUformXMLfile(nodeMap, this_id, this_type); String XMLfile = XMLhead + XMLtail; //去重 String[] temp = XMLfile.split("\n"); List<String> list = new LinkedList<String>(); for(int i = 0; i < temp.length; i++) { if(!list.contains(temp[i])) { list.add(temp[i]);//改为写文件 System.out.println(temp[i]); } } } @SuppressWarnings("rawtypes") public void RECUformXMLfile(Map nodeMap, String this_id, String this_type){ if(this_type.equals("start")){//start String[] toNodes = nodeMap.get(this_id).toString().split(";"); String next_id = toNodes[1].split(",")[0]; String next_type = toNodes[1].split(",")[1]; if(next_type.equals("split")){ XMLhead += "<startEvent id=\"startevent1\" name=\"Start\"></startEvent>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"startevent1\" targetRef=\"gateway_"+next_id+"\"></sequenceFlow>"+"\n"; RECUformXMLfile(nodeMap, next_id, next_type); } else if(next_type.equals("end_start_join")){//不可能 } else{//task XMLhead += "<startEvent id=\"startevent1\" name=\"Start\"></startEvent>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"startevent1\" targetRef=\"task_"+next_id+"\"></sequenceFlow>"+"\n"; RECUformXMLfile(nodeMap, next_id, next_type); } } else if(this_type.equals("split")){//split XMLhead += "<parallelGateway id=\"gateway_"+this_id+"\" name=\"Parallel Gateway\"></parallelGateway>"+"\n"; String[] toNodes = nodeMap.get(this_id).toString().split(";"); for(int i=1;i<toNodes.length;i++){ String next_id = toNodes[i].split(",")[0]; String next_type = toNodes[i].split(",")[1]; if(next_type.equals("split")){ XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"gateway_"+this_id+"\" targetRef=\"gateway_"+next_id+"\"></sequenceFlow>"+"\n"; RECUformXMLfile(nodeMap, next_id, next_type); } else if(next_type.equals("end_start_join")){//不可能 } else{//task XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"gateway_"+this_id+"\" targetRef=\"task_"+next_id+"\"></sequenceFlow>"+"\n"; RECUformXMLfile(nodeMap, next_id, next_type); } } } else if(this_type.equals("end")){//不会出现,接下来的两个推断分支可能的next_type==end时,都已经处理 } else if(this_type.equals("join")){//join,join和task,两者处理逻辑一样,除了一个用gateWay。一个用task String[] toNodes = nodeMap.get(this_id).toString().split(";"); String next_id = toNodes[1].split(",")[0]; String next_type = toNodes[1].split(",")[1]; if(next_type.equals("end")){ XMLhead += "<parallelGateway id=\"gateway_"+this_id+"\" name=\"Parallel Gateway\"></parallelGateway>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"gateway_"+this_id+"\" targetRef=\"endevent1\"></sequenceFlow>"+"\n"; XMLhead += "<endEvent id=\"endevent1\" name=\"End\"></endEvent>"+"\n"; return ; } else if(next_type.equals("start")){//不可能 } else if(next_type.equals("split")){ XMLhead += "<parallelGateway id=\"gateway_"+this_id+"\" name=\"Parallel Gateway\"></parallelGateway>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"gateway_"+this_id+"\" targetRef=\"gateway_"+next_id+"\"></sequenceFlow>"+"\n"; RECUformXMLfile(nodeMap, next_id, next_type); } else if(next_type.equals("join")){ XMLhead += "<parallelGateway id=\"gateway_"+this_id+"\" name=\"Parallel Gateway\"></parallelGateway>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"gateway_"+this_id+"\" targetRef=\"gateway_"+next_id+"\"></sequenceFlow>"+"\n"; return ; } else{//task XMLhead += "<parallelGateway id=\"gateway_"+this_id+"\" name=\"Parallel Gateway\"></parallelGateway>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"gateway_"+this_id+"\" targetRef=\"task_"+next_id+"\"></sequenceFlow>"+"\n"; RECUformXMLfile(nodeMap, next_id, next_type); } } else{//task,task和join。两者处理逻辑一样。除了一个用gateWay。一个用task String[] toNodes = nodeMap.get(this_id).toString().split(";"); String next_id = toNodes[1].split(",")[0]; String next_type = toNodes[1].split(",")[1]; if(next_type.equals("end")){ XMLhead += "<userTask id=\"task_"+this_id+"\" name=\""+this_id+"\"></userTask>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"task_"+this_id+"\" targetRef=\"endevent1\"></sequenceFlow>"+"\n"; XMLhead += "<endEvent id=\"endevent1\" name=\"End\"></endEvent>"+"\n"; return ; } else if(next_type.equals("start")){//不可能 } else if(next_type.equals("split")){ XMLhead += "<userTask id=\"task_"+this_id+"\" name=\""+this_id+"\"></userTask>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"task_"+this_id+"\" targetRef=\"gateway_"+next_id+"\"></sequenceFlow>"+"\n"; RECUformXMLfile(nodeMap, next_id, next_type); } else if(next_type.equals("join")){ XMLhead += "<userTask id=\"task_"+this_id+"\" name=\""+this_id+"\"></userTask>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"task_"+this_id+"\" targetRef=\"gateway_"+next_id+"\"></sequenceFlow>"+"\n"; //return ; RECUformXMLfile(nodeMap, next_id, next_type); } else{//task XMLhead += "<userTask id=\"task_"+this_id+"\" name=\""+this_id+"\"></userTask>"+"\n"; XMLhead += "<sequenceFlow id=\"flow_"+this_id+"\" sourceRef=\"task_"+this_id+"\" targetRef=\"task_"+next_id+"\"></sequenceFlow>"+"\n"; RECUformXMLfile(nodeMap, next_id, next_type); } } }
去哪网实习总结:递归构建“流程运行顺序”的XML文件(JavaWeb)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。