Domain model in EMF - can I produce POJOs using Acceleo? - eclipse-emf

I have a domain model that is created using ecore EMF.
And I would like to generate POJOs. I would like to be able customize the POJOs, so I am looking at using Acceleo.
However, I can only see creating POJOs in Acceleo from UML. When using EMF it produces EObjects, Estrings etc.
Is it possible to just produce POJOs?

With Acceleo, you can generate anything you want. If you want to generate just POJOs from an UML model, you can use or fork the UML to Java generator available on Github. If you do, make sure to use the version matching the version of UML that you are using (master branch for UML2 v4.0.0, R1_1_maintenance branch for UML2 v3.x.x).
If you are using UML2 v3.x.x, you can simply install it by using the Eclipse Marketplace. The 2.0.0 release of the generator fo UML2 v4.0.0 will be released soon.

See the following link for generating POJOs with EMF:
http://eclipseo.blogspot.be/2007/10/creating-pojos-using-emf.html
If you want to customize this even more, you could also use other methods:
XPand
XText
Acceleo ECore generation templates
etc

Related

Can I import doxygen tags in Enterprise Architect with reverse egineer in c++?

We're currently evaluating Enterprise Architect (12, release candidate).
The main reason we'd like to use it is to use the reverse engineering feature, from c++ to UML.
Our code base is documented using Doxygen tags.
Now, the parser of EA does not seem to recognize these tags. Is there a way I could enable it?
Edit:
The things I'm looking for are not to be inserted in the UML, but added to the model of the project. For instance, information defined by #param tags for methods are inserted in the "notes" of the methods and not in the "notes" of the parameters. The #author doxygen tags are not taken into consideration when generating the model, etc.
Some easy out-of-the-box customization of the parsers is probably not available.
I was solving similar problem of importing custom metadata (developer responsible for the class, corresponding database table or view mapping the entity, deployment package (.dll) and architecture layer, human-friendly class description, reference to specification documents etc.) contained elsewhere and making them available inside the Enterprise Architect in the form of informal notes and formal tagged values.
After some attempts to generate this metadata info as doxygen-style comments I gave up as the doxygen comment parser did not seem to be customizable and in order to make the non-ascii characters correctly imported the source code files had to contain the UTF-8 BOM preamble, which is not very 3rd party legacy tool-friendly encoding.
I have decided to go the way of generating XMI file with all the metadata placed inside the tags and documentation XML elements.
Before I resolved correct XMI encoding of composition and aggregation relationships the project was stopped at the phase when all the classes and attributes and associations and all the metamodel attributes (as notes and tagged values) were in there in under 600 lines of C# XMI-specific code and we had the few thousands of classes in EA available for analysts to work with.
In your case you may solve the need in a similar way:
import the C++ code base into Enterprise Architect using the reverse engineering
extract the doxygen comment metadata using some tool like doxygen's GENERATE_XML feature
export the Enterprise Architect model in a round-trip-friendly XMI format
write a single-purpose tool that will take the XMI model, your comment metadata and spit out new XMI model annotated with your proprietary information
import the XMI model back, done.
For steps 3...5 there may be an easier way as Enterprise Architect has the Scripting and Automation interface which allows to read/modify the model using languages like Visual Basic or C#

Can i add ocl to ecore with java code?

I want to add ocl to my .ecore metamodel with java code. But i cant find any example or tutorial.
So i want to ask is tihs possible or where can i find sample codes?
Did you check OCLinEcore? It allows embed OCL in your ecore model and edit it like a text which may be edited with the aid of syntax and semantic validation and completion suggestions.
This is exerpt from the link:
OCL can be embedded in Ecore using annotations. Maintenance of these
annotations is performed automatically by the OCLinEcore editor ...
The embedded OCL becomes active when the appropriate delegate
functionality is specified.
There are three type of delegate functionality:
Setting Delegate
Invocation Delegate
Validation Delegate
Also there are invariants constraints.
I see two alternatives:
Use EVL (Epsilon Validation Language), it is included in EMF (Eclipse Modeling Framework). In that way, you just right click .ecore model and create a new EVL Validation (under Epsilon options). EVL syntax is well documented on Epsilon book https://www.eclipse.org/epsilon/doc/book/.
Use OCL directly. For this purpose yo need to install OCL component on EMF. So, if you are using Eclipse, Help > Install Modeling Components > Find: OCL. Check the obtained result. Now this tutorial could help you http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FCompleteOCLTutorial.html.
I wish this could help.

