Application of EMF profiles - how to apply to Ecore model?

64 views
Skip to first unread message

mueller...@googlemail.com

unread,
May 28, 2015, 6:38:20 AM5/28/15
to emf-pr...@googlegroups.com
Hello,

I was searching for a possibility to apply profiles on Ecore models and I was happy seeing that EMF Profiles seems perfectly suitable for that.

However, when I try to follow the steps described in the screencasts, I have problems with actually applying my created profile. My use case is that I want to apply stereotypes on Ecore models, e.g. to apply a stereotype Entity on a EClass instance.
Creating the profile seems to work properly. For instance, the registered EMF profiles view shows the profile and the stereotypes etc.

My problem is that I don't find a way to apply my profile to ecore files. I tested different options: creating an ecore file using the tree editor and creating an ecore file using the Ecore Tools.
When using the Ecore tools I can create a .ecorediag file, but when I select a EClass, I can't find an option "EMF Profiles -> Apply Profile". There is only an "Apply Stereotype" but this reports "Can not apply any stereotype to EObject". I could not find something like "EMF Profiles -> ..." using the standard tree-based Ecore editor either.

In another post in this newsgroup (https://groups.google.com/forum/#!topic/emf-profiles/czUX-MRnabk) I found the following:
> To apply a profile, you need to open the model to which you want to apply the profile, open the EMF Profile > Profile Application View
> and hit the green plus button in that view. Then, you may choose the file to which you want to save the profile application and select the
> profile to be applied. Once the profile application is displayed in the profile application view, you can right-click any element in the model
> to which you want to apply the profile and select "Apply Stereotype".

I tried to perform these steps, but this was not successful. When I click the green plus button, I can select an "EMF Profile Application File", but this dialog expects a .".pa.xmi" file which I don't have. I tried to "trick" the dialog by renaming my example model file to a file ending with ".pa.xmi" but then I receive the error message "The file ... does not contain any profile applications", which is obviously right, as I didn't apply a profile yet.

Did I miss a required step? I only want to apply my profile example to some Ecore model to test EMF profiles. Later, I want to use it to create models with stereotypes which are used as input for e.g. Xtend to generate code.

Best regards
Klaus

Philip Langer

unread,
Jun 7, 2015, 6:24:13 AM6/7/15
to emf-pr...@googlegroups.com
Hi Klaus,

sorry for replying late. The EMF Profiles project is somewhat inactive
currently. But I'm very happy that there are still interested people
from time to time. So, thank you!

After reading your post, I think you were trying to load an existing
profile application (the green plus icon). However, I think you
actually want to create a new profile application file. Therefore, you
have to click the window+ symbol, which is the next symbol to the
left. There you need to enter the file to which the profile
application shall be stored, which is a .pa.xmi file.

Did you see this: http://me-at-big.blogspot.co.at/search/label/EMF%20profiles ?
On this page, there are some blog posts on EMF Profiles, also one
about creating a new profile application. The blog posts there are
probably the most current guides available, since the other
documentation pages are rather outdated.

If you are interested in using/extending EMF Profiles, let me know; I
think it is worth reviving this project.

Hope this helps, let me know if there are further questions!

Philip
> --
> You received this message because you are subscribed to the Google Groups
> "EMF Profiles" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emf-profiles...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

mueller...@googlemail.com

unread,
Jun 11, 2015, 2:13:57 AM6/11/15
to emf-pr...@googlegroups.com
Hi Philip,

thanks for your reply.


Am Sonntag, 7. Juni 2015 12:24:13 UTC+2 schrieb Philip Langer:
Did you see this: http://me-at-big.blogspot.co.at/search/label/EMF%20profiles ?
On this page, there are some blog posts on EMF Profiles, also one
about creating a new profile application. The blog posts there are
probably the most current guides available, since the other
documentation pages are rather outdated.

Yes, I saw this page, but obviously I missed that the description concerning the application of the profile is up to date there. Sorry for that.
I'm now able to apply my profile to my Ecore model.

My intended use case is to apply stereotypes to an Ecore model which should be used as input for a code generator, written in, e.g. Xtend or Acceleo.
I saw a post of you concerning this (https://groups.google.com/forum/#!searchin/emf-profiles/xtend/emf-profiles/5qoXYzMeBzM/q7RIFeOKTxkJ):
 
If you were referring with your question to considering your profile applications applied to your metamodel during the code generation, you'd have to load the profile application and read its tagged values from the respective code generation technology... e.g., with xtend it is easy to load profile applications and read them, as you can simply use the Profile Facade from within Xtend. But it is also possible with XPand, though it you have to do more manually since you cannot use the profile facade and you'd have to load and read the profile applications as normal EMF-based models.

Can you please explain this in a bit more detail? I've just started using Xtend and for testing purposes, I've created a very simple generator that basically looks as follows:

class DomainmodelGenerator implements IGenerator {

 
@Inject extension IQualifiedNameProvider

 
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
     
for(e: resource.allContents.toIterable.filter(EClass)) {
          fsa
.generateFile(
        e
.fullyQualifiedName.toString("/") + ".java",
        e
.compile)
     
}
 
}
 
 
def compile(EClass e) '''
  public class «e.name» {
      «FOR f:e.EReferences»
      private «f.EReferenceType.name» «f.name»;
      «ENDFOR»
  }
  '''


Hence, this simple generator only generates a class for each EClass and generates a variable declaration for references. This is just that simple for demonstration purposes. How could I integrate the handling of my defined stereotypes? I had expected to be able to write something like this (assuming that my profile contains an extension MyStereotype for EClass).


  def compile(EClass e) '''
  public class «e.name» {
      «FOR f:e.EReferences»
      private «f.EReferenceType.name» «f.name»;
      «ENDFOR»
  }
  '''

 
def compile(MyStereotype e) '''
  public class «e.name»Special {
      «FOR f:e.EReferences»
      private «f.EReferenceType.name» «f.name»;
      «ENDFOR»
      //my fancy extension
  }
  '''


Thanks in advance. I appreciate any kind of help. Perhaps a short documentation on this use case would be valuable for the blog posts page you sent?

Best regards
Klaus
 
Reply all
Reply to author
Forward
0 new messages