去哪網實習總結:遞迴構建“流程運行順序”的XML檔案(JavaWeb)

來源:互聯網
上載者:User

標籤:else   data-   www.   流程   model   equal   總結   cer   ble   

本來是以做資料採礦的目的進去哪網的,結構卻成了系統開發。。。

只是還是比較認真的做了三個月,老師非常認同我的工作態度和成果。。

實習立即就要結束了,總結一下幾點之前沒有注意過的變成習慣和問題。分享給大家。


同一時候打個廣告:去哪網內審部招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";//startString 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")){//startString[] 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{//taskXMLhead += "<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")){//splitXMLhead += "<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{//taskXMLhead += "<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。一個用taskString[] 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{//taskXMLhead += "<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。一個用taskString[] 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{//taskXMLhead += "<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個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.