Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Is it possible to Link OCL Queries to report on an EMF model?
Is it possible to Link OCL Queries to report on an EMF model? [message #771209] Mon, 26 December 2011 17:00 Go to next message
Nigel Daniels is currently offline Nigel DanielsFriend
Messages: 66
Registered: July 2009
Member
Hi,

I am new to using BIRT and I am trying to report on an EMF model. I have
set up an ODA connection to my EMF file and can report on parts of it.
What I would like to do is create a report that looks a bit like the EMF
tree view of my information. The model structure is :

A Project --- contains ---> Objectives --- contain ---> Issues

All of these elements have the string attributes, id, name and description.

I can create OCL queries based on the Project context :

self.objectives

to see all of the Objectives, then :

self.objectives.issues

to view all of the Issues, or even :

self.objectives->select(id='O1').issues

to see the Issues belonging to the Objective with the id 'O1'. Is there
anyway to nest a series of OCL quieries so that I could see each of the
objectives then their associated issues in one report.

Unlike a relational database the relationship is a feature of the file
structure in the EMF file rather than using index relationships. Because
of this I have not found a way of making join querys work as there is no
field to join on.

Any advice from a BIRT OCL expert would be very welcome!

Thanks for any help.

Regards, Nigel.
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #771252 is a reply to message #771209] Mon, 26 December 2011 19:28 Go to previous messageGo to next message
Eclipse UserFriend
Nigel,


See inline comments...


On 12/26/2011 11:02 AM, Nigel Daniels wrote:
> Hi,
>
> I am new to using BIRT and I am trying to report on an EMF model. I have
> set up an ODA connection to my EMF file and can report on parts of it.
Are you using the newest org.eclipse.emf.oda.ecore driver?

> What I would like to do is create a report that looks a bit like the EMF
> tree view of my information. The model structure is :
>
> A Project --- contains ---> Objectives --- contain ---> Issues
>
> All of these elements have the string attributes, id, name and description.
>
> I can create OCL queries based on the Project context :
>
> self.objectives
>
> to see all of the Objectives, then :
>
> self.objectives.issues
>
> to view all of the Issues, or even :
>
> self.objectives->select(id='O1').issues
>
> to see the Issues belonging to the Objective with the id 'O1'. Is there
> anyway to nest a series of OCL quieries so that I could see each of the
> objectives then their associated issues in one report.
>
> Unlike a relational database the relationship is a feature of the file
> structure in the EMF file rather than using index relationships. Because
> of this I have not found a way of making join querys work as there is no
> field to join on.
Right the brute force approach is to create three datasets:
Projects, Objectives, and Issues; then create a fourth Joint DataSet to
join Projects and Objectives and a fifth to join the Issues to the Joint
Projects and Objects BUT... as you say there is no index just a
containment. Plus (even if it would work) this is ugly.


But remember all EObjects do have an
public EObject eContainer()
method.

So you might try...
Creating a single dataset on all the Issues. Then add 6 computed
columns; 3 for Objective id, name and description; and 3 for Project id,
name and description.

In the computed columns of your Dataset use a function like
@self.getObject().eContainer() to move upward in the hierarchy to get
the Objective then in a similar fashion
@self.getObject().eContainer().eContainer() to get the Project. Once you
are at the object you can get the values for id, name and description.

Your dataset can be now used in a BIRT table where you can group on the
Project and sub group on Objective. This last subgroup will include the
Issues in the details row.

Your Tree.

>
> Any advice from a BIRT OCL expert would be very welcome!

If there are any BIRT OCL experts out there that can think of a better
way, please let us know...

John
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #772318 is a reply to message #771252] Thu, 29 December 2011 14:04 Go to previous messageGo to next message
Nigel Daniels is currently offline Nigel DanielsFriend
Messages: 66
Registered: July 2009
Member
Hi John,

thanks for getting back to me so quickly :) I have given these ideas a
go an I can get the container object as you suggested, so I'm a good
part of the way there but I'm not sure I know how to use OCL correctly
to get an objects id. Is there a way to cast the result then call its
methods?

I've added some comments on what i tried and the results below:

On 26/12/2011 19:28, John E. Conlon wrote:
> Nigel,
>
>
> See inline comments...
>
>
> On 12/26/2011 11:02 AM, Nigel Daniels wrote:
>> Hi,
>>
>> I am new to using BIRT and I am trying to report on an EMF model. I have
>> set up an ODA connection to my EMF file and can report on parts of it.
> Are you using the newest org.eclipse.emf.oda.ecore driver?
>
>> What I would like to do is create a report that looks a bit like the EMF
>> tree view of my information. The model structure is :
>>
>> A Project --- contains ---> Objectives --- contain ---> Issues
>>
>> All of these elements have the string attributes, id, name and
>> description.
>>
>> I can create OCL queries based on the Project context :
>>
>> self.objectives
>>
>> to see all of the Objectives, then :
>>
>> self.objectives.issues
>>
>> to view all of the Issues, or even :
>>
>> self.objectives->select(id='O1').issues
>>
>> to see the Issues belonging to the Objective with the id 'O1'. Is there
>> anyway to nest a series of OCL quieries so that I could see each of the
>> objectives then their associated issues in one report.
>>
>> Unlike a relational database the relationship is a feature of the file
>> structure in the EMF file rather than using index relationships. Because
>> of this I have not found a way of making join querys work as there is no
>> field to join on.
> Right the brute force approach is to create three datasets:
> Projects, Objectives, and Issues; then create a fourth Joint DataSet to
> join Projects and Objectives and a fifth to join the Issues to the Joint
> Projects and Objects BUT... as you say there is no index just a
> containment. Plus (even if it would work) this is ugly.

I agree that this approach would be a bit ugly and may not scale well,
even if the EMF structure allowed for it.

>
>
> But remember all EObjects do have an
> public EObject eContainer()
> method.

Ah-ha! I did not ralise I could access this.

>
> So you might try...
> Creating a single dataset on all the Issues. Then add 6 computed
> columns; 3 for Objective id, name and description; and 3 for Project id,
> name and description.

So I gave getting hold of an Objectives Id attribute via an Issue
dataset query. The query uses the Project as the context and returns an
Issue type, the query is:

self.objectives.issues

>
> In the computed columns of your Dataset use a function like
> @self.getObject().eContainer() to move upward in the hierarchy to get
> the Objective then in a similar fashion
> @self.getObject().eContainer().eContainer() to get the Project. Once you
> are at the object you can get the values for id, name and description.
>

I then added a computed column called ObjectiveObj :

row["@self"].getObject().eContainer()


> Your dataset can be now used in a BIRT table where you can group on the
> Project and sub group on Objective. This last subgroup will include the
> Issues in the details row.

This gives me the following sorts of results :

Description: Test issue 1
Id: O1.1
ObjectiveObj: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@59ae5a16
(eClass: org.eclipse.emf.ecore.impl.EClassImpl@38bf7b8 (name: Objective)
(instanceClassName: null) (abstract: false, interface: false))

It looks like I have the object reference to the containing Objective
object, but I'm not sure how I then cast this to an instance of
Objective to access it's getId() method?

>
> Your Tree.
>
>>
>> Any advice from a BIRT OCL expert would be very welcome!
>
> If there are any BIRT OCL experts out there that can think of a better
> way, please let us know...
>
> John
>
>

Thanks for your help,

Nigel
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #773178 is a reply to message #772318] Sat, 31 December 2011 19:27 Go to previous messageGo to next message
Eclipse UserFriend
HI Nigel,

See inline comments.

On 12/29/2011 08:04 AM, Nigel Daniels wrote:
> Hi John,
>
> thanks for getting back to me so quickly :) I have given these ideas a
> go an I can get the container object as you suggested, so I'm a good
> part of the way there but I'm not sure I know how to use OCL correctly
> to get an objects id. Is there a way to cast the result then call its
> methods?
Don't have to cast, its JavaScript! Just go ahead and use whatever
method in the Interface for container object that allows you to get the id.

Guess - is it
getID()

>
> I've added some comments on what i tried and the results below:
>
> On 26/12/2011 19:28, John E. Conlon wrote:
>> Nigel,
>>
>>
>> See inline comments...
>>
>>
>> On 12/26/2011 11:02 AM, Nigel Daniels wrote:
>>> Hi,
>>>
>>> I am new to using BIRT and I am trying to report on an EMF model. I have
>>> set up an ODA connection to my EMF file and can report on parts of it.
>> Are you using the newest org.eclipse.emf.oda.ecore driver?
>>
>>> What I would like to do is create a report that looks a bit like the EMF
>>> tree view of my information. The model structure is :
>>>
>>> A Project --- contains ---> Objectives --- contain ---> Issues
>>>
>>> All of these elements have the string attributes, id, name and
>>> description.
>>>
>>> I can create OCL queries based on the Project context :
>>>
>>> self.objectives
>>>
>>> to see all of the Objectives, then :
>>>
>>> self.objectives.issues
>>>
>>> to view all of the Issues, or even :
>>>
>>> self.objectives->select(id='O1').issues
>>>
>>> to see the Issues belonging to the Objective with the id 'O1'. Is there
>>> anyway to nest a series of OCL quieries so that I could see each of the
>>> objectives then their associated issues in one report.
>>>
>>> Unlike a relational database the relationship is a feature of the file
>>> structure in the EMF file rather than using index relationships. Because
>>> of this I have not found a way of making join querys work as there is no
>>> field to join on.
>> Right the brute force approach is to create three datasets:
>> Projects, Objectives, and Issues; then create a fourth Joint DataSet to
>> join Projects and Objectives and a fifth to join the Issues to the Joint
>> Projects and Objects BUT... as you say there is no index just a
>> containment. Plus (even if it would work) this is ugly.
>
> I agree that this approach would be a bit ugly and may not scale well,
> even if the EMF structure allowed for it.
>
>>
>>
>> But remember all EObjects do have an
>> public EObject eContainer()
>> method.
>
> Ah-ha! I did not ralise I could access this.

Yes, any method on your object instance should work.

>>
>> So you might try...
>> Creating a single dataset on all the Issues. Then add 6 computed
>> columns; 3 for Objective id, name and description; and 3 for Project id,
>> name and description.
>
> So I gave getting hold of an Objectives Id attribute via an Issue
> dataset query. The query uses the Project as the context and returns an
> Issue type, the query is:
>
> self.objectives.issues
Looks good
>
>>
>> In the computed columns of your Dataset use a function like
>> @self.getObject().eContainer() to move upward in the hierarchy to get
>> the Objective then in a similar fashion
>> @self.getObject().eContainer().eContainer() to get the Project. Once you
>> are at the object you can get the values for id, name and description.
>>
>
> I then added a computed column called ObjectiveObj :
>
> row["@self"].getObject().eContainer()

Rather call it ObjectID
and

row["@self"].getObject().eContainer().getID();

