Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » RDF Turtle code generation template
RDF Turtle code generation template [message #1783257] Fri, 09 March 2018 17:51 Go to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 46
Registered: December 2014
Member
Hello community,

I usually use fully integrated modeling solutions like EMF or xtext to generate code.

In a project, the meta-model and the model instance is declared in RDF (https://www.w3.org/TR/turtle/) turtle).

Example
Meta-Model
@prefix foo:<http://a#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

foo:Bar a rdfs:Class .


The model instance looks like:
@prefix foo:<http://a#> .

foo:MyBar a foo:Bar .



I would generate the following code. The meta-model classes (rdfs:Class) can be written manually.

I would generate java code like:
public class MyBar extends Bar



Is it possible to combine the turtle meta-models with a template language (xpand, xtend, JET etc.) together with mwe2 to generate java code? Unfortunately, I'm missing a starting point, how to implement something like this.

Cheers
Re: RDF Turtle code generation template [message #1783268 is a reply to message #1783257] Sat, 10 March 2018 06:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29545
Registered: July 2009
Senior Member
Of course you'd need some technology/library to read RDF into a Java representation, but yes, from there you could use a template language such as Xtend to generate something textual from it. Alternatively you might map/transform the RDF representation to Ecore and reuse what Ecore generates; that's how XSD is supported, for example.
Re: RDF Turtle code generation template [message #1783363 is a reply to message #1783268] Mon, 12 March 2018 12:11 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 46
Registered: December 2014
Member
Thanks for the answer.

Alternatively, I considered using xcore. But I'm not sure if xcore is the right technology to define my own meta-model.
So you can build on this metamodel instances with another xcore model
Re: RDF Turtle code generation template [message #1783370 is a reply to message #1783363] Mon, 12 March 2018 12:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6040
Registered: July 2009
Senior Member
Hi

Xcore is probably right for you, but the Eclipse Modeling tools offer many compatible options:

If you prefer a tree editor, traditional Ecore using the Sample Ecore Editor will do.

If you prefer a diagram editor, the Ecore Diagram Editor is what you want

If you want to define behaviour using OCL, then use OCLinEcore

If you want UML diagrams then use Papyrus

Regards

Ed Willink
Re: RDF Turtle code generation template [message #1783400 is a reply to message #1783370] Mon, 12 March 2018 15:32 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 46
Registered: December 2014
Member
I'm currently evaluating xcore with eson. Looks very good. Unfortunately, I can not find a example for constraints and own types.

On the subject of EMF:

The model should be understandable even if no Eclipse Tooling is available, so EMF with XMI is rather unsuitable.
I am not sure if a tree structure is sufficient for the meta-model
Re: RDF Turtle code generation template [message #1783405 is a reply to message #1783400] Mon, 12 March 2018 16:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6040
Registered: July 2009
Senior Member
Hi

No model tooling is a mad constraint. You might as well insist that your Word documents are readable as hex dumps or that your Java programs can be executed without a Java compiler.

Regards

Ed Willink
Re: RDF Turtle code generation template [message #1783591 is a reply to message #1783268] Wed, 14 March 2018 12:49 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 46
Registered: December 2014
Member
Ed Merks wrote on Sat, 10 March 2018 06:57
Of course you'd need some technology/library to read RDF into a Java representation, but yes, from there you could use a template language such as Xtend to generate something textual from it.


Do you already know existing templates in Xtend to generate Pojos? Or helper classes for upper case the first letter for getter/setter etc.
Re: RDF Turtle code generation template [message #1783595 is a reply to message #1783591] Wed, 14 March 2018 13:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6040
Registered: July 2009
Senior Member
Hi

I suspect that the Java you want is very similar to that produced by EMF's genmodel, so I would strongly recommend that you try to exploit it. If you need to abandon it then the many utils may still be helpful for cap-name etc.

If you really want trivial Java then generating it is so trivial that you should just do it. Anyone else's templates are liable to have the wrong emphasis.

If you want non-trivial Java, I recommend that you find a good Java model and code a to-Java-model M2M so that you can re-use the Java-model to Java-text that accompanies the good Java model. If you find this please let me know so that I can use it in my next rewrite of the OCL-to-intermediate-to-Java code generator. My best guess is that Modisco might provide something good.

Regards

Ed Willink
Re: RDF Turtle code generation template [message #1783600 is a reply to message #1783595] Wed, 14 March 2018 13:56 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 46
Registered: December 2014
Member
Ed Willink wrote on Wed, 14 March 2018 13:23
Hi

I suspect that the Java you want is very similar to that produced by EMF's genmodel, so I would strongly recommend that you try to exploit it. If you need to abandon it then the many utils may still be helpful for cap-name etc.


Yes correct, just something in the way of the EMF models, where can I find the JET templates?
Re: RDF Turtle code generation template [message #1783607 is a reply to message #1783600] Wed, 14 March 2018 14:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6040
Registered: July 2009
Senior Member
Hi

The JET templates are in the codegen plugin, but I would very strongly recommend that you do not edit them. Investigate the many configuration options that EMF already provides.

Regards

Ed Willink
Re: RDF Turtle code generation template [message #1783653 is a reply to message #1783607] Thu, 15 March 2018 06:44 Go to previous message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 46
Registered: December 2014
Member
Hi

thanks :)
Previous Topic:XText alternatives for DSL-2-JVM chain
Next Topic:New Modeling Project Creation Wizard
Goto Forum:
  


Current Time: Sun Sep 23 10:31:48 GMT 2018

Powered by FUDForum. Page generated in 0.01759 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top