Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » querying across multiple XMI resources
querying across multiple XMI resources [message #43959] Wed, 21 November 2007 14:49 Go to next message
John Yotka is currently offline John Yotka
Messages: 143
Registered: July 2009
Senior Member
I have an editor implemented via several EMF packages. I use OCL
queries to interrogate the model. The OCL queries are implemented using
org.eclipse.emf.ocl.helper classes. The problem is when that parts of
the model are contained in a second XMI resource (as a different EMF
package), when I select an object in that resource the OCL query doesn't
see any of the objects in the other resource.

For example: let resource 1 contains objects of type customer.
Reference 2 contains objects of type order. Customer has a reference
(type collection) to order. In the editor I can see and edit both
customers and orders and I can see the orders for a customer. But if I
select an customer(object) and try to execute an OCL query that selects
all orders, for that customer. I get no orders selected. I believe it
is because the "scope" of the OCL query is being limited to the contents
of reference 1 and the orders are in reference 2.

How can I get the query "scope" to include all resources loaded in the
editor?
Re: querying across multiple XMI resources [message #44000 is a reply to message #43959] Wed, 21 November 2007 17:24 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, John,

What do you mean by "ocl queries?" Do you mean SELECT statements using OCL
conditions (org.eclipse.emf.query.ocl plug-in of EMF Query component) or do
you mean non-boolean-valued OCL expressions? Is your OCL expression using
the allInstances() operation to find the orders related to a customer?

If you are using SELECT queries, then you just need to ensure that the
contents of all relevant resources are in the IEObjectSource from which you
initialize your FROM clause.

If you are using allInstances(), then you need to provide a custom "extent
map" in the evaluation of your expression, because the default
LazyExtentMap implementation is scoped to a single resource (including also
cross-resource containments).

Otherwise, if your OCL expression is just traversal associations in your
model, then it shouldn't matter what resource an element is in ...

HTH,

Christian


John Yotka wrote:

> I have an editor implemented via several EMF packages. I use OCL
> queries to interrogate the model. The OCL queries are implemented using
> org.eclipse.emf.ocl.helper classes. The problem is when that parts of
> the model are contained in a second XMI resource (as a different EMF
> package), when I select an object in that resource the OCL query doesn't
> see any of the objects in the other resource.
>
> For example: let resource 1 contains objects of type customer.
> Reference 2 contains objects of type order. Customer has a reference
> (type collection) to order. In the editor I can see and edit both
> customers and orders and I can see the orders for a customer. But if I
> select an customer(object) and try to execute an OCL query that selects
> all orders, for that customer. I get no orders selected. I believe it
> is because the "scope" of the OCL query is being limited to the contents
> of reference 1 and the orders are in reference 2.
>
> How can I get the query "scope" to include all resources loaded in the
> editor?
Re: querying across multiple XMI resources [message #44640 is a reply to message #44000] Sat, 24 November 2007 15:03 Go to previous messageGo to next message
John Yotka is currently offline John Yotka
Messages: 143
Registered: July 2009
Senior Member
Christian W. Damus wrote:
> Hi, John,
>
> What do you mean by "ocl queries?" Do you mean SELECT statements using OCL
> conditions (org.eclipse.emf.query.ocl plug-in of EMF Query component) or do
> you mean non-boolean-valued OCL expressions? Is your OCL expression using
> the allInstances() operation to find the orders related to a customer?
>
> If you are using SELECT queries, then you just need to ensure that the
> contents of all relevant resources are in the IEObjectSource from which you
> initialize your FROM clause.
>
> If you are using allInstances(), then you need to provide a custom "extent
> map" in the evaluation of your expression, because the default
> LazyExtentMap implementation is scoped to a single resource (including also
> cross-resource containments).
>
> Otherwise, if your OCL expression is just traversal associations in your
> model, then it shouldn't matter what resource an element is in ...
>
> HTH,
>
> Christian
>
>
> John Yotka wrote:
>
>> I have an editor implemented via several EMF packages. I use OCL
>> queries to interrogate the model. The OCL queries are implemented using
>> org.eclipse.emf.ocl.helper classes. The problem is when that parts of
>> the model are contained in a second XMI resource (as a different EMF
>> package), when I select an object in that resource the OCL query doesn't
>> see any of the objects in the other resource.
>>
>> For example: let resource 1 contains objects of type customer.
>> Reference 2 contains objects of type order. Customer has a reference
>> (type collection) to order. In the editor I can see and edit both
>> customers and orders and I can see the orders for a customer. But if I
>> select an customer(object) and try to execute an OCL query that selects
>> all orders, for that customer. I get no orders selected. I believe it
>> is because the "scope" of the OCL query is being limited to the contents
>> of reference 1 and the orders are in reference 2.
>>
>> How can I get the query "scope" to include all resources loaded in the
>> editor?
>


I've tried to implement the setExtentMap and i'm getting the following
error in the editor.

The method setExtentMap(Map<capture#32-of ?,? extends Set<? extends
capture#33-of ?>>) in
the type OCL<capture#23-of ?,Object,capture#24-of ?,capture#25-of
?,capture#26-of ?,
capture#27-of ?,capture#28-of ?,capture#29-of ?,capture#30-of
?,capture#31-of ?,capture#32-
of ?,capture#33-of ?> is not applicable for the arguments
(Map<capture#36-of ?,capture#37-of ?
>)

I'm getting this error even on the following:

IOCLFactory<Object> oclFactory = new EcoreOCLFactory();
OCL<?, Object, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?> ocl = oclFactory.createOCL();

// tell the OCL environment what our classifier extents are
ocl.setExtentMap(ocl.getExtentMap());

any ideas?
Re: querying across multiple XMI resources [message #44782 is a reply to message #44640] Mon, 26 November 2007 10:30 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, John,

The compiler can't match your wildcard type parameter substitutions because
the two different occurrences of wildcards in the same positions represent
unknown types that may or may not be the same.

I'm supposing that either your IOCLFactory interface needs to declare more
type parameters to correspond to the parameters of the OCL class, or your
createOCL() method needs these parameters. If this is derived from the
IOCLFactory in the interactive console example, then it should provide a
guide.

HTH,

Christian


John Yotka wrote:

> Christian W. Damus wrote:
>> Hi, John,
>>
>> What do you mean by "ocl queries?" Do you mean SELECT statements using
>> OCL conditions (org.eclipse.emf.query.ocl plug-in of EMF Query component)
>> or do
>> you mean non-boolean-valued OCL expressions? Is your OCL expression
>> using the allInstances() operation to find the orders related to a
>> customer?
>>
>> If you are using SELECT queries, then you just need to ensure that the
>> contents of all relevant resources are in the IEObjectSource from which
>> you initialize your FROM clause.
>>
>> If you are using allInstances(), then you need to provide a custom
>> "extent map" in the evaluation of your expression, because the default
>> LazyExtentMap implementation is scoped to a single resource (including
>> also cross-resource containments).
>>
>> Otherwise, if your OCL expression is just traversal associations in your
>> model, then it shouldn't matter what resource an element is in ...
>>
>> HTH,
>>
>> Christian
>>
>>
>> John Yotka wrote:
>>
>>> I have an editor implemented via several EMF packages. I use OCL
>>> queries to interrogate the model. The OCL queries are implemented using
>>> org.eclipse.emf.ocl.helper classes. The problem is when that parts of
>>> the model are contained in a second XMI resource (as a different EMF
>>> package), when I select an object in that resource the OCL query doesn't
>>> see any of the objects in the other resource.
>>>
>>> For example: let resource 1 contains objects of type customer.
>>> Reference 2 contains objects of type order. Customer has a reference
>>> (type collection) to order. In the editor I can see and edit both
>>> customers and orders and I can see the orders for a customer. But if I
>>> select an customer(object) and try to execute an OCL query that selects
>>> all orders, for that customer. I get no orders selected. I believe it
>>> is because the "scope" of the OCL query is being limited to the contents
>>> of reference 1 and the orders are in reference 2.
>>>
>>> How can I get the query "scope" to include all resources loaded in the
>>> editor?
>>
>
>
> I've tried to implement the setExtentMap and i'm getting the following
> error in the editor.
>
> The method setExtentMap(Map<capture#32-of ?,? extends Set<? extends
> capture#33-of ?>>) in
> the type OCL<capture#23-of ?,Object,capture#24-of ?,capture#25-of
> ?,capture#26-of ?,
> capture#27-of ?,capture#28-of ?,capture#29-of ?,capture#30-of
> ?,capture#31-of ?,capture#32-
> of ?,capture#33-of ?> is not applicable for the arguments
> (Map<capture#36-of ?,capture#37-of ?
> >)
>
> I'm getting this error even on the following:
>
> IOCLFactory<Object> oclFactory = new EcoreOCLFactory();
> OCL<?, Object, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?> ocl = oclFactory.createOCL();
>
> // tell the OCL environment what our classifier extents are
> ocl.setExtentMap(ocl.getExtentMap());
>
> any ideas?
Re: querying across multiple XMI resources [message #57136 is a reply to message #44000] Wed, 28 May 2008 12:07 Go to previous messageGo to next message
Eclipse User
Originally posted by: jconlon.apache.org

Hi Christian,
I too am encountered similar problems querying across resources in my
resourceSet. I have problems not only with allInstances() but with
oclAsType(), so I suspect like your reply indicated that I will need to
use a different Extent Map for my OCL queries.

Is there an implementation for ResourceSets that behaves like
LazyExtendMap? Or will I have forge my own?

Also - since my ResourceSet is being accessed using a transaction based
EditingDomain, does this require special handling from OCL?

thanks,
John

Christian W. Damus wrote:

> If you are using allInstances(), then you need to provide a custom "extent
> map" in the evaluation of your expression, because the default
> LazyExtentMap implementation is scoped to a single resource (including also
> cross-resource containments).
>
> Christian
>
>
> John Yotka wrote:
>
>> I have an editor implemented via several EMF packages. I use OCL
>> queries to interrogate the model. The OCL queries are implemented using
>> org.eclipse.emf.ocl.helper classes. The problem is when that parts of
>> the model are contained in a second XMI resource (as a different EMF
>> package), when I select an object in that resource the OCL query doesn't
>> see any of the objects in the other resource.
>>
>> For example: let resource 1 contains objects of type customer.
>> Reference 2 contains objects of type order. Customer has a reference
>> (type collection) to order. In the editor I can see and edit both
>> customers and orders and I can see the orders for a customer. But if I
>> select an customer(object) and try to execute an OCL query that selects
>> all orders, for that customer. I get no orders selected. I believe it
>> is because the "scope" of the OCL query is being limited to the contents
>> of reference 1 and the orders are in reference 2.
>>
>> How can I get the query "scope" to include all resources loaded in the
>> editor?
>
Re: querying across multiple XMI resources [message #57320 is a reply to message #57136] Thu, 29 May 2008 23:18 Go to previous message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

--=-LxpkrGxATRL/xEM/5a0Z
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, John,

MDT OCL doesn't provide a ResourceSet-scoped extent-map out of the box.
It really should, though. If you would be so kind as to raise an
enhancement request, I will ensure that it is scheduled for the 1.3
release. If you're interested, it would make a nice little
contribution :-)

OCL shouldn't require any special handling in a transactional editing
domain, because it must not (by definition) cause side-effects in the
model. However, I suppose that you should ensure that OCL constraints
are only evaluated in (at least) a read-only transaction. Evaluating
constraints can cause concrete side-effects such as proxy resolution and
computation of derived attributes, though it doesn't cause abstract
side-effects.

Cheers,

Christian

On Wed, 2008-05-28 at 11:07 -0500, John E. Conlon wrote:

> Hi Christian,
> I too am encountered similar problems querying across resources in my
> resourceSet. I have problems not only with allInstances() but with
> oclAsType(), so I suspect like your reply indicated that I will need to
> use a different Extent Map for my OCL queries.
>
> Is there an implementation for ResourceSets that behaves like
> LazyExtendMap? Or will I have forge my own?
>
> Also - since my ResourceSet is being accessed using a transaction based
> EditingDomain, does this require special handling from OCL?
>
> thanks,
> John
>
> Christian W. Damus wrote:
>
> > If you are using allInstances(), then you need to provide a custom "extent
> > map" in the evaluation of your expression, because the default
> > LazyExtentMap implementation is scoped to a single resource (including also
> > cross-resource containments).
> >
> > Christian
> >
> >
> > John Yotka wrote:
> >
> >> I have an editor implemented via several EMF packages. I use OCL
> >> queries to interrogate the model. The OCL queries are implemented using
> >> org.eclipse.emf.ocl.helper classes. The problem is when that parts of
> >> the model are contained in a second XMI resource (as a different EMF
> >> package), when I select an object in that resource the OCL query doesn't
> >> see any of the objects in the other resource.
> >>
> >> For example: let resource 1 contains objects of type customer.
> >> Reference 2 contains objects of type order. Customer has a reference
> >> (type collection) to order. In the editor I can see and edit both
> >> customers and orders and I can see the orders for a customer. But if I
> >> select an customer(object) and try to execute an OCL query that selects
> >> all orders, for that customer. I get no orders selected. I believe it
> >> is because the "scope" of the OCL query is being limited to the contents
> >> of reference 1 and the orders are in reference 2.
> >>
> >> How can I get the query "scope" to include all resources loaded in the
> >> editor?
> >

--=-LxpkrGxATRL/xEM/5a0Z
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.16.0">
</HEAD>
<BODY>
Hi, John,<BR>
<BR>
MDT OCL doesn't provide a ResourceSet-scoped extent-map out of the box.&nbsp; It really should, though.&nbsp; If you would be so kind as to raise an enhancement request, I will ensure that it is scheduled for the 1.3 release.&nbsp; If you're interested, it would make a nice little contribution&nbsp; :-)<BR>
<BR>
OCL shouldn't require any special handling in a transactional editing domain, because it must not (by definition) cause side-effects in the model.&nbsp; However, I suppose that you should ensure that OCL constraints are only evaluated in (at least) a read-only transaction.&nbsp; Evaluating constraints can cause concrete side-effects such as proxy resolution and computation of derived attributes, though it doesn't cause abstract side-effects.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
On Wed, 2008-05-28 at 11:07 -0500, John E. Conlon wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hi Christian,</FONT>
<FONT COLOR="#000000">I too am encountered similar problems querying across resources in my </FONT>
<FONT COLOR="#000000">resourceSet. I have problems not only with allInstances() but with </FONT>
<FONT COLOR="#000000">oclAsType(), so I suspect like your reply indicated that I will need to </FONT>
<FONT COLOR="#000000">use a different Extent Map for my OCL queries.</FONT>

<FONT COLOR="#000000">Is there an implementation for ResourceSets that behaves like </FONT>
<FONT COLOR="#000000">LazyExtendMap? Or will I have forge my own?</FONT>

<FONT COLOR="#000000">Also - since my ResourceSet is being accessed using a transaction based </FONT>
<FONT COLOR="#000000">EditingDomain, does this require special handling from OCL?</FONT>

<FONT COLOR="#000000">thanks,</FONT>
<FONT COLOR="#000000">John</FONT>

<FONT COLOR="#000000">Christian W. Damus wrote:</FONT>

<FONT COLOR="#000000">&gt; If you are using allInstances(), then you need to provide a custom &quot;extent</FONT>
<FONT COLOR="#000000">&gt; map&quot; in the evaluation of your expression, because the default</FONT>
<FONT COLOR="#000000">&gt; LazyExtentMap implementation is scoped to a single resource (including also</FONT>
<FONT COLOR="#000000">&gt; cross-resource containments).</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; Christian</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; John Yotka wrote:</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt;&gt; I have an editor implemented via several EMF packages. I use OCL</FONT>
<FONT COLOR="#000000">&gt;&gt; queries to interrogate the model. The OCL queries are implemented using</FONT>
<FONT COLOR="#000000">&gt;&gt; org.eclipse.emf.ocl.helper classes. The problem is when that parts of</FONT>
<FONT COLOR="#000000">&gt;&gt; the model are contained in a second XMI resource (as a different EMF</FONT>
<FONT COLOR="#000000">&gt;&gt; package), when I select an object in that resource the OCL query doesn't</FONT>
<FONT COLOR="#000000">&gt;&gt; see any of the objects in the other resource.</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; For example: let resource 1 contains objects of type customer.</FONT>
<FONT COLOR="#000000">&gt;&gt; Reference 2 contains objects of type order. Customer has a reference</FONT>
<FONT COLOR="#000000">&gt;&gt; (type collection) to order. In the editor I can see and edit both</FONT>
<FONT COLOR="#000000">&gt;&gt; customers and orders and I can see the orders for a customer. But if I</FONT>
<FONT COLOR="#000000">&gt;&gt; select an customer(object) and try to execute an OCL query that selects</FONT>
<FONT COLOR="#000000">&gt;&gt; all orders, for that customer. I get no orders selected. I believe it</FONT>
<FONT COLOR="#000000">&gt;&gt; is because the &quot;scope&quot; of the OCL query is being limited to the contents</FONT>
<FONT COLOR="#000000">&gt;&gt; of reference 1 and the orders are in reference 2.</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; How can I get the query &quot;scope&quot; to include all resources loaded in the</FONT>
<FONT COLOR="#000000">&gt;&gt; editor?</FONT>
<FONT COLOR="#000000">&gt; </FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-LxpkrGxATRL/xEM/5a0Z--
Previous Topic:OCL for UML2
Next Topic:Other model backends
Goto Forum:
  


Current Time: Sat Jul 26 07:21:28 EDT 2014

Powered by FUDForum. Page generated in 0.03067 seconds