(The data type for the computed column would be a string, unless that is
of course you have a number type for the ID in your EMF model.

>
>
>> Your dataset can be now used in a BIRT table where you can group on the
>> Project and sub group on Objective. This last subgroup will include the
>> Issues in the details row.
>
> This gives me the following sorts of results :
>
> Description: Test issue 1
> Id: O1.1
> ObjectiveObj: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@59ae5a16
> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@38bf7b8 (name: Objective)
> (instanceClassName: null) (abstract: false, interface: false))
>
> It looks like I have the object reference to the containing Objective
> object, but I'm not sure how I then cast this to an instance of
> Objective to access it's getId() method?

Again no cast needed - Just go for it and call a method.

cheers,
John
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #774616 is a reply to message #773178] Wed, 04 January 2012 09:40 Go to previous messageGo to next message
Nigel Daniels is currently offline Nigel DanielsFriend
Messages: 66
Registered: July 2009
Member
Hi John,

I have tried multiple ways of calling the method I'd like to call but I
don't think I'm getting back the object I expected. When I try to call
the method using:

row["@self"].getObject().eContainer().getId();

I get the result:

org.eclipse.birt.data.engine.core.DataException: Fail to compute value
for computed column "ObjectiveObj".
A BIRT exception occurred. See next exception for more information.
There are errors evaluating script
"row["@self"].getObject().eContainer().getId();":
TypeError: Cannot find function getId in object
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@b500f60 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@474715d4 (name: Objective)
(instanceClassName: null) (abstract: false, interface: false)).
at
org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
....


I also tried the variations (a bit of a guess):

row["@self"].getObject().eContainer().row["Id"];
and:
row["@self"].getObject().eContainer().column["Id"];

with the result:

org.eclipse.birt.data.engine.core.DataException: Fail to compute value
for computed column "ObjectiveObj".
A BIRT exception occurred. See next exception for more information.
There are errors evaluating script
"row["@self"].getObject().eContainer().row["Id"];":
TypeError: Cannot read property "Id" from undefined
at
org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
....


Finally I tried (based on looking at the avaliable items in a dataset):

row["@self"].getObject().eContainer().Id;

This returns the data set but the computed column is empty.


I suspect my last three attempts are in error but I thought I should try
out any ideas and see if they worked out.

The result from the first attempt seems to suggest that I am not getting
back the expected object but that I have a DynamicEObjectImpl instead.
When I look at the result for running:

row["@self"].getObject().eContainer();

It gives me a result like this for the computed column:

org.eclipse.emf.ecore.impl.DynamicEObjectImpl@51b5449f (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@6433aa85 (name: Objective)
(instanceClassName: null) (abstract: false, interface: false))

In the attribute (name: Objective) I can see that it looks to contain
the Objective type I expect, but without the ability to type cast this
to an Objective class I suspect I will not be able to access the getId()
method. Do you have an example of how I should be doing this? It would
be great to take a look in case there is a step I have failed to do in
configuring my BIRT/EMF/ODA set-up?

Regards,

Nigel


On 31/12/2011 19:27, John E. Conlon wrote:
> HI Nigel,
>
> See inline comments.
>
> On 12/29/2011 08:04 AM, Nigel Daniels wrote:
>> Hi John,
>>
>> thanks for getting back to me so quickly :) I have given these ideas a
>> go an I can get the container object as you suggested, so I'm a good
>> part of the way there but I'm not sure I know how to use OCL correctly
>> to get an objects id. Is there a way to cast the result then call its
>> methods?
> Don't have to cast, its JavaScript! Just go ahead and use whatever
> method in the Interface for container object that allows you to get the id.
>
> Guess - is it
> getID()
>
>>
>> I've added some comments on what i tried and the results below:
>>
>> On 26/12/2011 19:28, John E. Conlon wrote:
>>> Nigel,
>>>
>>>
>>> See inline comments...
>>>
>>>
>>> On 12/26/2011 11:02 AM, Nigel Daniels wrote:
>>>> Hi,
>>>>
>>>> I am new to using BIRT and I am trying to report on an EMF model. I
>>>> have
>>>> set up an ODA connection to my EMF file and can report on parts of it.
>>> Are you using the newest org.eclipse.emf.oda.ecore driver?
>>>
>>>> What I would like to do is create a report that looks a bit like the
>>>> EMF
>>>> tree view of my information. The model structure is :
>>>>
>>>> A Project --- contains ---> Objectives --- contain ---> Issues
>>>>
>>>> All of these elements have the string attributes, id, name and
>>>> description.
>>>>
>>>> I can create OCL queries based on the Project context :
>>>>
>>>> self.objectives
>>>>
>>>> to see all of the Objectives, then :
>>>>
>>>> self.objectives.issues
>>>>
>>>> to view all of the Issues, or even :
>>>>
>>>> self.objectives->select(id='O1').issues
>>>>
>>>> to see the Issues belonging to the Objective with the id 'O1'. Is there
>>>> anyway to nest a series of OCL quieries so that I could see each of the
>>>> objectives then their associated issues in one report.
>>>>
>>>> Unlike a relational database the relationship is a feature of the file
>>>> structure in the EMF file rather than using index relationships.
>>>> Because
>>>> of this I have not found a way of making join querys work as there
>>>> is no
>>>> field to join on.
>>> Right the brute force approach is to create three datasets:
>>> Projects, Objectives, and Issues; then create a fourth Joint DataSet to
>>> join Projects and Objectives and a fifth to join the Issues to the Joint
>>> Projects and Objects BUT... as you say there is no index just a
>>> containment. Plus (even if it would work) this is ugly.
>>
>> I agree that this approach would be a bit ugly and may not scale well,
>> even if the EMF structure allowed for it.
>>
>>>
>>>
>>> But remember all EObjects do have an
>>> public EObject eContainer()
>>> method.
>>
>> Ah-ha! I did not ralise I could access this.
>
> Yes, any method on your object instance should work.
>
>>>
>>> So you might try...
>>> Creating a single dataset on all the Issues. Then add 6 computed
>>> columns; 3 for Objective id, name and description; and 3 for Project id,
>>> name and description.
>>
>> So I gave getting hold of an Objectives Id attribute via an Issue
>> dataset query. The query uses the Project as the context and returns an
>> Issue type, the query is:
>>
>> self.objectives.issues
> Looks good
>>
>>>
>>> In the computed columns of your Dataset use a function like
>>> @self.getObject().eContainer() to move upward in the hierarchy to get
>>> the Objective then in a similar fashion
>>> @self.getObject().eContainer().eContainer() to get the Project. Once you
>>> are at the object you can get the values for id, name and description.
>>>
>>
>> I then added a computed column called ObjectiveObj :
>>
>> row["@self"].getObject().eContainer()
>
> Rather call it ObjectID
> and
>
> row["@self"].getObject().eContainer().getID();
>
> (The data type for the computed column would be a string, unless that is
> of course you have a number type for the ID in your EMF model.
>
>>
>>
>>> Your dataset can be now used in a BIRT table where you can group on the
>>> Project and sub group on Objective. This last subgroup will include the
>>> Issues in the details row.
>>
>> This gives me the following sorts of results :
>>
>> Description: Test issue 1
>> Id: O1.1
>> ObjectiveObj: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@59ae5a16
>> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@38bf7b8 (name: Objective)
>> (instanceClassName: null) (abstract: false, interface: false))
>>
>> It looks like I have the object reference to the containing Objective
>> object, but I'm not sure how I then cast this to an instance of
>> Objective to access it's getId() method?
>
> Again no cast needed - Just go for it and call a method.
>
> cheers,
> John
>
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #774650 is a reply to message #774616] Wed, 04 January 2012 10:45 Go to previous messageGo to next message
Nigel Daniels is currently offline Nigel DanielsFriend
Messages: 66
Registered: July 2009
Member
Hi John,

I just managed to answer my own query, as I have the DynamicEObjectImpl
wrapper I was able to use EMF techniques to access the attribute I
needed. so the computed column expression becomes:

row["@self"].getObject().eContainer().dynamicGet(1);

This returns the value of the Id attribute that I need.

Thanks for all of your help in guiding me towards this result.

Best regards,

Nigel


