Package org.structr.core.entity

Examples of org.structr.core.entity.AbstractRelationship


  }

  @Override
  public void processMessage(final WebSocketMessage webSocketData) {

    AbstractRelationship rel = getRelationship(webSocketData.getId());

    if (rel != null) {
      webSocketData.setResult(Arrays.asList(rel));

      // send only over local connection (no broadcast)
View Full Code Here


  public void test05CascadeDeleteOutgoing() {

    try {

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

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

        startNodeId = rel.getSourceNode().getUuid();
        endNodeId   = rel.getTargetNode().getUuid();
        sourceNode  = rel.getSourceNode();
      }

      deleteCascade(sourceNode);

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

        // Start node should not be found after deletion
        assertNodeNotFound(startNodeId);

        // End node should not be found after deletion
        assertNodeNotFound(endNodeId);
      }

      // Create another relationship with DELETE_OUTGOING
      rel = cascadeRel(TestOne.class, TestTwo.class, Relation.SOURCE_TO_TARGET);

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

        startNodeId = rel.getSourceNode().getUuid();
        endNodeId   = rel.getTargetNode().getUuid();
        targetNode  = rel.getTargetNode();
      }

      deleteCascade(targetNode);

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

  public void test06CascadeDeleteBidirectional() {

    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()) {

        startNodeId = rel.getSourceNode().getUuid();
        endNodeId   = rel.getTargetNode().getUuid();
        sourceNode  = rel.getSourceNode();
      }

      deleteCascade(sourceNode);

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

        // Start node should not be found after deletion
        assertNodeNotFound(startNodeId);

        // End node should not be found after deletion of start node
        assertNodeNotFound(endNodeId);
      }

      // Create a relationship with DELETE_INCOMING
      rel = cascadeRel(TestOne.class, TestTwo.class, Relation.TARGET_TO_SOURCE | Relation.SOURCE_TO_TARGET);

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

        startNodeId = rel.getSourceNode().getUuid();
        endNodeId   = rel.getTargetNode().getUuid();
        targetNode  = rel.getTargetNode();
      }

      deleteCascade(targetNode);

      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()) {

        startNodeId = rel.getSourceNode().getUuid();
        endNodeId   = rel.getTargetNode().getUuid();
        sourceNode  = rel.getSourceNode();
      }

      deleteCascade(sourceNode);

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

        // Start node should be deleted
        assertNodeNotFound(startNodeId);

        // End node should be deleted
        assertNodeNotFound(endNodeId);
      }

      rel = cascadeRel(TestOne.class, TestThree.class, Relation.CONSTRAINT_BASED);

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

        startNodeId = rel.getSourceNode().getUuid();
        endNodeId   = rel.getTargetNode().getUuid();
        sourceNode   = rel.getSourceNode();
      }

      deleteCascade(sourceNode);

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

        // Start node should be deleted
        assertNodeNotFound(startNodeId);

        // End node should still be there
        assertNodeExists(endNodeId);
      }

      rel = cascadeRel(TestOne.class, TestFour.class, Relation.CONSTRAINT_BASED);

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

        startNodeId = rel.getSourceNode().getUuid();
        endNodeId   = rel.getTargetNode().getUuid();
        sourceNode   = rel.getSourceNode();
      }

      deleteCascade(sourceNode);

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

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

      AbstractNode start       = createTestNode(type1);
      AbstractNode end         = createTestNode(type2);
      AbstractRelationship rel = createTestRelationship(start, end, NodeHasLocation.class);

      rel.setProperty(AbstractRelationship.cascadeDelete, cascadeDeleteFlag);

      tx.success();

      return rel;
    }
View Full Code Here

    final SecurityContext securityContext = getWebSocket().getSecurityContext();
    final App app = StructrApp.getInstance(securityContext);

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

      final AbstractRelationship rel = (AbstractRelationship)app.get(id);

      tx.success();

      return rel;
View Full Code Here

        List<GraphObject> resultList = new LinkedList<GraphObject>();
        for(GraphObject obj : results) {

          if(obj instanceof AbstractRelationship) {

            AbstractRelationship rel = (AbstractRelationship)obj;
            if(startNode) {

              resultList.add(rel.getSourceNode());

            } else {

              resultList.add(rel.getTargetNode());
            }
          }
        }

        return new Result(resultList, null, isCollectionResource(), isPrimitiveArray());
View Full Code Here

  @Override
  public Object revert(Object source) {
   
    if(currentObject instanceof AbstractRelationship) {
     
      AbstractRelationship rel = (AbstractRelationship)currentObject;
      if(rel != null) {
       
        NodeInterface startNode = rel.getSourceNode();
        if(startNode != null) {
         
          return startNode.getType();
        }
      }
View Full Code Here

  @Override
  public Object revert(Object source) {

    if (currentObject instanceof AbstractRelationship) {

      AbstractRelationship rel = (AbstractRelationship) currentObject;

      if (rel != null) {

        return rel.getTargetNode();
      }

    }

    return null;
View Full Code Here

  @Override
  public Object revert(String source) {
   
    if (currentObject instanceof AbstractRelationship) {
     
      AbstractRelationship rel = (AbstractRelationship) currentObject;
      if (rel != null) {
       
        NodeInterface endNode = rel.getTargetNode();
        if (endNode != null) {
         
          return endNode.getType();
        }
      }
View Full Code Here

TOP

Related Classes of org.structr.core.entity.AbstractRelationship

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.