From bd2f5ad1c601801f78f6dc079cbcb7290f922c68 Mon Sep 17 00:00:00 2001 From: zhaowei8188127 <18810460332@163.com> Date: Fri, 27 Dec 2013 15:29:06 +0800 Subject: [PATCH] fix bugs in flow rename. --- src/main/java/haflow/service/FlowService.java | 36 ++++++++++++++++--- .../haflow/ui/controller/FlowController.java | 9 ++--- .../java/haflow/ui/helper/FlowHelper.java | 19 +++++++--- src/main/webapp/WEB-INF/views/.gitignore | 1 + .../webapp/script/haflow.flow_operation.js | 21 ++++++----- src/main/webapp/script/haflow.jsplumb.js | 6 +++- src/main/webapp/script/haflow.report.js | 2 +- 7 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 src/main/webapp/WEB-INF/views/.gitignore diff --git a/src/main/java/haflow/service/FlowService.java b/src/main/java/haflow/service/FlowService.java index 3f59b4c..f57e6ee 100644 --- a/src/main/java/haflow/service/FlowService.java +++ b/src/main/java/haflow/service/FlowService.java @@ -7,6 +7,7 @@ import haflow.dto.entity.MainUser; import haflow.dto.entity.Node; import haflow.util.SessionHelper; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -143,6 +144,30 @@ public class FlowService { } } + @SuppressWarnings("unchecked") + public List afterrenamegetFlowList(int userid, String path) { + System.out.println(userid); + System.out.println(path); + Session session = this.getSessionHelper().openSession(); + try { + + Query query = session.createQuery("select f from Flow f where f.id =? and f.user.id=?"); + query.setString(0, path); + query.setInteger(1, userid); + List flows = (List) query.list(); + for(Flow flow : flows){ + + System.out.println("database��"+flow.getId() + " : " + flow.getNode() + " : " + flow.getPath()+ " : " + flow.getParentpath()); + } + session.close(); + return flows; + } catch (Exception e) { + e.printStackTrace(); + session.close(); + return null; + } + } + @SuppressWarnings("unchecked") public void renameFlowPath(int userid,UUID flowId,String path,Session session) { @@ -166,11 +191,12 @@ public class FlowService { } @SuppressWarnings("unchecked") - public boolean renameFlowFolder(int userid,UUID flowId,String name) { + public List renameFlowFolder(int userid,UUID flowId,String name) { Session session = this.getSessionHelper().openSession(); Transaction trans=session.beginTransaction(); try { //�޸��ļ��� + List flowandfolder=new ArrayList(); Flow flowfolder = (Flow) session.get(Flow.class, flowId); flowfolder.setName(name); //�޸�·�� @@ -183,23 +209,25 @@ public class FlowService { newpath+=name; flowfolder.setPath(newpath); session.update(flowfolder); + flowandfolder.add(flowfolder); //�������ļ� String parentpath=flowId.toString(); Query querychild= session.createQuery("select f from Flow f where f.parentpath =?"); querychild.setString(0, parentpath); List flows = (List)querychild.list(); - for(Flow flow : flows){ + for(Flow flow : flows){ + flowandfolder.add(flow); System.out.println("child��"+flow.getId() + " : " + flow.getNode() + " : " + flow.getPath()+ " : " + flow.getParentpath()); renameFlowPath(userid,flow.getId(),newpath,session); } //�ҵ�����д�ļ�·�� trans.commit(); session.close(); - return true; + return flowandfolder; } catch (Exception e) { e.printStackTrace(); session.close(); - return false; + return null; } } diff --git a/src/main/java/haflow/ui/controller/FlowController.java b/src/main/java/haflow/ui/controller/FlowController.java index a715a15..7838190 100644 --- a/src/main/java/haflow/ui/controller/FlowController.java +++ b/src/main/java/haflow/ui/controller/FlowController.java @@ -69,15 +69,12 @@ public class FlowController { @RequestMapping(value = "/rename/{flowId}", method = RequestMethod.GET) @ResponseBody - public boolean renameFlowFolder(@PathVariable UUID flowId, + public FlowListModel renameFlowFolder(@PathVariable UUID flowId, @RequestParam(value = "name", required = true) String name, HttpServletRequest request) { System.out.println("rename flow controller"); - if (getFlowHelper().renameFlowFolder(flowId, name, - (Integer) request.getSession().getAttribute("userid"))) - return true; - else - return false; + return getFlowHelper().renameFlowFolder(flowId, name, + (Integer) request.getSession().getAttribute("userid")); } @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) diff --git a/src/main/java/haflow/ui/helper/FlowHelper.java b/src/main/java/haflow/ui/helper/FlowHelper.java index 189f0cd..d6ada5e 100644 --- a/src/main/java/haflow/ui/helper/FlowHelper.java +++ b/src/main/java/haflow/ui/helper/FlowHelper.java @@ -228,11 +228,20 @@ public class FlowHelper { return result; } - public boolean renameFlowFolder(UUID flowId, String name,int userid) { + public FlowListModel renameFlowFolder(UUID flowId, String name,int userid) { System.out.println("rename flow helper"); - if(this.getFlowService().renameFlowFolder(userid, flowId, name)) - return true; - else - return false; + List flowList =this.getFlowService().renameFlowFolder(userid, flowId, name); + FlowListModel flowListModel = new FlowListModel(); + flowListModel.setFlows(new ArrayList()); + for (Flow flow : flowList) { + FlowBriefModel flowBriefModel = new FlowBriefModel(); + flowBriefModel.setId(flow.getId()); + flowBriefModel.setName(flow.getName()); + flowBriefModel.setNode(flow.getNode()); + flowBriefModel.setPath(flow.getPath()); + flowBriefModel.setParentpath(flow.getParentpath()); + flowListModel.getFlows().add(flowBriefModel); + } + return flowListModel; } } diff --git a/src/main/webapp/WEB-INF/views/.gitignore b/src/main/webapp/WEB-INF/views/.gitignore new file mode 100644 index 0000000..bacdb28 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/.gitignore @@ -0,0 +1 @@ +/grid.jsp diff --git a/src/main/webapp/script/haflow.flow_operation.js b/src/main/webapp/script/haflow.flow_operation.js index 65297ff..3efd427 100644 --- a/src/main/webapp/script/haflow.flow_operation.js +++ b/src/main/webapp/script/haflow.flow_operation.js @@ -796,19 +796,18 @@ HAFlow.Main.prototype.saveFlowFolderName = function(newVal,instance, flowId) { name : value }, success : function(data, status) { - if(data==true) - { - instance.getFlowBriefById(instance, flowId).name = value; - instance.flowListStore.remove(flowId); + if(data!=null){ + for(var i=0;i