@RequestMapping(value = "/MGResolution/{pid}/{gid}", method = RequestMethod.GET) public String mainGoalResolution( @PathVariable("gid") int gid, @PathVariable("pid") int pid, Model model) { model.addAttribute("pageTitle", "Lista Grids"); this.setActiveButton(2, model); Grid working = this.gridService.getLatestWorkingGrid(pid); Grid current = this.gridService.getGridById(gid); List<String> mergedGoalLabels = new ArrayList<String>(); if (working == null) { model.addAttribute("error", "The working Grid is not available"); } else if (current == null) { model.addAttribute("error", "The requested Grid is not available"); } else if ((!current.isMainGoalsChanged())) { model.addAttribute("error", "The requested Grid is not in pending state"); } else { String workingMGList = "['" + pid + "', '" + current.getId() + "', "; List<Goal> temp = working.getMainGoals(); for (int i = 0; i < temp.size(); i++) { if (!mergedGoalLabels.contains(temp.get(i).getLabel())) { mergedGoalLabels.add(temp.get(i).getLabel()); } if (i < temp.size() - 1) { workingMGList = workingMGList + "'" + temp.get(i).getLabel() + "',"; } else { workingMGList = workingMGList + "'" + temp.get(i).getLabel() + "'"; } } workingMGList = workingMGList + "]"; String currentMGList = "['" + pid + "', '" + current.getId() + "', "; temp = current.getMainGoals(); for (int i = 0; i < temp.size(); i++) { if (!mergedGoalLabels.contains(temp.get(i).getLabel())) { mergedGoalLabels.add(temp.get(i).getLabel()); } if (i < temp.size() - 1) { currentMGList = currentMGList + "'" + temp.get(i).getLabel() + "',"; } else { currentMGList = currentMGList + "'" + temp.get(i).getLabel() + "'"; } } currentMGList = currentMGList + "]"; model.addAttribute("mergedGoalLabels", mergedGoalLabels); model.addAttribute("workingGrid", working); model.addAttribute("currentGrid", current); model.addAttribute("workingMGList", workingMGList); model.addAttribute("currentMGList", currentMGList); model.addAttribute("GEService", this.gridElementService); } return "MGResolution"; }
private String createChart(Grid g) { if (g.getMainGoals().size() != 0) { List<Object> stack = new ArrayList<Object>(); stack.addAll(g.getMainGoals()); String chart = "chart_config = {chart: { connectors: {type: \"bCurve\",style: {\"stroke-width\": 2}}, container: \"#gridChart\", siblingSeparation:70, rootOrientation:'WEST', subTeeSeparation:70, animateOnInit: true,node: {collapsable: true, HTMLclass: 'nodeExample1'},animation: {nodeAnimation: \"easeOutBounce\",nodeSpeed: 500,connectorsAnimation: \"bounce\",connectorsSpeed: 700}},"; chart = chart + "nodeStructure: {HTMLclass: 'project',innerHTML:\"<div class='nodeTxt'><div class='txtProjectTitle'>" + g.getProject().getProjectId() + "</div><div class='txtElement'>" + g.getProject().getDescription() + "</div></div>\",children: ["; chart = chart + updateChart(stack) + "]}};"; return chart; } else { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "error"); jsonObject.put("resp", "grid main goal error"); return jsonObject.toString(); } }