@RequestMapping(value = "/GEResolution/{pid}/{type}/{label}", method = RequestMethod.GET)
  public String GEResolution(
      @PathVariable("type") String type,
      @PathVariable("pid") int pid,
      @PathVariable("label") String label,
      Model model) {
    model.addAttribute("pageTitle", "Grids Versioning System");
    GridElement workingGE = this.gridElementService.getLatestWorking(label, type);
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    String email = auth.getName(); // get logged in username
    Practitioner p = this.practitionerService.getPractitionerByEmail(email);

    if (Modification.minorUpdateClass.contains(workingGE.getClass())) {
      model.addAttribute("error", "You cannot access to this element (minor conflict)");
    } else {
      Practitioner currentPract = this.projectService.getProjectById(pid).getProjectManager();
      if (currentPract == null) {
        currentPract =
            this.defaultResponsibleService.getResponsibleByClassName("pm").getPractitioner();
      }
      if (currentPract == p) {
        List<GridElement> geList =
            this.gridElementService.getElementByLabelAndState(
                label, type, GridElement.State.MAJOR_UPDATING);
        geList.addAll(
            this.gridElementService.getElementByLabelAndState(
                label, type, GridElement.State.MAJOR_CONFLICTING));
        geList.addAll(
            this.gridElementService.getElementByLabelAndState(
                label, type, GridElement.State.MINOR_CONFLICTING));
        List<GridElement> newGeList = Utils.removeDuplicates(geList);

        if (newGeList.size() > 0 && workingGE != null) {
          model.addAttribute("workingGE", workingGE);
          model.addAttribute("updatingElements", newGeList);
          model.addAttribute("nupdatingElements", geList.size());

        } else if (workingGE != null && newGeList.size() == 0) {
          model.addAttribute("error", "The requested Grid Element is in a consistent state");
        } else {
          model.addAttribute("error", "The requested Grid Element is not available");
        }
      } else {
        model.addAttribute("error", "You cannot access to this element");
      }
    }
    model.addAttribute("ProjectId", pid);
    model.addAttribute("GEService", this.gridElementService);
    return "GEResolution";
  }
 private String updateChart(List<Object> stack) {
   String chart = "";
   for (int i = 0; i < stack.size(); i++) {
     String image = "";
     String name = "";
     String desc = "";
     List<Object> newStack = new ArrayList<Object>();
     GridElement ge = (GridElement) stack.get(i);
     name =
         stack.get(i).getClass().getSimpleName()
             + " "
             + ge.getLabel()
             + " - <i>"
             + Utils.dateStringFromTimestamp(ge.getTimestamp())
             + "</i>";
     desc = "<div class='txtElement'><i>" + ge.getState().name() + "</i></div>";
     // TODO this part is not the same in utils?? (obtain HTML)
     Field[] fields = ge.getClass().getDeclaredFields();
     for (int j = 0; j < fields.length; j++) {
       Field tempField = fields[j];
       tempField.setAccessible(true);
       try {
         Object fieldValue = tempField.get(ge);
         if (fieldValue instanceof GridElement) {
           newStack.add(fieldValue);
         } else if (fieldValue instanceof List) {
           List myList = (List) fieldValue;
           if (myList.size() > 0) {
             Object first = myList.get(0);
             if (first instanceof GridElement) {
               newStack.addAll(myList);
             }
           }
         } else {
           // desc=desc+"<div style='float:left;min-width: 200px;'>"+tempField.getName()+":
           // "+fieldValueStr+"</div>";
           if (fieldValue != null) {
             if (!tempField.getName().equals("logger")) {
               String fieldValueStr = (String) fieldValue.toString();
               String txt = tempField.getName() + ": </i> " + fieldValueStr;
               int maxLength = 60;
               if (txt.length() > maxLength) txt = txt.substring(0, maxLength) + "...";
               desc = desc + "<div class='txtElement'><i>" + txt + "</div>";
             }
           }
         }
       } catch (IllegalArgumentException e) {
         e.printStackTrace();
       } catch (IllegalAccessException e) {
         e.printStackTrace();
       }
     }
     String geType = "";
     if (ge.getClass().getSimpleName().equals("Goal")
         || ge.getClass().getSimpleName().equals("Strategy")) {
       geType = "HTMLclass: 'gqmplusstrategy',";
     } else {
       geType = "HTMLclass: 'gqmgraph',";
     }
     chart =
         chart
             + "\n{"
             + geType
             + " innerHTML:\"<div style=\'background-color: red;\'><div class=\'nodeTxt\'><div class='txtElementTitle'><div class='nodeImg' ><img src='/ISSSR/resources/images/ImgGVS/"
             + ge.getClass().getSimpleName()
             + ".png' /></div><a style='z-index: 10;position:relative; color:black;' href='/ISSSR/element/"
             + ge.getClass().getSimpleName()
             + "/"
             + ge.getIdElement()
             + "'>"
             + name
             + "</a></div>"
             + desc
             + "</div></div>\", ";
     // chart=chart+"{text: { name: \""+name+"\", desc: \""+desc+"\"
     // },innerHTML:\"<div><h1>test</h1></div>\", collapsed: true";
     if (newStack.size() > 0) {
       chart = chart + " collapsed: true ,children: [";
       chart = chart + updateChart(newStack);
       chart = chart + "]";
     } else chart = chart + " collapsed: false";
     chart = chart + "}";
     if (i < stack.size() - 1) chart = chart + ",";
   }
   return chart;
 }