Biblioteca Java - Blame information for rev 18

Subversion Repositories:
Rev:
Rev Author Line No. Line
18 mihai 1 /**
2  * Licensed to Neo Technology under one or more contributor
3  * license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright
5  * ownership. Neo Technology licenses this file to you under
6  * the Apache License, Version 2.0 (the "License"); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19  
20 package com.linkscreens.graphsin.repository;
21  
22 import java.util.Date;
23  
24 import org.neo4j.graphdb.Direction;
25 import org.neo4j.graphdb.Node;
26 import org.neo4j.graphdb.traversal.Evaluators;
27 import org.neo4j.graphdb.traversal.TraversalDescription;
28 import org.neo4j.graphdb.traversal.Traverser;
29 import org.neo4j.helpers.collection.IteratorUtil;
30  
31  
32 public class StatusUpdateNode
33 {
34     private final Node underlyingNode;
35     static final String TEXT = "TEXT";
36     static final String DATE = "DATE";
37  
38     public StatusUpdateNode( Node underlyingNode )
39     {
40  
41         this.underlyingNode = underlyingNode;
42     }
43  
44     public Node getUnderlyingNode()
45     {
46         return underlyingNode;
47     }
48  
49     public PersonNode getPerson()
50     {
51         return new PersonNode( getPersonNode() );
52     }
53  
54     private Node getPersonNode()
55     {
56         TraversalDescription traversalDescription = underlyingNode.getGraphDatabase()
57                 .traversalDescription()
58                 .depthFirst()
59                 .relationships( RelTypes.NEXT, Direction.INCOMING )
60                 .relationships( RelTypes.STATUS, Direction.INCOMING )
61                 .evaluator( Evaluators.includeWhereLastRelationshipTypeIs( RelTypes.STATUS ) );
62  
63         Traverser traverser = traversalDescription.traverse( getUnderlyingNode() );
64  
65         return IteratorUtil.singleOrNull( traverser.iterator() ).endNode();
66     }
67  
68     public String getStatusText()
69     {
70         return (String) underlyingNode.getProperty( TEXT );
71     }
72  
73     public Date getDate()
74     {
75         Long l = (Long) underlyingNode.getProperty( DATE );
76  
77         return new Date( l );
78     }
79  
80 }