Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Find a class with a given Stereotype.
Find a class with a given Stereotype. [message #50850] Mon, 18 September 2006 19:23 Go to next message
Eclipse UserFriend
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 #51049 is a reply to message #50850] Tue, 19 September 2006 15:48 Go to previous messageGo to next message
Chris McGee is currently offline Chris McGeeFriend
Messages: 99
Registered: July 2009
Member
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 #51077 is a reply to message #51049] Tue, 19 September 2006 20:16 Go to previous messageGo to next message
Eclipse UserFriend
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 #51162 is a reply to message #51077] Wed, 20 September 2006 13:07 Go to previous message
Chris Lenz is currently offline Chris LenzFriend
Messages: 214
Registered: July 2009
Senior Member
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 15:48 Go to previous message
Chris McGee is currently offline Chris McGeeFriend
Messages: 99
Registered: July 2009
Member
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 20:16 Go to previous message
Eclipse UserFriend
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 13:07 Go to previous message
Chris Lenz is currently offline Chris LenzFriend
Messages: 214
Registered: July 2009
Senior Member
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.
Previous Topic:Teneo with JPOX-1.1.2
Next Topic:OCL help needed
Goto Forum:
  


Current Time: Sun Jun 30 13:52:30 GMT 2024

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

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

Back to the top