Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem with load
Problem with load [message #1798685] Thu, 22 November 2018 16:55 Go to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 316
Registered: July 2016
Senior Member
Hi there,

When I load the resource with resource.load(null) it does not clear the previous content. What shall I do?

In the below code, the `Test` method is called several times. First, I load the resource and at the end I delete the resource in order the previous content is cleared for next method call but it still has the previous content.
public ArrayList<EObject> Test(Resource r) {
		try {
			r.load(null);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		//do something and store results in expressions variable

		try {
			r.delete(null);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	    return expressions;
	}


Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Thu, 22 November 2018 16:56]

Report message to a moderator

Re: Problem with load [message #1798704 is a reply to message #1798685] Fri, 23 November 2018 04:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30462
Registered: July 2009
Senior Member
The debugger in your friend. If you'd stepped through the code with your friend, you'd find that all the load methods are guarded like this:
  public void load(Map<?, ?> options) throws IOException
  {
    if (!isLoaded)
    {
Then if you looked through the code of ResourceImpl, you'd see that this isLoaded field is changed only by setLoaded, which is protected, so you can't call it directly. Looking further at the Call Hierarchy of that method, you'd notice that unload() sets it to false. Then you would have answered the question yourself, i.e., you must unload the resource before it can be loaded again.
Re: Problem with load [message #1800560 is a reply to message #1798704] Wed, 02 January 2019 13:07 Go to previous messageGo to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 316
Registered: July 2016
Senior Member
Hi there,

I have used unload method but it still doesn't work. It only works when I delete the model and save new model with the new name.
public ArrayList<EObject> Test(Resource r) {
		try {
			r.load(null);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		//do something and store results in expressions variable

		r.unload();
		
	    return expressions;
	}


Best Regards,
Banafsheh


Member of MDSE Research Group
http://mdse.ui.ac.ir
Re: Problem with load [message #1800566 is a reply to message #1800560] Wed, 02 January 2019 14:49 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30462
Registered: July 2009
Senior Member
There isn't a question mark, so there isn't a question? Did you intend at some point to call unload first and then call load afterwards? Did you look at any of what's going on using the debugger?
Previous Topic:[CDO] Auto-Commit in CDO
Next Topic:[CDO] Caching and explicit garbage collection
Goto Forum:
  


Current Time: Sun Sep 22 16:57:09 GMT 2019

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

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

Back to the top