Home » Modeling » EMF » Bug ? Resolving Ecore Cross References
|
Re: Bug ? Resolving Ecore Cross References [message #950063 is a reply to message #949932] |
Fri, 19 October 2012 15:48 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Florian,
Comments below.
On 19/10/2012 3:00 PM, Florian B. wrote:
> Hi folks, I already posted this issue in the Ecore tool forum, but I
> think the topic is related to the forum better.
> I have a problem concerning the resolving of ecore cross references.
>
> In my model I have cross references from entities to the same entity
> in a different file.
> In my ecore model the reference's upper bound is set to unbounded and
> the lower bound is set to 1.
> The problem is, when the XML are parsed and I want to access the
> referenced objects in foo as single entities, these objects (in my
> case "ports") are null. It seems the factory returns just new objects
> of the types.
Or they're unresolved proxies?
>
> <foo>
> <refPort>bar_test.bar_specification#//@devices/@device[name='testDevice1']/@port[name='TestDevice1Port']</refPort>
>
> <refPort>bar_test.bar_specification#//@devices/@device[name='testDevice2']/@port[name='TestDevice2Port']</refPort>
>
Is this referenced file in the same folder as the file that contains the
above reference?
> </foo>
>
>
> The weird thing is, the references seems to be resolved, if only one
> referenced object is defined in the XML document as attribute of foo,
> like the following example.
> <foo
> refport="bar_test.bar_specification#//@devices/@device[name='testDevice1']/@port[name='TestDevice1Port']"
> />
>
>
> Maybe some properties are wrong in the .ecore ?
Maybe, but since you don't show the Ecore, who's to know? After
parsing, does the getRefPort list contain more than one element?
> Thx again,
>
> Florian
> EDIT1:
> I also tried to resolve the references with the static method
> EcoreUtil.resolveAll()
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Bug ? Resolving Ecore Cross References [message #950089 is a reply to message #950063] |
Fri, 19 October 2012 16:23 |
Florian B. Messages: 21 Registered: July 2012 Location: Hamburg Germany |
Junior Member |
|
|
Hi Ed,
Quote:> Hi folks, I already posted this issue in the Ecore tool forum, but I
> think the topic is related to the forum better.
> I have a problem concerning the resolving of ecore cross references.
>
> In my model I have cross references from entities to the same entity
> in a different file.
> In my ecore model the reference's upper bound is set to unbounded and
> the lower bound is set to 1.
> The problem is, when the XML are parsed and I want to access the
> referenced objects in foo as single entities, these objects (in my
> case "ports") are null. It seems the factory returns just new objects
> of the types.
Or they're unresolved proxies?
Well, I get the amount of objects in the EList, when I call getRefPorts in foo.
But all theses objects seems to be genereated by the default values defined in the ecore.
Quote:
> <foo>
> <refPort>bar_test.bar_specification#//@devices/@device[name='testDevice1']/@port[name='TestDevice1Port']</refPort>
>
> <refPort>bar_test.bar_specification#//@devices/@device[name='testDevice2']/@port[name='TestDevice2Port']</refPort>
>
Is this referenced file in the same folder as the file that contains the
above reference?
Yes, they are.
How should I provide you the .ecore? As text, or screenshot? I don't know whats easier for you...
Thank you very much for your help,
Florian
|
|
|
Re: Bug ? Resolving Ecore Cross References [message #950106 is a reply to message #950089] |
Fri, 19 October 2012 16:36 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Florian,
Comments below.
On 19/10/2012 6:23 PM, Florian B. wrote:
> Hi Ed, Quote:
>> > Hi folks, I already posted this issue in the Ecore tool forum, but
>> I > think the topic is related to the forum better.
>> > I have a problem concerning the resolving of ecore cross references.
>> >
>> > In my model I have cross references from entities to the same
>> entity > in a different file.
>> > In my ecore model the reference's upper bound is set to unbounded
>> and > the lower bound is set to 1.
>> > The problem is, when the XML are parsed and I want to access the >
>> referenced objects in foo as single entities, these objects (in my >
>> case "ports") are null. It seems the factory returns just new objects
>> > of the types.
>> Or they're unresolved proxies?
>
> Well, I get the amount of objects in the EList, when I call
> getRefPorts in foo. But all theses objects seems to be genereated by
> the default values defined in the ecore.
So no doubt they're unresolved proxies. I.e., I'm sure eIsProxy is true
for these objects. What's their proxy URI; you can see that in the
debugger.
>
> Quote:
>> > <foo>
>> >
>> <refPort>bar_test.bar_specification#//@devices/@device[name='testDevice1']/@port[name='TestDevice1Port']</refPort>
>> >
>> >
>> <refPort>bar_test.bar_specification#//@devices/@device[name='testDevice2']/@port[name='TestDevice2Port']</refPort>
>> >
>> Is this referenced file in the same folder as the file that contains
>> the above reference?
>
> Yes, they are.
And did you load the resource containing these references with an
absolute URI?
> How should I provide you the .ecore? As text, or screenshot? I don't
> know whats easier for you...
>
> Thank you very much for your help,
>
> Florian
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: Bug ? Resolving Ecore Cross References [message #953764 is a reply to message #953724] |
Mon, 22 October 2012 14:09 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Florian,
Comments below.
On 22/10/2012 3:38 PM, Florian B. wrote:
> Hi Ed, Quote:
>> So no doubt they're unresolved proxies. I.e., I'm sure eIsProxy is
>> true for these objects. What's their proxy URI; you can see that in
>> the debugger.
>
> I did the test and eIsProxy() returns false
For which objects? The ones that apparently have no values populated?
If they resolved, then whatever they've resolved to have no populated
values...
> I cannot see any URI in the debugger... shall they be located in the
> eProperties?
Yes.
> In my case this is null as well...
> Quote:
>> And did you load the resource containing these references with an
>> absolute URI?
>
> I didn't load the resource explicetely.
You must of loaded some initial resource to get this all started. After
all, a resource set will be empty until you do something explicit to
load something.
> I thought, the reference would be resolved as runtime, if I just
> access the referenced objects.
Yes, but as I said, the initial resource must be loaded explicitly.
> Other references in my model seem to be resolved perfectly because I
> can access other objects defined in this file containing ports without
> problems.
> Thanks again
So either they're unresolved proxies, or they've resolved to objects
that really don't have any specified value. What can I say about that?
You have all the resources in your resource set. With the debugger you
can determine all the contents of all those resources. That will answer
questions better than my guesses...
>
> Flo
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Bug ? Resolving Ecore Cross References [message #953835 is a reply to message #953764] |
Mon, 22 October 2012 15:16 |
Florian B. Messages: 21 Registered: July 2012 Location: Hamburg Germany |
Junior Member |
|
|
Hi Ed,
Quote:> I did the test and eIsProxy() returns false
For which objects? The ones that apparently have no values populated?
If they resolved, then whatever they've resolved to have no populated
values...
Yes, when you look at my example the values of refPort are null... and the test whether the refPort is proxy is false.
Quote:> I didn't load the resource explicetely.
You must of loaded some initial resource to get this all started. After
all, a resource set will be empty until you do something explicit to
load something.
Yes sure, I loaded the "main initial file" and in the debugger, I can see all other resources in the resource set.
So no problem at this point. I figured out in the debugger all of the referenced resources will be loaded and the URI of these files are correct, too.
Now i went in the debugger to the loaded resource which contains the refPort in the resourceset and got to the refPort.
If it is defined as an attribute of the containing object, like in the 2nd example in my first post, all attributes of the port are resolved and are correct.
Also the eProperties has a value (eProperties BasicEObjectImpl$EPropertiesHolderImpl (id=1969) <-- in my case )
these are the values of properties:
eClass = null
eContents = EContentsList {eObject = PortImpl}
eCrossReference = null
eProxyURI = null
eResource = null
eSettings = null
but in the first case when refPort is defined as an xml-entity of the containing object (see example 1 )
eProperties is null
and the values are like the default value literals defined in the ecore for the objects of Port....
|
|
|
Re: Bug ? Resolving Ecore Cross References [message #954215 is a reply to message #953835] |
Mon, 22 October 2012 21:42 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Florian,
Comments below.
On 22/10/2012 5:16 PM, Florian B. wrote:
> Hi Ed,
> Quote:
>> > I did the test and eIsProxy() returns false
>> For which objects? The ones that apparently have no values populated?
>> If they resolved, then whatever they've resolved to have no populated
>> values...
>
> Yes, when you look at my example the values of refPort are null... and
> the test whether the refPort is proxy is false.
> Quote:
>> > I didn't load the resource explicetely.
>> You must of loaded some initial resource to get this all started.
>> After all, a resource set will be empty until you do something
>> explicit to load something.
>
>
> Yes sure, I loaded the "main initial file" and in the debugger, I can
> see all other resources in the resource set. So no problem at this
> point. I figured out in the debugger all of the referenced resources
> will be loaded and the URI of these files are correct, too.
>
> Now i went in the debugger to the loaded resource which contains the
> refPort in the resourceset and got to the refPort.
> If it is defined as an attribute of the containing object, like in the
> 2nd example in my first post, all attributes of the port are resolved
> and are correct.
Keep in mind that attributes are not resolved. The reference itself is
resolved. So you're saying in the first example they resolve, but the
object they resolve to has no values for the attributes. So the
question is, what are they resolving too? Why doesn't that object have
any values? You say it's not a proxy, so it must have an eContainer()
that's not null, or an eResource() that's not null. I can't say why that
object has not values for the attributes but that's a problem with the
resolved object and you've told me nothing about that object. You've
only told me that the reference is properly resolve...
> Also the eProperties has a value (eProperties
> BasicEObjectImpl$EPropertiesHolderImpl (id=1969) <-- in my case )
> these are the values of properties:
> eClass = null
> eContents = EContentsList {eObject = PortImpl}
> eCrossReference = null
> eProxyURI = null
> eResource = null
> eSettings = null
> but in the first case when refPort is defined as an xml-entity of the
> containing object (see example 1 )
> eProperties is null and the values are like the default value literals
> defined in the ecore for the objects of Port....
So follow the eContainer references to figure out what resource it's
contained. Should the object in that resource really have values for
the attributes?
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: Bug ? Resolving Ecore Cross References [message #955196 is a reply to message #954922] |
Tue, 23 October 2012 15:45 |
|
Hi, Florian,
I think your XML is telling EMF to create a Port instance that has no
attributes.
To tell EMF that you are referencing an existing Port instance defined
elsewhere, you need an href or an idref attribute in your <refPort>
element. Try something like this:
<tool>
<schedule>
<refPort
href="System_test.system#//@devices/@device[name='testDevice1']/@port[name='TestDevice1Port']"
/>
</schedule>
</tool>
HTH,
Christian
On 2012-10-23 11:07:29 +0000, Florian B. said:
> Hi Ed,
> what should I say to make my problem more clear??? I'll try it now by
> giving more information about my model: I have several single ecore
> models (Configuration, System, Tool) that describe any system. All of
> these models have their own XML-Instance.
> One model called "System" has an object "Device" with the "Port" object
> defined in it. The "Port" has several attributes like speed i.e.
> Another model called "Tool" has an object "Schedule" with the "refPort"
> as EType of "Port" as attribute. This "refPort" has no upper bound and
> the lower bound is 1. The "System" model has other objects too, that
> have a reference to the defined "Port" in an "Device".
> The main or initial model "Configuration" has references to the
> "System" and the "Tool" model.
>
> Now again to my specific problem:
> I load an XML-instance of the "Configuration" and all other resources
> are present in the resourceSet. Which is fine and I can access the
> "System" and also the the "Tool".
>
> Now I want to access the refPort inside my "Tool" model. There are two
> possibilities now I figured out. One possibility works and resolves the
> reference of the "refPort" to the "Port" and another will not work.
> Here is the first example which works: The refPort is set as
> xml-attribute of "Schedules"
> <?xml ...>
> <tool>
> <schedule
>
> refPort="System_test.system#//@devices/@device[name='testDevice1']/@port[name='TestDevice1Port']">
>
> ... some other objects of Schedule
> </schedule>
> .... some other objects of Tool
> </tool>
>
> When I use the debugger, I can see attributes of eProperties and eContainer.
> The attributes of eProperties are:
> eClass = null
> eContents = EContentsList {eObject = PortImpl}
> eCrossReference = null
> eProxyURI = null
> eResource = null
> eSettings = null
> And the attributes of eContainer:
> DeviceImpl with all their containing attributes.
>
> The problem with this XML-Instance is, it is not possible to model more
> than one "refPort" inside the "Schedule" of "Tool" since in xml
> attributes are allowed only once...
>
> When I want to model more than on refPort I need to specify this in the
> xml via dedicated entities of "refPort". The next example code of an
> XML-instance of "Tool" will not work.
>
>
> <?xml ...>
> <tool>
> <schedule>
>
> <refPort>System_test.system#//@devices/@device[name='testDevice1']/@port[name='TestDevice1Port']</refPort>
>
> .... some other objects of Schedule
> </schedule>
> .... some other objects tool
> </tool>
>
> You see the reference to the "Port" object has not changed inside the
> XML, just the way it is specified. Now eContainer is null as well as
> eProperties and the values of the refPort are the default values
> defined in the .ecore model.
> As you can see in the upper and lower bounds of refPort, I need more
> then one refPort inside the "Schedule".
> What is going on here Ed?
|
|
| | | | | | | | | |
Goto Forum:
Current Time: Thu Sep 26 15:17:56 GMT 2024
Powered by FUDForum. Page generated in 0.06087 seconds
|