Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Problem when setting values of applied Stereotypes(The property comes from an association between two stereotypes.)
icon9.gif  Problem when setting values of applied Stereotypes [message #1076437] Wed, 31 July 2013 11:54 Go to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi everyone,

I got a profile with two stereotypes: View and Perspective. Both have two properties (name and icon, which are both Strings), Perspective also has a relationship with View (association called 'views') meaning it actually ends up having one more attribute which is a Sequence of Views.

So I can set values properly without a problem to both name and icon, but the problem comes when changing the value of the attribute "views". I can access the value properly and give it an empty sequence without any trouble, but I don't know how to add to it the other classes that are stereotyped with View.

Here is what I tried:
src.setValue(profile!Stereotype.allInstances().asSequence() -> select(i | i.qualifiedName ='RCP::Perspective').last(), 'views', UML2!Class.										allInstancesFrom('OUT') -> select(e | not e.getAppliedStereotype('RCP::View').oclIsUndefined()));

And I get a java.lang.IllegalArgumentException because apparently the classes are not the proper argument. I thought that the property 'views' was addressing a sequence of different classes with the stereotype 'View', but I'm thinking that maybe it addresses the stereotypes directly, but I have no idea of how to get them.

So my question is, how do I do this? what is the proper call I should use to get those stereotypes or whatever I need and what kind of element is it expecting?

Well I hope that wasn't too confusing but if you need more information just ask.
Thanks in advance,
regards,
Javier

[Updated on: Wed, 31 July 2013 12:31]

Report message to a moderator

Re: Problem when setting values of applied Stereotypes [message #1076471 is a reply to message #1076437] Wed, 31 July 2013 12:53 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

I don't know if your current problem actually comes from this but I've seen that, in your expression, you're trying to pass to setValue an output model element.
ATL is declarative, so you shouldn't navigate the output model as you cannot know which elements have already been created at a given point in time.
You should rather pass the related input model element, ATL will automatically do the resolution itself according to the corresponding matched rule.
I hope this helps.

Best regards,


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Problem when setting values of applied Stereotypes [message #1077018 is a reply to message #1076471] Thu, 01 August 2013 06:21 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi Hugo,
thanks for your answer, here is the whole code of my rule:
endpoint rule EndRule() {
	do {
		for(src in UML2!Class.allInstancesFrom('OUT')) {
			if (src.getNearestPackage().name = 'View Actions'){
			src.applyStereotype(profile!Stereotype.allInstances().asSequence() ->
					select(i | i.qualifiedName = 'RCP::ViewAction').last()); 
			src.name<-src.name + ' ViewAction';
			} 
			else if (src.getNearestPackage().name = 'Workbench Actions'){
			src.applyStereotype(profile!Stereotype.allInstances().asSequence() ->
					select(i | i.qualifiedName = 'RCP::WorkbenchAction').last());
			src.setValue(profile!Stereotype.allInstances().asSequence() -> select(i | i.
					qualifiedName = 'RCP::WorkbenchAction').last(), 'label', src.
					getXmlAttribute('actionSet', 'label'));
			src.name<-src.name + ' WorkbenchAction';
			}
			else if (src.getNearestPackage().name = 'Popup Menus'){
			src.applyStereotype(profile!Stereotype.allInstances().asSequence() ->
					select(i | i.qualifiedName = 'RCP::PopupMenu').last());
			src.name<-src.name + ' PopupMenu';
			}
			else if (src.getNearestPackage().name = 'Toolbars'){
			src.applyStereotype(profile!Stereotype.allInstances().asSequence() ->
					select(i | i.qualifiedName = 'RCP::ToolBar').last()); 
							src.setValue(profile!Stereotype.allInstances().asSequence()
									-> select(i | i.qualifiedName = 'RCP::ToolBar').
									last(), 'toolBar', src.getToolbarPath());
			src.name<-'Toolbar ' + src.getToolbarPath();
			}
			else if (not src.getAppliedStereotype('RCP::Perspective').oclIsUndefined()){

------------------------TODO: make this work:
								src.setValue(profile!Stereotype.allInstances().
										asSequence() -> select(i | i.qualifiedName =
										'RCP::Perspective').last(), 'views', UML2!Class.
										allInstancesFrom('OUT') -> select(e | not e.
										getAppliedStereotype('RCP::View').oclIsUndefined()));
			}
			
		}
	}
}

As you can see it's an endpoint rule, I thought it was ok to use allInstancesFrom('OUT') in there since it's the last thing that will be run, and as you can see I use it in other calls and it works alright.
By the way the problematic call is the last one, if I delete it everything runs smoothly.

My problem is that the input model has no profile applied so in my transformation I apply the profile and the stereotypes, and since I need to change these values I need to check on the output model. I tried using allInstances() but it shows the same result.

The complete stack trace I get is:
Quote:
org.eclipse.m2m.atl.engine.emfvm.VMException: Exception during invocation of operation setValue on org.eclipse.uml2.uml.internal.impl.ClassImpl@9685c9 (name: MonitoringPerspective, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
Java Stack:
org.eclipse.m2m.atl.engine.emfvm.VMException: Exception during invocation of operation setValue on org.eclipse.uml2.uml.internal.impl.ClassImpl@9685c9 (name: MonitoringPerspective, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.invoke(EMFModelAdapter.java:734)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:425)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:208)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.internalLaunch(EMFVMLauncher.java:170)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMUILauncher.launch(EMFVMUILauncher.java:46)
at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:136)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(AtlLaunchConfigurationDelegate.java:300)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:237)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.IllegalArgumentException: [org.eclipse.uml2.uml.internal.impl.ClassImpl@3435a9 (name: MapElementsView, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false), org.eclipse.uml2.uml.internal.impl.ClassImpl@1af27e6 (name: IncidentTreeView, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false), org.eclipse.uml2.uml.internal.impl.ClassImpl@648371 (name: DetailView, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false), org.eclipse.uml2.uml.internal.impl.ClassImpl@f1ad77 (name: SnapshotView, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)]
at org.eclipse.uml2.uml.internal.operations.ElementOperations.setValue(ElementOperations.java:752)
at org.eclipse.uml2.uml.internal.impl.ElementImpl.setValue(ElementImpl.java:306)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.invoke(EMFModelAdapter.java:727)
... 13 more


So I think that I'm just not using the proper arguments and I don't know what should I use instead.
I have tried this both with eclipse Indigo and Juno and I get the same result.

[Updated on: Thu, 01 August 2013 06:51]

Report message to a moderator

Re: Problem when setting values of applied Stereotypes [message #1079849 is a reply to message #1077018] Mon, 05 August 2013 06:42 Go to previous message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi, I just found out how to fix it, you can read the solution here: http://www.eclipse.org/forums/index.php/t/456910/ pretty much just had to use getStereotypeApplications() instead of directly getting the class.
Previous Topic:resolveTemp() in lazy rule
Next Topic:throw exceptions within ATL rules?
Goto Forum:
  


Current Time: Thu Mar 28 23:48:40 GMT 2024

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

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

Back to the top