Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending NodeRelationshipMethods #31

Open
stephenmuss opened this issue Aug 5, 2014 · 4 comments
Open

Extending NodeRelationshipMethods #31

stephenmuss opened this issue Aug 5, 2014 · 4 comments

Comments

@stephenmuss
Copy link
Contributor

It would be extremely useful to extend OutgoingRelationshipBuilder and IncomingRelationshipBuilder in order to be able to determine whether a node has a specific relationship and to get nodes at the other end of the relationship.

I am unsure about the methods in terms of whether they should use symbols or English but they should be idiomatic enough to be easily read.

For example, to determine whether a node has a relationship we could use something along the lines of:

node --> "SOME_RELATIONSHIP" exists // English
node --> "SOME_RELATIONSHIP" ? // Symbol

node <-- "SOME_RELATIONSHIP" exists
node <-- "SOME_RELATIONSHIP" ?

To get nodes at the other end of the relationship(s)

node --> "SOME_RELATIONSHIP" getNodes
node --> "SOME_RELATIONSHIP" *

node <-- "SOME_RELATIONSHIP" getNodes
node <-- "SOME_RELATIONSHIP" *

The snippets are not necessarily using the method names I would suggest but merely for example. In any case they would be quite useful.

Currently, to achieve the same result it would be necessary to write something like this:

val rels = node.getRelationships(Direction.OUTGOING, DynamicRelationshipType.withName("SOME_RELATIONSHIP"))
val nodes = rels.toList.map((rel: Relationship) => rel.getOtherNode(node))

val hasRel = node.hasRelationship(DynamicRelationshipType.withName("SOME_RELATIONSHIP"), Direction.OUTGOING)

I'd be happy to submit a pull request for this.

@FaKod
Copy link
Owner

FaKod commented Aug 5, 2014

Some prefer symbols, some (like me) prefer English. I think that the '?' is quite obvious, but a '*' is questionable. However, it is possible to provide both, as we are creating a common library.

@stephenmuss
Copy link
Contributor Author

I agree that using * is probably not the greatest idea but couldn't think of an alternative for the sake of the example.

Providing both the English methods and their symbol equivalents seems like it could be the way to go.

What are your ideas as an alternative to *?

@stephenmuss
Copy link
Contributor Author

Hi Christopher, now that 0.3.1-SNAPSHOT is out I wouldn't mind having a crack at this. What would your preference be for symbol method names for node <-- "SOME_RELATIONSHIP" getNodes or even for the English ones?

@FaKod
Copy link
Owner

FaKod commented Oct 31, 2014

I think * and getNodes is ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants