@Vertex
class User {
String firstName
String lastName
List<Knows> knows
List<User> friendsOfFriends
static mapping = {
knows path: outE('knows').toList(Knows)
friendsOfFriends path: out('knows').out('knows').except(this).toList(User)
}
}
@Edge
class Knows {
int years
}
public abstract class User extends AbstractVertexFrame {
@Property("firstName")
public abstract String getFirstName();
@Property("firstName")
public abstract void setFristName(String newFirstName);
@Property("lastName")
public abstract String getLastName();
@Property("lastName")
public abstract void setLastName(String newLastName);
@Incidence("knows")
public abstract Iterable<Knows> getKnowsAsIterable();
public List<Knows> getKnowsAsList() {
return this.outE("knows").toList(Knows.class);
}
public List<User> getFriendsOfFriends() {
return this.out("knows").out("knows").hasNot("id", this.getId()).toList(User.class);
}
}
public class Knows extends VertexFrame {
@Property("years")
int getYears();
@Property("years")
void setYears(int newYears);
@InVertex
User getInVertex();
@OutVertex
User getOutVertex();
}
Thank you for response.
But I think I need to describe my main goal in more detail.
I worked with JavaEE stack for 5 years, and I really tired
with it. From now I can say: I hate java's verbosity, after using
groovylang for a year.
For
now I have a task to try OrientDB inside our grails-app, and I started
searching for domain model that will work with graph api.
And then I found your project.
When I first took a look at your readme.md I found it very useful. Your tinkerpop frames implementation is based on classes, not interfaces, it is better for me.
But when I look at your example Person class, i really start feeling a java boilerplate smell :)
What
i really want to get is a wrapper around your code, then I can describe
entity class in grails-way, like I showed it before.
I can apply AST-transformation (similar to macros in scala-lang), it will tell groovy compiler to modify source code of entity class, after that it will look like your implementation.
For now I finished first simple version of @Vertex transformation, I think I can share it in few days.
Please
if you worked with hibernate/jpa stuff (grails actually uses it under
the hood) take a look how much boilerplate is removed by grails:
https://grails.github.io/grails-doc/latest/guide/GORM.html#manyToMany
And
finally, I think I am enough experienced with groovy to reach this
goal, but I am not sure about tinkerpop stuff :) so I need some help
with examples
Thanks.