Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.Node


    private void index( final String value, final Node node,
        final String partIndexName, final ImdbSearchRelTypes relType )
    {
        for ( String part : splitSearchString( value ) )
        {
            Node wordNode = getSingleNode(partIndexName, part);
            if ( wordNode == null )
            {
                wordNode = graphDbService.createNode();
                // not needed for the functionality
                nodeIndex.add(wordNode, partIndexName, part);

                wordNode.setProperty( WORD_PROPERTY, part );
            }
            wordNode.createRelationshipTo( node, relType );
            wordNode.setProperty( COUNT_PROPERTY, ((Integer) wordNode
                .getProperty( COUNT_PROPERTY, 0 )) + 1 );
        }
    }
View Full Code Here


        final List<Node> wordList = findSearchWords( value, indexName );
        if ( wordList.isEmpty() )
        {
            return null;
        }
        final Node startNode = wordList.remove( 0 );
        // set up a match to use if everything else fails
        Node match = startNode.getRelationships( wordRelType ).iterator()
            .next().getEndNode();
        // check if there is only one node in the list
        if ( wordList.isEmpty() )
        {
            return match;
        }
        int bestCount = 0;
        final int listSize = wordList.size();
        for ( Relationship targetRel : startNode.getRelationships( wordRelType ) )
        {
            Node targetNode = targetRel.getEndNode();
            int hitCount = 0;
            for ( Relationship wordRel : targetNode
                .getRelationships( wordRelType ) )
            {
                if ( wordList.contains( wordRel.getStartNode() ) )
                {
                    if ( ++hitCount == listSize )
View Full Code Here

    {
        final List<Node> wordList = new ArrayList<Node>();
        // prepare search terms
        for ( String part : splitSearchString( userInput ) )
        {
            Node wordNode = getSingleNode(partIndexName, part);
            if ( wordNode == null || !wordNode.hasRelationship()
                || wordList.contains( wordNode ) )
            {
                continue;
            }
            wordList.add( wordNode );
View Full Code Here

    }

    @Override
    public Role getRole( final Movie inMovie )
    {
        final Node movieNode = ((MovieImpl) inMovie).getUnderlyingNode();
        for ( Relationship rel : underlyingNode.getRelationships(
            RelTypes.ACTS_IN, Direction.OUTGOING ) )
        {
            if ( rel.getEndNode().equals( movieNode ) )
            {
View Full Code Here

        }

        @Override
        public boolean isReturnableNode( TraversalPosition currentPos )
        {
            Node currentNode = currentPos.currentNode();
            Node prevNode = currentPos.previousNode();
            if ( !otherNodes.containsKey( currentNode ) )
            {
                myNodes.put( currentNode, prevNode );
            }
            else
            {
                match = new LinkedList<Node>();
                match.add( currentNode );
                while ( prevNode != null )
                {
                    match.add( prevNode );
                    prevNode = myNodes.get( prevNode );
                }
                Node otherNode = otherNodes.get( currentNode );
                while ( otherNode != null )
                {
                    match.addFirst( otherNode );
                    otherNode = otherNodes.get( otherNode );
                }
View Full Code Here

    }

    @Override
    public Actor createActor( final String name )
    {
        final Node actorNode = graphDbService.createNode();
        final Actor actor = new ActorImpl( actorNode );
        actor.setName( name );
        searchEngine.indexActor( actor );
        nodeIndex.add(actorNode, NAME_INDEX, name);
        return actor;
View Full Code Here

    }

    @Override
    public Movie createMovie( final String title, final int year )
    {
        final Node movieNode = graphDbService.createNode();
        final Movie movie = new MovieImpl( movieNode );
        movie.setTitle( title );
        movie.setYear( year );
        searchEngine.indexMovie( movie );
        nodeIndex.add(movieNode, TITLE_INDEX, title);
View Full Code Here

        }
        if ( movie == null )
        {
            throw new IllegalArgumentException( "Null movie" );
        }
        final Node actorNode = ((ActorImpl) actor).getUnderlyingNode();
        final Node movieNode = ((MovieImpl) movie).getUnderlyingNode();
        final Relationship rel = actorNode.createRelationshipTo( movieNode,
            RelTypes.ACTS_IN );
        final Role role = new RoleImpl( rel );
        if ( roleName != null )
        {
View Full Code Here

    }

    @Override
    public Actor getActor( final String name )
    {
        Node actorNode = getSingleNode(NAME_INDEX, name);
        if ( actorNode == null )
        {
            actorNode = searchEngine.searchActor( name );
        }
        Actor actor = null;
View Full Code Here

    }

    @Override
    public Movie getMovie( final String title )
    {
        Node movieNode = getExactMovieNode( title );
        if ( movieNode == null )
        {
            movieNode = searchEngine.searchMovie( title );
        }
        Movie movie = null;
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.Node

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.