Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL query to find classes
OCL query to find classes [message #484277] Sat, 05 September 2009 11:24 Go to next message
Eclipse UserFriend
Originally posted by: pkol2009.yahoo.com

Hi,

I am new to OCL, I am using OCL interpreter to find classes in a model
(EMF XMI model) at M2 layer, using following query.
> Class.allInstances()

when I execute this query I found Classes like Statemachine, Usecase, Node
and so on. basically I want to find only classes in a model without
classes like statemachine, usease or any other modeling element. Can any
body help me in this regard?

Thanks,
pkojo
Re: OCL query to find classes [message #484297 is a reply to message #484277] Sat, 05 September 2009 19:25 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
As suggested in the UML User Group @ google:

Well, both a look into the UML2 spec and the OCL spec might be very
helpful and recommended...

Since StateMachines, UseCases, Components etc. are all subclasses of
UML::Class, you need a more detailed OCL concept like
oclTypeOf(object) and oclKindOf(object). The first one checks, whether
self is exactly the type of the parameter, the latter one checks if self
is conform (a subclass) to the parameter#s type.

good luck from this starting point!

pkojo schrieb:
> Hi,
>
> I am new to OCL, I am using OCL interpreter to find classes in a model
> (EMF XMI model) at M2 layer, using following query.
>> Class.allInstances()
>
> when I execute this query I found Classes like Statemachine, Usecase,
> Node and so on. basically I want to find only classes in a model without
> classes like statemachine, usease or any other modeling element. Can any
> body help me in this regard?
>
> Thanks,
> pkojo
>
Re: OCL query to find classes [message #485030 is a reply to message #484277] Thu, 10 September 2009 10:02 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
What about

model.allOwnedElements->collect(e:Element|e.oclIsTypeOf(Class))

Please, let me know, if this helps you...

pkojo schrieb:
> Hi,
>
> I am new to OCL, I am using OCL interpreter to find classes in a model
> (EMF XMI model) at M2 layer, using following query.
>> Class.allInstances()
>
> when I execute this query I found Classes like Statemachine, Usecase,
> Node and so on. basically I want to find only classes in a model without
> classes like statemachine, usease or any other modeling element. Can any
> body help me in this regard?
>
> Thanks,
> pkojo
>
Re: OCL query to find classes [message #485088 is a reply to message #485030] Thu, 10 September 2009 13:45 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 847
Registered: July 2009
Senior Member
--=-bdr2PJD4PXcAbBCMJKv1
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Timothy,

I think you intended a select iterator:

model.allOwnedElements->select(e:Element|e.oclIsTypeOf(Class))

Cheers,

Christian


On Thu, 2009-09-10 at 12:02 +0200, Timothy Marc wrote:

> What about
>
> model.allOwnedElements->collect(e:Element|e.oclIsTypeOf(Class))
>
> Please, let me know, if this helps you...
>
> pkojo schrieb:
> > Hi,
> >
> > I am new to OCL, I am using OCL interpreter to find classes in a model
> > (EMF XMI model) at M2 layer, using following query.
> >> Class.allInstances()
> >
> > when I execute this query I found Classes like Statemachine, Usecase,
> > Node and so on. basically I want to find only classes in a model without
> > classes like statemachine, usease or any other modeling element. Can any
> > body help me in this regard?
> >
> > Thanks,
> > pkojo
> >

--=-bdr2PJD4PXcAbBCMJKv1
Content-Type: text/html; charset="utf-8"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
Hi, Timothy,<BR>
<BR>
I think you intended a select iterator:<BR>
<BR>
&nbsp;&nbsp;&nbsp; model.allOwnedElements-&gt;select(e:Element|e.oclIsTypeO f(Class)) <BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Thu, 2009-09-10 at 12:02 +0200, Timothy Marc wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
What about

model.allOwnedElements-&gt;collect(e:Element|e.oclIsType Of(Class))

Please, let me know, if this helps you...

pkojo schrieb:
&gt; Hi,
&gt;
&gt; I am new to OCL, I am using OCL interpreter to find classes in a model
&gt; (EMF XMI model) at M2 layer, using following query.
&gt;&gt; Class.allInstances()
&gt;
&gt; when I execute this query I found Classes like Statemachine, Usecase,
&gt; Node and so on. basically I want to find only classes in a model without
&gt; classes like statemachine, usease or any other modeling element. Can any
&gt; body help me in this regard?
&gt;
&gt; Thanks,
&gt; pkojo
&gt;
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-bdr2PJD4PXcAbBCMJKv1--
Re: OCL query to find classes [message #485277 is a reply to message #485088] Fri, 11 September 2009 07:38 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Christian,

yes of course... thanks for this correction.

Timothy

Christian W. Damus schrieb:
> Hi, Timothy,
>
> I think you intended a select iterator:
>
> model.allOwnedElements->select(e:Element|e.oclIsTypeOf(Class))
>
> Cheers,
>
> Christian
>
>
> On Thu, 2009-09-10 at 12:02 +0200, Timothy Marc wrote:
>> What about
>>
>> model.allOwnedElements->collect(e:Element|e.oclIsTypeOf(Class))
>>
>> Please, let me know, if this helps you...
>>
>> pkojo schrieb:
>> > Hi,
>> >
>> > I am new to OCL, I am using OCL interpreter to find classes in a model
>> > (EMF XMI model) at M2 layer, using following query.
>> >> Class.allInstances()
>> >
>> > when I execute this query I found Classes like Statemachine, Usecase,
>> > Node and so on. basically I want to find only classes in a model without
>> > classes like statemachine, usease or any other modeling element. Can any
>> > body help me in this regard?
>> >
>> > Thanks,
>> > pkojo
>> >
Re: OCL query to find classes [message #485713 is a reply to message #485277] Mon, 14 September 2009 15:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pkol2009.yahoo.com

Hello Chirstian & Timothy,

I tried to run queries as you mentioned in your previous replies but that
query does not give me result, but it helps me to look into ownedElement,
now I am able to find all classes in a UML models. Here is the query:

ownedElement.allOwnedElements()->select(e|e.oclIsTypeOf(Class))

regards,
pokojo
Re: OCL query to find classes [message #485718 is a reply to message #485713] Mon, 14 September 2009 15:42 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 847
Registered: July 2009
Senior Member
--=-RPbQTMN1w6eG5YmoH1E2
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, pokojo,

Sorry, yes, I think our examples used a variable name "model" which
probably doesn't exist. In the context of your root model element you
could do:

self.allOwnedElements()->select(oclIsTypeOf(Class))

or, thanks to the getModel() operation defined by MDT UML2 (not
specified by UML 2.x, I don't think), in the context of any element you
can do:

getModel().allOwnedElements()->select(oclIsTypeOf(Class))

Note that "ownedElement.allOwnedElements()" will miss any Classes that
are directly owned by the context element (the expression's "self")
because it iterates only the elements owned by the elements owned by
self.

Cheers,

Christian


On Mon, 2009-09-14 at 15:32 +0000, pkojo wrote:

> Hello Chirstian & Timothy,
>
> I tried to run queries as you mentioned in your previous replies but that
> query does not give me result, but it helps me to look into ownedElement,
> now I am able to find all classes in a UML models. Here is the query:
>
> ownedElement.allOwnedElements()->select(e|e.oclIsTypeOf(Class))
>
> regards,
> pokojo
>

--=-RPbQTMN1w6eG5YmoH1E2
Content-Type: text/html; charset="utf-8"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
Hi, pokojo,<BR>
<BR>
Sorry, yes, I think our examples used a variable name &quot;model&quot; which probably doesn't exist.&nbsp; In the context of your root model element you could do:<BR>
<BR>
&nbsp; self.allOwnedElements()-&gt;select(oclIsTypeOf(Class))<BR >
<BR>
or, thanks to the getModel() operation defined by MDT UML2 (not specified by UML 2.x, I don't think), in the context of any element you can do:<BR>
<BR>
&nbsp; getModel().allOwnedElements()-&gt;select(oclIsTypeOf(Cla ss)) <BR>
<BR>
Note that &quot;ownedElement.allOwnedElements()&quot; will miss any Classes that are directly owned by the context element (the expression's &quot;self&quot;) because it iterates only the elements owned by the elements owned by self.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Mon, 2009-09-14 at 15:32 +0000, pkojo wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Hello Chirstian &amp; Timothy,

I tried to run queries as you mentioned in your previous replies but that
query does not give me result, but it helps me to look into ownedElement,
now I am able to find all classes in a UML models. Here is the query:

ownedElement.allOwnedElements()-&gt;select(e|e.oclIsType Of(Class))

regards,
pokojo

</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-RPbQTMN1w6eG5YmoH1E2--
Re: OCL query to find classes [message #485864 is a reply to message #485718] Tue, 15 September 2009 11:10 Go to previous message
Eclipse UserFriend
Originally posted by: pkol2009.yahoo.com

Hi Christian,

Thanks for your help. getModel() is also provides desired result. I have
one problem with eclipse, I am just feed up with this error, I dont know
how to resolve this. I have loaded OCLInterpreter example in eclipse and
than I run new eclipse Instance, where I have java project and it contains
EMF XMI model, here I run my OCL queries on the model. After running two
three queries I stuck with the eclipse and following error is produced:
my eclipse.ini contains following parameters:
-Xms40m
-Xmx256m
-XX:MaxPermSize=256m
------------------------------------------------------------ -
Exception in thread "AutoAssist Delay" org.eclipse.swt.SWTException:
Failed to execute runnable (java.lang.OutOfMemoryError: Java heap space)
at org.eclipse.swt.SWT.error(SWT.java:3777)
at org.eclipse.swt.SWT.error(SWT.java:3695)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.j ava:194)
at
org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchroniz er.java:150)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4251)
at
org.eclipse.jface.text.contentassist.ContentAssistant$AutoAs sistListener.showAssist(ContentAssistant.java:366)
at
org.eclipse.jface.text.contentassist.ContentAssistant$AutoAs sistListener.run(ContentAssistant.java:278)
at java.lang.Thread.run(Unknown Source)
........
-------------------------------

regards,
pokojo
Previous Topic:custom operators and functions using model information
Next Topic:OCLConsole Saving Error: The 'no duplicates' constraint is violated
Goto Forum:
  


Current Time: Sun Dec 21 08:31:21 GMT 2014

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

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