On 04/01/2012 09:42, Nigel Daniels wrote:
> Hi John,
>
> I have tried multiple ways of calling the method I'd like to call but I
> don't think I'm getting back the object I expected. When I try to call
> the method using:
>
> row["@self"].getObject().eContainer().getId();
>
> I get the result:
>
> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
> for computed column "ObjectiveObj".
> A BIRT exception occurred. See next exception for more information.
> There are errors evaluating script
> "row["@self"].getObject().eContainer().getId();":
> TypeError: Cannot find function getId in object
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@b500f60 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@474715d4 (name: Objective)
> (instanceClassName: null) (abstract: false, interface: false)).
> at
> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>
> ....
>
>
> I also tried the variations (a bit of a guess):
>
> row["@self"].getObject().eContainer().row["Id"];
> and:
> row["@self"].getObject().eContainer().column["Id"];
>
> with the result:
>
> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
> for computed column "ObjectiveObj".
> A BIRT exception occurred. See next exception for more information.
> There are errors evaluating script
> "row["@self"].getObject().eContainer().row["Id"];":
> TypeError: Cannot read property "Id" from undefined
> at
> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>
> ....
>
>
> Finally I tried (based on looking at the avaliable items in a dataset):
>
> row["@self"].getObject().eContainer().Id;
>
> This returns the data set but the computed column is empty.
>
>
> I suspect my last three attempts are in error but I thought I should try
> out any ideas and see if they worked out.
>
> The result from the first attempt seems to suggest that I am not getting
> back the expected object but that I have a DynamicEObjectImpl instead.
> When I look at the result for running:
>
> row["@self"].getObject().eContainer();
>
> It gives me a result like this for the computed column:
>
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@51b5449f (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@6433aa85 (name: Objective)
> (instanceClassName: null) (abstract: false, interface: false))
>
> In the attribute (name: Objective) I can see that it looks to contain
> the Objective type I expect, but without the ability to type cast this
> to an Objective class I suspect I will not be able to access the getId()
> method. Do you have an example of how I should be doing this? It would
> be great to take a look in case there is a step I have failed to do in
> configuring my BIRT/EMF/ODA set-up?
>
> Regards,
>
> Nigel
>
>
> On 31/12/2011 19:27, John E. Conlon wrote:
>> HI Nigel,
>>
>> See inline comments.
>>
>> On 12/29/2011 08:04 AM, Nigel Daniels wrote:
>>> Hi John,
>>>
>>> thanks for getting back to me so quickly :) I have given these ideas a
>>> go an I can get the container object as you suggested, so I'm a good
>>> part of the way there but I'm not sure I know how to use OCL correctly
>>> to get an objects id. Is there a way to cast the result then call its
>>> methods?
>> Don't have to cast, its JavaScript! Just go ahead and use whatever
>> method in the Interface for container object that allows you to get
>> the id.
>>
>> Guess - is it
>> getID()
>>
>>>
>>> I've added some comments on what i tried and the results below:
>>>
>>> On 26/12/2011 19:28, John E. Conlon wrote:
>>>> Nigel,
>>>>
>>>>
>>>> See inline comments...
>>>>
>>>>
>>>> On 12/26/2011 11:02 AM, Nigel Daniels wrote:
>>>>> Hi,
>>>>>
>>>>> I am new to using BIRT and I am trying to report on an EMF model. I
>>>>> have
>>>>> set up an ODA connection to my EMF file and can report on parts of it.
>>>> Are you using the newest org.eclipse.emf.oda.ecore driver?
>>>>
>>>>> What I would like to do is create a report that looks a bit like the
>>>>> EMF
>>>>> tree view of my information. The model structure is :
>>>>>
>>>>> A Project --- contains ---> Objectives --- contain ---> Issues
>>>>>
>>>>> All of these elements have the string attributes, id, name and
>>>>> description.
>>>>>
>>>>> I can create OCL queries based on the Project context :
>>>>>
>>>>> self.objectives
>>>>>
>>>>> to see all of the Objectives, then :
>>>>>
>>>>> self.objectives.issues
>>>>>
>>>>> to view all of the Issues, or even :
>>>>>
>>>>> self.objectives->select(id='O1').issues
>>>>>
>>>>> to see the Issues belonging to the Objective with the id 'O1'. Is
>>>>> there
>>>>> anyway to nest a series of OCL quieries so that I could see each of
>>>>> the
>>>>> objectives then their associated issues in one report.
>>>>>
>>>>> Unlike a relational database the relationship is a feature of the file
>>>>> structure in the EMF file rather than using index relationships.
>>>>> Because
>>>>> of this I have not found a way of making join querys work as there
>>>>> is no
>>>>> field to join on.
>>>> Right the brute force approach is to create three datasets:
>>>> Projects, Objectives, and Issues; then create a fourth Joint DataSet to
>>>> join Projects and Objectives and a fifth to join the Issues to the
>>>> Joint
>>>> Projects and Objects BUT... as you say there is no index just a
>>>> containment. Plus (even if it would work) this is ugly.
>>>
>>> I agree that this approach would be a bit ugly and may not scale well,
>>> even if the EMF structure allowed for it.
>>>
>>>>
>>>>
>>>> But remember all EObjects do have an
>>>> public EObject eContainer()
>>>> method.
>>>
>>> Ah-ha! I did not ralise I could access this.
>>
>> Yes, any method on your object instance should work.
>>
>>>>
>>>> So you might try...
>>>> Creating a single dataset on all the Issues. Then add 6 computed
>>>> columns; 3 for Objective id, name and description; and 3 for Project
>>>> id,
>>>> name and description.
>>>
>>> So I gave getting hold of an Objectives Id attribute via an Issue
>>> dataset query. The query uses the Project as the context and returns an
>>> Issue type, the query is:
>>>
>>> self.objectives.issues
>> Looks good
>>>
>>>>
>>>> In the computed columns of your Dataset use a function like
>>>> @self.getObject().eContainer() to move upward in the hierarchy to get
>>>> the Objective then in a similar fashion
>>>> @self.getObject().eContainer().eContainer() to get the Project. Once
>>>> you
>>>> are at the object you can get the values for id, name and description.
>>>>
>>>
>>> I then added a computed column called ObjectiveObj :
>>>
>>> row["@self"].getObject().eContainer()
>>
>> Rather call it ObjectID
>> and
>>
>> row["@self"].getObject().eContainer().getID();
>>
>> (The data type for the computed column would be a string, unless that is
>> of course you have a number type for the ID in your EMF model.
>>
>>>
>>>
>>>> Your dataset can be now used in a BIRT table where you can group on the
>>>> Project and sub group on Objective. This last subgroup will include the
>>>> Issues in the details row.
>>>
>>> This gives me the following sorts of results :
>>>
>>> Description: Test issue 1
>>> Id: O1.1
>>> ObjectiveObj: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@59ae5a16
>>> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@38bf7b8 (name: Objective)
>>> (instanceClassName: null) (abstract: false, interface: false))
>>>
>>> It looks like I have the object reference to the containing Objective
>>> object, but I'm not sure how I then cast this to an instance of
>>> Objective to access it's getId() method?
>>
>> Again no cast needed - Just go for it and call a method.
>>
>> cheers,
>> John
>>
>
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #775247 is a reply to message #774650] Thu, 05 January 2012 16:23 Go to previous messageGo to next message
Eclipse UserFriend
Hi Nigel,

First of all, I am glad you got this working, but your model behaves
different than mine.

To quote a famous wise man:
>Why question magical incantations that are working well?

Ok so I am curios...

In my case, I have a model element called Animal which contains multiple
Tag elements which contains multiple Event elements.

I can traverse upward my tree from the Event context like this:
row["@self"].getObject().getTag().getAnimal().getWeight()

But to test what we were discussing today I changed it and so can also do:
row["@self"].getObject().eContainer().eContainer().getWeight()
to get the same results.

So it seems that I am working directly with my generated EObjects while
you are not. Why?

Could you be in the same situation as:
http://www.eclipsezone.com/eclipse/forums/t107335.html
??

John


On 01/04/2012 04:47 AM, Nigel Daniels wrote:
> Hi John,
>
> I just managed to answer my own query, as I have the DynamicEObjectImpl
> wrapper I was able to use EMF techniques to access the attribute I
> needed. so the computed column expression becomes:
>
> row["@self"].getObject().eContainer().dynamicGet(1);
>
> This returns the value of the Id attribute that I need.
>
> Thanks for all of your help in guiding me towards this result.
>
> Best regards,
>
> Nigel
>
>
> On 04/01/2012 09:42, Nigel Daniels wrote:
>> Hi John,
>>
>> I have tried multiple ways of calling the method I'd like to call but I
>> don't think I'm getting back the object I expected. When I try to call
>> the method using:
>>
>> row["@self"].getObject().eContainer().getId();
>>
>> I get the result:
>>
>> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
>> for computed column "ObjectiveObj".
>> A BIRT exception occurred. See next exception for more information.
>> There are errors evaluating script
>> "row["@self"].getObject().eContainer().getId();":
>> TypeError: Cannot find function getId in object
>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@b500f60 (eClass:
>> org.eclipse.emf.ecore.impl.EClassImpl@474715d4 (name: Objective)
>> (instanceClassName: null) (abstract: false, interface: false)).
>> at
>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>
>>
>> ....
>>
>>
>> I also tried the variations (a bit of a guess):
>>
>> row["@self"].getObject().eContainer().row["Id"];
>> and:
>> row["@self"].getObject().eContainer().column["Id"];
>>
>> with the result:
>>
>> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
>> for computed column "ObjectiveObj".
>> A BIRT exception occurred. See next exception for more information.
>> There are errors evaluating script
>> "row["@self"].getObject().eContainer().row["Id"];":
>> TypeError: Cannot read property "Id" from undefined
>> at
>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>
>>
>> ....
>>
>>
>> Finally I tried (based on looking at the avaliable items in a dataset):
>>
>> row["@self"].getObject().eContainer().Id;
>>
>> This returns the data set but the computed column is empty.
>>
>>
>> I suspect my last three attempts are in error but I thought I should try
>> out any ideas and see if they worked out.
>>
>> The result from the first attempt seems to suggest that I am not getting
>> back the expected object but that I have a DynamicEObjectImpl instead.
>> When I look at the result for running:
>>
>> row["@self"].getObject().eContainer();
>>
>> It gives me a result like this for the computed column:
>>
>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@51b5449f (eClass:
>> org.eclipse.emf.ecore.impl.EClassImpl@6433aa85 (name: Objective)
>> (instanceClassName: null) (abstract: false, interface: false))
>>
>> In the attribute (name: Objective) I can see that it looks to contain
>> the Objective type I expect, but without the ability to type cast this
>> to an Objective class I suspect I will not be able to access the getId()
>> method. Do you have an example of how I should be doing this? It would
>> be great to take a look in case there is a step I have failed to do in
>> configuring my BIRT/EMF/ODA set-up?
>>
>> Regards,
>>
>> Nigel
>>
>>
>> On 31/12/2011 19:27, John E. Conlon wrote:
>>> HI Nigel,
>>>
>>> See inline comments.
>>>
>>> On 12/29/2011 08:04 AM, Nigel Daniels wrote:
>>>> Hi John,
>>>>
>>>> thanks for getting back to me so quickly :) I have given these ideas a
>>>> go an I can get the container object as you suggested, so I'm a good
>>>> part of the way there but I'm not sure I know how to use OCL correctly
>>>> to get an objects id. Is there a way to cast the result then call its
>>>> methods?
>>> Don't have to cast, its JavaScript! Just go ahead and use whatever
>>> method in the Interface for container object that allows you to get
>>> the id.
>>>
>>> Guess - is it
>>> getID()
>>>
>>>>
>>>> I've added some comments on what i tried and the results below:
>>>>
>>>> On 26/12/2011 19:28, John E. Conlon wrote:
>>>>> Nigel,
>>>>>
>>>>>
>>>>> See inline comments...
>>>>>
>>>>>
>>>>> On 12/26/2011 11:02 AM, Nigel Daniels wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I am new to using BIRT and I am trying to report on an EMF model. I
>>>>>> have
>>>>>> set up an ODA connection to my EMF file and can report on parts of
>>>>>> it.
>>>>> Are you using the newest org.eclipse.emf.oda.ecore driver?
>>>>>
>>>>>> What I would like to do is create a report that looks a bit like the
>>>>>> EMF
>>>>>> tree view of my information. The model structure is :
>>>>>>
>>>>>> A Project --- contains ---> Objectives --- contain ---> Issues
>>>>>>
>>>>>> All of these elements have the string attributes, id, name and
>>>>>> description.
>>>>>>
>>>>>> I can create OCL queries based on the Project context :
>>>>>>
>>>>>> self.objectives
>>>>>>
>>>>>> to see all of the Objectives, then :
>>>>>>
>>>>>> self.objectives.issues
>>>>>>
>>>>>> to view all of the Issues, or even :
>>>>>>
>>>>>> self.objectives->select(id='O1').issues
>>>>>>
>>>>>> to see the Issues belonging to the Objective with the id 'O1'. Is
>>>>>> there
>>>>>> anyway to nest a series of OCL quieries so that I could see each of
>>>>>> the
>>>>>> objectives then their associated issues in one report.
>>>>>>
>>>>>> Unlike a relational database the relationship is a feature of the
>>>>>> file
>>>>>> structure in the EMF file rather than using index relationships.
>>>>>> Because
>>>>>> of this I have not found a way of making join querys work as there
>>>>>> is no
>>>>>> field to join on.
>>>>> Right the brute force approach is to create three datasets:
>>>>> Projects, Objectives, and Issues; then create a fourth Joint
>>>>> DataSet to
>>>>> join Projects and Objectives and a fifth to join the Issues to the
>>>>> Joint
>>>>> Projects and Objects BUT... as you say there is no index just a
>>>>> containment. Plus (even if it would work) this is ugly.
>>>>
>>>> I agree that this approach would be a bit ugly and may not scale well,
>>>> even if the EMF structure allowed for it.
>>>>
>>>>>
>>>>>
>>>>> But remember all EObjects do have an
>>>>> public EObject eContainer()
>>>>> method.
>>>>
>>>> Ah-ha! I did not ralise I could access this.
>>>
>>> Yes, any method on your object instance should work.
>>>
>>>>>
>>>>> So you might try...
>>>>> Creating a single dataset on all the Issues. Then add 6 computed
>>>>> columns; 3 for Objective id, name and description; and 3 for Project
>>>>> id,
>>>>> name and description.
>>>>
>>>> So I gave getting hold of an Objectives Id attribute via an Issue
>>>> dataset query. The query uses the Project as the context and returns an
>>>> Issue type, the query is:
>>>>
>>>> self.objectives.issues
>>> Looks good
>>>>
>>>>>
>>>>> In the computed columns of your Dataset use a function like
>>>>> @self.getObject().eContainer() to move upward in the hierarchy to get
>>>>> the Objective then in a similar fashion
>>>>> @self.getObject().eContainer().eContainer() to get the Project. Once
>>>>> you
>>>>> are at the object you can get the values for id, name and description.
>>>>>
>>>>
>>>> I then added a computed column called ObjectiveObj :
>>>>
>>>> row["@self"].getObject().eContainer()
>>>
>>> Rather call it ObjectID
>>> and
>>>
>>> row["@self"].getObject().eContainer().getID();
>>>
>>> (The data type for the computed column would be a string, unless that is
>>> of course you have a number type for the ID in your EMF model.
>>>
>>>>
>>>>
>>>>> Your dataset can be now used in a BIRT table where you can group on
>>>>> the
>>>>> Project and sub group on Objective. This last subgroup will include
>>>>> the
>>>>> Issues in the details row.
>>>>
>>>> This gives me the following sorts of results :
>>>>
>>>> Description: Test issue 1
>>>> Id: O1.1
>>>> ObjectiveObj: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@59ae5a16
>>>> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@38bf7b8 (name:
>>>> Objective)
>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>>
>>>> It looks like I have the object reference to the containing Objective
>>>> object, but I'm not sure how I then cast this to an instance of
>>>> Objective to access it's getId() method?
>>>
>>> Again no cast needed - Just go for it and call a method.
>>>
>>> cheers,
>>> John
>>>
>>
>
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #775760 is a reply to message #775247] Fri, 06 January 2012 16:33 Go to previous messageGo to next message
Nigel Daniels is currently offline Nigel DanielsFriend
Messages: 66
Registered: July 2009
Member
Hi John,

that is odd! I wonder if it is another symptom of an early problem I
had. Whenever I tried to create a data source using my xmi file it
failed claiming it could not load a referenced namespace (my own, as I
recall). I resolved this problem by adding:

saveOptions.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

To the edit code that persists the file. From then on I was able to
create the DataSource. Following the post you cited I replaced this with:

editingDomain.getResourceSet().getPackageRegistry().put("http://uk.co.acme.datagathering/1.0",
DataGatheringPackage.eINSTANCE);

I was able to create a DataSource but it still get a DynamicEObjectImpl
instead of an instance of the resource I was expecting.

I too am curious as to why this is? It would be a lot simpler to call
the methods I would expect to see. Still the incantation is working for
now ;)

