fix bugs in flow rename.
This commit is contained in:
parent
30599aff7f
commit
bd2f5ad1c6
|
@ -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<Flow> 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<Flow> flows = (List<Flow>) query.list();
|
||||
for(Flow flow : flows){
|
||||
|
||||
System.out.println("database<EFBFBD><EFBFBD>"+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<Flow> renameFlowFolder(int userid,UUID flowId,String name) {
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
Transaction trans=session.beginTransaction();
|
||||
try {
|
||||
//<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
||||
List<Flow> flowandfolder=new ArrayList<Flow>();
|
||||
Flow flowfolder = (Flow) session.get(Flow.class, flowId);
|
||||
flowfolder.setName(name);
|
||||
//<EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>
|
||||
|
@ -183,23 +209,25 @@ public class FlowService {
|
|||
newpath+=name;
|
||||
flowfolder.setPath(newpath);
|
||||
session.update(flowfolder);
|
||||
flowandfolder.add(flowfolder);
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
String parentpath=flowId.toString();
|
||||
Query querychild= session.createQuery("select f from Flow f where f.parentpath =?");
|
||||
querychild.setString(0, parentpath);
|
||||
List<Flow> flows = (List<Flow>)querychild.list();
|
||||
for(Flow flow : flows){
|
||||
for(Flow flow : flows){
|
||||
flowandfolder.add(flow);
|
||||
System.out.println("child<EFBFBD><EFBFBD>"+flow.getId() + " : " + flow.getNode() + " : " + flow.getPath()+ " : " + flow.getParentpath());
|
||||
renameFlowPath(userid,flow.getId(),newpath,session);
|
||||
}
|
||||
//<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
|
||||
trans.commit();
|
||||
session.close();
|
||||
return true;
|
||||
return flowandfolder;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
session.close();
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<Flow> flowList =this.getFlowService().renameFlowFolder(userid, flowId, name);
|
||||
FlowListModel flowListModel = new FlowListModel();
|
||||
flowListModel.setFlows(new ArrayList<FlowBriefModel>());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/grid.jsp
|
|
@ -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<data.flows.length;i++) {
|
||||
instance.flowListStore.remove(data.flows[i].id);
|
||||
instance.flowListStore.put({
|
||||
id : flowfolder.id,
|
||||
name : flowfolder.name,
|
||||
node : false,
|
||||
path:flowfolder.path,
|
||||
parentpath:flowfolder.parentpath
|
||||
});
|
||||
id : data.flows[i].id,
|
||||
name : data.flows[i].name,
|
||||
node : data.flows[i].node,
|
||||
path:data.flows[i].path,
|
||||
parentpath:data.flows[i].parentpath
|
||||
});
|
||||
}
|
||||
else
|
||||
} else
|
||||
_currentInstance.addToConsole("An error occurred while saving flowfolder", true);
|
||||
|
||||
},
|
||||
|
|
|
@ -199,6 +199,9 @@ HAFlow.Main.prototype.onConnectionClicked = function(instance, flowId, info) {
|
|||
});
|
||||
button.placeAt(dojo.byId("delete_connection_button"));
|
||||
button.startup();
|
||||
|
||||
var informationPane = dijit.byId(instance.informationContainerId);
|
||||
this.ui.bottomContainer.selectChild(informationPane);
|
||||
};
|
||||
|
||||
HAFlow.Main.prototype.onConnectionCreated = function(instance, flowId, info) {
|
||||
|
@ -265,7 +268,8 @@ HAFlow.Main.prototype.onNodeClicked = function(instance, flowId, nodeId){
|
|||
button.startup();
|
||||
this.initNodeDataGrid(instance,flowId,nodeId);
|
||||
|
||||
|
||||
var informationPane = dijit.byId(instance.informationContainerId);
|
||||
this.ui.bottomContainer.selectChild(informationPane);
|
||||
};
|
||||
HAFlow.Main.prototype.initNodeDataGrid=function(instance,flowId,nodeId){
|
||||
var node = instance.getNodeById(instance, flowId, nodeId);
|
||||
|
|
|
@ -830,7 +830,7 @@ HAFlow.Main.prototype.initChart = function(chart, currentPortlet, legendDivId){
|
|||
var legend;
|
||||
|
||||
$.ajax({
|
||||
url : "http://localhost:8080/haflow/report/getchartseries",
|
||||
url : _currentInstance.basePath + "report/" + "getchartseries",
|
||||
type : "POST",
|
||||
dataType : "json",
|
||||
data : JSON.stringify(currentPortlet.chartSeries),
|
||||
|
|
Loading…
Reference in New Issue