| | |
| | | import org.dom4j.DocumentHelper; |
| | | import org.dom4j.Document; |
| | | import org.dom4j.Element; |
| | | import org.dom4j.io.OutputFormat; |
| | | import org.dom4j.io.XMLWriter; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.zt.common.db.query.QueryFilter; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.StringWriter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | // 5. 转换为算法库接口XML |
| | | if (result) { |
| | | // result = createIfXmlFromRbd(modelRbd, algorithmList, modelNodeAndVnodeList); |
| | | result = createIfXmlFromRbd(modelRbd, algorithmList, modelNodeAndVnodeList); |
| | | } |
| | | |
| | | // 6. 保存模型 |
| | |
| | | block = link.addElement("Block"); |
| | | block.addAttribute("Name", "Start"); |
| | | |
| | | document.setXMLEncoding("UTF-8"); |
| | | String xmlString = document.asXML(); |
| | | modelRbd.setIfXml(xmlString); |
| | | // document.setXMLEncoding("UTF-8"); |
| | | // String xmlString = document.asXML(); |
| | | // 输出格式化xml |
| | | XMLWriter xmlWriter = null; |
| | | try { |
| | | OutputFormat format = OutputFormat.createPrettyPrint(); |
| | | format.setEncoding("UTF-8"); |
| | | StringWriter writer = new StringWriter(); |
| | | xmlWriter = new XMLWriter(writer, format); |
| | | xmlWriter.write(document); |
| | | modelRbd.setPublishedXml(writer.toString()); |
| | | } finally { |
| | | if (xmlWriter!=null) xmlWriter.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | result = false; |
| | |
| | | ModelNode endNode = getBranchNodesOneParallel(pathOneGroup, branchNodeList); |
| | | if ("connect".equals(startNode.getNodeType()) && pathOneGroup.size()==lines.size()) { |
| | | // 替换成虚节点 |
| | | modelNodeAndVnodeList.add(startNode); |
| | | replaceToVnode("parallel", modelId, modelNodeList, modelLineList, |
| | | algorithmList, modelNodeAndVnodeList, startNode, endNode, branchNodeList); |
| | | } else { |
| | |
| | | |
| | | if ("connect".equals(startNode.getNodeType()) && startNode.getInLineNum()==2) { |
| | | // 替换成虚节点 |
| | | modelNodeAndVnodeList.add(startNode); |
| | | replaceToVnode("bridge", modelId, modelNodeList, modelLineList, |
| | | algorithmList, modelNodeAndVnodeList, startNode, endNode, branchNodeList); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | if (thisNodeSuccess) { |
| | | modelNodeAndVnodeList.add(opNode); |
| | | replaceToVnode(opNode.getNodeType(), modelId, modelNodeList, modelLineList, |
| | | algorithmList, modelNodeAndVnodeList, opNode, endNode, branchNodeList); |
| | | hasSimplified = true; |
| | |
| | | algorithm.setAlgorithmType(type); |
| | | algorithm.setComputerList(computerList.get(0)); |
| | | algorithm.setObjectList(computerList.get(1)); |
| | | if ("vote".equals(type)) algorithm.setVoteNum(startNode.getVoteNum()); |
| | | algorithm.setStep(algorithmList.size()==0 ? 0 : algorithmList.get(algorithmList.size()-1).getStep()+1); |
| | | algorithmList.add(algorithm); |
| | | |
| | |
| | | } |
| | | |
| | | // 更新RBD数据 |
| | | modelRbd.setPublishedContent(modelRbd.getContent()); |
| | | modelRbdDao.updateById(modelRbd); |
| | | } |
| | | |