Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Refining Mode with two input models?
[ATL] Refining Mode with two input models? [message #107143] Wed, 24 June 2009 19:36 Go to next message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009
Member
Hi everyone!

It's glad to see that it is possible to make In-Place transformations with
ATL.
With the Refining-Mode feature of ATL, is it possible to realize the
scenario as follows?:

I have two input models IM1 and IM2. The metamodels of both are not
equal. The output model OM bases on the same metamodel as IM1.

Using ATL transformation, IM1 should be refined into OM.
- Transformation Rules concerning elements of IM1 if the identifier
(each model element is identifiable) of these elements exist in IM2.
In the case that the contents of two elements with the same identifier
are not equal, the content should be taken from the element of IM2.
- In addition, an element of IM2 whose identifier do not correspond
with an identifier of an element of IM1 should be transformed into a
new element adding into OM.
- Finally, all elements of IM1 which are not matched by any rule above
will just be copied into OM.

So, what I need here is a refinment of IM1 into OM concerning
transformation rule conditions based on comparison of contents between
IM1 and IM2.

Is it possible to define such a transformation using ATL?

Thanks in advance, Helko
Re: [ATL] Refining Mode with two input models? [message #107175 is a reply to message #107143] Thu, 25 June 2009 10:11 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 297
Registered: July 2009
Senior Member
Hello,

To me your scenario seems possible in refining mode, but in fact it
depends of what you are going to do when replacing elements: at this
time we can't delete elements in refining mode (but you can add).

Anyway, if the refining mode doesn't match your needs, you can define a
standard transformation which copies elements from IM1 and IM2 according
to the specification you gave.

Best regards,

William

Helko Glathe a écrit :
> Hi everyone!
>
> It's glad to see that it is possible to make In-Place transformations
> with ATL.
> With the Refining-Mode feature of ATL, is it possible to realize the
> scenario as follows?:
>
> I have two input models IM1 and IM2. The metamodels of both are not
> equal. The output model OM bases on the same metamodel as IM1.
>
> Using ATL transformation, IM1 should be refined into OM.
> - Transformation Rules concerning elements of IM1 if the identifier
> (each model element is identifiable) of these elements exist in IM2.
> In the case that the contents of two elements with the same identifier
> are not equal, the content should be taken from the element of IM2.
> - In addition, an element of IM2 whose identifier do not correspond
> with an identifier of an element of IM1 should be transformed into a
> new element adding into OM.
> - Finally, all elements of IM1 which are not matched by any rule above
> will just be copied into OM.
>
> So, what I need here is a refinment of IM1 into OM concerning
> transformation rule conditions based on comparison of contents between
> IM1 and IM2.
>
> Is it possible to define such a transformation using ATL?
>
> Thanks in advance, Helko
>
>
Re: [ATL] Refining Mode with two input models? [message #108008 is a reply to message #107175] Tue, 07 July 2009 14:20 Go to previous messageGo to next message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009
Member
Hi William,

sorry for the late reply.

The demands to the transformation have been changed after few discussions:
- Input Models: IM1, IM2
- Input MetaModels: IMM1, IMM2
- Ouptut Model: OM
- Output MetaModel: IMM1

-> First, all elements of IM1 shall be copied to OM
-> a new container element should be added do OM
-> all elements of IM2 shall be transformed as new instances of the newly
created container mentioned before
-> Also inside OM, reference links between elements outside the container and
inside the container shall be established, if two such elements have the same
identifier value (ID Matching)

The activity of deleting elements is not longer relevant for me. So, I can
ignore this problematic.

So, you mean that it is possible to have many input models (here: IM1 and
IM2) in refining mode and to only consider exactly one of these input
models (IM1) as to be refined into the output model (OM)?

Is this correct?

Best regards and thanks in advance, Helko



William Piers wrote:

> Hello,

> To me your scenario seems possible in refining mode, but in fact it
> depends of what you are going to do when replacing elements: at this
> time we can't delete elements in refining mode (but you can add).

> Anyway, if the refining mode doesn't match your needs, you can define a
> standard transformation which copies elements from IM1 and IM2 according
> to the specification you gave.

> Best regards,

> William

> Helko Glathe a écrit :
>> Hi everyone!
>>
>> It's glad to see that it is possible to make In-Place transformations
>> with ATL.
>> With the Refining-Mode feature of ATL, is it possible to realize the
>> scenario as follows?:
>>
>> I have two input models IM1 and IM2. The metamodels of both are not
>> equal. The output model OM bases on the same metamodel as IM1.
>>
>> Using ATL transformation, IM1 should be refined into OM.
>> - Transformation Rules concerning elements of IM1 if the identifier
>> (each model element is identifiable) of these elements exist in IM2.
>> In the case that the contents of two elements with the same identifier
>> are not equal, the content should be taken from the element of IM2.
>> - In addition, an element of IM2 whose identifier do not correspond
>> with an identifier of an element of IM1 should be transformed into a
>> new element adding into OM.
>> - Finally, all elements of IM1 which are not matched by any rule above
>> will just be copied into OM.
>>
>> So, what I need here is a refinment of IM1 into OM concerning
>> transformation rule conditions based on comparison of contents between
>> IM1 and IM2.
>>
>> Is it possible to define such a transformation using ATL?
>>
>> Thanks in advance, Helko
>>
>>
Re: [ATL] Refining Mode with two input models? [message #108462 is a reply to message #108008] Mon, 20 July 2009 08:49 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 297
Registered: July 2009
Senior Member
Hello,

Helko Glathe a écrit :
> Hi William,
>
> sorry for the late reply.

So do I...

>
> The demands to the transformation have been changed after few discussions:
> - Input Models: IM1, IM2
> - Input MetaModels: IMM1, IMM2
> - Ouptut Model: OM
> - Output MetaModel: IMM1
>
> -> First, all elements of IM1 shall be copied to OM
> -> a new container element should be added do OM
> -> all elements of IM2 shall be transformed as new instances of the
> newly created container mentioned before
> -> Also inside OM, reference links between elements outside the
> container and inside the container shall be established, if two such
> elements have the same identifier value (ID Matching)
>
> The activity of deleting elements is not longer relevant for me. So, I
> can ignore this problematic.
> So, you mean that it is possible to have many input models (here: IM1
> and IM2) in refining mode and to only consider exactly one of these
> input models (IM1) as to be refined into the output model (OM)?
>
> Is this correct?

Yes. Just keep in mind that during the transformation, ATL consider IM1
and OM as an unique EMF resource.
After launch, if you specified the same path for IM1 and OM (in the
launch configuration), the IM1 resource will be updated. Otherwise, a
new model will be created at OM path.

Best regards,

William

>
> Best regards and thanks in advance, Helko
>
>
>
> William Piers wrote:
>
>> Hello,
>
>> To me your scenario seems possible in refining mode, but in fact it
>> depends of what you are going to do when replacing elements: at this
>> time we can't delete elements in refining mode (but you can add).
>
>> Anyway, if the refining mode doesn't match your needs, you can define
>> a standard transformation which copies elements from IM1 and IM2
>> according to the specification you gave.
>
>> Best regards,
>
>> William
>
>> Helko Glathe a écrit :
>>> Hi everyone!
>>>
>>> It's glad to see that it is possible to make In-Place transformations
>>> with ATL.
>>> With the Refining-Mode feature of ATL, is it possible to realize the
>>> scenario as follows?:
>>>
>>> I have two input models IM1 and IM2. The metamodels of both are not
>>> equal. The output model OM bases on the same metamodel as IM1.
>>>
>>> Using ATL transformation, IM1 should be refined into OM.
>>> - Transformation Rules concerning elements of IM1 if the identifier
>>> (each model element is identifiable) of these elements exist in IM2.
>>> In the case that the contents of two elements with the same identifier
>>> are not equal, the content should be taken from the element of IM2.
>>> - In addition, an element of IM2 whose identifier do not correspond
>>> with an identifier of an element of IM1 should be transformed into a
>>> new element adding into OM.
>>> - Finally, all elements of IM1 which are not matched by any rule above
>>> will just be copied into OM.
>>>
>>> So, what I need here is a refinment of IM1 into OM concerning
>>> transformation rule conditions based on comparison of contents between
>>> IM1 and IM2.
>>>
>>> Is it possible to define such a transformation using ATL?
>>>
>>> Thanks in advance, Helko
>>>
>>>
>
>
Re: [ATL] Refining Mode with two input models? [message #108720 is a reply to message #108462] Mon, 27 July 2009 09:21 Go to previous messageGo to next message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009
Member
Hi William, another late reply ;-)

What you have written sounds very good to me. So, I will try out.

Cheers, Helko

William Piers wrote:

> Hello,

> Helko Glathe a écrit :
>> Hi William,
>>
>> sorry for the late reply.

> So do I...

>>
>> The demands to the transformation have been changed after few discussions:
>> - Input Models: IM1, IM2
>> - Input MetaModels: IMM1, IMM2
>> - Ouptut Model: OM
>> - Output MetaModel: IMM1
>>
>> -> First, all elements of IM1 shall be copied to OM
>> -> a new container element should be added do OM
>> -> all elements of IM2 shall be transformed as new instances of the
>> newly created container mentioned before
>> -> Also inside OM, reference links between elements outside the
>> container and inside the container shall be established, if two such
>> elements have the same identifier value (ID Matching)
>>
>> The activity of deleting elements is not longer relevant for me. So, I
>> can ignore this problematic.
>> So, you mean that it is possible to have many input models (here: IM1
>> and IM2) in refining mode and to only consider exactly one of these
>> input models (IM1) as to be refined into the output model (OM)?
>>
>> Is this correct?

> Yes. Just keep in mind that during the transformation, ATL consider IM1
> and OM as an unique EMF resource.
> After launch, if you specified the same path for IM1 and OM (in the
> launch configuration), the IM1 resource will be updated. Otherwise, a
> new model will be created at OM path.

> Best regards,

> William

>>
>> Best regards and thanks in advance, Helko
>>
>>
>>
>> William Piers wrote:
>>
>>> Hello,
>>
>>> To me your scenario seems possible in refining mode, but in fact it
>>> depends of what you are going to do when replacing elements: at this
>>> time we can't delete elements in refining mode (but you can add).
>>
>>> Anyway, if the refining mode doesn't match your needs, you can define
>>> a standard transformation which copies elements from IM1 and IM2
>>> according to the specification you gave.
>>
>>> Best regards,
>>
>>> William
>>
>>> Helko Glathe a écrit :
>>>> Hi everyone!
>>>>
>>>> It's glad to see that it is possible to make In-Place transformations
>>>> with ATL.
>>>> With the Refining-Mode feature of ATL, is it possible to realize the
>>>> scenario as follows?:
>>>>
>>>> I have two input models IM1 and IM2. The metamodels of both are not
>>>> equal. The output model OM bases on the same metamodel as IM1.
>>>>
>>>> Using ATL transformation, IM1 should be refined into OM.
>>>> - Transformation Rules concerning elements of IM1 if the identifier
>>>> (each model element is identifiable) of these elements exist in IM2.
>>>> In the case that the contents of two elements with the same identifier
>>>> are not equal, the content should be taken from the element of IM2.
>>>> - In addition, an element of IM2 whose identifier do not correspond
>>>> with an identifier of an element of IM1 should be transformed into a
>>>> new element adding into OM.
>>>> - Finally, all elements of IM1 which are not matched by any rule above
>>>> will just be copied into OM.
>>>>
>>>> So, what I need here is a refinment of IM1 into OM concerning
>>>> transformation rule conditions based on comparison of contents between
>>>> IM1 and IM2.
>>>>
>>>> Is it possible to define such a transformation using ATL?
>>>>
>>>> Thanks in advance, Helko
>>>>
>>>>
>>
>>
icon5.gif  Re: [ATL] Refining Mode with two input models? [message #503998 is a reply to message #107143] Wed, 16 December 2009 18:43 Go to previous message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009
Member
Hi William and all,

I'm back with my Refining Mode problem (see above).

I've enhanced the Public2Private (InPlace) Example as follows..:

- an additional Metamodel called "Unsinn" (Unsinn.ecore) which is only containing one type called "UnsinnType" (this type has no further Features/Attributes).
- the enhanced Public2Private.atl (Excerpt) with additional Input "IN2" and a simple rule "UnsinnHandle" which shall take all elements of type "Unsinn.UnsinnType" and transform them into new elements of type UML.Class:

module Public2Private;
create OUT : UML refining IN : UML, IN2 : Unsinn;

...
...

rule UnsinnHandle{
	from
		unsinnElement : Unsinn!UnsinnType
	to
		newUMLClass : UML!Class(name <- 'test')

}

rule Property {
	from
		publicAttribute : UML!Property (
			publicAttribute.visibility = #public and publicAttribute.association.oclIsUndefined()
		)
	to
		privateAttribute : UML!Property (
			visibility <- #private
		),
...
...


Running this from ATL User Interface gives me the following error message:

Quote:

org.eclipse.m2m.atl.engine.emfvm.VMException: Feature name does not exist on UnsinnType
<native>
at __applyRefiningTrace__(Public2Private.atl)
local variables: self=thisModule
at main(Public2Private.atl)
local variables: self=thisModule



I've tried it programmaticaly with source code as follows...:

/*******************************************************************************
 * Copyright (c) 2008, 2009 Obeo.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Obeo - Public2Private example IDE
 *******************************************************************************/
package org.eclipse.m2m.atl.examples.public2private.ui;

import java.io.FileInputStream;
import java.net.URL;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.m2m.atl.core.ATLCoreException;
import org.eclipse.m2m.atl.core.IExtractor;
import org.eclipse.m2m.atl.core.IInjector;
import org.eclipse.m2m.atl.core.IModel;
import org.eclipse.m2m.atl.core.IReferenceModel;
import org.eclipse.m2m.atl.core.ModelFactory;
import org.eclipse.m2m.atl.core.launch.ILauncher;
import org.eclipse.m2m.atl.core.service.CoreService;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.osgi.framework.Bundle;

/**
 * Privatize action implementation.
 * 
 * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
 */
public class PrivatizeAction implements IObjectActionDelegate {

	private static IInjector injector;

	private static IExtractor extractor;

	private static IReferenceModel umlMetamodel;
	
	private static IReferenceModel unsinnMetamodel;
	
	private static IReferenceModel refiningTraceMetamodel;

	private static URL asmURL;

	private ISelection currentSelection;

	static {
		// ATL public2private transformation
		Bundle bundle = Platform.getBundle("org.eclipse.m2m.atl.examples.public2private"); //$NON-NLS-1$
		asmURL = bundle.getEntry("transformation/Public2Private.asm"); //$NON-NLS-1$
		try {
			injector = CoreService.getInjector("EMF"); //$NON-NLS-1$
			extractor = CoreService.getExtractor("EMF"); //$NON-NLS-1$			
		} catch (ATLCoreException e) {
			e.printStackTrace();
		}
	}

	/**
	 * Constructor for Action1.
	 */
	public PrivatizeAction() {
		super();
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
	 *      org.eclipse.ui.IWorkbenchPart)
	 */
	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
	public void run(IAction action) {
		// Getting files from selection
		IStructuredSelection iss = (IStructuredSelection)currentSelection;
		for (Iterator<?> iterator = iss.iterator(); iterator.hasNext();) {
			try {
				privatize((IFile)iterator.next());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
	}

	private void privatize(IFile file) throws Exception {
		// Defaults
		ModelFactory factory = CoreService.createModelFactory("EMF"); //$NON-NLS-1$

		// Metamodels
		umlMetamodel = factory.newReferenceModel();
		unsinnMetamodel = factory.newReferenceModel();
		
		
		injector.inject(umlMetamodel, "http://www.eclipse.org/uml2/2.1.0/UML"); //$NON-NLS-1$
		Map map = Collections.EMPTY_MAP;
		FileInputStream fis = new FileInputStream("D:/myTmp/Unsinn.ecore");
		injector.inject(unsinnMetamodel, fis, map);
		unsinnMetamodel.setIsTarget(false);
		refiningTraceMetamodel = factory.getBuiltInResource("RefiningTrace.ecore"); //$NON-NLS-1$

		// Getting launcher
		ILauncher launcher = null;
		launcher = CoreService.getLauncher("EMF-specific VM"); //$NON-NLS-1$
		//launcher = CoreService.getLauncher("Regular VM (with debugger)"); //$NON-NLS-1$
		launcher.initialize(Collections.<String, Object> emptyMap());

		// Creating models
		IModel refiningTraceModel = factory.newModel(refiningTraceMetamodel);
		IModel umlModel = factory.newModel(umlMetamodel);
		IModel unsinnModel = factory.newModel(unsinnMetamodel);

		// Loading existing model
		injector.inject(umlModel, file.getFullPath().toString());
		Map map2 = Collections.EMPTY_MAP;
		FileInputStream fis2 = new FileInputStream("D:/myTmp/My.unsinn");
		injector.inject(unsinnModel, fis2, map2);
		unsinnModel.setIsTarget(false);

		// Launching
		launcher.addOutModel(refiningTraceModel, "refiningTrace", "RefiningTrace"); //$NON-NLS-1$ //$NON-NLS-2$
		launcher.addInOutModel(umlModel, "IN", "UML"); //$NON-NLS-1$ //$NON-NLS-2$
		launcher.addInModel(unsinnModel, "IN2", "Unsinn");

		launcher.launch(ILauncher.RUN_MODE, new NullProgressMonitor(), Collections
				.<String, Object> emptyMap(), asmURL.openStream());

		// Saving model
		extractor.extract(umlModel, file.getFullPath().toString());

		// Refresh workspace
		file.getParent().refreshLocal(IProject.DEPTH_INFINITE, null);

	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
	 *      org.eclipse.jface.viewers.ISelection)
	 */
	public void selectionChanged(IAction action, ISelection selection) {
		this.currentSelection = selection;
	}
}



But the error message remains / is the same after execution.

Is something wrong in my source code or ATL transformation definition?

Or isn't it possible to have multiple input models - where each of them have a different metamodel as a base - in one ATL Refining Transformation (Refer to my initial two postings in this thread).


Thanks in advance, Helko
Previous Topic:[ATL] No Resource found, unable to extract
Next Topic:[QVT] How to process element/package imports to href models/libraries?
Goto Forum:
  


Current Time: Wed Aug 21 12:17:33 GMT 2019

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

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

Back to the top