djangonic way to deal with rdf?

I was looking for an RDF project for django and I cant find any active.
This seems to be a good one http://code.google.com/p/django-rdf, but the last commit was in 2008, (4 years ago). The group in google-groups seems to be abandoned. Last no-spam post was in 2008.
Therefore it has no support for new django versions.
Is there any library or some prebuilt open source app to easily expose rdf data?
Maybe is easy to solve, like writing a view and returning something using https://github.com/RDFLib/rdflib in one or two lines of code, but I can't figure it out how to do it...
The idea using RDFlib would be to take a django object or collection of objects and transform it to rdf in some way, maybe using an rdf parser.
I thought I could give html responses if the client request "accept:text/html", and RDF if the user requested the same page using a html accept header with rdf+xml or rdf+turtle (and it could exist an app that handles that for me)
From what little I've read of RDF you are probably going to have to do manual work to get meaningful RDF statements from Django models since it's not a simple data representation format like JSON, it is trying to encode semantic meaning.
That said, have a look at django-rdflib:
https://github.com/odeoncg/django-rdflib
There doesn't seem to be any documentation (and it seems to have been built for a specific app) but the author has posted here about a manage.py syncvb command that generates an RDF graph from existing Django models:
https://groups.google.com/d/msg/django-rdf/14WVK7t88PE/ktAKJo-aCfUJ
Not sure exactly what views django-rdflib provides, but if it can make an RDFlib graph for you then you can probably use the serialization plugins provided by RDFlib to output rdf+xml or whatever from your own view.
http://code.google.com/p/djubby/
SURF is useful as a RDF->object mapper (or RDFAlchemy)
injecting rdfa into your templates should work either (if you want to avoid triplestores)
you can also expose your database as a sparql endpoint using a tool such as http://d2rq.org/

Is it possible to generate real Java code with Dresden OCL Toolkit?

I tried using Dresden OCL to describe constraints for an UML class diagram. It looks like it can generate AspectJ code fine but I could not find a way to generate the Java code representing the modeled classes (and their attributes and methods). The examples provided with Dresden OCL Toolkit also show how to generate AspectJ code once the Java code is already present (OCL22Java tutorial).
Is it possible to generate the Java (not AspectJ) code with constraints embedded inside? And if it is, then how is it done?
It is not possible to do that with Dresden OCL Toolkit, therefore some other tool must be used for that. I used Uml2Java for Acceleo.
The standalone engine of DresdenOCL (StandaloneFacade) includes a function called generateJavaCode. I'm not sure though if this function is actually "complete" and generates correct Java Code for all possible OCL constraints. You also cannot find any info about that function on Google, it's just used in the standalone example.
Edit: As an example what Java code it generates:
For this OCL expression (on some simple UML model that I created)
context person
inv: self.age >= 0
you get this piece of Java code
(aClass.age >= new Integer(0))
And for this OCL expression
context person::havingBirthday()
post: self.age = self.age#pre+1
you get this:
((Object) aClass.age).equals((atPreValue1 + new Integer(1)))
So the generated Java code is not that usable atm, you need to modify it (or your Java functions) a bit to actually use it.
Eclipse OCL provides support for enriching the Java generated from Ecore models with complete inline Java code for OCL embedded within Ecore. Eclipse UML2 provides support for converting UML with embedded OCL to Ecore with embedded OCL. This now provides all that you ask for. It has been available for a couple of years. See the Code Generator tutorial in the Eclipse OCL documentation for an example and further information.

A good ORM to use with qt4 (c++) ? (Django like...)

Does anyone have a recommendation for an ORM for qt4 (c++)? (Like a Django ORM).
I would suggest you take a look at the QDjango ORM, it might be just what you are looking for. This C++ ORM only depends on Qt and builds upon Qt's Meta-Object System to provide introspection. On top of the basic create/update/delete operations at the model level, it provides a queryset template class (modeled after django's querysets) which allows to build fairly complex lookups.
Optional QtScript support is also provided, so you can access your models and perform database queries from scripts.
There is also a new open source ORM C++ library : QxOrm. QxOrm is based on QtSql Qt module to communicate with database and boost::serialization to serialize your data with xml and binary format. The web site is in french but quick sample code and tutorial code is in english (a translation is in progress...).