Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.Relationship


            }
            if ( currentTime > timestamp )
            {
                break;
            }
            Relationship rel = currentNode.getSingleRelationship(
                    RelTypes.TIMELINE_NEXT_ENTRY, Direction.OUTGOING );
            currentNode = rel.getEndNode();
        }
        while ( !currentNode.equals( underlyingNode ) );
        return nodeList;
    }
View Full Code Here


            {
                if ( position.currentNode().equals( underlyingNode ) )
                {
                    return false;
                }
                Relationship last = position.lastRelationshipTraversed();
                if ( !timeOk && last != null
                     && last.isType( RelTypes.TIMELINE_NEXT_ENTRY ) )
                {
                    Node node = position.currentNode();
                    long currentTime = (Long) node.getProperty( TIMESTAMP );
                    timeOk = currentTime > timestamp;
                    return false;
                }
                if ( timeOk
                     && last.isType( RelTypes.TIMELINE_INSTANCE ) )
                {
                    return true;
                }
                return false;
            }
View Full Code Here

            {
                if ( position.currentNode().equals( underlyingNode ) )
                {
                    return false;
                }
                Relationship last = position.lastRelationshipTraversed();
                if ( !timeOk && last != null
                     && last.isType( RelTypes.TIMELINE_NEXT_ENTRY ) )
                {
                    Node node = position.currentNode();
                    long currentTime = (Long) node.getProperty( TIMESTAMP );
                    timeOk = currentTime > timestamp;
                }
View Full Code Here

    {
        return underlyingNode.traverse( Order.DEPTH_FIRST, new StopEvaluator()
        {
            public boolean isStopNode( TraversalPosition position )
            {
                Relationship last = position.lastRelationshipTraversed();
                if ( last != null
                     && last.isType( RelTypes.TIMELINE_NEXT_ENTRY ) )
                {
                    Node node = position.currentNode();
                    long currentTime = (Long) node.getProperty( TIMESTAMP );
                    return currentTime >= timestamp;
                }
                return false;
            }
        }, new ReturnableEvaluator()
        {
            public boolean isReturnableNode( TraversalPosition position )
            {
                Relationship last = position.lastRelationshipTraversed();
                if ( last != null
                     && last.isType( RelTypes.TIMELINE_INSTANCE) )
                {
                    return true;
                }
                return false;
            }
View Full Code Here

        Node startNode = getIndexedStartNode( startTime );
        return startNode.traverse( Order.DEPTH_FIRST, new StopEvaluator()
        {
            public boolean isStopNode( TraversalPosition position )
            {
                Relationship last = position.lastRelationshipTraversed();
                if ( last != null
                     && position.currentNode().equals( underlyingNode ) )
                {
                    return true;
                }
                if ( last != null
                     && last.isType( RelTypes.TIMELINE_NEXT_ENTRY ) )
                {
                    Node node = position.currentNode();
                    long currentTime = (Long) node.getProperty( TIMESTAMP );
                    return currentTime >= endTime;
                }
                return false;
            }
        }, new ReturnableEvaluator()
        {
            private boolean timeOk = false;

            public boolean isReturnableNode( TraversalPosition position )
            {
                if ( position.currentNode().equals( underlyingNode ) )
                {
                    return false;
                }
                Relationship last = position.lastRelationshipTraversed();
                if ( !timeOk && last != null
                     && last.isType( RelTypes.TIMELINE_NEXT_ENTRY ) )
                {
                    Node node = position.currentNode();
                    long currentTime = (Long) node.getProperty( TIMESTAMP );
                    timeOk = currentTime > startTime;
                    return false;
                }
                if ( timeOk
                     && last.isType( RelTypes.TIMELINE_INSTANCE ) )
                {
                    return true;
                }
                return false;
            }
View Full Code Here

    {
        if ( indexed )
        {
            indexBTree.delete();
        }
        Relationship rel = underlyingNode.getSingleRelationship(
                RelTypes.TIMELINE_NEXT_ENTRY, Direction.OUTGOING );
        while ( rel != null )
        {
            Node node = rel.getEndNode();
            if ( !node.equals( underlyingNode ) )
            {
                for ( Relationship instance : node.getRelationships( RelTypes.TIMELINE_INSTANCE ) )
                {
                    instance.delete();
                }
                rel.delete();
                rel = node.getSingleRelationship( RelTypes.TIMELINE_NEXT_ENTRY,
                        Direction.OUTGOING );
                node.delete();
            }
            else
            {
                rel.delete();
                rel = null;
            }
        }
    }
View Full Code Here

    return relType;
  }

  @Override
  public <U extends LeftRestrictedConnectionMode>Vertex getVertex(ConnectorType<U> connectorType) {
    Relationship rel = getNode().getSingleRelationship(DynamicRelationshipType.withName(getType().getName()+EDGEROLE_SEPARATOR+connectorType.getName()), Direction.OUTGOING);
    return getDb().getVertex(rel.getEndNode());
  }
View Full Code Here

    if (this.isEmpty()) {
      underlyingNode.createRelationshipTo(entry, RelTypes.FIRST_ELEMENT);
      underlyingNode.createRelationshipTo(entry, RelTypes.LAST_ELEMENT);
      underlyingNode.setProperty(INDEX_SIZE, 1);
    } else {
      Relationship lastElementRelation = underlyingNode
          .getSingleRelationship(RelTypes.LAST_ELEMENT,
              Direction.OUTGOING);
      Node lastElement = lastElementRelation.getEndNode();
      lastElementRelation.delete();
      lastElement.createRelationshipTo(entry, RelTypes.NEXT_ELEMENT);
      underlyingNode.createRelationshipTo(entry, RelTypes.LAST_ELEMENT);
      int i = (Integer) underlyingNode.getProperty(INDEX_SIZE);
      underlyingNode.setProperty(INDEX_SIZE, i+1);
    }
View Full Code Here

      }
      element.createRelationshipTo(n, RelTypes.LIST_ENTRY);
    }

    if (firstElement != null) {
      Relationship currentEntryRelation = underlyingNode
          .getSingleRelationship(RelTypes.FIRST_ELEMENT,
              Direction.OUTGOING);
      Node currentEntry = currentEntryRelation.getEndNode();
      if (index == 0) {
        currentEntryRelation.delete();
        underlyingNode.createRelationshipTo(firstElement,
            RelTypes.FIRST_ELEMENT);
        lastElement.createRelationshipTo(currentEntry,
            RelTypes.NEXT_ELEMENT);
        underlyingNode.setProperty(INDEX_SIZE, size()+c.size());
      } else {
        for (int i = 0; i < index; i++) {
          currentEntryRelation = currentEntry.getSingleRelationship(
              RelTypes.NEXT_ELEMENT, Direction.OUTGOING);
          currentEntry = currentEntryRelation.getEndNode();
        }
        Node prevEntry = currentEntryRelation.getStartNode();
        currentEntryRelation.delete();
        prevEntry.createRelationshipTo(firstElement,
            RelTypes.NEXT_ELEMENT);
        lastElement.createRelationshipTo(currentEntry,
            RelTypes.NEXT_ELEMENT);
        underlyingNode.setProperty(INDEX_SIZE, size()+c.size());
View Full Code Here

  @Override
  public Node remove(int index) {
    if (index < 0 || index >= size())
      throw new IndexOutOfBoundsException();
    Relationship currentEntryRelation = underlyingNode
        .getSingleRelationship(RelTypes.FIRST_ELEMENT,
            Direction.OUTGOING);
    Node currentEntry = currentEntryRelation.getEndNode();
    Node currentNode = currentEntry.getSingleRelationship(
        RelTypes.LIST_ENTRY, Direction.OUTGOING).getEndNode();
    Relationship lastEntryRelation = underlyingNode.getSingleRelationship(
        RelTypes.LAST_ELEMENT, Direction.OUTGOING);
    Node lastEntry = lastEntryRelation.getEndNode();
    if (index == 0) {
      currentEntryRelation.delete();
      if (currentEntry.getId() == lastEntry.getId()) {
        lastEntryRelation.delete();
        Relationship entryRelation = currentEntry
            .getSingleRelationship(RelTypes.LIST_ENTRY,
                Direction.OUTGOING);
        entryRelation.delete();
        currentEntry.delete();
        underlyingNode.setProperty(INDEX_SIZE, 0);

      } else {
        Relationship nextEntryRelation = currentEntry
            .getSingleRelationship(RelTypes.NEXT_ELEMENT,
                Direction.OUTGOING);
        Node nextEntry = nextEntryRelation.getEndNode();
        nextEntryRelation.delete();
        Relationship entryRelation = currentEntry
            .getSingleRelationship(RelTypes.LIST_ENTRY,
                Direction.OUTGOING);
        entryRelation.delete();
        currentEntry.delete();
        underlyingNode.createRelationshipTo(nextEntry,
            RelTypes.FIRST_ELEMENT);
        int i = (Integer) underlyingNode.getProperty(INDEX_SIZE);
        underlyingNode.setProperty(INDEX_SIZE, i-1);
      }
    } else {
      for (int i = 0; i < index; i++) {
        currentEntryRelation = currentEntry.getSingleRelationship(
            RelTypes.NEXT_ELEMENT, Direction.OUTGOING);
        currentEntry = currentEntryRelation.getEndNode();
      }
      currentNode = currentEntry.getSingleRelationship(
          RelTypes.LIST_ENTRY, Direction.OUTGOING).getEndNode();
      Node prevEntry = currentEntryRelation.getStartNode();
      currentEntryRelation.delete();
      if (currentEntry.getId() == lastEntry.getId()) {
        lastEntryRelation.delete();
        underlyingNode.createRelationshipTo(prevEntry,
            RelTypes.LAST_ELEMENT);
        Relationship entryRelation = currentEntry
            .getSingleRelationship(RelTypes.LIST_ENTRY,
                Direction.OUTGOING);
        entryRelation.delete();
        currentEntry.delete();
        int i = (Integer) underlyingNode.getProperty(INDEX_SIZE);
        underlyingNode.setProperty(INDEX_SIZE, i-1);
      } else {
        Relationship nextEntryRelation = currentEntry
            .getSingleRelationship(RelTypes.NEXT_ELEMENT,
                Direction.OUTGOING);
        Node nextEntry = nextEntryRelation.getEndNode();
        nextEntryRelation.delete();
        Relationship entryRelation = currentEntry
            .getSingleRelationship(RelTypes.LIST_ENTRY,
                Direction.OUTGOING);
        entryRelation.delete();
        currentEntry.delete();
        prevEntry
            .createRelationshipTo(nextEntry, RelTypes.NEXT_ELEMENT);
        int i = (Integer) underlyingNode.getProperty(INDEX_SIZE);
        underlyingNode.setProperty(INDEX_SIZE, i-1);
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.Relationship

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.