Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] UML Stereotypes application not set when launching transformation from Java
[QVTo] UML Stereotypes application not set when launching transformation from Java [message #723094] Wed, 07 September 2011 15:37 Go to next message
--alex--  is currently offline --alex-- Friend
Messages: 26
Registered: October 2009
Junior Member
Hi all,
I managed to implement a transformation that takes a INOUT UML model and the MARTE profile and adds to the model some elements stereotyped with MARTE stereotypes.

When I launch the transformation via the "Run configuration" the model is transformed as intended and everything is fine.
However if I try to launch the transformation from Java all the stereotypes are created correctly (along with the model elements) but their "base_element" attribute is not saved. In the end the stereotypes are not attached to the model elements Sad

Is there a way to solve this problem?

The code to launch the transformation is the following:
ModelSet rs = new ModelSet();
Resource inResource = rs.getResource(inURI, true);
Resource marteResource = rs.getResource(marteURI, true);
ExecutionContextImpl context = new ExecutionContextImpl();
context.setConfigProperty("keepModeling", true);
ModelExtent input1 = new BasicModelExtent(inResource.getContents());
ModelExtent input2 = new BasicModelExtent(marteResource.getContents());
final Resource traceResource = new ResourceImpl();
InternalTransformationExecutor txExecutor = 
	new InternalTransformationExecutor(transfURI) {
    protected void handleExecutionTraces(Trace traces) {
ExecutionDiagnostic result = txExecutor.execute(context, input1, input2);

//At this point input1 does not have the stereotypes correctly set

Resource actualTraceResource = rs.createResource(traceURI);
actualTraceResource.getContents().addAll(traceResource.getContents()); NullProgressMonitor());
Re: [QVTo] UML Stereotypes application not set when launching transformation from Java [message #723487 is a reply to message #723094] Thu, 08 September 2011 16:33 Go to previous message
--alex--  is currently offline --alex-- Friend
Messages: 26
Registered: October 2009
Junior Member
Since I didn't find any way to resolve my problem (perhaps it is due to the ResourceSet) I solved by:

- creating a new launch configuration dynamically in Java and
- launching it DIRECTLY, i.e. not with a launch delegate (I need it to run in the same thread)

The code which solves my problem is the following:

ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType c = manager.getLaunchConfigurationType(QvtLaunchConfigurationDelegate.LAUNCH_CONFIGURATION_TYPE_ID);
ILaunchConfigurationWorkingCopy instance = c.newInstance(null, NAME);
instance.setAttribute(IQvtLaunchConstants.CLEAR_CONTENTS+"1", true);
instance.setAttribute(IQvtLaunchConstants.CLEAR_CONTENTS+"2", true);
instance.setAttribute(IQvtLaunchConstants.CONFIGURATION_PROPERTIES, new HashMap());
instance.setAttribute(IQvtLaunchConstants.ELEM_COUNT, 2);
instance.setAttribute(IQvtLaunchConstants.FEATURE_NAME+"1", "");
instance.setAttribute(IQvtLaunchConstants.FEATURE_NAME+"2", "" );
instance.setAttribute(IQvtLaunchConstants.MODULE, transfURIString);
instance.setAttribute(IQvtLaunchConstants.TARGET_MODEL+"1", modelURIString);
instance.setAttribute(IQvtLaunchConstants.TARGET_MODEL+"2", marteURIString);
instance.setAttribute(IQvtLaunchConstants.TARGET_TYPE+"1", "NEW_MODEL");
instance.setAttribute(IQvtLaunchConstants.TARGET_TYPE+"2", "NEW_MODEL");
instance.setAttribute(IQvtLaunchConstants.TRACE_FILE, traceURIString);		
instance.setAttribute(IQvtLaunchConstants.USE_TRACE_FILE, true);
QvtTransformation qvtTransformation = new QvtInterpretedTransformation(QvtLaunchConfigurationDelegateBase.getQvtModule(instance));
IStatus status = QvtLaunchConfigurationDelegateBase.validate(qvtTransformation, instance);                    
if(status.getSeverity() > IStatus.WARNING)
   throw new CoreException(status);
StreamsProxy streamsProxy = new StreamsProxy();
EvaluationMonitor execMonitor = createMonitor();
Context context = QvtLaunchUtil.createContext(instance);
context.setLog(new WriterLog(streamsProxy.getOutputWriter()));
QvtLaunchConfigurationDelegateBase.doLaunch(qvtTransformation, instance, context);

p.s. I created a monster but I don't have the time to tidy up the code Very Happy
Previous Topic:ATL : Reference to a target class using a different rule
Next Topic:[QVTo] How to extend a model
Goto Forum:

Current Time: Sun Apr 14 12:02:39 GMT 2024

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

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

Back to the top