Bug 300149 - Support remote cross referencing with a convenient API on the client and SPI on the server for the stores to implement
Summary: Support remote cross referencing with a convenient API on the client and SPI ...
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard: Power to the People
Keywords: noteworthy
: 256927 (view as bug list)
Depends on: 318998
Blocks:
  Show dependency tree
 
Reported: 2010-01-20 04:01 EST by Martin Taal CLA
Modified: 2011-06-23 03:41 EDT (History)
4 users (show)

See Also:
stepper: review-


Attachments
Utility class retrieving cross referencers by CDOQuery (8.39 KB, application/octet-stream)
2010-03-18 06:45 EDT, Bjoern Sundin CLA
no flags Details
patch v1 (8.06 KB, patch)
2010-04-27 13:06 EDT, Victor Roldan Betancort CLA
no flags Details | Diff
patch v2 (30.57 KB, patch)
2010-04-28 14:15 EDT, Victor Roldan Betancort CLA
no flags Details | Diff
patch v3 (little bit reformatted) (30.59 KB, patch)
2010-05-09 03:45 EDT, Eike Stepper CLA
no flags Details | Diff
patch v1 (31.35 KB, patch)
2010-05-11 07:23 EDT, Victor Roldan Betancort CLA
no flags Details | Diff
patch v4 (31.35 KB, patch)
2010-05-11 07:24 EDT, Victor Roldan Betancort CLA
no flags Details | Diff
Patch v5 (41.83 KB, patch)
2010-07-05 08:33 EDT, Eike Stepper CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Taal CLA 2010-01-20 04:01:52 EST
It would be great to extend CDO with the possibility to query all the objects referencing a certain object. The so-called crossreferencing (or xref) functionality. 

Using the model available on the server it is possible to determine for each EClass what queries are needed to retrieve the referencing objects.

A thing to consider is how to handle larger volumes of referencing objects. It is clearly possible that multiple queries are needed to retrieve all cross referencers so it can be difficult to implement paging or sublist behavior. So maybe the client api can pass in a max number of returned objects.

To support xref I think we need:
- an api and convenience method on the client
- a server side api definition 
- implementation of this functionality in each store

Eike and others let me know if you have any comments or feedback on this. 

Thanks!

Martin T.
Comment 1 Martin Taal CLA 2010-01-20 04:03:10 EST
For your info, this feature was present in CDO 0.7:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=155725
Comment 2 Bjoern Sundin CLA 2010-03-18 06:45:16 EDT
Created attachment 162388 [details]
Utility class retrieving cross referencers by CDOQuery

I thought I could share this class as an initial suggestion to solve resolving  cross references in the database. I use it in my application and it works well. Callers of the method getDbCrossReferencers will also have to consider local changes in the view. 
The EPackages can be registered at initiation (when they anyway are registered)
Comment 3 Victor Roldan Betancort CLA 2010-04-27 13:06:36 EDT
Created attachment 166221 [details]
patch v1

Hi,

this is result of a dicussion between Eike and I.

This query language is DBStore dependant.
Comment 4 Victor Roldan Betancort CLA 2010-04-27 13:07:09 EDT
I'm gonna make also a DBStore test for this new query language
Comment 5 Victor Roldan Betancort CLA 2010-04-28 14:15:52 EDT
Created attachment 166359 [details]
patch v2

- Added API Support in CDOUtil: CDOUtil.getCrossReferences. This
  returns a nice Setting implementation with Lazy behaviour, this is, 
  referencer   EObject is not retrieved eagerly when instantiated, rather when 
  calling any of the methods in the Setting API.

  This method depends in the backend supporting XREF language.

- The EStructuralFeature through which the object is referenced can be retrieved.
  This has been made configurable now, by passing a boolean "provideFeatureName" 
  parameter.

- It is no longer necessary to specify the CrossReferenced object's EClass and EPackage nsUri. These are extracted from the backend

