Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » ATL transformations - applying profiles to a model
ATL transformations - applying profiles to a model [message #87470] Wed, 06 August 2008 12:32 Go to next message
Eclipse UserFriend
Originally posted by: simon.triv.org.uk

I'm trying to use ATL to do a model transformation where the destination
metamodel is UML with the MARTE profile.

One plug-in contains the MARTE profile. It is composed of several
sub-profiles quoted in the plugin.xml file, for example:

<UMLProfile
id="MARTE_HRM"
name="MARTE_HRM"
path="pathmap://MARTE_PROFILE/MARTE_HRM.epx"
required="false"
visible="true"/>

Another plug-in contains the ATL transformation code. This plug-in
provides an Eclipse extension from which the transformation is launched by
indirectly calling AtlLauncher.launch().

My problem is that I can't work out how to apply profiles to the
destination model. The the UML2 API call, Model.applyProfile(), appears to
do what I want, but from where can I obtain an instance of the profile to
pass as the argument? Can I somehow reference the profiles specified in
the MARTE plug-in?

Constrained by the dependency of the MARTE tools on Rational Software
Architect 7.0.0 (based on Eclipse 3.2), I am using the 2007-02-16 release
of ATL downloaded from
< http://www.sciences.univ-nantes.fr/lina/atl/www/atldemo/Old% 20Files/adt_am3.zip>.

Does anyone have any suggestions? I suspect there's a simple enough answer
but I'm new to ATL and all the examples I've seen seem to involve reading
profile stereotypes, not writing them.

Thanks,
Simon
[ATL] Re: ATL transformations - applying profiles to a model [message #88039 is a reply to message #87470] Mon, 11 August 2008 12:56 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 301
Registered: July 2009
Senior Member
Hello,

Answers below :

Simon Heywood a écrit :
> I'm trying to use ATL to do a model transformation where the destination
> metamodel is UML with the MARTE profile.
>
> One plug-in contains the MARTE profile. It is composed of several
> sub-profiles quoted in the plugin.xml file, for example:
>
> <UMLProfile
> id="MARTE_HRM"
> name="MARTE_HRM"
> path="pathmap://MARTE_PROFILE/MARTE_HRM.epx"
> required="false"
> visible="true"/>
>
> Another plug-in contains the ATL transformation code. This plug-in
> provides an Eclipse extension from which the transformation is launched
> by indirectly calling AtlLauncher.launch().
>
> My problem is that I can't work out how to apply profiles to the
> destination model. The the UML2 API call, Model.applyProfile(), appears
> to do what I want,

Here you will find a good example of how applying stereotypes :
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2m/org .eclipse.m2m.atl/tests/org.eclipse.m2m.atl.tests/data/inputs /Relational2UML/Relational2UML.atl?root=Modeling_Project& ;view=markup

> but from where can I obtain an instance of the
> profile to pass as the argument? Can I somehow reference the profiles
> specified in the MARTE plug-in?
>

Normally I will say that you specify the pathmap://... or the
platform:/plugin/... corresponding to your profile, but it seems that
the launch configuration doesn't allow it :-/

But as you said, you launch ATL programmatically, so you might be able
to load the profiles with the correct path (plugin) before calling
AtlLauncher.launch

Anyway if you encounter problems a basic workaround would be to copy the
profiles in the same project than the transformation itself.

> Constrained by the dependency of the MARTE tools on Rational Software
> Architect 7.0.0 (based on Eclipse 3.2), I am using the 2007-02-16
> release of ATL downloaded from
> < http://www.sciences.univ-nantes.fr/lina/atl/www/atldemo/Old% 20Files/adt_am3.zip>.

You better have to use the last release, available here :
http://www.eclipse.org/modeling/m2m/downloads/index.php?proj ect=atl

Best regards,

William

>
> Does anyone have any suggestions? I suspect there's a simple enough
> answer but I'm new to ATL and all the examples I've seen seem to involve
> reading profile stereotypes, not writing them.
>
> Thanks,
> Simon
>
>
Re: [ATL] Re: ATL transformations - applying profiles to a model [message #88070 is a reply to message #88039] Mon, 11 August 2008 14:50 Go to previous messageGo to next message
Eclipse UserFriend
Hello William,

I am using your VMLauncher.java in order to do a UML-Profile
transformation.
Unfortuantely, I get the error : "java.lang.RuntimeException: cannot find
model Relational"

Hope you can show me what I do wrong.

Regards,

Thomas


I added the following stuff :

public class VMLauncher {

// for registrying the UML stuff
public static ResourceSet resSet;

// register the UML2 Handler and UML2 Profile stuff
public static AtlUML2ModelHandler getDefaultHandler(String repository) {
AtlUML2ModelHandler amhUML2 = null;
try {
resSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);

AtlModelHandler.registerDefaultHandler("UML",new AtlUML2ModelHandler());
amhUML2 = (AtlUML2ModelHandler) AtlUML2ModelHandler.getDefault("UML");
resSet=amhUML2.getResourceSet();
resSet.getResourceFactoryRegistry().getExtensionToFactoryMap ().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Map uriMap = resSet.getURIConverter().getURIMap();
URI uri =
URI.createURI(" jar:file:/C:/gany/plugins/org.eclipse.uml2.uml.resources_2.2 .0.v200805131030.jar!/ ");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
uri.appendSegment("profiles").appendSegment(""));
} catch (Throwable e) {
e.printStackTrace();}
return (AtlUML2ModelHandler) amhUML2;}


//simple standalone application
public static void main (String args[]) throws Exception {

getDefaultHandler("UML");
VMLauncher atl=new VMLauncher ();

Map in =new HashMap<String, String>();

in.put("IN","UML");
in.put("PRO","UML");

Map out=new HashMap<String, String>();

out.put("OUT", "UML");

Map path =new HashMap<String, String>();

path.put("Relational",
"file:c:/eclipse/workspace/UMLPro/relational.ecore");
path.put("UML", "uri:http://www.eclipse.org/uml2/2.1.0/UML");

path.put("IN", "sample-Relational.ecore");
path.put("PRO", "relational.uml");
path.put("OUT", "sample-Relational.uml");


//ModelHandler
Map hand=new HashMap<String, String>();

hand.put("UML", "UML");

atl.launch(new
URL("file:c:/eclipse/workspace/UMLPro/Relational2UML.asm"), in, out, path,
Collections.EMPTY_MAP, Collections.EMPTY_MAP,hand ,
Collections.EMPTY_LIST);
}
Re: [ATL] Re: ATL transformations - applying profiles to a model [message #88191 is a reply to message #88070] Tue, 12 August 2008 09:45 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 301
Registered: July 2009
Senior Member
Hello,

I corrected the errors below :

TWink a écrit :
> Hello William,
>
> I am using your VMLauncher.java in order to do a UML-Profile
> transformation.
> Unfortuantely, I get the error : "java.lang.RuntimeException: cannot
> find model Relational"
>
> Hope you can show me what I do wrong.
>
> Regards,
>
> Thomas
>
>
> I added the following stuff :
>
> public class VMLauncher {
>

//You don't need to make a method to load the UML2 model handler, the
//launcher ever do it. So you can remove the lines I commented :
/*
> // for registrying the UML stuff
> public static ResourceSet resSet;
>
> // register the UML2 Handler and UML2 Profile stuff
> public static AtlUML2ModelHandler getDefaultHandler(String repository) {
> AtlUML2ModelHandler amhUML2 = null;
> try {
> resSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>
> AtlModelHandler.registerDefaultHandler("UML",new AtlUML2ModelHandler());
> amhUML2 = (AtlUML2ModelHandler) AtlUML2ModelHandler.getDefault("UML");
> resSet=amhUML2.getResourceSet();
> resSet.getResourceFactoryRegistry().getExtensionToFactoryMap ().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> Map uriMap = resSet.getURIConverter().getURIMap();
> URI uri =
> URI.createURI(" jar:file:/C:/gany/plugins/org.eclipse.uml2.uml.resources_2.2 .0.v200805131030.jar!/ ");
>
> uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
> uri.appendSegment("libraries").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
> uri.appendSegment("metamodels").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
> uri.appendSegment("profiles").appendSegment(""));
> } catch (Throwable e) {
> e.printStackTrace();}
> return (AtlUML2ModelHandler) amhUML2;}
>
*/
> //simple standalone application
> public static void main (String args[]) throws Exception {
>
/*
> getDefaultHandler("UML");
*/
> VMLauncher atl=new VMLauncher ();
>
> Map in =new HashMap<String, String>();
>
// Here you need to specify the same parameters as in the launch
// configuration which is used to run the transformation.
// Here is the launch config :
//http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2m/o rg.eclipse.m2m.atl/tests/org.eclipse.m2m.atl.tests/data/inpu ts/Relational2UML/Relational2UML.launch?root=Modeling_Projec t&view=markup
// So correct values are :
/*
> in.put("IN","UML");
> in.put("PRO","UML");
*/
in.put("IN","Relational");
in.put("PRO","UML");
> Map out=new HashMap<String, String>();
>
> out.put("OUT", "UML");
>
> Map path =new HashMap<String, String>();
>
> path.put("Relational",
> "file:c:/eclipse/workspace/UMLPro/relational.ecore");
> path.put("UML", "uri:http://www.eclipse.org/uml2/2.1.0/UML");
>
> path.put("IN", "sample-Relational.ecore");
> path.put("PRO", "relational.uml");
> path.put("OUT", "sample-Relational.uml");
>
>
> //ModelHandler
> Map hand=new HashMap<String, String>();
>
//And finally :
/*
> hand.put("UML", "UML");
*/
hand.put("UML", "UML2");
hand.put("Relational", "EMF");
>
> atl.launch(new
> URL("file:c:/eclipse/workspace/UMLPro/Relational2UML.asm"), in, out,
> path, Collections.EMPTY_MAP, Collections.EMPTY_MAP,hand ,
> Collections.EMPTY_LIST);
> }
>
>

Best regards,

William
Re: [ATL] Re: ATL transformations - applying profiles to a model [message #88277 is a reply to message #88191] Wed, 13 August 2008 10:02 Go to previous messageGo to next message
Eclipse UserFriend
Hi William,

Thanks for the fast response.

I corrected the code as suggested by you. Unfortunately, I get the
following error message :
"Exception in thread "main" java.lang.RuntimeException: Eclipse platform
extension registry not found. Dynamic repository lookup does not work
outside Eclipse"

pointing to line 73: AtlModelHandler.getDefault(currentModelHandler));

So I explicitly tried to add the register command in the beginning of the
launch method :

public static double launch(....

boolean checkSameModel = false;

//explicitly register the UML2 Handler
AtlModelHandler.registerDefaultHandler("UML2", new AtlUML2ModelHandler());

// model handler
Map atlModelHandler = new HashMap();
.....

But then I got the error message :

"java.io.FileNotFoundException:
c:\eclipse\workspace\UMLPro\uri:http:\www.eclipse.org\uml2\2 .1.0\UML "

Somehow, this one is not resoloved correctly :

path.put("UML", "uri:http://www.eclipse.org/uml2/2.1.0/UML");

Regards,

Thomas
Re: [ATL] Re: ATL transformations - applying profiles to a model [message #88293 is a reply to message #88039] Thu, 14 August 2008 14:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.triv.org.uk

William Piers wrote:
> Simon Heywood a écrit :
>> I'm trying to use ATL to do a model transformation where the destination
>> metamodel is UML with the MARTE profile.
>>
>> One plug-in contains the MARTE profile. It is composed of several
>> sub-profiles quoted in the plugin.xml file, for example:
>>
>> <UMLProfile
>> id="MARTE_HRM"
>> name="MARTE_HRM"
>> path="pathmap://MARTE_PROFILE/MARTE_HRM.epx"
>> required="false"
>> visible="true"/>
>>
>> Another plug-in contains the ATL transformation code. This plug-in
>> provides an Eclipse extension from which the transformation is launched
>> by indirectly calling AtlLauncher.launch().
>>
>> My problem is that I can't work out how to apply profiles to the
>> destination model. The the UML2 API call, Model.applyProfile(), appears
>> to do what I want,
>
> Here you will find a good example of how applying stereotypes :
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2m/org .eclipse.m2m.atl/tests/org.eclipse.m2m.atl.tests/data/inputs /Relational2UML/Relational2UML.atl?root=Modeling_Project& ;view=markup

Thanks for pointing me at that. It uses
UML!Stereotype.allInstancesFrom('<model>'), which is probably good enough,
although MARTE seems to be composed of a dozen or so sub-profiles which I
imagine would all need to be passed as input models to each ATL script.

That leaves the problem of how to load the profiles such that ATL is aware
of them.

>> but from where can I obtain an instance of the
>> profile to pass as the argument? Can I somehow reference the profiles
>> specified in the MARTE plug-in?
>
> Normally I will say that you specify the pathmap://... or the
> platform:/plugin/... corresponding to your profile, but it seems that
> the launch configuration doesn't allow it :-/
>
> But as you said, you launch ATL programmatically, so you might be able
> to load the profiles with the correct path (plugin) before calling
> AtlLauncher.launch

Do you know where I could find some documentation on this?

> Anyway if you encounter problems a basic workaround would be to copy the
> profiles in the same project than the transformation itself.

In that case, how would I reference the files in ATL / Java? I've tried
passing a suitable FileInputStream to AtlEMFModelHandler.loadModel(String,
ASMModel, InputStream), but that just generates stack traces like this:

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with
uri 'http:///schemas/ProfileBase/1' not found.
(file:///C:/Program%20Files/IBM/SDP70/MARTE_HRM, 5214, 2762)
at
org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLL oadImpl.java:80)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:189)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:179)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1094)
at
org.atl.engine.repositories.emf4atl.ASMEMFModel.loadASMEMFMo del(ASMEMFModel.java:341)
at
org.atl.eclipse.engine.AtlEMFModelHandler.loadModel(AtlEMFMo delHandler.java:110)
at com.thalesgroup.atl.ATLTransform.loadModel(ATLTransform.java :159)
at com.thalesgroup.atl.ATLTransform.addInputModel(ATLTransform. java:193)
at
com.thalesgroup.spear.marte.atl.SPEARTransform.run(SPEARTran sform.java:79)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:113)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package
with uri 'http:///schemas/ProfileBase/1' not found.
(file:///C:/Program%20Files/IBM/SDP70/MARTE_HRM, 5214, 2762)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2322)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(XMLHandler.java:2160)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1137)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1239)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:877)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:82)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown
Source)
at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyEle ment(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
... 8 more

>> Constrained by the dependency of the MARTE tools on Rational Software
>> Architect 7.0.0 (based on Eclipse 3.2), I am using the 2007-02-16
>> release of ATL downloaded from
>>
< http://www.sciences.univ-nantes.fr/lina/atl/www/atldemo/Old% 20Files/adt_am3.zip>.

> You better have to use the last release, available here :
> http://www.eclipse.org/modeling/m2m/downloads/index.php?proj ect=atl

I'm tied to Eclipse 3.2 compatibility because of the dependency on
Rational Software Architect, so unless anyone can point me to some newer
release of ATL that's compatible with Rational Software Architect, EMF,
etc., then unfortunately I'm stuck with the 2007-02-16 release.

Regards,
Simon
[ATL] Source code for the 2007-02-16 release of the ATL development tools [message #88504 is a reply to message #87470] Mon, 18 August 2008 09:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.triv.org.uk

Simon Heywood wrote:
> Constrained by the dependency of the MARTE tools on Rational Software
> Architect 7.0.0 (based on Eclipse 3.2), I am using the 2007-02-16 release
> of ATL downloaded from
>
< http://www.sciences.univ-nantes.fr/lina/atl/www/atldemo/Old% 20Files/adt_am3.zip>.

Does anyone know where I can obtain the source code for this version of
the ATL development tools? As I understand it, the EPL requires published
binary code to be accompanied by the corresponding source code, or at
least a means of requesting it.

I can't find any relevant tags in the dev.eclipse.org CVS repository,
which I'm guessing is because that version predates the transition to the
Eclipse m2m project. I suppose one of the contacts listed at
<http://www.sciences.univ-nantes.fr/lina/atl/> may be more able to help,
but I thought I'd ask on here first.

Alternatively, is there another release of ATL that's compatible with
Rational Software Architect (i.e. Eclipse 3.2 and EMF 2.2.1 or 2.2.3)?
Re: [ATL] Source code for the 2007-02-16 release of the ATL development tools [message #89956 is a reply to message #88504] Fri, 05 September 2008 09:28 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> Does anyone know where I can obtain the source code for this version of
> the ATL development tools? As I understand it, the EPL requires
> published binary code to be accompanied by the corresponding source
> code, or at least a means of requesting it.
>
> I can't find any relevant tags in the dev.eclipse.org CVS repository,
> which I'm guessing is because that version predates the transition to
> the Eclipse m2m project. I suppose one of the contacts listed at
> <http://www.sciences.univ-nantes.fr/lina/atl/> may be more able to help,
> but I thought I'd ask on here first.

ATL source code is available from the Eclipse.org CVS:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2m/org .eclipse.m2m.atl/?root=Modeling_Project
Check out information is available at:
http://wiki.eclipse.org/index.php/CVS_Howto

The current version of ATL plugins is in the plugins/ folder. Older
versions (i.e., before the migration of ATL from GMT to M2M) are in the
deprecated/ folder. When no other tag is available for a specific
version, you may use a date tag.


Best regards,

Frédéric Jouault
Previous Topic:[ATL]meta-model interference
Next Topic:[ATL] Problems using UML2 models
Goto Forum:
  


Current Time: Thu Apr 18 11:48:42 GMT 2024

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

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

Back to the top