NodeRep( GraphDatabaseService db, Node node, boolean includeIndexes ) { id = node.getId(); properties = new PropertiesRep( node, node.getId() ); long highestRel = 0; for ( Relationship rel : node.getRelationships( Direction.OUTGOING ) ) { outRelationships.put( rel.getId(), new PropertiesRep( rel, rel.getId() ) ); highestRel = Math.max( highestRel, rel.getId() ); } this.highestRelationshipId = highestRel; this.index = includeIndexes ? checkIndex( db ) : null; }
private void compareRelationships( NodeRep other, DiffReport diff ) { for ( PropertiesRep rel : outRelationships.values() ) { PropertiesRep otherRel = other.outRelationships.get( rel.entityId ); if ( otherRel == null ) { diff.add( "I have relationship " + rel.entityId + " which other don't" ); continue; } rel.compareWith( otherRel, diff ); } for ( Long id : other.outRelationships.keySet() ) { if ( !outRelationships.containsKey( id ) ) { diff.add( "Other has relationship " + id + " which I don't" ); } } }
@Override public int hashCode() { int result = 7; result += properties.hashCode() * 7; result += outRelationships.hashCode() * 13; result += id * 17; if ( index != null ) { result += index.hashCode() * 19; } return result; }
private void compareRelationships( NodeRep other, DiffReport diff ) { for ( PropertiesRep rel : outRelationships.values() ) { PropertiesRep otherRel = other.outRelationships.get( rel.entityId ); if ( otherRel == null ) { diff.add( "I have relationship " + rel.entityId + " which other don't" ); continue; } rel.compareWith( otherRel, diff ); } for ( Long id : other.outRelationships.keySet() ) { if ( !outRelationships.containsKey( id ) ) { diff.add( "Other has relationship " + id + " which I don't" ); } } }
@Override public int hashCode() { int result = 7; result += properties.hashCode() * 7; result += outRelationships.hashCode() * 13; result += id * 17; if ( index != null ) { result += index.hashCode() * 19; } return result; }
NodeRep( GraphDatabaseService db, Node node, boolean includeIndexes ) { id = node.getId(); properties = new PropertiesRep( node, node.getId() ); long highestRel = 0; for ( Relationship rel : node.getRelationships( Direction.OUTGOING ) ) { outRelationships.put( rel.getId(), new PropertiesRep( rel, rel.getId() ) ); highestRel = Math.max( highestRel, rel.getId() ); } this.highestRelationshipId = highestRel; this.index = includeIndexes ? checkIndex( db ) : null; }
void compareWith( NodeRep other, DiffReport diff ) { if ( other.id != id ) { diff.add( "Id differs mine:" + id + ", other:" + other.id ); } properties.compareWith( other.properties, diff ); if ( index != null && other.index != null ) { compareIndex( other, diff ); } compareRelationships( other, diff ); }
void compareWith( NodeRep other, DiffReport diff ) { if ( other.id != id ) { diff.add( "Id differs mine:" + id + ", other:" + other.id ); } properties.compareWith( other.properties, diff ); if ( index != null && other.index != null ) { compareIndex( other, diff ); } compareRelationships( other, diff ); }