- Multiple bugs fixed
Comment 6 Victor Roldan Betancort CLA 2010-04-28 14:22:11 EDT
Now that I look at the Martin's initial comment, I must warn that:

- the path provides only functionality for DBStore (however, this can be implemented the same way for other IStore by using the CDOQuery API)

- nothing implemented regarding sublist and paging, but CDOQuery API itself provides iterator mechanisms.

But I tackled:
- an api and convenience method on the client (CDOUtil.getCrossReferences())
Comment 7 Eike Stepper CLA 2010-05-09 03:44:32 EDT
Comments:

1) CDOIDUtil.getLong(object.cdoID())) is only good when you exactly know that the id is a CDOIDLong, but you can not know that in the client. Put the whole object into a query parameter instead.

2) If the query has a parameter (XREFQueryHandler.provideFeatureName) why is it not usable in CDOUtil?

3) XREFQueryHandler.provideFeatureName must not be an instance field.

4) BLOCKER: Your XREFQueryHandler assumes a certain DB schema that only the mapping strategy can know.
Comment 8 Eike Stepper CLA 2010-05-09 03:45:25 EDT
Created attachment 167618 [details]
patch v3 (little bit reformatted)
Comment 9 Victor Roldan Betancort CLA 2010-05-11 06:27:51 EDT
(In reply to comment #7)
> Comments:
> 
> 1) CDOIDUtil.getLong(object.cdoID())) is only good when you exactly know that
> the id is a CDOIDLong, but you can not know that in the client. Put the whole
> object into a query parameter instead.

agree


> 2) If the query has a parameter (XREFQueryHandler.provideFeatureName) why is it
> not usable in CDOUtil?

The new method in CDOUtil returns Collection<EStructuralFeature.Setting>. To construct these, "provideFeatureName" must mandatorily be true. Making it configurable in that method is incompatible with the return value.

> 3) XREFQueryHandler.provideFeatureName must not be an instance field.

agree

> 4) BLOCKER: Your XREFQueryHandler assumes a certain DB schema that only the
> mapping strategy can know.

I guess you refer to the SQL queries constructed in the xrefXYZ methods. Could give me a hint on how to get that information from the mapping strategy?
Comment 10 Eike Stepper CLA 2010-05-11 06:58:34 EDT
(In reply to comment #9)
> > 4) BLOCKER: Your XREFQueryHandler assumes a certain DB schema that only the
> > mapping strategy can know.
> 
> I guess you refer to the SQL queries constructed in the xrefXYZ methods. Could
> give me a hint on how to get that information from the mapping strategy?

You need to add new methods to IMappingStrategy like queryCrossReferences(...).
Comment 11 Victor Roldan Betancort CLA 2010-05-11 07:10:03 EDT
> You need to add new methods to IMappingStrategy like queryCrossReferences(...).

are we going to add a new method to IMappingStrategy each time we create a new query? :(
Comment 12 Victor Roldan Betancort CLA 2010-05-11 07:23:27 EDT
Created attachment 167895 [details]
patch v1

includes all suggested changes except last issue
Comment 13 Victor Roldan Betancort CLA 2010-05-11 07:24:24 EDT
Created attachment 167896 [details]
patch v4

oops, wrongly versioned
Comment 14 Eike Stepper CLA 2010-06-29 04:51:04 EDT
Rebasing all outstanding enhancements requests to version 4.0
Comment 15 Eike Stepper CLA 2010-07-05 08:33:06 EDT
Created attachment 173420 [details]
Patch v5
Comment 16 Eike Stepper CLA 2010-07-06 08:21:59 EDT
Committed to HEAD.

But waiting for bug 318998 [DB]...
Comment 17 Eike Stepper CLA 2011-01-18 13:18:49 EST
*** Bug 256927 has been marked as a duplicate of this bug. ***
Comment 18 Eike Stepper CLA 2011-06-23 03:41:59 EDT
Available in R20110608-1407