/** {@inheritDoc} */
 @Override
 public void addGridElement(GridElement e) {
   Session session = this.sessionFactory.getCurrentSession();
   session.persist(e);
   logger.info(
       "added a new "
           + e.getClass().getSimpleName()
           + " on persistence layer id:"
           + e.getIdElement());
 }
 @RequestMapping(value = "/elementhistory/{type}/{label}")
 public String getElementHistory(
     @PathVariable("label") String label, @PathVariable("type") String type, Model model) {
   List<GridElement> tempList = this.gridElementService.getElementLog(label, type);
   GridElement workingGe = this.gridElementService.getLatestWorking(label, type);
   Map<String, String> status = new HashMap<String, String>();
   for (GridElement ge : tempList) {
     if (!(ge.getIdElement() == workingGe.getIdElement())
         && ge.getState().equals(GridElement.State.WORKING)) {
       status.put(ge.getIdElement() + "", "ARCHIVED");
     } else {
       status.put(ge.getIdElement() + "", ge.getState().toString());
     }
   }
   logger.info(status.toString());
   model.addAttribute("nGridElements", tempList.size());
   model.addAttribute("listGridElements", tempList);
   model.addAttribute("status", status);
   model.addAttribute("type", type);
   model.addAttribute("label", label);
   // System.out.println(tempList.toString());
   return "elementhistory";
 }
 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;
 }