Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » is there a way to ignore an EPackage during the java code generation ?
is there a way to ignore an EPackage during the java code generation ? [message #1759051] Wed, 05 April 2017 15:10 Go to next message
vincent lorenzo is currently offline vincent lorenzoFriend
Messages: 93
Registered: June 2010
Location: Paris Saclay, France
Member
Hello everybody,
I'm looking for a way to configure my GenModel in order to have no code generated for a given EPackage.

Does someone know if it is possible and how ?

Re: is there a way to ignore an EPackage during the java code generation ? [message #1759053 is a reply to message #1759051] Wed, 05 April 2017 15:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5980
Registered: July 2009
Senior Member
Hi

Define a separate GernModel for that/each EPackage and reference the unwanted GenModel as a usedGenPackages.

Regards

Ed Willink
Re: is there a way to ignore an EPackage during the java code generation ? [message #1759106 is a reply to message #1759053] Thu, 06 April 2017 13:31 Go to previous messageGo to next message
vincent lorenzo is currently offline vincent lorenzoFriend
Messages: 93
Registered: June 2010
Location: Paris Saclay, France
Member
Hi Ed, thank you for your answer.
I think I must give you more details on my usecase, because I tried this solution and it didn't work.

I'm doing these things : Papyrus UML Model -> Ecore Model -> java code.
In my Papyrus Model, I have :
- a PrimitiveType mapped on java.lang.Boolean (stereotyped as EDataType)
- a class representing EClass (stereotyped as EClass)
- a class representing EObject (stereotyped as EClass)

Of course these objects are used to types UML Properties

The UML to EMF tool creates an EDatatype and 2 EClasses adressing the real object.
The code generation works fine. (there are no code generated for boolean, EClass and EObject !)

Now, I would like to group these objects in a dedicated Package (or a dedicated model). I do a simple model (in attachment ) to apply your answer.
As the objects in this package are used as type in the second model, the generated code for xxxPackageImpl#init() doesn't compile because we initialize the useless dependency to the package I didn't generate

In attachment a simple example to reproduce my problem in EMF pure.
Thank you for your help.


Of course, I could avoid headache using EBooleanObject, EClass and EObject instead of creating EDatatype and EClass to represent them, but this is the current result of the UMLToEcore transformation so I would like to know if it is possible to not reference a not generated package when it contains only predefined types.

Regards,

/Vincent Lorenzo

  • Attachment: example.zip
    (Size: 24.35KB, Downloaded 41 times)
Re: is there a way to ignore an EPackage during the java code generation ? [message #1759145 is a reply to message #1759106] Thu, 06 April 2017 22:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29459
Registered: July 2009
Senior Member
Looking at the XMI of this package
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="Example" nsURI="ExampleURI" nsPrefix="Example">
  <eClassifiers xsi:type="ecore:EClass" name="MyClass">
    <eStructuralFeatures xsi:type="ecore:EReference" name="anEClass" eType="ecore:EClass externaltypes.ecore#//EClass"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="localBoolean" eType="ecore:EDataType externaltypes.ecore#//Boolean"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="anEObject" eType="ecore:EClass externaltypes.ecore#//EObject"/>
  </eClassifiers>
</ecore:EPackage>
it seems to me these should all be referencing EClassifiers from Ecore.ecore. I can't comment on what "externaltypes.ecore" is supposed to mean. That's a UML thing. But given the names, Ecore.ecore has EClassifiers named EClass, EObject, and EBoolean and I would expect those are what you'd want to be using here.
Re: is there a way to ignore an EPackage during the java code generation ? [message #1759156 is a reply to message #1759145] Fri, 07 April 2017 06:17 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5980
Registered: July 2009
Senior Member
Hi

Primitives are a source of endless fun. I think that I counted no fewer than 7 different 'Boolean' types between OMG UML via Eclipse UML, Eclipse OCL, Ecore and Java. I suspect that you need to be unifying rather than ignoring.

Since you are doing UML -> Ecore -> Java, you might consider exploiting the OCL->Java code generator so that your UML has OCL 'bodies'. Eclipse UML2, Eclipse OCL supports UML+OCL -> Ecore -> Java.

Regards

Ed Willink
Previous Topic:Easy way of Filtering in EMF List Dialogs
Next Topic:XML Namespace not being propagated
Goto Forum:
  


Current Time: Sat Jul 21 17:05:00 GMT 2018

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

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

Back to the top