Home » Modeling » EMF » Duplicates in EList
Duplicates in EList [message #416168] |
Mon, 21 January 2008 08:04 |
Ian Bull Messages: 145 Registered: July 2009 |
Senior Member |
|
|
I have a pretty large emf model (about 40,000 EObjects) representing 87
years of NHL statistics. (It's not a crystal ball, but it does tell me
that the leafs are not winning this year) :-)
But that's not the point...
The data originally came from generated EMF, but I have tried loading it
using dynamic EMF and it works fine. I even did a test, I grabbed Wayne
Gretzky's Player object, got the feature that represented his stats, and
got the size of this list, 20... good, he played for 20 years.
However, when I use the following load options:
loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new
XMLParserPoolImpl());
and I run the same query (nothing else in the program changed) it tells
me that Wayne played for 40 years. The EList of stats attached to the
Wayne's player object has 40 elements in it. Looking at the object
ID's, it seems to have just put the same set of 20 objects in the list
twice, such as
[1,2,3,....,19,20,1,2,3,...19,20]
I first noticed this using ALT, but it seems to be a dynamic EMF thing.
Thoughts?
Cheers,
Ian
|
|
|
Re: Duplicates in EList [message #416173 is a reply to message #416168] |
Mon, 21 January 2008 13:14 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------090604060604090406020505
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Ian,
I think I'd need to see it reproduced in a test case. The effect of
this option is
if
(Boolean.TRUE.equals(options.get(XMLResource.OPTION_DEFER_ID REF_RESOLUTION)))
{
helper.setCheckForDuplicates(deferIDREFResolution = true);
}
It forces all references to be treated as forward references and it
should cause the helper to check for duplicates before adding to the
list; look for where the checkForDuplicates is used in XMLHelperImpl.
Ian Bull wrote:
> I have a pretty large emf model (about 40,000 EObjects) representing
> 87 years of NHL statistics. (It's not a crystal ball, but it does tell
> me that the leafs are not winning this year) :-)
>
> But that's not the point...
>
> The data originally came from generated EMF, but I have tried loading
> it using dynamic EMF and it works fine. I even did a test, I grabbed
> Wayne Gretzky's Player object, got the feature that represented his
> stats, and got the size of this list, 20... good, he played for 20 years.
>
> However, when I use the following load options:
>
> loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
> loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new
> XMLParserPoolImpl());
>
> and I run the same query (nothing else in the program changed) it
> tells me that Wayne played for 40 years. The EList of stats attached
> to the Wayne's player object has 40 elements in it. Looking at the
> object ID's, it seems to have just put the same set of 20 objects in
> the list twice, such as
>
> [1,2,3,....,19,20,1,2,3,...19,20]
>
> I first noticed this using ALT, but it seems to be a dynamic EMF thing.
>
> Thoughts?
>
> Cheers,
> Ian
--------------090604060604090406020505
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ian,<br>
<br>
I think I'd need to see it reproduced in a test case. The effect of
this option is<br>
<br>
<small> if
(Boolean.TRUE.equals(options.get(XMLResource.OPTION_DEFER_ID REF_RESOLUTION))) <br>
{<br>
helper.setCheckForDuplicates(deferIDREFResolution = true);<br>
}</small><br>
<br>
It forces all references to be treated as forward references and it
should cause the helper to check for duplicates before adding to the
list; look for where the checkForDuplicates is used in XMLHelperImpl.<br>
<br>
<br>
Ian Bull wrote:
<blockquote cite="mid:fn1jlo$4ma$1@build.eclipse.org" type="cite">I
have a pretty large emf model (about 40,000 EObjects) representing 87
years of NHL statistics. (It's not a crystal ball, but it does tell me
that the leafs are not winning this year) :-)
<br>
<br>
But that's not the point...
<br>
<br>
The data originally came from generated EMF, but I have tried loading
it using dynamic EMF and it works fine. I even did a test, I grabbed
Wayne Gretzky's Player object, got the feature that represented his
stats, and got the size of this list, 20... good, he played for 20
years.
<br>
<br>
However, when I use the following load options:
<br>
<br>
loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,
Boolean.TRUE);
<br>
loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new
XMLParserPoolImpl());
<br>
<br>
and I run the same query (nothing else in the program changed) it tells
me that Wayne played for 40 years. The EList of stats attached to the
Wayne's player object has 40 elements in it. Looking at the object
ID's, it seems to have just put the same set of 20 objects in the list
twice, such as
<br>
<br>
[1,2,3,....,19,20,1,2,3,...19,20]
<br>
<br>
I first noticed this using ALT, but it seems to be a dynamic EMF thing.
<br>
<br>
Thoughts?
<br>
<br>
Cheers,
<br>
Ian
<br>
</blockquote>
<br>
</body>
</html>
--------------090604060604090406020505--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Duplicates in EList [message #416185 is a reply to message #416173] |
Mon, 21 January 2008 15:47 |
Ian Bull Messages: 145 Registered: July 2009 |
Senior Member |
|
|
I can post a test case. I'm not sure if you guys have the data or not,
at one point I think I contributed to the model for a test case, but I
can't remember.
Although, it sounds like the check for duplicates might be it, since I
am getting duplicates when I turn on the defer resolution. Is this
something that I'm supposed to do? Or is this XML Helper used internal
by EMF. I put a breakpoint, and it doesn't seem to be getting called.
Actually, the only place that setCheckForDuplicates is, is in
saveString, which doesn't get called. Should this be in setOptions?
I have posted the test case below, the test cases prompts the user for
an ecore file, then another file. Both are loaded, and then I traverse
the list to check for the duplicates. Up top, I set the load options.
I can post the ecore file and hockeydb file if it is not in a test case
somewhere.
Thanks,
Ian
import java.util.Map;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMIHelperImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
public class Tester {
/**
* @param args
*/
public static void main(String[] args) {
Display d = new Display();
Shell shell = new Shell(d);
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterNames(new String[] { "Ecore Files", "All Files (*.*)" });
dialog.setFilterExtensions(new String[] { "*.ecore", "*.*" }); // Windows
dialog.setFilterPath("c:\\"); // Windows path
String ecoreFilePath = dialog.open();
ResourceSet resourceSet = new ResourceSetImpl();
Map loadOptions = resourceSet.getLoadOptions();
if ( true ) {
loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new
XMLParserPoolImpl());
}
resourceSet.getPackageRegistry().put(EcorePackage.eINSTANCE. getNsURI(),
EcorePackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "*",
new XMIResourceFactoryImpl());
URI fileURIMM = URI.createFileURI(ecoreFilePath);
Resource resourceMM = resourceSet.getResource(fileURIMM, true);
EPackage ePackage = (EPackage) resourceMM.getContents().get(0);
resourceSet.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterNames(new String[] { "Ecore Files", "All Files (*.*)" });
dialog.setFilterExtensions(new String[] { "*.hockeydb", "*.*" }); //
Windows
dialog.setFilterPath("c:\\"); // Windows path
String hockeydbPath = dialog.open();
URI fileURI = URI.createFileURI(hockeydbPath);
Resource resource = resourceSet.getResource(fileURI, true);
XMIHelperImpl helper = new XMIHelperImpl();
EList<EObject>contents =resource.getContents();
for (EObject object : contents) {
if ( object.eClass().getName().equals("PlayerList") ) {
EStructuralFeature structuralFeature =
object.eClass().getEStructuralFeature("players");
EList<EObject> list = (EList<EObject>) object.eGet(structuralFeature);
for (EObject player : list) {
EStructuralFeature name =
player.eClass().getEStructuralFeature("name");
if ( player.eGet(name).equals("Wayne Gretzky") ) {
EStructuralFeature yearlyStats =
player.eClass().getEStructuralFeature("yearlyStats");
Object stats = player.eGet(yearlyStats);
EList<EObject> playerStats = (EList<EObject>) stats;
// There are 20 elements in this list, but with the load option
set, I get 40
System.out.println(playerStats.size());
}
}
}
}
}
}
Ed Merks wrote:
> Ian,
>
> I think I'd need to see it reproduced in a test case. The effect of
> this option is
>
> if
> (Boolean.TRUE.equals(options.get(XMLResource.OPTION_DEFER_ID REF_RESOLUTION)))
> {
> helper.setCheckForDuplicates(deferIDREFResolution = true);
> }
>
> It forces all references to be treated as forward references and it
> should cause the helper to check for duplicates before adding to the
> list; look for where the checkForDuplicates is used in XMLHelperImpl.
>
>
> Ian Bull wrote:
>> I have a pretty large emf model (about 40,000 EObjects) representing
>> 87 years of NHL statistics. (It's not a crystal ball, but it does tell
>> me that the leafs are not winning this year) :-)
>>
>> But that's not the point...
>>
>> The data originally came from generated EMF, but I have tried loading
>> it using dynamic EMF and it works fine. I even did a test, I grabbed
>> Wayne Gretzky's Player object, got the feature that represented his
>> stats, and got the size of this list, 20... good, he played for 20 years.
>>
>> However, when I use the following load options:
>>
>> loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
>> loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new
>> XMLParserPoolImpl());
>>
>> and I run the same query (nothing else in the program changed) it
>> tells me that Wayne played for 40 years. The EList of stats attached
>> to the Wayne's player object has 40 elements in it. Looking at the
>> object ID's, it seems to have just put the same set of 20 objects in
>> the list twice, such as
>>
>> [1,2,3,....,19,20,1,2,3,...19,20]
>>
>> I first noticed this using ALT, but it seems to be a dynamic EMF thing.
>>
>> Thoughts?
>>
>> Cheers,
>> Ian
>
|
|
|
Re: Duplicates in EList [message #416188 is a reply to message #416185] |
Mon, 21 January 2008 16:04 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Ian,
It should work perfectly. The option is checked in the handler as well,
and it sets the flag for the helper. I cant find the data on my
machine... Maybe just assume it's a bug and open a bugzilla with
attachments...
Ian Bull wrote:
> I can post a test case. I'm not sure if you guys have the data or
> not, at one point I think I contributed to the model for a test case,
> but I can't remember.
>
> Although, it sounds like the check for duplicates might be it, since I
> am getting duplicates when I turn on the defer resolution. Is this
> something that I'm supposed to do? Or is this XML Helper used internal
> by EMF. I put a breakpoint, and it doesn't seem to be getting called.
>
> Actually, the only place that setCheckForDuplicates is, is in
> saveString, which doesn't get called. Should this be in setOptions?
>
>
> I have posted the test case below, the test cases prompts the user for
> an ecore file, then another file. Both are loaded, and then I traverse
> the list to check for the duplicates. Up top, I set the load options.
>
> I can post the ecore file and hockeydb file if it is not in a test
> case somewhere.
>
> Thanks,
> Ian
>
>
> import java.util.Map;
>
> import org.eclipse.emf.common.util.EList;
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.emf.ecore.EcorePackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.xmi.XMLResource;
> import org.eclipse.emf.ecore.xmi.impl.XMIHelperImpl;
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
> import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.FileDialog;
> import org.eclipse.swt.widgets.Shell;
>
>
> public class Tester {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> Display d = new Display();
> Shell shell = new Shell(d);
>
> FileDialog dialog = new FileDialog(shell, SWT.OPEN);
> dialog.setFilterNames(new String[] { "Ecore Files", "All Files
> (*.*)" });
> dialog.setFilterExtensions(new String[] { "*.ecore", "*.*" });
> // Windows
> dialog.setFilterPath("c:\\"); // Windows path
>
> String ecoreFilePath = dialog.open();
>
>
> ResourceSet resourceSet = new ResourceSetImpl();
> Map loadOptions = resourceSet.getLoadOptions();
> if ( true ) {
> loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,
> Boolean.TRUE);
> loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new
> XMLParserPoolImpl());
> }
>
>
> resourceSet.getPackageRegistry().put(EcorePackage.eINSTANCE. getNsURI(),
> EcorePackage.eINSTANCE);
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "*",
> new XMIResourceFactoryImpl());
> URI fileURIMM = URI.createFileURI(ecoreFilePath);
> Resource resourceMM = resourceSet.getResource(fileURIMM, true);
>
> EPackage ePackage = (EPackage) resourceMM.getContents().get(0);
>
> resourceSet.getPackageRegistry().put(ePackage.getNsURI(),
> ePackage);
>
> dialog = new FileDialog(shell, SWT.OPEN);
> dialog.setFilterNames(new String[] { "Ecore Files", "All Files
> (*.*)" });
> dialog.setFilterExtensions(new String[] { "*.hockeydb", "*.*"
> }); // Windows
> dialog.setFilterPath("c:\\"); // Windows path
>
> String hockeydbPath = dialog.open();
>
> URI fileURI = URI.createFileURI(hockeydbPath);
> Resource resource = resourceSet.getResource(fileURI, true);
> XMIHelperImpl helper = new XMIHelperImpl();
>
>
> EList<EObject>contents =resource.getContents();
>
>
> for (EObject object : contents) {
> if ( object.eClass().getName().equals("PlayerList") ) {
> EStructuralFeature structuralFeature =
> object.eClass().getEStructuralFeature("players");
> EList<EObject> list = (EList<EObject>)
> object.eGet(structuralFeature);
> for (EObject player : list) {
> EStructuralFeature name =
> player.eClass().getEStructuralFeature("name");
> if ( player.eGet(name).equals("Wayne Gretzky") ) {
> EStructuralFeature yearlyStats =
> player.eClass().getEStructuralFeature("yearlyStats");
> Object stats = player.eGet(yearlyStats);
> EList<EObject> playerStats = (EList<EObject>)
> stats;
> // There are 20 elements in this list, but
> with the load option set, I get 40
> System.out.println(playerStats.size());
> }
> }
> }
> }
>
> }
>
> }
>
>
> Ed Merks wrote:
>> Ian,
>>
>> I think I'd need to see it reproduced in a test case. The effect of
>> this option is
>>
>> if
>> (Boolean.TRUE.equals(options.get(XMLResource.OPTION_DEFER_ID REF_RESOLUTION)))
>>
>> {
>> helper.setCheckForDuplicates(deferIDREFResolution = true);
>> }
>>
>> It forces all references to be treated as forward references and it
>> should cause the helper to check for duplicates before adding to the
>> list; look for where the checkForDuplicates is used in XMLHelperImpl.
>>
>>
>> Ian Bull wrote:
>>> I have a pretty large emf model (about 40,000 EObjects) representing
>>> 87 years of NHL statistics. (It's not a crystal ball, but it does
>>> tell me that the leafs are not winning this year) :-)
>>>
>>> But that's not the point...
>>>
>>> The data originally came from generated EMF, but I have tried
>>> loading it using dynamic EMF and it works fine. I even did a test,
>>> I grabbed Wayne Gretzky's Player object, got the feature that
>>> represented his stats, and got the size of this list, 20... good, he
>>> played for 20 years.
>>>
>>> However, when I use the following load options:
>>>
>>> loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,
>>> Boolean.TRUE);
>>> loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new
>>> XMLParserPoolImpl());
>>>
>>> and I run the same query (nothing else in the program changed) it
>>> tells me that Wayne played for 40 years. The EList of stats
>>> attached to the Wayne's player object has 40 elements in it.
>>> Looking at the object ID's, it seems to have just put the same set
>>> of 20 objects in the list twice, such as
>>>
>>> [1,2,3,....,19,20,1,2,3,...19,20]
>>>
>>> I first noticed this using ALT, but it seems to be a dynamic EMF thing.
>>>
>>> Thoughts?
>>>
>>> Cheers,
>>> Ian
>>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Duplicates in EList [message #416202 is a reply to message #416188] |
Tue, 22 January 2008 05:13 |
Ian Bull Messages: 145 Registered: July 2009 |
Senior Member |
|
|
Just posting the link to the bug report for future reference:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=216009
thanks Ed,
ian
Ed Merks wrote:
> Ian,
>
> It should work perfectly. The option is checked in the handler as well,
> and it sets the flag for the helper. I cant find the data on my
> machine... Maybe just assume it's a bug and open a bugzilla with
> attachments...
>
>
> Ian Bull wrote:
>> I can post a test case. I'm not sure if you guys have the data or
>> not, at one point I think I contributed to the model for a test case,
>> but I can't remember.
>>
>> Although, it sounds like the check for duplicates might be it, since I
>> am getting duplicates when I turn on the defer resolution. Is this
>> something that I'm supposed to do? Or is this XML Helper used internal
>> by EMF. I put a breakpoint, and it doesn't seem to be getting called.
>>
>> Actually, the only place that setCheckForDuplicates is, is in
>> saveString, which doesn't get called. Should this be in setOptions?
>>
>>
>> I have posted the test case below, the test cases prompts the user for
>> an ecore file, then another file. Both are loaded, and then I traverse
>> the list to check for the duplicates. Up top, I set the load options.
>>
>> I can post the ecore file and hockeydb file if it is not in a test
>> case somewhere.
>>
>> Thanks,
>> Ian
>>
>>
>> import java.util.Map;
>>
>> import org.eclipse.emf.common.util.EList;
>> import org.eclipse.emf.common.util.URI;
>> import org.eclipse.emf.ecore.EObject;
>> import org.eclipse.emf.ecore.EPackage;
>> import org.eclipse.emf.ecore.EStructuralFeature;
>> import org.eclipse.emf.ecore.EcorePackage;
>> import org.eclipse.emf.ecore.resource.Resource;
>> import org.eclipse.emf.ecore.resource.ResourceSet;
>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>> import org.eclipse.emf.ecore.xmi.XMLResource;
>> import org.eclipse.emf.ecore.xmi.impl.XMIHelperImpl;
>> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
>> import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl;
>> import org.eclipse.swt.SWT;
>> import org.eclipse.swt.widgets.Display;
>> import org.eclipse.swt.widgets.FileDialog;
>> import org.eclipse.swt.widgets.Shell;
>>
>>
>> public class Tester {
>>
>> /**
>> * @param args
>> */
>> public static void main(String[] args) {
>> Display d = new Display();
>> Shell shell = new Shell(d);
>> FileDialog dialog = new FileDialog(shell, SWT.OPEN);
>> dialog.setFilterNames(new String[] { "Ecore Files", "All Files
>> (*.*)" });
>> dialog.setFilterExtensions(new String[] { "*.ecore", "*.*" });
>> // Windows
>> dialog.setFilterPath("c:\\"); // Windows path
>> String ecoreFilePath = dialog.open();
>>
>> ResourceSet resourceSet = new ResourceSetImpl();
>> Map loadOptions = resourceSet.getLoadOptions();
>> if ( true ) {
>> loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,
>> Boolean.TRUE);
>> loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new
>> XMLParserPoolImpl());
>> }
>>
>>
>> resourceSet.getPackageRegistry().put(EcorePackage.eINSTANCE. getNsURI(),
>> EcorePackage.eINSTANCE);
>>
>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "*",
>> new XMIResourceFactoryImpl());
>> URI fileURIMM = URI.createFileURI(ecoreFilePath);
>> Resource resourceMM = resourceSet.getResource(fileURIMM, true);
>> EPackage ePackage = (EPackage)
>> resourceMM.getContents().get(0);
>>
>> resourceSet.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
>> dialog = new FileDialog(shell, SWT.OPEN);
>> dialog.setFilterNames(new String[] { "Ecore Files", "All Files
>> (*.*)" });
>> dialog.setFilterExtensions(new String[] { "*.hockeydb", "*.*"
>> }); // Windows
>> dialog.setFilterPath("c:\\"); // Windows path
>> String hockeydbPath = dialog.open();
>> URI fileURI = URI.createFileURI(hockeydbPath);
>> Resource resource = resourceSet.getResource(fileURI, true);
>> XMIHelperImpl helper = new XMIHelperImpl();
>> EList<EObject>contents =resource.getContents();
>> for (EObject object : contents) {
>> if ( object.eClass().getName().equals("PlayerList") ) {
>> EStructuralFeature structuralFeature =
>> object.eClass().getEStructuralFeature("players");
>> EList<EObject> list = (EList<EObject>)
>> object.eGet(structuralFeature);
>> for (EObject player : list) {
>> EStructuralFeature name =
>> player.eClass().getEStructuralFeature("name");
>> if ( player.eGet(name).equals("Wayne Gretzky") ) {
>> EStructuralFeature yearlyStats =
>> player.eClass().getEStructuralFeature("yearlyStats");
>> Object stats = player.eGet(yearlyStats);
>> EList<EObject> playerStats = (EList<EObject>)
>> stats;
>> // There are 20 elements in this list, but
>> with the load option set, I get 40
>> System.out.println(playerStats.size());
>> }
>> }
>> }
>> }
>>
>> }
>>
>> }
>>
>>
>> Ed Merks wrote:
>>> Ian,
>>>
>>> I think I'd need to see it reproduced in a test case. The effect of
>>> this option is
>>>
>>> if
>>> (Boolean.TRUE.equals(options.get(XMLResource.OPTION_DEFER_ID REF_RESOLUTION)))
>>>
>>> {
>>> helper.setCheckForDuplicates(deferIDREFResolution = true);
>>> }
>>>
>>> It forces all references to be treated as forward references and it
>>> should cause the helper to check for duplicates before adding to the
>>> list; look for where the checkForDuplicates is used in XMLHelperImpl.
>>>
>>>
>>> Ian Bull wrote:
>>>> I have a pretty large emf model (about 40,000 EObjects) representing
>>>> 87 years of NHL statistics. (It's not a crystal ball, but it does
>>>> tell me that the leafs are not winning this year) :-)
>>>>
>>>> But that's not the point...
>>>>
>>>> The data originally came from generated EMF, but I have tried
>>>> loading it using dynamic EMF and it works fine. I even did a test,
>>>> I grabbed Wayne Gretzky's Player object, got the feature that
>>>> represented his stats, and got the size of this list, 20... good, he
>>>> played for 20 years.
>>>>
>>>> However, when I use the following load options:
>>>>
>>>> loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,
>>>> Boolean.TRUE);
>>>> loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new
>>>> XMLParserPoolImpl());
>>>>
>>>> and I run the same query (nothing else in the program changed) it
>>>> tells me that Wayne played for 40 years. The EList of stats
>>>> attached to the Wayne's player object has 40 elements in it.
>>>> Looking at the object ID's, it seems to have just put the same set
>>>> of 20 objects in the list twice, such as
>>>>
>>>> [1,2,3,....,19,20,1,2,3,...19,20]
>>>>
>>>> I first noticed this using ALT, but it seems to be a dynamic EMF thing.
>>>>
>>>> Thoughts?
>>>>
>>>> Cheers,
>>>> Ian
>>>
|
|
|
Goto Forum:
Current Time: Fri Apr 26 11:39:08 GMT 2024
Powered by FUDForum. Page generated in 0.03245 seconds
|