Support Grails like mapped files

24 views
Skip to first unread message

eugene....@gmail.com

unread,
May 8, 2015, 12:20:28 AM5/8/15
to ferma...@syncleus.com
Hi there,

Guys I want to create AST transformations with groovy-lang to reduce boilerplate code. But I need more examples of Ferma usage, where can I find them?
To be better understandable take a look, all methods and other boilerplate will be added at compile stage:
@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
}

fre...@gmail.com

unread,
May 8, 2015, 8:04:11 AM5/8/15
to ferma...@syncleus.com
I would be happy to expand the documentation a bit with additional examples and references, this is needed anyway. Can you tell me a few specific things you'd like to see examples of and I'll be happy to use that in the documentation. There are some basic examples int he readme also. I will work on this in a few hours if you can get me a list by then.

fre...@gmail.com

unread,
May 8, 2015, 9:15:25 AM5/8/15
to ferma...@syncleus.com
I havent used groovy so the example you gave is a bit confusing to me. Specifically what Java Ferma examples could I demonstrate for you?


On Friday, 8 May 2015 00:20:28 UTC-4, Eugene Kamenev wrote:

fre...@gmail.com

unread,
May 8, 2015, 11:38:54 AM5/8/15
to ferma...@syncleus.com
Here is what it might look like using Ferma in Java (hope this helps):

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();
}

Note I demonstrated how to get Knows both as an Iterable and a List (though I wouldn't be opposed to adding Ferma support to return lists as well as iterables through use of the annotation, that is if you think this would be useful for you, just let me know). Finally despite these classes being abstract and an interface, you do not need to implement a concrete class for them. When you pass them into ferma because of the annotations these methods will be implemented for you automatically. Let me know if this answers your question and if there is anything else I could do to help.


On Friday, 8 May 2015 00:20:28 UTC-4, Eugene Kamenev wrote:

fre...@gmail.com

unread,
May 8, 2015, 12:00:20 PM5/8/15
to ferma...@syncleus.com, fre...@gmail.com
Oh and one small correction, I should have used "except" instead of "hasNot" which is what you originally requested.

Eugene Kamenev

unread,
May 8, 2015, 1:37:40 PM5/8/15
to ferma...@syncleus.com, fre...@gmail.com

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.

But, i really liked groovy grails web-framework's way to create apps and follow domain philosophy of grails.

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.


пятница, 8 мая 2015 г., 22:00:20 UTC+6 пользователь fre...@gmail.com написал:

Jeffrey Freeman

unread,
May 8, 2015, 1:39:49 PM5/8/15
to ferma...@syncleus.com, eugene....@gmail.com, fre...@gmail.com
Unfortunately most of the effort revolving around grails-specific stuff you'll be on your own for, I don't personally use grails. With that said, I would be happy to incorporate any grails-helper stuff you create into an official extension for Ferma (to encourage others to help maintain it). What I can help with however is anything on the Ferma/Java side. I'd be more than happy to show you how Ferma works and answer any specific questions. Also if there is anything i can add or change with regards to the java implementation to make your job easier I'd be happy to contribute on that end as well. So I'd be more than happy to help with examples, just let me know if there are any specific examples I can provide you with.

Eugene Kamenev

unread,
Jun 14, 2015, 12:29:54 PM6/14/15
to ferma...@syncleus.com, eugene....@gmail.com, fre...@gmail.com
Jeffrey hi there.

Finally I got it without Ferma. But if you want to know, when i tried ferma, I experienced strange field "ferma_class" that was created at database, i can understand for what it is used inside ferma, but in OrientDB if you add field to edge it will become not "lightweight" and you can experience some performance degradation with these fields on edges.

And i decided to use directly OrientVertex with groovy.
My work is here:
https://github.com/eugene-kamenev/orientdb-groovy

Thanks.

пятница, 8 мая 2015 г., 23:39:49 UTC+6 пользователь Jeffrey Freeman написал:

Jeffrey Freeman

unread,
Jun 14, 2015, 12:31:53 PM6/14/15
to Eugene Kamenev, ferma...@syncleus.com
Actually you could have easily fixed this problem by simply turning off typing in Ferma. Check out the FermaGraph constructor, this is where you specify if you want typing activated or not.
Reply all
Reply to author
Forward
0 new messages