Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » Migration of new profile definition does not work
icon5.gif  Migration of new profile definition does not work [message #777349] Tue, 10 January 2012 05:13 Go to next message
Eclipse UserFriend
Hello everyone,

currently I try to apply a profile ("ansicextension") to an existing UML model programmatically in an xTend script. For that I am following the code suggested by org.eclipse.uml2.uml.editor.actions.ApplyProfileAction:

setProfile(uml::Package p, uml::Profile profile) :
    let m = p.getModel() :
	    if (m.getProfileApplication(m.getAppliedProfile("ansicextension")) == null ||
	        m.getProfileApplication(m.getAppliedProfile("ansicextension")) != profile.getDefinition()) then (
	        "All applied profiles:".info() ->
            m.getAllAppliedProfiles().info() ->
            "".info() ->
            "Profile application of profile with old definition:".info() ->  
            m.getProfileApplication(m.getAppliedProfile("ansicextension")).info() ->
            "".info() ->
            "Applying profile with new definition...".info() ->
            "".info() ->
            //m.applyProfile(profile) ->
            m.migrateProfile(profile) ->
            "All applied profiles:".info() ->
            m.getAllAppliedProfiles().info() ->
            "".info() ->
            "Definition of profile \"ansicextension\"".info() ->
            m.getAppliedProfile("ansicextension").getDefinition().info() ->
            "".info() ->
            "Definition of passed profile".info() ->
            m.getProfileApplication(profile).getAppliedDefinition().info() ->
            "".info() ->
            "Applied definition of profile \"ansicextension\"".info() ->
            m.getProfileApplication(m.getAppliedProfile("ansicextension")).getAppliedDefinition().info() ->
            "".info()
	    )
;

(The new "ansicextension" is passed to setProfile to get its most current definition and there might be already an applied "ansicextension" with an old definition)

I get the following console output:

1859 INFO  IOExtensions       - All applied profiles:
1869 INFO  IOExtensions       - [org.eclipse.uml2.uml.internal.impl.ProfileImpl@1daf835 (name: ansicextension, visibility: <unset>)]
1870 INFO  IOExtensions       - 
1870 INFO  IOExtensions       - Profile application of profile with old definition:
1872 INFO  IOExtensions       - org.eclipse.uml2.uml.internal.impl.ProfileApplicationImpl@11f24bb (isStrict: false)
1873 INFO  IOExtensions       - 
1874 INFO  IOExtensions       - Applying profile with new definition...
1874 INFO  IOExtensions       - 
1929 INFO  IOExtensions       - All applied profiles:
1930 INFO  IOExtensions       - [org.eclipse.uml2.uml.internal.impl.ProfileImpl@1daf835 (name: ansicextension, visibility: <unset>), org.eclipse.uml2.uml.internal.impl.ProfileImpl@863d22 (name: ansicextension, visibility: <unset>)]
1930 INFO  IOExtensions       - 
1931 INFO  IOExtensions       - Definition of profile "ansicextension"
1933 INFO  IOExtensions       - org.eclipse.emf.ecore.impl.EPackageImpl@1606bf5 (name: ansicextension) (nsURI: http:///schemas/ansicextension/_XJckUDq7EeGbEJmsvlSgdQ/10, nsPrefix: ansicextension)
1934 INFO  IOExtensions       - 
1934 INFO  IOExtensions       - Definition of passed profile
1936 INFO  IOExtensions       - org.eclipse.emf.ecore.impl.EPackageImpl@be0382 (name: ansicextension) (nsURI: http:///schemas/ansicextension/_XJckUDq7EeGbEJmsvlSgdQ/10, nsPrefix: ansicextension)
1936 INFO  IOExtensions       - 
1937 INFO  IOExtensions       - Applied definition of profile "ansicextension"
1937 INFO  IOExtensions       - org.eclipse.emf.ecore.impl.EPackageImpl@8bf223 (name: ansicextension) (nsURI: http:///schemas/ansicextension/_ZWVOQMzAEeCV_4ZI_I7CJQ/9, nsPrefix: ansicextension)
1938 INFO  IOExtensions       - 


It can be seen that the profile to be applied is just added to all applied profiles and whereas the both profiles are the same (but the new one with a new definition) the new profile is not migrated into the old one. In the end the old definition keeps applied.
Does anyone have an idea what I am doing wrong?

Thanks in advance and best regards,
Tom Smile
Re: Migration of new profile definition does not work [message #777371 is a reply to message #777349] Tue, 10 January 2012 06:03 Go to previous message
Eclipse UserFriend
Hello,

ok I found my mistake. The mistake was, that the new profile was loaded at another instance in my workflow. Hence, it couldn't be the same instance which is loaded for the model and an equality check with the present applied profiles fails. I observed that by debugging org.eclipse.uml2.uml.internal.operations.PackageOperations.applyProfile.

In my case the code has to be changed to:

setProfile(uml::Package p) :
    let m = p.getModel() :
        if (m.getAppliedProfile("ansicextension") == null) then (
            m.applyProfile(getAnsiCExtensionURI())
        ) else (
            if (m.getProfileApplication(m.getAppliedProfile("ansicextension")).getAppliedDefinition() != m.getAppliedProfile("ansicextension").getDefinition()) then (
                m.applyProfile(m.getAppliedProfile("ansicextension"))
            )
        )
;


Bye Tom Smile
Previous Topic:Namespace Problems
Next Topic:Inject multiple XML records
Goto Forum:
  


Current Time: Tue Apr 29 01:46:44 EDT 2025

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

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

Back to the top