| Find a class with a given Stereotype. [message #50850] | 
Mon, 18 September 2006 15:23   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: firstname.name.gmail.com 
 
Hello, 
 
I try to understand a little bit how the emft query/statement works (doesn't 
really want to use OCL). Up to now, I have created some basic queries (find a 
class having a specific attribute). But now, I would like to retrieve all the 
elements stereotyped by a given stereotype. 
 
I know that a stereotype is applied on a specific element with an association 
base_/extension_. But I don't know how to create this condition. I have 
investigated on using #isApplied(Stereotype), but without success. 
 
Best Regards 
 
--  
F. Lagarde
 |  
 |  
  | 
 | 
 | 
| Re: Find a class with a given Stereotype. [message #51162 is a reply to message #51077] | 
Wed, 20 September 2006 09:07   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
We are just building something like a Catalog of OCL expressions for UML2. 
We dont have it yet online but I will post an adress if we have one. 
The solution for your question: 
 
self.getAppliedStereotypes()->exists(s : Stereotype |s.qualifiedName = 
'test::test') 
 
to get the qualified name, select the stereotype and say self.qualifiedName 
 
François Lagarde schrieb: 
> In the last post, on 09/19 around 05h, "Chris" (Chris McGee) wrote: 
>  
>        Chris> Hello François, Couldn't you use a condition something like this 
>        Chris> in your query? 
>  
>        Chris> public class StereotypeAppliedCondition extends EObjectCondition { 
>        Chris> 	public boolean isSatisfied(EObject eObj) { if (eObj instanceof 
>        [...] 
>        Chris> 	} 
>        Chris> } 
>  
> Hello, 
>  
> Thanks a lot. I have finally realized my query by providing a specific 
> BooleanAdapter, but your solution sounds better. 
>  
> I have to confess that I have some difficulties to write queries on EFeatures... 
>  
> Hopping to become good enough to help others people.
 |  
 |  
  | 
| Re: Find a class with a given Stereotype. [message #591397 is a reply to message #50850] | 
Tue, 19 September 2006 11:48   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hello François, 
 
Couldn't you use a condition something like this in your query? 
 
public class StereotypeAppliedCondition extends EObjectCondition { 
	private Stereotype s; 
 
	public StereotypeAppliedCondition(Stereotype s) { 
		this.s = s; 
	} 
 
	public boolean isSatisfied(EObject eObj) { 
		if (eObj instanceof Element) { 
			return (((Element)eObj).isStereotypeApplied(s)); 
		} 
		// Not a UML2 object, therefore, no stereotype is applied 
		return false; 
	} 
} 
 
I hope this helps, 
Chris 
 
François Lagarde wrote: 
> Hello, 
>  
> I try to understand a little bit how the emft query/statement works (doesn't 
> really want to use OCL). Up to now, I have created some basic queries (find a 
> class having a specific attribute). But now, I would like to retrieve all the 
> elements stereotyped by a given stereotype. 
>  
> I know that a stereotype is applied on a specific element with an association 
> base_/extension_. But I don't know how to create this condition. I have 
> investigated on using #isApplied(Stereotype), but without success. 
>  
> Best Regards 
>
 |  
 |  
  | 
| Re: Find a class with a given Stereotype. [message #591409 is a reply to message #51049] | 
Tue, 19 September 2006 16:16   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: firstname.name.gmail.com 
 
In the last post, on 09/19 around 05h, "Chris" (Chris McGee) wrote: 
 
       Chris> Hello François, Couldn't you use a condition something like this 
       Chris> in your query? 
 
       Chris> public class StereotypeAppliedCondition extends EObjectCondition { 
       Chris> 	public boolean isSatisfied(EObject eObj) { if (eObj instanceof 
       [...] 
       Chris> 	} 
       Chris> } 
 
Hello, 
 
Thanks a lot. I have finally realized my query by providing a specific 
BooleanAdapter, but your solution sounds better. 
 
I have to confess that I have some difficulties to write queries on EFeatures... 
 
Hopping to become good enough to help others people. 
--  
F. Lagarde
 |  
 |  
  | 
| Re: Find a class with a given Stereotype. [message #591439 is a reply to message #51077] | 
Wed, 20 September 2006 09:07   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
We are just building something like a Catalog of OCL expressions for UML2. 
We dont have it yet online but I will post an adress if we have one. 
The solution for your question: 
 
self.getAppliedStereotypes()->exists(s : Stereotype |s.qualifiedName = 
'test::test') 
 
to get the qualified name, select the stereotype and say self.qualifiedName 
 
François Lagarde schrieb: 
> In the last post, on 09/19 around 05h, "Chris" (Chris McGee) wrote: 
>  
>        Chris> Hello François, Couldn't you use a condition something like this 
>        Chris> in your query? 
>  
>        Chris> public class StereotypeAppliedCondition extends EObjectCondition { 
>        Chris> 	public boolean isSatisfied(EObject eObj) { if (eObj instanceof 
>        [...] 
>        Chris> 	} 
>        Chris> } 
>  
> Hello, 
>  
> Thanks a lot. I have finally realized my query by providing a specific 
> BooleanAdapter, but your solution sounds better. 
>  
> I have to confess that I have some difficulties to write queries on EFeatures... 
>  
> Hopping to become good enough to help others people.
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.53883 seconds