Thanks for your help,

Nigel

On 05/01/2012 16:23, John E. Conlon wrote:
> Hi Nigel,
>
> First of all, I am glad you got this working, but your model behaves
> different than mine.
>
> To quote a famous wise man:
> >Why question magical incantations that are working well?
>
> Ok so I am curios...
>
> In my case, I have a model element called Animal which contains multiple
> Tag elements which contains multiple Event elements.
>
> I can traverse upward my tree from the Event context like this:
> row["@self"].getObject().getTag().getAnimal().getWeight()
>
> But to test what we were discussing today I changed it and so can also do:
> row["@self"].getObject().eContainer().eContainer().getWeight()
> to get the same results.
>
> So it seems that I am working directly with my generated EObjects while
> you are not. Why?
>
> Could you be in the same situation as:
> http://www.eclipsezone.com/eclipse/forums/t107335.html
> ??
>
> John
>
>
> On 01/04/2012 04:47 AM, Nigel Daniels wrote:
>> Hi John,
>>
>> I just managed to answer my own query, as I have the DynamicEObjectImpl
>> wrapper I was able to use EMF techniques to access the attribute I
>> needed. so the computed column expression becomes:
>>
>> row["@self"].getObject().eContainer().dynamicGet(1);
>>
>> This returns the value of the Id attribute that I need.
>>
>> Thanks for all of your help in guiding me towards this result.
>>
>> Best regards,
>>
>> Nigel
>>
>>
>> On 04/01/2012 09:42, Nigel Daniels wrote:
>>> Hi John,
>>>
>>> I have tried multiple ways of calling the method I'd like to call but I
>>> don't think I'm getting back the object I expected. When I try to call
>>> the method using:
>>>
>>> row["@self"].getObject().eContainer().getId();
>>>
>>> I get the result:
>>>
>>> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
>>> for computed column "ObjectiveObj".
>>> A BIRT exception occurred. See next exception for more information.
>>> There are errors evaluating script
>>> "row["@self"].getObject().eContainer().getId();":
>>> TypeError: Cannot find function getId in object
>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@b500f60 (eClass:
>>> org.eclipse.emf.ecore.impl.EClassImpl@474715d4 (name: Objective)
>>> (instanceClassName: null) (abstract: false, interface: false)).
>>> at
>>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>>
>>>
>>>
>>> ....
>>>
>>>
>>> I also tried the variations (a bit of a guess):
>>>
>>> row["@self"].getObject().eContainer().row["Id"];
>>> and:
>>> row["@self"].getObject().eContainer().column["Id"];
>>>
>>> with the result:
>>>
>>> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
>>> for computed column "ObjectiveObj".
>>> A BIRT exception occurred. See next exception for more information.
>>> There are errors evaluating script
>>> "row["@self"].getObject().eContainer().row["Id"];":
>>> TypeError: Cannot read property "Id" from undefined
>>> at
>>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>>
>>>
>>>
>>> ....
>>>
>>>
>>> Finally I tried (based on looking at the avaliable items in a dataset):
>>>
>>> row["@self"].getObject().eContainer().Id;
>>>
>>> This returns the data set but the computed column is empty.
>>>
>>>
>>> I suspect my last three attempts are in error but I thought I should try
>>> out any ideas and see if they worked out.
>>>
>>> The result from the first attempt seems to suggest that I am not getting
>>> back the expected object but that I have a DynamicEObjectImpl instead.
>>> When I look at the result for running:
>>>
>>> row["@self"].getObject().eContainer();
>>>
>>> It gives me a result like this for the computed column:
>>>
>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@51b5449f (eClass:
>>> org.eclipse.emf.ecore.impl.EClassImpl@6433aa85 (name: Objective)
>>> (instanceClassName: null) (abstract: false, interface: false))
>>>
>>> In the attribute (name: Objective) I can see that it looks to contain
>>> the Objective type I expect, but without the ability to type cast this
>>> to an Objective class I suspect I will not be able to access the getId()
>>> method. Do you have an example of how I should be doing this? It would
>>> be great to take a look in case there is a step I have failed to do in
>>> configuring my BIRT/EMF/ODA set-up?
>>>
>>> Regards,
>>>
>>> Nigel
>>>
>>>
>>> On 31/12/2011 19:27, John E. Conlon wrote:
>>>> HI Nigel,
>>>>
>>>> See inline comments.
>>>>
>>>> On 12/29/2011 08:04 AM, Nigel Daniels wrote:
>>>>> Hi John,
>>>>>
>>>>> thanks for getting back to me so quickly :) I have given these ideas a
>>>>> go an I can get the container object as you suggested, so I'm a good
>>>>> part of the way there but I'm not sure I know how to use OCL correctly
>>>>> to get an objects id. Is there a way to cast the result then call its
>>>>> methods?
>>>> Don't have to cast, its JavaScript! Just go ahead and use whatever
>>>> method in the Interface for container object that allows you to get
>>>> the id.
>>>>
>>>> Guess - is it
>>>> getID()
>>>>
>>>>>
>>>>> I've added some comments on what i tried and the results below:
>>>>>
>>>>> On 26/12/2011 19:28, John E. Conlon wrote:
>>>>>> Nigel,
>>>>>>
>>>>>>
>>>>>> See inline comments...
>>>>>>
>>>>>>
>>>>>> On 12/26/2011 11:02 AM, Nigel Daniels wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am new to using BIRT and I am trying to report on an EMF model. I
>>>>>>> have
>>>>>>> set up an ODA connection to my EMF file and can report on parts of
>>>>>>> it.
>>>>>> Are you using the newest org.eclipse.emf.oda.ecore driver?
>>>>>>
>>>>>>> What I would like to do is create a report that looks a bit like the
>>>>>>> EMF
>>>>>>> tree view of my information. The model structure is :
>>>>>>>
>>>>>>> A Project --- contains ---> Objectives --- contain ---> Issues
>>>>>>>
>>>>>>> All of these elements have the string attributes, id, name and
>>>>>>> description.
>>>>>>>
>>>>>>> I can create OCL queries based on the Project context :
>>>>>>>
>>>>>>> self.objectives
>>>>>>>
>>>>>>> to see all of the Objectives, then :
>>>>>>>
>>>>>>> self.objectives.issues
>>>>>>>
>>>>>>> to view all of the Issues, or even :
>>>>>>>
>>>>>>> self.objectives->select(id='O1').issues
>>>>>>>
>>>>>>> to see the Issues belonging to the Objective with the id 'O1'. Is
>>>>>>> there
>>>>>>> anyway to nest a series of OCL quieries so that I could see each of
>>>>>>> the
>>>>>>> objectives then their associated issues in one report.
>>>>>>>
>>>>>>> Unlike a relational database the relationship is a feature of the
>>>>>>> file
>>>>>>> structure in the EMF file rather than using index relationships.
>>>>>>> Because
>>>>>>> of this I have not found a way of making join querys work as there
>>>>>>> is no
>>>>>>> field to join on.
>>>>>> Right the brute force approach is to create three datasets:
>>>>>> Projects, Objectives, and Issues; then create a fourth Joint
>>>>>> DataSet to
>>>>>> join Projects and Objectives and a fifth to join the Issues to the
>>>>>> Joint
>>>>>> Projects and Objects BUT... as you say there is no index just a
>>>>>> containment. Plus (even if it would work) this is ugly.
>>>>>
>>>>> I agree that this approach would be a bit ugly and may not scale well,
>>>>> even if the EMF structure allowed for it.
>>>>>
>>>>>>
>>>>>>
>>>>>> But remember all EObjects do have an
>>>>>> public EObject eContainer()
>>>>>> method.
>>>>>
>>>>> Ah-ha! I did not ralise I could access this.
>>>>
>>>> Yes, any method on your object instance should work.
>>>>
>>>>>>
>>>>>> So you might try...
>>>>>> Creating a single dataset on all the Issues. Then add 6 computed
>>>>>> columns; 3 for Objective id, name and description; and 3 for Project
>>>>>> id,
>>>>>> name and description.
>>>>>
>>>>> So I gave getting hold of an Objectives Id attribute via an Issue
>>>>> dataset query. The query uses the Project as the context and
>>>>> returns an
>>>>> Issue type, the query is:
>>>>>
>>>>> self.objectives.issues
>>>> Looks good
>>>>>
>>>>>>
>>>>>> In the computed columns of your Dataset use a function like
>>>>>> @self.getObject().eContainer() to move upward in the hierarchy to get
>>>>>> the Objective then in a similar fashion
>>>>>> @self.getObject().eContainer().eContainer() to get the Project. Once
>>>>>> you
>>>>>> are at the object you can get the values for id, name and
>>>>>> description.
>>>>>>
>>>>>
>>>>> I then added a computed column called ObjectiveObj :
>>>>>
>>>>> row["@self"].getObject().eContainer()
>>>>
>>>> Rather call it ObjectID
>>>> and
>>>>
>>>> row["@self"].getObject().eContainer().getID();
>>>>
>>>> (The data type for the computed column would be a string, unless
>>>> that is
>>>> of course you have a number type for the ID in your EMF model.
>>>>
>>>>>
>>>>>
>>>>>> Your dataset can be now used in a BIRT table where you can group on
>>>>>> the
>>>>>> Project and sub group on Objective. This last subgroup will include
>>>>>> the
>>>>>> Issues in the details row.
>>>>>
>>>>> This gives me the following sorts of results :
>>>>>
>>>>> Description: Test issue 1
>>>>> Id: O1.1
>>>>> ObjectiveObj: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@59ae5a16
>>>>> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@38bf7b8 (name:
>>>>> Objective)
>>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>>>
>>>>> It looks like I have the object reference to the containing Objective
>>>>> object, but I'm not sure how I then cast this to an instance of
>>>>> Objective to access it's getId() method?
>>>>
>>>> Again no cast needed - Just go for it and call a method.
>>>>
>>>> cheers,
>>>> John
>>>>
>>>
>>
>
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #775778 is a reply to message #775760] Fri, 06 January 2012 16:55 Go to previous messageGo to next message
Eclipse UserFriend
Hi Nigel,

Yep, something does not appear right with your model plugins. You
should try and fix it.

Also from a community educational standpoint...
would you mind re-posting these EMF related questions to the EMF
eclipse.tools.emf newsgroup and then if you find out a solution let us
know back on this thread?

thanks,
John

On 01/06/2012 10:33 AM, Nigel Daniels wrote:
> Hi John,
>
> that is odd! I wonder if it is another symptom of an early problem I
> had. Whenever I tried to create a data source using my xmi file it
> failed claiming it could not load a referenced namespace (my own, as I
> recall). I resolved this problem by adding:
>
> saveOptions.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
>
> To the edit code that persists the file. From then on I was able to
> create the DataSource. Following the post you cited I replaced this with:
>
> editingDomain.getResourceSet().getPackageRegistry().put("http://uk.co.acme.datagathering/1.0",
> DataGatheringPackage.eINSTANCE);
>
> I was able to create a DataSource but it still get a DynamicEObjectImpl
> instead of an instance of the resource I was expecting.
>
> I too am curious as to why this is? It would be a lot simpler to call
> the methods I would expect to see. Still the incantation is working for
> now ;)
>
> Thanks for your help,
>
> Nigel
>
> On 05/01/2012 16:23, John E. Conlon wrote:
>> Hi Nigel,
>>
>> First of all, I am glad you got this working, but your model behaves
>> different than mine.
>>
>> To quote a famous wise man:
>> >Why question magical incantations that are working well?
>>
>> Ok so I am curios...
>>
>> In my case, I have a model element called Animal which contains multiple
>> Tag elements which contains multiple Event elements.
>>
>> I can traverse upward my tree from the Event context like this:
>> row["@self"].getObject().getTag().getAnimal().getWeight()
>>
>> But to test what we were discussing today I changed it and so can also
>> do:
>> row["@self"].getObject().eContainer().eContainer().getWeight()
>> to get the same results.
>>
>> So it seems that I am working directly with my generated EObjects while
>> you are not. Why?
>>
>> Could you be in the same situation as:
>> http://www.eclipsezone.com/eclipse/forums/t107335.html
>> ??
>>
>> John
>>
>>
>> On 01/04/2012 04:47 AM, Nigel Daniels wrote:
>>> Hi John,
>>>
>>> I just managed to answer my own query, as I have the DynamicEObjectImpl
>>> wrapper I was able to use EMF techniques to access the attribute I
>>> needed. so the computed column expression becomes:
>>>
>>> row["@self"].getObject().eContainer().dynamicGet(1);
>>>
>>> This returns the value of the Id attribute that I need.
>>>
>>> Thanks for all of your help in guiding me towards this result.
>>>
>>> Best regards,
>>>
>>> Nigel
>>>
>>>
>>> On 04/01/2012 09:42, Nigel Daniels wrote:
>>>> Hi John,
>>>>
>>>> I have tried multiple ways of calling the method I'd like to call but I
>>>> don't think I'm getting back the object I expected. When I try to call
>>>> the method using:
>>>>
>>>> row["@self"].getObject().eContainer().getId();
>>>>
>>>> I get the result:
>>>>
>>>> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
>>>> for computed column "ObjectiveObj".
>>>> A BIRT exception occurred. See next exception for more information.
>>>> There are errors evaluating script
>>>> "row["@self"].getObject().eContainer().getId();":
>>>> TypeError: Cannot find function getId in object
>>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@b500f60 (eClass:
>>>> org.eclipse.emf.ecore.impl.EClassImpl@474715d4 (name: Objective)
>>>> (instanceClassName: null) (abstract: false, interface: false)).
>>>> at
>>>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>>>
>>>>
>>>>
>>>>
>>>> ....
>>>>
>>>>
>>>> I also tried the variations (a bit of a guess):
>>>>
>>>> row["@self"].getObject().eContainer().row["Id"];
>>>> and:
>>>> row["@self"].getObject().eContainer().column["Id"];
>>>>
>>>> with the result:
>>>>
>>>> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
>>>> for computed column "ObjectiveObj".
>>>> A BIRT exception occurred. See next exception for more information.
>>>> There are errors evaluating script
>>>> "row["@self"].getObject().eContainer().row["Id"];":
>>>> TypeError: Cannot read property "Id" from undefined
>>>> at
>>>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>>>
>>>>
>>>>
>>>>
>>>> ....
>>>>
>>>>
>>>> Finally I tried (based on looking at the avaliable items in a dataset):
>>>>
>>>> row["@self"].getObject().eContainer().Id;
>>>>
>>>> This returns the data set but the computed column is empty.
>>>>
>>>>
>>>> I suspect my last three attempts are in error but I thought I should
>>>> try
>>>> out any ideas and see if they worked out.
>>>>
>>>> The result from the first attempt seems to suggest that I am not
>>>> getting
>>>> back the expected object but that I have a DynamicEObjectImpl instead.
>>>> When I look at the result for running:
>>>>
>>>> row["@self"].getObject().eContainer();
>>>>
>>>> It gives me a result like this for the computed column:
>>>>
>>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@51b5449f (eClass:
>>>> org.eclipse.emf.ecore.impl.EClassImpl@6433aa85 (name: Objective)
>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>>
>>>> In the attribute (name: Objective) I can see that it looks to contain
>>>> the Objective type I expect, but without the ability to type cast this
>>>> to an Objective class I suspect I will not be able to access the
>>>> getId()
>>>> method. Do you have an example of how I should be doing this? It would
>>>> be great to take a look in case there is a step I have failed to do in
>>>> configuring my BIRT/EMF/ODA set-up?
>>>>
>>>> Regards,
>>>>
>>>> Nigel
>>>>
>>>>
>>>> On 31/12/2011 19:27, John E. Conlon wrote:
>>>>> HI Nigel,
>>>>>
>>>>> See inline comments.
>>>>>
>>>>> On 12/29/2011 08:04 AM, Nigel Daniels wrote:
>>>>>> Hi John,
>>>>>>
>>>>>> thanks for getting back to me so quickly :) I have given these
>>>>>> ideas a
>>>>>> go an I can get the container object as you suggested, so I'm a good
>>>>>> part of the way there but I'm not sure I know how to use OCL
>>>>>> correctly
>>>>>> to get an objects id. Is there a way to cast the result then call its
>>>>>> methods?
>>>>> Don't have to cast, its JavaScript! Just go ahead and use whatever
>>>>> method in the Interface for container object that allows you to get
>>>>> the id.
>>>>>
>>>>> Guess - is it
>>>>> getID()
>>>>>
>>>>>>
>>>>>> I've added some comments on what i tried and the results below:
>>>>>>
>>>>>> On 26/12/2011 19:28, John E. Conlon wrote:
>>>>>>> Nigel,
>>>>>>>
>>>>>>>
>>>>>>> See inline comments...
>>>>>>>
>>>>>>>
>>>>>>> On 12/26/2011 11:02 AM, Nigel Daniels wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I am new to using BIRT and I am trying to report on an EMF model. I
>>>>>>>> have
>>>>>>>> set up an ODA connection to my EMF file and can report on parts of
>>>>>>>> it.
>>>>>>> Are you using the newest org.eclipse.emf.oda.ecore driver?
>>>>>>>
>>>>>>>> What I would like to do is create a report that looks a bit like
>>>>>>>> the
>>>>>>>> EMF
>>>>>>>> tree view of my information. The model structure is :
>>>>>>>>
>>>>>>>> A Project --- contains ---> Objectives --- contain ---> Issues
>>>>>>>>
>>>>>>>> All of these elements have the string attributes, id, name and
>>>>>>>> description.
>>>>>>>>
>>>>>>>> I can create OCL queries based on the Project context :
>>>>>>>>
>>>>>>>> self.objectives
>>>>>>>>
>>>>>>>> to see all of the Objectives, then :
>>>>>>>>
>>>>>>>> self.objectives.issues
>>>>>>>>
>>>>>>>> to view all of the Issues, or even :
>>>>>>>>
>>>>>>>> self.objectives->select(id='O1').issues
>>>>>>>>
>>>>>>>> to see the Issues belonging to the Objective with the id 'O1'. Is
>>>>>>>> there
>>>>>>>> anyway to nest a series of OCL quieries so that I could see each of
>>>>>>>> the
>>>>>>>> objectives then their associated issues in one report.
>>>>>>>>
>>>>>>>> Unlike a relational database the relationship is a feature of the
>>>>>>>> file
>>>>>>>> structure in the EMF file rather than using index relationships.
>>>>>>>> Because
>>>>>>>> of this I have not found a way of making join querys work as there
>>>>>>>> is no
>>>>>>>> field to join on.
>>>>>>> Right the brute force approach is to create three datasets:
>>>>>>> Projects, Objectives, and Issues; then create a fourth Joint
>>>>>>> DataSet to
>>>>>>> join Projects and Objectives and a fifth to join the Issues to the
>>>>>>> Joint
>>>>>>> Projects and Objects BUT... as you say there is no index just a
>>>>>>> containment. Plus (even if it would work) this is ugly.
>>>>>>
>>>>>> I agree that this approach would be a bit ugly and may not scale
>>>>>> well,
>>>>>> even if the EMF structure allowed for it.
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> But remember all EObjects do have an
>>>>>>> public EObject eContainer()
>>>>>>> method.
>>>>>>
>>>>>> Ah-ha! I did not ralise I could access this.
>>>>>
>>>>> Yes, any method on your object instance should work.
>>>>>
>>>>>>>
>>>>>>> So you might try...
>>>>>>> Creating a single dataset on all the Issues. Then add 6 computed
>>>>>>> columns; 3 for Objective id, name and description; and 3 for Project
>>>>>>> id,
>>>>>>> name and description.
>>>>>>
>>>>>> So I gave getting hold of an Objectives Id attribute via an Issue
>>>>>> dataset query. The query uses the Project as the context and
>>>>>> returns an
>>>>>> Issue type, the query is:
>>>>>>
>>>>>> self.objectives.issues
>>>>> Looks good
>>>>>>
>>>>>>>
>>>>>>> In the computed columns of your Dataset use a function like
>>>>>>> @self.getObject().eContainer() to move upward in the hierarchy to
>>>>>>> get
>>>>>>> the Objective then in a similar fashion
>>>>>>> @self.getObject().eContainer().eContainer() to get the Project. Once
>>>>>>> you
>>>>>>> are at the object you can get the values for id, name and
>>>>>>> description.
>>>>>>>
>>>>>>
>>>>>> I then added a computed column called ObjectiveObj :
>>>>>>
>>>>>> row["@self"].getObject().eContainer()
>>>>>
>>>>> Rather call it ObjectID
>>>>> and
>>>>>
>>>>> row["@self"].getObject().eContainer().getID();
>>>>>
>>>>> (The data type for the computed column would be a string, unless
>>>>> that is
>>>>> of course you have a number type for the ID in your EMF model.
>>>>>
>>>>>>
>>>>>>
>>>>>>> Your dataset can be now used in a BIRT table where you can group on
>>>>>>> the
>>>>>>> Project and sub group on Objective. This last subgroup will include
>>>>>>> the
>>>>>>> Issues in the details row.
>>>>>>
>>>>>> This gives me the following sorts of results :
>>>>>>
>>>>>> Description: Test issue 1
>>>>>> Id: O1.1
>>>>>> ObjectiveObj: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@59ae5a16
>>>>>> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@38bf7b8 (name:
>>>>>> Objective)
>>>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>>>>
>>>>>> It looks like I have the object reference to the containing Objective
>>>>>> object, but I'm not sure how I then cast this to an instance of
>>>>>> Objective to access it's getId() method?
>>>>>
>>>>> Again no cast needed - Just go for it and call a method.
>>>>>
>>>>> cheers,
>>>>> John
>>>>>
>>>>
>>>
>>
>
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #776823 is a reply to message #775778] Mon, 09 January 2012 10:15 Go to previous messageGo to next message
Nigel Daniels is currently offline Nigel DanielsFriend
Messages: 66
Registered: July 2009
Member
Hi John,

I've posted a question in the EMF forum so lets see if anyone can
resolve this oddity.

BTW I have also started thinking of using sub-reports to achieve the
same effect as i was looking for here. However this approach has run
into it's own problems. I'll start a new post for that issue.

Thanks for your help.

Best regards,

Nigel

On 06/01/2012 16:55, John E. Conlon wrote:
> Hi Nigel,
>
> Yep, something does not appear right with your model plugins. You should
> try and fix it.
>
> Also from a community educational standpoint...
> would you mind re-posting these EMF related questions to the EMF
> eclipse.tools.emf newsgroup and then if you find out a solution let us
> know back on this thread?
>
> thanks,
> John
>
> On 01/06/2012 10:33 AM, Nigel Daniels wrote:
>> Hi John,
>>
>> that is odd! I wonder if it is another symptom of an early problem I
>> had. Whenever I tried to create a data source using my xmi file it
>> failed claiming it could not load a referenced namespace (my own, as I
>> recall). I resolved this problem by adding:
>>
>> saveOptions.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
>>
>> To the edit code that persists the file. From then on I was able to
>> create the DataSource. Following the post you cited I replaced this with:
>>
>> editingDomain.getResourceSet().getPackageRegistry().put("http://uk.co.acme.datagathering/1.0",
>>
>> DataGatheringPackage.eINSTANCE);
>>
>> I was able to create a DataSource but it still get a DynamicEObjectImpl
>> instead of an instance of the resource I was expecting.
>>
>> I too am curious as to why this is? It would be a lot simpler to call
>> the methods I would expect to see. Still the incantation is working for
>> now ;)
>>
>> Thanks for your help,
>>
>> Nigel
>>
>> On 05/01/2012 16:23, John E. Conlon wrote:
>>> Hi Nigel,
>>>
>>> First of all, I am glad you got this working, but your model behaves
>>> different than mine.
>>>
>>> To quote a famous wise man:
>>> >Why question magical incantations that are working well?
>>>
>>> Ok so I am curios...
>>>
>>> In my case, I have a model element called Animal which contains multiple
>>> Tag elements which contains multiple Event elements.
>>>
>>> I can traverse upward my tree from the Event context like this:
>>> row["@self"].getObject().getTag().getAnimal().getWeight()
>>>
>>> But to test what we were discussing today I changed it and so can also
>>> do:
>>> row["@self"].getObject().eContainer().eContainer().getWeight()
>>> to get the same results.
>>>
>>> So it seems that I am working directly with my generated EObjects while
>>> you are not. Why?
>>>
>>> Could you be in the same situation as:
>>> http://www.eclipsezone.com/eclipse/forums/t107335.html
>>> ??
>>>
>>> John
>>>
>>>
>>> On 01/04/2012 04:47 AM, Nigel Daniels wrote:
>>>> Hi John,
>>>>
>>>> I just managed to answer my own query, as I have the DynamicEObjectImpl
>>>> wrapper I was able to use EMF techniques to access the attribute I
>>>> needed. so the computed column expression becomes:
>>>>
>>>> row["@self"].getObject().eContainer().dynamicGet(1);
>>>>
>>>> This returns the value of the Id attribute that I need.
>>>>
>>>> Thanks for all of your help in guiding me towards this result.
>>>>
>>>> Best regards,
>>>>
>>>> Nigel
>>>>
>>>>
>>>> On 04/01/2012 09:42, Nigel Daniels wrote:
>>>>> Hi John,
>>>>>
>>>>> I have tried multiple ways of calling the method I'd like to call
>>>>> but I
>>>>> don't think I'm getting back the object I expected. When I try to call
>>>>> the method using:
>>>>>
>>>>> row["@self"].getObject().eContainer().getId();
>>>>>
>>>>> I get the result:
>>>>>
>>>>> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
>>>>> for computed column "ObjectiveObj".
>>>>> A BIRT exception occurred. See next exception for more information.
>>>>> There are errors evaluating script
>>>>> "row["@self"].getObject().eContainer().getId();":
>>>>> TypeError: Cannot find function getId in object
>>>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@b500f60 (eClass:
>>>>> org.eclipse.emf.ecore.impl.EClassImpl@474715d4 (name: Objective)
>>>>> (instanceClassName: null) (abstract: false, interface: false)).
>>>>> at
>>>>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ....
>>>>>
>>>>>
>>>>> I also tried the variations (a bit of a guess):
>>>>>
>>>>> row["@self"].getObject().eContainer().row["Id"];
>>>>> and:
>>>>> row["@self"].getObject().eContainer().column["Id"];
>>>>>
>>>>> with the result:
>>>>>
>>>>> org.eclipse.birt.data.engine.core.DataException: Fail to compute value
>>>>> for computed column "ObjectiveObj".
>>>>> A BIRT exception occurred. See next exception for more information.
>>>>> There are errors evaluating script
>>>>> "row["@self"].getObject().eContainer().row["Id"];":
>>>>> TypeError: Cannot read property "Id" from undefined
>>>>> at
>>>>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ....
>>>>>
>>>>>
>>>>> Finally I tried (based on looking at the avaliable items in a
>>>>> dataset):
>>>>>
>>>>> row["@self"].getObject().eContainer().Id;
>>>>>
>>>>> This returns the data set but the computed column is empty.
>>>>>
>>>>>
>>>>> I suspect my last three attempts are in error but I thought I should
>>>>> try
>>>>> out any ideas and see if they worked out.
>>>>>
>>>>> The result from the first attempt seems to suggest that I am not
>>>>> getting
>>>>> back the expected object but that I have a DynamicEObjectImpl instead.
>>>>> When I look at the result for running:
>>>>>
>>>>> row["@self"].getObject().eContainer();
>>>>>
>>>>> It gives me a result like this for the computed column:
>>>>>
>>>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@51b5449f (eClass:
>>>>> org.eclipse.emf.ecore.impl.EClassImpl@6433aa85 (name: Objective)
>>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>>>
>>>>> In the attribute (name: Objective) I can see that it looks to contain
>>>>> the Objective type I expect, but without the ability to type cast this
>>>>> to an Objective class I suspect I will not be able to access the
>>>>> getId()
>>>>> method. Do you have an example of how I should be doing this? It would
>>>>> be great to take a look in case there is a step I have failed to do in
>>>>> configuring my BIRT/EMF/ODA set-up?
>>>>>
>>>>> Regards,
>>>>>
>>>>> Nigel
>>>>>
>>>>>
>>>>> On 31/12/2011 19:27, John E. Conlon wrote:
>>>>>> HI Nigel,
>>>>>>
>>>>>> See inline comments.
>>>>>>
>>>>>> On 12/29/2011 08:04 AM, Nigel Daniels wrote:
>>>>>>> Hi John,
>>>>>>>
>>>>>>> thanks for getting back to me so quickly :) I have given these
>>>>>>> ideas a
>>>>>>> go an I can get the container object as you suggested, so I'm a good
>>>>>>> part of the way there but I'm not sure I know how to use OCL
>>>>>>> correctly
>>>>>>> to get an objects id. Is there a way to cast the result then call
>>>>>>> its
>>>>>>> methods?
>>>>>> Don't have to cast, its JavaScript! Just go ahead and use whatever
>>>>>> method in the Interface for container object that allows you to get
>>>>>> the id.
>>>>>>
>>>>>> Guess - is it
>>>>>> getID()
>>>>>>
>>>>>>>
>>>>>>> I've added some comments on what i tried and the results below:
>>>>>>>
>>>>>>> On 26/12/2011 19:28, John E. Conlon wrote:
>>>>>>>> Nigel,
>>>>>>>>
>>>>>>>>
>>>>>>>> See inline comments...
>>>>>>>>
>>>>>>>>
>>>>>>>> On 12/26/2011 11:02 AM, Nigel Daniels wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I am new to using BIRT and I am trying to report on an EMF
>>>>>>>>> model. I
>>>>>>>>> have
>>>>>>>>> set up an ODA connection to my EMF file and can report on parts of
>>>>>>>>> it.
>>>>>>>> Are you using the newest org.eclipse.emf.oda.ecore driver?
>>>>>>>>
>>>>>>>>> What I would like to do is create a report that looks a bit like
>>>>>>>>> the
>>>>>>>>> EMF
>>>>>>>>> tree view of my information. The model structure is :
>>>>>>>>>
>>>>>>>>> A Project --- contains ---> Objectives --- contain ---> Issues
>>>>>>>>>
>>>>>>>>> All of these elements have the string attributes, id, name and
>>>>>>>>> description.
>>>>>>>>>
>>>>>>>>> I can create OCL queries based on the Project context :
>>>>>>>>>
>>>>>>>>> self.objectives
>>>>>>>>>
>>>>>>>>> to see all of the Objectives, then :
>>>>>>>>>
>>>>>>>>> self.objectives.issues
>>>>>>>>>
>>>>>>>>> to view all of the Issues, or even :
>>>>>>>>>
>>>>>>>>> self.objectives->select(id='O1').issues
>>>>>>>>>
>>>>>>>>> to see the Issues belonging to the Objective with the id 'O1'. Is
>>>>>>>>> there
>>>>>>>>> anyway to nest a series of OCL quieries so that I could see
>>>>>>>>> each of
>>>>>>>>> the
>>>>>>>>> objectives then their associated issues in one report.
>>>>>>>>>
>>>>>>>>> Unlike a relational database the relationship is a feature of the
>>>>>>>>> file
>>>>>>>>> structure in the EMF file rather than using index relationships.
>>>>>>>>> Because
>>>>>>>>> of this I have not found a way of making join querys work as there
>>>>>>>>> is no
>>>>>>>>> field to join on.
>>>>>>>> Right the brute force approach is to create three datasets:
>>>>>>>> Projects, Objectives, and Issues; then create a fourth Joint
>>>>>>>> DataSet to
>>>>>>>> join Projects and Objectives and a fifth to join the Issues to the
>>>>>>>> Joint
>>>>>>>> Projects and Objects BUT... as you say there is no index just a
>>>>>>>> containment. Plus (even if it would work) this is ugly.
>>>>>>>
>>>>>>> I agree that this approach would be a bit ugly and may not scale
>>>>>>> well,
>>>>>>> even if the EMF structure allowed for it.
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> But remember all EObjects do have an
>>>>>>>> public EObject eContainer()
>>>>>>>> method.
>>>>>>>
>>>>>>> Ah-ha! I did not ralise I could access this.
>>>>>>
>>>>>> Yes, any method on your object instance should work.
>>>>>>
>>>>>>>>
>>>>>>>> So you might try...
>>>>>>>> Creating a single dataset on all the Issues. Then add 6 computed
>>>>>>>> columns; 3 for Objective id, name and description; and 3 for
>>>>>>>> Project
>>>>>>>> id,
>>>>>>>> name and description.
>>>>>>>
>>>>>>> So I gave getting hold of an Objectives Id attribute via an Issue
>>>>>>> dataset query. The query uses the Project as the context and
>>>>>>> returns an
>>>>>>> Issue type, the query is:
>>>>>>>
>>>>>>> self.objectives.issues
>>>>>> Looks good
>>>>>>>
>>>>>>>>
>>>>>>>> In the computed columns of your Dataset use a function like
>>>>>>>> @self.getObject().eContainer() to move upward in the hierarchy to
>>>>>>>> get
>>>>>>>> the Objective then in a similar fashion
>>>>>>>> @self.getObject().eContainer().eContainer() to get the Project.
>>>>>>>> Once
>>>>>>>> you
>>>>>>>> are at the object you can get the values for id, name and
>>>>>>>> description.
>>>>>>>>
>>>>>>>
>>>>>>> I then added a computed column called ObjectiveObj :
>>>>>>>
>>>>>>> row["@self"].getObject().eContainer()
>>>>>>
>>>>>> Rather call it ObjectID
>>>>>> and
>>>>>>
>>>>>> row["@self"].getObject().eContainer().getID();
>>>>>>
>>>>>> (The data type for the computed column would be a string, unless
>>>>>> that is
>>>>>> of course you have a number type for the ID in your EMF model.
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Your dataset can be now used in a BIRT table where you can group on
>>>>>>>> the
>>>>>>>> Project and sub group on Objective. This last subgroup will include
>>>>>>>> the
>>>>>>>> Issues in the details row.
>>>>>>>
>>>>>>> This gives me the following sorts of results :
>>>>>>>
>>>>>>> Description: Test issue 1
>>>>>>> Id: O1.1
>>>>>>> ObjectiveObj: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@59ae5a16
>>>>>>> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@38bf7b8 (name:
>>>>>>> Objective)
>>>>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>>>>>
>>>>>>> It looks like I have the object reference to the containing
>>>>>>> Objective
>>>>>>> object, but I'm not sure how I then cast this to an instance of
>>>>>>> Objective to access it's getId() method?
>>>>>>
>>>>>> Again no cast needed - Just go for it and call a method.
>>>>>>
>>>>>> cheers,
>>>>>> John
>>>>>>
>>>>>
>>>>
>>>
>>
>
Re: Is it possible to Link OCL Queries to report on an EMF model? [message #778758 is a reply to message #776823] Fri, 13 January 2012 19:26 Go to previous message
Eclipse UserFriend
Hi Nigel,

Saw your post in the EMF group. Ed said that the DynamicEObjectImpl was
the result of your models not being found, and asked if you have
included all your generated plugins in your app that is using BIRT.

If so have included them, you may want to insure that these plugins are
active and have met all their dependencies in order to be so. In the
OSGi console. Go to Console open up a OSGi Console, and type in ss
<your plugins symbolic name> and check out the state.

John

On 01/09/2012 04:15 AM, Nigel Daniels wrote:
> Hi John,
>
> I've posted a question in the EMF forum so lets see if anyone can
> resolve this oddity.
>
> BTW I have also started thinking of using sub-reports to achieve the
> same effect as i was looking for here. However this approach has run
> into it's own problems. I'll start a new post for that issue.
>
> Thanks for your help.
>
> Best regards,
>
> Nigel
>
> On 06/01/2012 16:55, John E. Conlon wrote:
>> Hi Nigel,
>>
>> Yep, something does not appear right with your model plugins. You should
>> try and fix it.
>>
>> Also from a community educational standpoint...
>> would you mind re-posting these EMF related questions to the EMF
>> eclipse.tools.emf newsgroup and then if you find out a solution let us
>> know back on this thread?
>>
>> thanks,
>> John
>>
>> On 01/06/2012 10:33 AM, Nigel Daniels wrote:
>>> Hi John,
>>>
>>> that is odd! I wonder if it is another symptom of an early problem I
>>> had. Whenever I tried to create a data source using my xmi file it
>>> failed claiming it could not load a referenced namespace (my own, as I
>>> recall). I resolved this problem by adding:
>>>
>>> saveOptions.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
>>>
>>> To the edit code that persists the file. From then on I was able to
>>> create the DataSource. Following the post you cited I replaced this
>>> with:
>>>
>>> editingDomain.getResourceSet().getPackageRegistry().put("http://uk.co.acme.datagathering/1.0",
>>>
>>>
>>> DataGatheringPackage.eINSTANCE);
>>>
>>> I was able to create a DataSource but it still get a DynamicEObjectImpl
>>> instead of an instance of the resource I was expecting.
>>>
>>> I too am curious as to why this is? It would be a lot simpler to call
>>> the methods I would expect to see. Still the incantation is working for
>>> now ;)
>>>
>>> Thanks for your help,
>>>
>>> Nigel
>>>
>>> On 05/01/2012 16:23, John E. Conlon wrote:
>>>> Hi Nigel,
>>>>
>>>> First of all, I am glad you got this working, but your model behaves
>>>> different than mine.
>>>>
>>>> To quote a famous wise man:
>>>> >Why question magical incantations that are working well?
>>>>
>>>> Ok so I am curios...
>>>>
>>>> In my case, I have a model element called Animal which contains
>>>> multiple
>>>> Tag elements which contains multiple Event elements.
>>>>
>>>> I can traverse upward my tree from the Event context like this:
>>>> row["@self"].getObject().getTag().getAnimal().getWeight()
>>>>
>>>> But to test what we were discussing today I changed it and so can also
>>>> do:
>>>> row["@self"].getObject().eContainer().eContainer().getWeight()
>>>> to get the same results.
>>>>
>>>> So it seems that I am working directly with my generated EObjects while
>>>> you are not. Why?
>>>>
>>>> Could you be in the same situation as:
>>>> http://www.eclipsezone.com/eclipse/forums/t107335.html
>>>> ??
>>>>
>>>> John
>>>>
>>>>
>>>> On 01/04/2012 04:47 AM, Nigel Daniels wrote:
>>>>> Hi John,
>>>>>
>>>>> I just managed to answer my own query, as I have the
>>>>> DynamicEObjectImpl
>>>>> wrapper I was able to use EMF techniques to access the attribute I
>>>>> needed. so the computed column expression becomes:
>>>>>
>>>>> row["@self"].getObject().eContainer().dynamicGet(1);
>>>>>
>>>>> This returns the value of the Id attribute that I need.
>>>>>
>>>>> Thanks for all of your help in guiding me towards this result.
>>>>>
>>>>> Best regards,
>>>>>
>>>>> Nigel
>>>>>
>>>>>
>>>>> On 04/01/2012 09:42, Nigel Daniels wrote:
>>>>>> Hi John,
>>>>>>
>>>>>> I have tried multiple ways of calling the method I'd like to call
>>>>>> but I
>>>>>> don't think I'm getting back the object I expected. When I try to
>>>>>> call
>>>>>> the method using:
>>>>>>
>>>>>> row["@self"].getObject().eContainer().getId();
>>>>>>
>>>>>> I get the result:
>>>>>>
>>>>>> org.eclipse.birt.data.engine.core.DataException: Fail to compute
>>>>>> value
>>>>>> for computed column "ObjectiveObj".
>>>>>> A BIRT exception occurred. See next exception for more information.
>>>>>> There are errors evaluating script
>>>>>> "row["@self"].getObject().eContainer().getId();":
>>>>>> TypeError: Cannot find function getId in object
>>>>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@b500f60 (eClass:
>>>>>> org.eclipse.emf.ecore.impl.EClassImpl@474715d4 (name: Objective)
>>>>>> (instanceClassName: null) (abstract: false, interface: false)).
>>>>>> at
>>>>>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ....
>>>>>>
>>>>>>
>>>>>> I also tried the variations (a bit of a guess):
>>>>>>
>>>>>> row["@self"].getObject().eContainer().row["Id"];
>>>>>> and:
>>>>>> row["@self"].getObject().eContainer().column["Id"];
>>>>>>
>>>>>> with the result:
>>>>>>
>>>>>> org.eclipse.birt.data.engine.core.DataException: Fail to compute
>>>>>> value
>>>>>> for computed column "ObjectiveObj".
>>>>>> A BIRT exception occurred. See next exception for more information.
>>>>>> There are errors evaluating script
>>>>>> "row["@self"].getObject().eContainer().row["Id"];":
>>>>>> TypeError: Cannot read property "Id" from undefined
>>>>>> at
>>>>>> org.eclipse.birt.data.engine.impl.ComputedColumnHelper$ComputedColumnHelperInstance.process(ComputedColumnHelper.java:523)
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ....
>>>>>>
>>>>>>
>>>>>> Finally I tried (based on looking at the avaliable items in a
>>>>>> dataset):
>>>>>>
>>>>>> row["@self"].getObject().eContainer().Id;
>>>>>>
>>>>>> This returns the data set but the computed column is empty.
>>>>>>
>>>>>>
>>>>>> I suspect my last three attempts are in error but I thought I should
>>>>>> try
>>>>>> out any ideas and see if they worked out.
>>>>>>
>>>>>> The result from the first attempt seems to suggest that I am not
>>>>>> getting
>>>>>> back the expected object but that I have a DynamicEObjectImpl
>>>>>> instead.
>>>>>> When I look at the result for running:
>>>>>>
>>>>>> row["@self"].getObject().eContainer();
>>>>>>
>>>>>> It gives me a result like this for the computed column:
>>>>>>
>>>>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@51b5449f (eClass:
>>>>>> org.eclipse.emf.ecore.impl.EClassImpl@6433aa85 (name: Objective)
>>>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>>>>
>>>>>> In the attribute (name: Objective) I can see that it looks to contain
>>>>>> the Objective type I expect, but without the ability to type cast
>>>>>> this
>>>>>> to an Objective class I suspect I will not be able to access the
>>>>>> getId()
>>>>>> method. Do you have an example of how I should be doing this? It
>>>>>> would
>>>>>> be great to take a look in case there is a step I have failed to
>>>>>> do in
>>>>>> configuring my BIRT/EMF/ODA set-up?
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Nigel
>>>>>>
>>>>>>
>>>>>> On 31/12/2011 19:27, John E. Conlon wrote:
>>>>>>> HI Nigel,
>>>>>>>
>>>>>>> See inline comments.
>>>>>>>
>>>>>>> On 12/29/2011 08:04 AM, Nigel Daniels wrote:
>>>>>>>> Hi John,
>>>>>>>>
>>>>>>>> thanks for getting back to me so quickly :) I have given these
>>>>>>>> ideas a
>>>>>>>> go an I can get the container object as you suggested, so I'm a
>>>>>>>> good
>>>>>>>> part of the way there but I'm not sure I know how to use OCL
>>>>>>>> correctly
>>>>>>>> to get an objects id. Is there a way to cast the result then call
>>>>>>>> its
>>>>>>>> methods?
>>>>>>> Don't have to cast, its JavaScript! Just go ahead and use whatever
>>>>>>> method in the Interface for container object that allows you to get
>>>>>>> the id.
>>>>>>>
>>>>>>> Guess - is it
>>>>>>> getID()
>>>>>>>
>>>>>>>>
>>>>>>>> I've added some comments on what i tried and the results below:
>>>>>>>>
>>>>>>>> On 26/12/2011 19:28, John E. Conlon wrote:
>>>>>>>>> Nigel,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> See inline comments...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 12/26/2011 11:02 AM, Nigel Daniels wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I am new to using BIRT and I am trying to report on an EMF
>>>>>>>>>> model. I
>>>>>>>>>> have
>>>>>>>>>> set up an ODA connection to my EMF file and can report on
>>>>>>>>>> parts of
>>>>>>>>>> it.
>>>>>>>>> Are you using the newest org.eclipse.emf.oda.ecore driver?
>>>>>>>>>
>>>>>>>>>> What I would like to do is create a report that looks a bit like
>>>>>>>>>> the
>>>>>>>>>> EMF
>>>>>>>>>> tree view of my information. The model structure is :
>>>>>>>>>>
>>>>>>>>>> A Project --- contains ---> Objectives --- contain ---> Issues
>>>>>>>>>>
>>>>>>>>>> All of these elements have the string attributes, id, name and
>>>>>>>>>> description.
>>>>>>>>>>
>>>>>>>>>> I can create OCL queries based on the Project context :
>>>>>>>>>>
>>>>>>>>>> self.objectives
>>>>>>>>>>
>>>>>>>>>> to see all of the Objectives, then :
>>>>>>>>>>
>>>>>>>>>> self.objectives.issues
>>>>>>>>>>
>>>>>>>>>> to view all of the Issues, or even :
>>>>>>>>>>
>>>>>>>>>> self.objectives->select(id='O1').issues
>>>>>>>>>>
>>>>>>>>>> to see the Issues belonging to the Objective with the id 'O1'. Is
>>>>>>>>>> there
>>>>>>>>>> anyway to nest a series of OCL quieries so that I could see
>>>>>>>>>> each of
>>>>>>>>>> the
>>>>>>>>>> objectives then their associated issues in one report.
>>>>>>>>>>
>>>>>>>>>> Unlike a relational database the relationship is a feature of the
>>>>>>>>>> file
>>>>>>>>>> structure in the EMF file rather than using index relationships.
>>>>>>>>>> Because
>>>>>>>>>> of this I have not found a way of making join querys work as
>>>>>>>>>> there
>>>>>>>>>> is no
>>>>>>>>>> field to join on.
>>>>>>>>> Right the brute force approach is to create three datasets:
>>>>>>>>> Projects, Objectives, and Issues; then create a fourth Joint
>>>>>>>>> DataSet to
>>>>>>>>> join Projects and Objectives and a fifth to join the Issues to the
>>>>>>>>> Joint
>>>>>>>>> Projects and Objects BUT... as you say there is no index just a
>>>>>>>>> containment. Plus (even if it would work) this is ugly.
>>>>>>>>
>>>>>>>> I agree that this approach would be a bit ugly and may not scale
>>>>>>>> well,
>>>>>>>> even if the EMF structure allowed for it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> But remember all EObjects do have an
>>>>>>>>> public EObject eContainer()
>>>>>>>>> method.
>>>>>>>>
>>>>>>>> Ah-ha! I did not ralise I could access this.
>>>>>>>
>>>>>>> Yes, any method on your object instance should work.
>>>>>>>
>>>>>>>>>
>>>>>>>>> So you might try...
>>>>>>>>> Creating a single dataset on all the Issues. Then add 6 computed
>>>>>>>>> columns; 3 for Objective id, name and description; and 3 for
>>>>>>>>> Project
>>>>>>>>> id,
>>>>>>>>> name and description.
>>>>>>>>
>>>>>>>> So I gave getting hold of an Objectives Id attribute via an Issue
>>>>>>>> dataset query. The query uses the Project as the context and
>>>>>>>> returns an
>>>>>>>> Issue type, the query is:
>>>>>>>>
>>>>>>>> self.objectives.issues
>>>>>>> Looks good
>>>>>>>>
>>>>>>>>>
>>>>>>>>> In the computed columns of your Dataset use a function like
>>>>>>>>> @self.getObject().eContainer() to move upward in the hierarchy to
>>>>>>>>> get
>>>>>>>>> the Objective then in a similar fashion
>>>>>>>>> @self.getObject().eContainer().eContainer() to get the Project.
>>>>>>>>> Once
>>>>>>>>> you
>>>>>>>>> are at the object you can get the values for id, name and
>>>>>>>>> description.
>>>>>>>>>
>>>>>>>>
>>>>>>>> I then added a computed column called ObjectiveObj :
>>>>>>>>
>>>>>>>> row["@self"].getObject().eContainer()
>>>>>>>
>>>>>>> Rather call it ObjectID
>>>>>>> and
>>>>>>>
>>>>>>> row["@self"].getObject().eContainer().getID();
>>>>>>>
>>>>>>> (The data type for the computed column would be a string, unless
>>>>>>> that is
>>>>>>> of course you have a number type for the ID in your EMF model.
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Your dataset can be now used in a BIRT table where you can
>>>>>>>>> group on
>>>>>>>>> the
>>>>>>>>> Project and sub group on Objective. This last subgroup will
>>>>>>>>> include
>>>>>>>>> the
>>>>>>>>> Issues in the details row.
>>>>>>>>
>>>>>>>> This gives me the following sorts of results :
>>>>>>>>
>>>>>>>> Description: Test issue 1
>>>>>>>> Id: O1.1
>>>>>>>> ObjectiveObj:
>>>>>>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@59ae5a16
>>>>>>>> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@38bf7b8 (name:
>>>>>>>> Objective)
>>>>>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>>>>>>
>>>>>>>> It looks like I have the object reference to the containing
>>>>>>>> Objective
>>>>>>>> object, but I'm not sure how I then cast this to an instance of
>>>>>>>> Objective to access it's getId() method?
>>>>>>>
>>>>>>> Again no cast needed - Just go for it and call a method.
>>>>>>>
>>>>>>> cheers,
>>>>>>> John
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
Previous Topic:Parameter in sequence
Next Topic:CSV export in BIRT 2.1.1 performs unwanted data formatting
Goto Forum:
  


Current Time: Fri Apr 26 21:34:19 GMT 2024

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

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

Back to the top