Package org.structr.core.graph

Examples of org.structr.core.graph.NodeAttribute


      SchemaNode node = null;

      // setup
      try (final Tx tx = app.tx()) {

        node = app.create(SchemaNode.class, new NodeAttribute(SchemaNode.name, "TestType"));
        node.setProperty(new StringProperty("_test"), "Integer");

        tx.success();
      }

      // fetch dynamic type info
      final Class dynamicType   = StructrApp.getConfiguration().getNodeEntityClass("TestType");
      final PropertyKey testKey = StructrApp.getConfiguration().getPropertyKeyForJSONName(dynamicType, "test");

      // modify schema node but keep reference to "old" type
      try (final Tx tx = app.tx()) {

        node.setProperty(new StringProperty("_test2"), "String");

        tx.success();
      }

      // create test nodes
      try (final Tx tx = app.tx()) {

        app.create(dynamicType, new NodeAttribute(testKey, 10));
        app.create(dynamicType, new NodeAttribute(testKey, 11));
        app.create(dynamicType, new NodeAttribute(testKey, 12));

        tx.success();
      }

      // query test nodes
View Full Code Here


  private File createFileNode(final String uuid, final String name, final String contentType, final long size, final long checksum) throws FrameworkException {

    String relativeFilePath = File.getDirectoryPath(uuid) + "/" + uuid;
    File fileNode = app.create(File.class,
      new NodeAttribute(GraphObject.id, uuid),
      new NodeAttribute(AbstractNode.name, name),
      new NodeAttribute(File.relativeFilePath, relativeFilePath),
      new NodeAttribute(File.contentType, contentType),
      new NodeAttribute(File.size, size),
      new NodeAttribute(File.checksum, checksum),
      new NodeAttribute(File.version, 1),
      new NodeAttribute(AbstractNode.visibleToPublicUsers, publicVisible),
      new NodeAttribute(AbstractNode.visibleToAuthenticatedUsers, authVisible));

    return fileNode;

  }
View Full Code Here

  private Image createImageNode(final String uuid, final String name, final String contentType, final long size, final long checksum) throws FrameworkException {

    String relativeFilePath = Image.getDirectoryPath(uuid) + "/" + uuid;
    Image imageNode = app.create(Image.class,
      new NodeAttribute(GraphObject.id, uuid),
      new NodeAttribute(AbstractNode.name, name),
      new NodeAttribute(File.relativeFilePath, relativeFilePath),
      new NodeAttribute(File.contentType, contentType),
      new NodeAttribute(File.size, size),
      new NodeAttribute(File.checksum, checksum),
      new NodeAttribute(AbstractNode.visibleToPublicUsers, publicVisible),
      new NodeAttribute(AbstractNode.visibleToAuthenticatedUsers, authVisible));

    return imageNode;

  }
View Full Code Here

      final Folder parentFolder = (Folder) FileHelper.getFileByAbsolutePath(SecurityContext.getSuperUserInstance(), StringUtils.substringBeforeLast(newPath, "/"));

      try {
        Folder newFolder = (Folder) StructrApp.getInstance().command(CreateNodeCommand.class).execute(
          new NodeAttribute(AbstractNode.type, Folder.class.getSimpleName()),
          new NodeAttribute(AbstractNode.owner, owner.getStructrUser()),
          new NodeAttribute(AbstractNode.name, getName())
        );

        if (parentFolder != null) {
          newFolder.setProperty(AbstractFile.parent, parentFolder);
        }
View Full Code Here

    DOMElement element;
    try {
      final Class entityClass = SchemaHelper.getEntityClassForRawType(elementType);
      if (entityClass != null) {

        element = (DOMElement) app.create(entityClass, new NodeAttribute(DOMElement.tag, tag));
        element.doAdopt(_page);

        return element;
      }
View Full Code Here

    try {

      // create new content element
      Content content = (Content) StructrApp.getInstance(securityContext).command(CreateNodeCommand.class).execute(
        new NodeAttribute(AbstractNode.type, Content.class.getSimpleName()),
        new NodeAttribute(Content.content, text)
      );

      // create relationship from ownerDocument to new text element
      ((RelationProperty<DOMNode>) Page.elements).addSingleElement(securityContext, Page.this, content);
      //Page.elements.createRelationship(securityContext, Page.this, content);
View Full Code Here

    try {

      // create new content element
      org.structr.web.entity.dom.Comment commentNode = (org.structr.web.entity.dom.Comment) StructrApp.getInstance(securityContext).command(CreateNodeCommand.class).execute(
        new NodeAttribute(AbstractNode.type, org.structr.web.entity.dom.Comment.class.getSimpleName()),
        new NodeAttribute(Content.content, comment)
      );

      // create relationship from ownerDocument to new text element
      ((RelationProperty<DOMNode>) Page.elements).addSingleElement(securityContext, Page.this, commentNode);
      //Page.elements.createRelationship(securityContext, Page.this, content);
View Full Code Here

    try {

      // create new content element
      Cdata content = (Cdata) StructrApp.getInstance(securityContext).command(CreateNodeCommand.class).execute(
        new NodeAttribute(AbstractNode.type, Cdata.class.getSimpleName())
      );

      // create relationship from ownerDocument to new text element
      ((RelationProperty<DOMNode>) Page.elements).addSingleElement(securityContext, Page.this, content);
      //Page.elements.createRelationship(securityContext, Page.this, content);
View Full Code Here

      ResourceAccess grant = app.nodeQuery(ResourceAccess.class).and(ResourceAccess.signature, signature).getFirst();
      if (grant == null) {

        // create new grant
        grants.add(app.create(DynamicResourceAccess.class,
          new NodeAttribute(DynamicResourceAccess.signature, signature),
          new NodeAttribute(DynamicResourceAccess.flags, initialFlagsValue)
        ));

        // create additional grant for the _schema resource
        grants.add(app.create(DynamicResourceAccess.class,
          new NodeAttribute(DynamicResourceAccess.signature, "_schema/" + signature),
          new NodeAttribute(DynamicResourceAccess.flags, initialFlagsValue)
        ));

        // create additional grant for the Ui view
        grants.add(app.create(DynamicResourceAccess.class,
          new NodeAttribute(DynamicResourceAccess.signature, signature + "/_Ui"),
          new NodeAttribute(DynamicResourceAccess.flags, initialFlagsValue)
        ));
      }

    } catch (Throwable t) {
View Full Code Here

    NodeInterface child1 = null;
    NodeInterface child2 = null;

    try (final Tx tx = app.tx()) {

      itemNode = app.create(SchemaNode.class, new NodeAttribute(SchemaNode.name, "Item"));

      final PropertyMap properties = new PropertyMap();
      properties.put(SchemaRelationship.relationshipType, "CHILD");
      properties.put(SchemaRelationship.sourceMultiplicity, "1");
      properties.put(SchemaRelationship.targetMultiplicity, "*");
 
View Full Code Here

TOP

Related Classes of org.structr.core.graph.NodeAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.