Package org.structr.core.graph

Examples of org.structr.core.graph.NodeInterface


    try {

      // Create a relationship with DELETE_INCOMING
      AbstractRelationship rel = cascadeRel(TestOne.class, TestTwo.class, Relation.TARGET_TO_SOURCE | Relation.SOURCE_TO_TARGET);
      NodeInterface sourceNode;
      NodeInterface targetNode;
      String startNodeId;
      String endNodeId;

      try (final Tx tx = app.tx()) {
View Full Code Here


  public void test07CascadeDeleteConditional() {

    try {

      AbstractRelationship rel = cascadeRel(TestOne.class, TestTwo.class, Relation.CONSTRAINT_BASED);
      NodeInterface sourceNode;
      String startNodeId;
      String endNodeId;

      try (final Tx tx = app.tx()) {
View Full Code Here

  public void test03CreateRelationship() {

    try {

      final List<GenericNode> nodes = createTestNodes(GenericNode.class, 2);
      final NodeInterface startNode = nodes.get(0);
      final NodeInterface endNode   = nodes.get(1);
      NodeHasLocation rel           = null;

      assertTrue(startNode != null);
      assertTrue(endNode != null);

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

        rel = app.create(startNode, endNode, NodeHasLocation.class);
        tx.success();
      }

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

        assertEquals(startNode.getUuid(), rel.getSourceNodeId());
        assertEquals(endNode.getUuid(), rel.getTargetNodeId());
        assertEquals(RelType.IS_AT.name(), rel.getType());
        assertEquals(NodeHasLocation.class, rel.getClass());
      }

    } catch (FrameworkException ex) {
View Full Code Here

          }

          logger.log(Level.INFO, "Creating node of type {0}", type);

          NodeInterface node = app.create(type, props);

          assertTrue(type.getSimpleName().equals(node.getProperty(AbstractNode.type)));

          // Remove mandatory fields for ResourceAccess from props map
          if (type.equals(ResourceAccess.class)) {

            props.remove(ResourceAccess.signature);
View Full Code Here

          String type = entityClass.getSimpleName();

          logger.log(Level.INFO, "Creating relationship of type {0}", type);

          List<GenericNode> nodes        = createTestNodes(GenericNode.class, 2);
          final NodeInterface startNode  = nodes.get(0);
          final NodeInterface endNode    = nodes.get(1);
          final RelationshipType relType = RelType.IS_AT;
          NodeHasLocation rel       = app.create(startNode, endNode, NodeHasLocation.class);

          assertTrue(rel != null);
          assertTrue(rel.getType().equals(relType.name()));
View Full Code Here

      final PropertyMap props = new PropertyMap();
      final String type       = "UnknownTestType";
      final String name       = "GenericNode-name";
     
      NodeInterface node      = null;

      props.put(AbstractNode.type, type);
      props.put(AbstractNode.name, name);

      try (final Tx tx = app.tx()) {
       
        node = app.create(GenericNode.class, props);
        tx.success();
      }

      try (final Tx tx = app.tx()) {
       
        // Check defaults
        assertEquals(GenericNode.class.getSimpleName(), node.getProperty(AbstractNode.type));
        assertTrue(node.getProperty(AbstractNode.name).equals(name));
        assertTrue(!node.getProperty(AbstractNode.hidden));
        assertTrue(!node.getProperty(AbstractNode.deleted));
        assertTrue(!node.getProperty(AbstractNode.visibleToAuthenticatedUsers));
        assertTrue(!node.getProperty(AbstractNode.visibleToPublicUsers));
      }

      final String name2 = "GenericNode-name-äöüß";

      try (final Tx tx = app.tx()) {
       
        // Modify values
        node.setProperty(AbstractNode.name, name2);
        node.setProperty(AbstractNode.hidden, true);
        node.setProperty(AbstractNode.deleted, true);
        node.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
        node.setProperty(AbstractNode.visibleToPublicUsers, true);

        tx.success();
      }

      try (final Tx tx = app.tx()) {
       
        assertTrue(node.getProperty(AbstractNode.name).equals(name2));
        assertTrue(node.getProperty(AbstractNode.hidden));
        assertTrue(node.getProperty(AbstractNode.deleted));
        assertTrue(node.getProperty(AbstractNode.visibleToAuthenticatedUsers));
        assertTrue(node.getProperty(AbstractNode.visibleToPublicUsers));
      }

    } catch (FrameworkException ex) {

      logger.log(Level.SEVERE, ex.toString());
View Full Code Here

   
    if (obj instanceof RelationshipInterface) {
   
      try {
        final Relationship relationship = ((RelationshipInterface)obj).getRelationship();
        final NodeInterface endNode     = new NodeFactory<>(securityContext).instantiate(relationship.getEndNode());

        if (endNode != null) {
         
          return endNode.getUuid();
        }
       
      } catch (Throwable t) {
       
        t.printStackTrace();
View Full Code Here

  public PropertyMap getGroupedProperties(SecurityContext securityContext, GraphObject source) {

    if(source instanceof AbstractRelationship) {

      RelationshipInterface rel = (RelationshipInterface)source;
      NodeInterface startNode   = rel.getSourceNode();

      return super.getGroupedProperties(securityContext, startNode);
    }

    return null;
View Full Code Here

      return;
    }

    final App app = StructrApp.getInstance(securityContext);

    final NodeInterface newStartNode = (NodeInterface)app.get(startNodeId);
    final NodeInterface endNode      = getTargetNode();
    final Class relationType         = getClass();
    final PropertyMap _props         = getProperties();
    final String type                = this.getClass().getSimpleName();

    if (newStartNode == null) {
View Full Code Here

      return;
    }

    final App app = StructrApp.getInstance(securityContext);

    final NodeInterface newTargetNode = (NodeInterface)app.get(targetIdNode);
    final NodeInterface startNode     = getSourceNode();
    final Class relationType          = getClass();
    final PropertyMap _props          = getProperties();
    final String type                 = this.getClass().getSimpleName();

    if (newTargetNode == null) {
View Full Code Here

TOP

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

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.