public String getType() {
   try {
     return theNode.getProperty("type").toString();
   } catch (Exception e) {
     return "";
   }
 }
  public VNodeDefinition(Node node) throws RepositoryException {
    name = node.getProperty(JCR_NODETYPENAME).getString();

    // do properties
    properties = new HashMap<String, VPropertyDefinitionI>();
    childSuggestions = new HashMap<String, String>();
    NodeIterator nodeIterator = node.getNodes();
    while (nodeIterator.hasNext()) {
      Node definitionNode = nodeIterator.nextNode();
      String nodeType = definitionNode.getProperty(AbstractProperty.JCR_PRIMARYTYPE).getString();

      // do a property
      if (NT_PROPERTYDEFINITION.equals(nodeType)) {
        String propertyName = "*"; // default to wildcard name
        if (definitionNode.hasProperty(JCR_NAME)) {

          // only add non-autogenerated properties
          if (!definitionNode.getProperty(JCR_AUTOCREATED).getBoolean()) {
            propertyName = definitionNode.getProperty(JCR_NAME).getString();
            properties.put(propertyName, new VPropertyDefinition(definitionNode));
          }
        } else {
          // property with no name means this node can accept custom properties
          canAddProperties = true;
        }
      }

      // do a child suggestion
      if (NT_CHILDNODEDEFINITION.equals(nodeType)) {
        String childName = "*";
        // only do well-defined childnodedefinitions with the following 2 jcr properties
        if (definitionNode.hasProperty(JCR_NAME)
            && definitionNode.hasProperty(JCR_DEFAULTPRIMARYTYPE)) {
          childSuggestions.put(
              definitionNode.getProperty(JCR_NAME).getString(),
              definitionNode.getProperty(JCR_DEFAULTPRIMARYTYPE).getString());
        }
      }
    }

    // do supertypes
    supertypes = new HashSet<String>();
    if (node.hasProperty(JCR_SUPERTYPES)) {
      for (Value value : node.getProperty(JCR_SUPERTYPES).getValues()) {
        supertypes.add(value.getString());
      }
    }

    // set mixin status
    isMixin = node.hasProperty(JCR_ISMIXIN) && node.getProperty(JCR_ISMIXIN).getBoolean();
  }
Пример #3
0
  private static Map<String, List<LinkedHashMap<String, Object>>> getFeaturesForAllClasses(
      GraphDatabaseService db) {
    List<Node> classes = getAllClasses(db);

    Map<String, List<LinkedHashMap<String, Object>>> featureMap = new HashMap<>();

    Transaction tx = db.beginTx();
    for (Node thisClass : classes) {
      featureMap.put((String) thisClass.getProperty("name"), getFeaturesForClass(db, thisClass));
    }
    tx.success();
    tx.close();

    return featureMap;
  }
  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;
  }