/**
   * Dynamically write javascript code to set variables to fill in the grid
   *
   * @param relationsMap
   * @param listOfAttributes
   * @param dir
   * @param theNode
   * @param out
   * @param key
   */
  private static void computeGrid(
      HashMap<String, HashMap<String, String>> listOfAttributes, Node theNode, JspWriter out) {
    try {
      for (String strType : DefaultTemplate.sortAttributes(listOfAttributes.keySet())) {
        HashMap<String, String> attribs = listOfAttributes.get(strType);
        List<String> sortedAttribs = DefaultTemplate.sortAttributes(attribs.keySet());

        out.print("gridColumns['" + strType + "'] = [");
        out.print("{text:'Link', flex:1, dataIndex:'Link'}");
        out.print(",{text:'Relation', flex:1, dataIndex:'Relation', hidden:true}");
        for (String attribute : sortedAttribs)
          out.print(
              ",{text:'"
                  + attribute
                  + "', flex:1, filtrable:true, filter:true, dataIndex:'"
                  + attribute
                  + "', editor: { allowBlank: true }}");
        out.print("];\n");

        out.print("gridFields['" + strType + "'] = [");
        out.print("'Link','Relation'");
        for (String attribute : sortedAttribs) out.print(",'" + attribute + "'");
        out.print("];\n");

        out.print("gridSorters['" + strType + "'] = [");
        out.print("'Link'");
        for (String attribute : sortedAttribs) out.print(",'" + attribute + "'");
        out.print("];\n");

        out.print("gridName['" + strType + "'] = '" + strType + "';\n");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public String getAttributeJSON(String varName) {
    // EDITING THE STRING
    String output = "var " + varName + " = {";

    String AttributeObjectString = "";
    for (String key : theNode.getPropertyKeys()) {
      if (DefaultTemplate.keepAttribute(key))
        AttributeObjectString +=
            ",\""
                + key
                + "\":\""
                + DefaultTemplate.Sanitize(theNode.getProperty(key).toString())
                + "\"";
    }
    if (AttributeObjectString.isEmpty()) output += "};\n";
    else output += AttributeObjectString.substring(1) + "};\n";
    return output;
  }
 public DefaultNode(String nodeID) {
   theNode = DefaultTemplate.graphDb().getNodeById(Long.valueOf(nodeID));
 }