Home » Modeling » OCL » OCL query to find classes
OCL query to find classes [message #484277] |
Sat, 05 September 2009 11:24 |
Eclipse User |
|
|
|
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 |
Timothy Marc 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 |
Timothy Marc 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 |
|
--=-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>
model.allOwnedElements->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->collect(e:Element|e.oclIsType Of(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
>
</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 |
Timothy Marc 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 |
Eclipse User |
|
|
|
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 |
|
--=-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 "model" which probably doesn't exist. In the context of your root model element you could do:<BR>
<BR>
self.allOwnedElements()->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>
getModel().allOwnedElements()->select(oclIsTypeOf(Cla ss)) <BR>
<BR>
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.<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 & 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.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 |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Sat Apr 20 03:02:11 GMT 2024
Powered by FUDForum. Page generated in 0.02481 seconds
|