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.
Related
Its difficult to give more details as I haven't even found a clue in OBEO Designer Community to model OCL constraints.
Anyone has a idea how to do this?
Thanks
You should be able to add Validation rules with a constraint expressed in AQL -- Acceleo Query Language (a flavor of OCL) directly in the .odesign file.
See thecorresponding part of the tutorial.
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#
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
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.
I would like to do bidirectional Model2Model transformations. Both models are EMF / eCore based. Actually I would prefer that one model is an editable view on the other.
What are my options?
Which tools and tranformation languages are avaiable and what are their restrictions?
M2M are the hardest. Industries strength tools are rare, lots of academia stuff. If you're dead set on a M2M language, look into ATL which should also support ecore. Otherwise you can look at Xtend, which was made for model to text but you can abuse it and it should be more comftable than plain java. If your into research look at Scala based transformations here
http://metrikforge.informatik.hu-berlin.de/attachments/download/193/george_wider_scheidgen_ICMT_2012.pdf
There are more transformation tools than you can imagine for EMF, its kind of crazy...
For metamodel to metamodel transformation where the models are not very similar:
ATL is probably the most popular and most "baked"
Epsilon project has the Epsilon Transformation Language.
If the metamodels are very similar and you only need to tweak some things then there are tools targeted that type of migration/updating:
ATL now has a refining mode
Epsilon has Flock
Edapt looks very interesting as well because it does the metamodel/model changes together. It lets you work on a tree view and comes with a set prebuilt set of rules.
Henshin which lets you operate on a diagram view of the model
EMF Refactor is a more code-level approach, that can also use Henshin rules somehow.
You can always directly manipulate the metamodel and model using the EMF Java APIs as well.
I'll add, if you are doing any real EMF work you will need to get and read EMF: Eclipse Modeling Framework. It's available in Safari also. I highly recommend Safari, for $39 a month you get almost every development ebook you could ever use.
If you insist on doing bidirectional M2M transformations, (so-called Bxs), then know that there is an active researcher's community updating that wiki : http://bx-community.wikidot.com.
If you visit it, you will find that they list a bunch of tool suitable for Bx transformations http://bx-community.wikidot.com/relatedtools.
I used ECHO in the past which provides an implementation of QVT-R based on the KodKod constraints solver.
It's definitely worth giving it a try.
Since you specifically asked for bi-directional model transformations, I must say that you have no options. To make it claer, adding to the answer you got form Ed Willink, none of the existing M2M transformation languages (AFAIK) supports bi-directional model transformations.
Work on a QVTr and QVTc execution engine is starting to look promising if you are still interested in this: QVTd Project.