Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application
[EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1268410] Mon, 10 March 2014 13:18 Go to next message
Marina Knieling is currently offline Marina Knieling
Messages: 78
Registered: February 2013
Member
Hey guys,

another problem or strange behaviour just popped up. I'm using the
EMFStore API to store my objects. I have a wizard that creates an object
and in the performFinish method I create a ESLocalProject, add my own
object to the modelElements and share it with the server. This works
perfectly fine, the file is created and the object is stored in it.

I also have a mechanism to switch the active element to work with (like
switching the workspace in eclipse). This is implemented using a JFace
ListDialog. The idea was to iterate through all local projects and get
the first modelElement out of it (which should be my top object). This
works fine, when I do it in the same "session" where I created that
object / that local project. But when I shut down my application and
start it again, the ListDialog keeps empty and debugging shows, that
there are no elements in the modelElements reference from the
ESLocalProject. I even tried the projects from the helloworld example
and they are also empty.

The code is the following:

List<ESLocalProject> projects = workspace.getLocalProjects();
List<Organ> allOrgans = new ArrayList<Organ>();
for(ESLocalProject p : projects){
System.out.println("modelElements: " + p.getModelElements().size());
for(EObject o : p.getModelElements()){
if(o instanceof Organ)
allOrgans.add((Organ) o);
}

}
System.out.println("organs: " + allOrgans.size());
dialog.setInput(allOrgans);

Is there something wrong with my code? Do I have to do anything else?

Thanks in advance
Marina
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1268621 is a reply to message #1268410] Mon, 10 March 2014 19:00 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas Helming
Messages: 454
Registered: July 2009
Senior Member
Hi,

do you save the project somewhere?

regards

jonas

Am 10.03.2014 14:18, schrieb Marina Knieling:
> Hey guys,
>
> another problem or strange behaviour just popped up. I'm using the
> EMFStore API to store my objects. I have a wizard that creates an object
> and in the performFinish method I create a ESLocalProject, add my own
> object to the modelElements and share it with the server. This works
> perfectly fine, the file is created and the object is stored in it.
>
> I also have a mechanism to switch the active element to work with (like
> switching the workspace in eclipse). This is implemented using a JFace
> ListDialog. The idea was to iterate through all local projects and get
> the first modelElement out of it (which should be my top object). This
> works fine, when I do it in the same "session" where I created that
> object / that local project. But when I shut down my application and
> start it again, the ListDialog keeps empty and debugging shows, that
> there are no elements in the modelElements reference from the
> ESLocalProject. I even tried the projects from the helloworld example
> and they are also empty.
>
> The code is the following:
>
> List<ESLocalProject> projects = workspace.getLocalProjects();
> List<Organ> allOrgans = new ArrayList<Organ>();
> for(ESLocalProject p : projects){
> System.out.println("modelElements: " +
> p.getModelElements().size());
> for(EObject o : p.getModelElements()){
> if(o instanceof Organ)
> allOrgans.add((Organ) o);
> }
>
> }
> System.out.println("organs: " + allOrgans.size());
> dialog.setInput(allOrgans);
>
> Is there something wrong with my code? Do I have to do anything else?
>
> Thanks in advance
> Marina
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1268628 is a reply to message #1268621] Mon, 10 March 2014 19:18 Go to previous messageGo to next message
Marina Knieling is currently offline Marina Knieling
Messages: 78
Registered: February 2013
Member
What exactly do you mean?
This is what I do in my performFinish method:

ESLocalProject organProject =
workspace.createLocalProject(organ.getOrganID());
ESUsersession userSession =
workspace.getServers().get(0).getLastUsersession();
organProject.getModelElements().add(organ);
organProject.shareProject(userSession, new ESSystemOutProgressMonitor());

And the xml files also exist in the .emfstore/client and
..emfstore/server folders. The projects get read and the IDs are exactly
as they are displayed in the folder. It's only the model elements that
aren't populated.

This is one of the xml files (client version):

<?xml version="1.0" encoding="UTF-8"?>
<org.eclipse.emf.emfstore.internal.common.model:Project
xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:commamod="http://www.vknie.com/commamod"
xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
<modelElements xsi:type="commamod:Organ"
xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel" location="Paderborn"
numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
numberOfPipes="9840" numberOfRanks="4"/>
</org.eclipse.emf.emfstore.internal.common.model:Project>

So obviously there IS a model element (the Organ) in the file. But
calling localProject.getModelElements().size() returns 0 and debugging
also only displays an empty list.

Am 10.03.2014 20:00, schrieb Jonas Helming:
> Hi,
>
> do you save the project somewhere?
>
> regards
>
> jonas
>
> Am 10.03.2014 14:18, schrieb Marina Knieling:
>> Hey guys,
>>
>> another problem or strange behaviour just popped up. I'm using the
>> EMFStore API to store my objects. I have a wizard that creates an object
>> and in the performFinish method I create a ESLocalProject, add my own
>> object to the modelElements and share it with the server. This works
>> perfectly fine, the file is created and the object is stored in it.
>>
>> I also have a mechanism to switch the active element to work with (like
>> switching the workspace in eclipse). This is implemented using a JFace
>> ListDialog. The idea was to iterate through all local projects and get
>> the first modelElement out of it (which should be my top object). This
>> works fine, when I do it in the same "session" where I created that
>> object / that local project. But when I shut down my application and
>> start it again, the ListDialog keeps empty and debugging shows, that
>> there are no elements in the modelElements reference from the
>> ESLocalProject. I even tried the projects from the helloworld example
>> and they are also empty.
>>
>> The code is the following:
>>
>> List<ESLocalProject> projects = workspace.getLocalProjects();
>> List<Organ> allOrgans = new ArrayList<Organ>();
>> for(ESLocalProject p : projects){
>> System.out.println("modelElements: " +
>> p.getModelElements().size());
>> for(EObject o : p.getModelElements()){
>> if(o instanceof Organ)
>> allOrgans.add((Organ) o);
>> }
>>
>> }
>> System.out.println("organs: " + allOrgans.size());
>> dialog.setInput(allOrgans);
>>
>> Is there something wrong with my code? Do I have to do anything else?
>>
>> Thanks in advance
>> Marina
>
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1269016 is a reply to message #1268628] Tue, 11 March 2014 09:20 Go to previous messageGo to next message
Edgar Mueller is currently offline Edgar Mueller
Messages: 61
Registered: March 2011
Member
Hi Marina,

Jonas meant whether you called the save() method on the ESLocalProject
after you've added your model elements, but this should already be the
case when sharing a project.

I do not yet entirely understand your application's control flow. When
the performFinished method has finished and you restart your
application, does anything happen before you iterate through the
workspace? Can you check the project's contents right after application
has restarted?

The helloworld example does work for me (although you'll need to modify
the example since it always creates a new empty project). Can you tell
me how you checked the helloworld example? Ideally, something
reproducable would help us to diagnose the problem.

Cheers,
Edgar

Am 10.03.2014 20:18, schrieb Marina Knieling:
> What exactly do you mean?
> This is what I do in my performFinish method:
>
> ESLocalProject organProject =
> workspace.createLocalProject(organ.getOrganID());
> ESUsersession userSession =
> workspace.getServers().get(0).getLastUsersession();
> organProject.getModelElements().add(organ);
> organProject.shareProject(userSession, new ESSystemOutProgressMonitor());
>
> And the xml files also exist in the .emfstore/client and
> .emfstore/server folders. The projects get read and the IDs are exactly
> as they are displayed in the folder. It's only the model elements that
> aren't populated.
>
> This is one of the xml files (client version):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <org.eclipse.emf.emfstore.internal.common.model:Project
> xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:commamod="http://www.vknie.com/commamod"
> xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
>
> <modelElements xsi:type="commamod:Organ"
> xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel" location="Paderborn"
> numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
> numberOfPipes="9840" numberOfRanks="4"/>
> </org.eclipse.emf.emfstore.internal.common.model:Project>
>
> So obviously there IS a model element (the Organ) in the file. But
> calling localProject.getModelElements().size() returns 0 and debugging
> also only displays an empty list.
>
> Am 10.03.2014 20:00, schrieb Jonas Helming:
>> Hi,
>>
>> do you save the project somewhere?
>>
>> regards
>>
>> jonas
>>
>> Am 10.03.2014 14:18, schrieb Marina Knieling:
>>> Hey guys,
>>>
>>> another problem or strange behaviour just popped up. I'm using the
>>> EMFStore API to store my objects. I have a wizard that creates an object
>>> and in the performFinish method I create a ESLocalProject, add my own
>>> object to the modelElements and share it with the server. This works
>>> perfectly fine, the file is created and the object is stored in it.
>>>
>>> I also have a mechanism to switch the active element to work with (like
>>> switching the workspace in eclipse). This is implemented using a JFace
>>> ListDialog. The idea was to iterate through all local projects and get
>>> the first modelElement out of it (which should be my top object). This
>>> works fine, when I do it in the same "session" where I created that
>>> object / that local project. But when I shut down my application and
>>> start it again, the ListDialog keeps empty and debugging shows, that
>>> there are no elements in the modelElements reference from the
>>> ESLocalProject. I even tried the projects from the helloworld example
>>> and they are also empty.
>>>
>>> The code is the following:
>>>
>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>> for(ESLocalProject p : projects){
>>> System.out.println("modelElements: " +
>>> p.getModelElements().size());
>>> for(EObject o : p.getModelElements()){
>>> if(o instanceof Organ)
>>> allOrgans.add((Organ) o);
>>> }
>>>
>>> }
>>> System.out.println("organs: " + allOrgans.size());
>>> dialog.setInput(allOrgans);
>>>
>>> Is there something wrong with my code? Do I have to do anything else?
>>>
>>> Thanks in advance
>>> Marina
>>
>


--
Edgar Mueller

Get Professional Eclipse Support: http://eclipsesource.com/munich
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1269134 is a reply to message #1269016] Tue, 11 March 2014 12:36 Go to previous messageGo to next message
Marina Knieling is currently offline Marina Knieling
Messages: 78
Registered: February 2013
Member
Ok, let's try again:

When the application is started the very first time, the user needs to
create an Organ object (this is my top level object in my hierarchy -
like the League in the helloworld example). I create this object via a
JFace wizard. The performFinish method creates an ESLocalProject, adds
the Organ object to its modelelements and shares the project (as already
mentioned in the previous post).

I have a command to switch the Organ (like switching the workspace in
eclipse) and if I call this command/handler now (in the same "session"
where I created the Organ object), the recently added Organ gets
displayed in the ListDialog and my console output says 1 modelelement is
there and 1 project.

I now close my application. I checked back the standard .emfstore
folders whether the project was created correctly and I don't find any
errors there. The project file exists and has the before mentioned
contents (see last post).

Now I start my application again and call the SwitchOrgan handler. The
ListDialog keeps empty and the console output says 0 modelElements, but
1 project.

Concerning the helloworld example:
I ran the example and then ran my application afterwards (so the
..emfstore folder still had the 2 projects from the helloworld example)
and my console output said: 3 projects and 0 modelElements for each of
those projects.

Console output refers to these lines in the OrganSelectionDialog class
with the ListDialog in it, which should be populated with all Organs
(i.e. all top level modelElements from all local projects):

List<ESLocalProject> projects = workspace.getLocalProjects();
System.out.println("# projects: " + projects.size());
List<Organ> allOrgans = new ArrayList<Organ>();
for(ESLocalProject p : projects){
System.out.println("# modelElements: " + p.getModelElements().size());
for(EObject o : p.getModelElements()){
if(o instanceof Organ)
allOrgans.add((Organ) o);
}
}
System.out.println("organs: " + allOrgans.size());
dialog.setInput(allOrgans);

---
The only thing I do during startup is to find the last active Organ (I
store the ID in the preferences), but already there the modelelements
are empty, see attached screenshot of debug.

I hope my problem is now clear and you understand what I'm doing. Thanks
for your help guys.

Am 11.03.2014 10:20, schrieb Edgar Mueller:
> Hi Marina,
>
> Jonas meant whether you called the save() method on the ESLocalProject
> after you've added your model elements, but this should already be the
> case when sharing a project.
>
> I do not yet entirely understand your application's control flow. When
> the performFinished method has finished and you restart your
> application, does anything happen before you iterate through the
> workspace? Can you check the project's contents right after application
> has restarted?
>
> The helloworld example does work for me (although you'll need to modify
> the example since it always creates a new empty project). Can you tell
> me how you checked the helloworld example? Ideally, something
> reproducable would help us to diagnose the problem.
>
> Cheers,
> Edgar
>
> Am 10.03.2014 20:18, schrieb Marina Knieling:
>> What exactly do you mean?
>> This is what I do in my performFinish method:
>>
>> ESLocalProject organProject =
>> workspace.createLocalProject(organ.getOrganID());
>> ESUsersession userSession =
>> workspace.getServers().get(0).getLastUsersession();
>> organProject.getModelElements().add(organ);
>> organProject.shareProject(userSession, new ESSystemOutProgressMonitor());
>>
>> And the xml files also exist in the .emfstore/client and
>> .emfstore/server folders. The projects get read and the IDs are exactly
>> as they are displayed in the folder. It's only the model elements that
>> aren't populated.
>>
>> This is one of the xml files (client version):
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <org.eclipse.emf.emfstore.internal.common.model:Project
>> xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:commamod="http://www.vknie.com/commamod"
>> xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
>>
>> <modelElements xsi:type="commamod:Organ"
>> xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel" location="Paderborn"
>> numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
>> numberOfPipes="9840" numberOfRanks="4"/>
>> </org.eclipse.emf.emfstore.internal.common.model:Project>
>>
>> So obviously there IS a model element (the Organ) in the file. But
>> calling localProject.getModelElements().size() returns 0 and debugging
>> also only displays an empty list.
>>
>> Am 10.03.2014 20:00, schrieb Jonas Helming:
>>> Hi,
>>>
>>> do you save the project somewhere?
>>>
>>> regards
>>>
>>> jonas
>>>
>>> Am 10.03.2014 14:18, schrieb Marina Knieling:
>>>> Hey guys,
>>>>
>>>> another problem or strange behaviour just popped up. I'm using the
>>>> EMFStore API to store my objects. I have a wizard that creates an object
>>>> and in the performFinish method I create a ESLocalProject, add my own
>>>> object to the modelElements and share it with the server. This works
>>>> perfectly fine, the file is created and the object is stored in it.
>>>>
>>>> I also have a mechanism to switch the active element to work with (like
>>>> switching the workspace in eclipse). This is implemented using a JFace
>>>> ListDialog. The idea was to iterate through all local projects and get
>>>> the first modelElement out of it (which should be my top object). This
>>>> works fine, when I do it in the same "session" where I created that
>>>> object / that local project. But when I shut down my application and
>>>> start it again, the ListDialog keeps empty and debugging shows, that
>>>> there are no elements in the modelElements reference from the
>>>> ESLocalProject. I even tried the projects from the helloworld example
>>>> and they are also empty.
>>>>
>>>> The code is the following:
>>>>
>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>> for(ESLocalProject p : projects){
>>>> System.out.println("modelElements: " +
>>>> p.getModelElements().size());
>>>> for(EObject o : p.getModelElements()){
>>>> if(o instanceof Organ)
>>>> allOrgans.add((Organ) o);
>>>> }
>>>>
>>>> }
>>>> System.out.println("organs: " + allOrgans.size());
>>>> dialog.setInput(allOrgans);
>>>>
>>>> Is there something wrong with my code? Do I have to do anything else?
>>>>
>>>> Thanks in advance
>>>> Marina
>>>
>>
>
>
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1269177 is a reply to message #1269134] Tue, 11 March 2014 13:36 Go to previous messageGo to next message
Edgar Mueller is currently offline Edgar Mueller
Messages: 61
Registered: March 2011
Member
Hi Marina,

from your screenshot I can see that your workspace didn't initialze
correctly (modCount of the modelElements feature should not be 0), i.e.
the load function within ESWorkspaceProviderImpl did not get called or
failed for some reason.
How do you initialize your workspace reference? Do you use
ESWorkspaceProvider.INSTANCE? Are you able to send me the complete code
of your Activator?

Cheers,
Edgar

Am 11.03.2014 13:36, schrieb Marina Knieling:
> Ok, let's try again:
>
> When the application is started the very first time, the user needs to
> create an Organ object (this is my top level object in my hierarchy -
> like the League in the helloworld example). I create this object via a
> JFace wizard. The performFinish method creates an ESLocalProject, adds
> the Organ object to its modelelements and shares the project (as already
> mentioned in the previous post).
>
> I have a command to switch the Organ (like switching the workspace in
> eclipse) and if I call this command/handler now (in the same "session"
> where I created the Organ object), the recently added Organ gets
> displayed in the ListDialog and my console output says 1 modelelement is
> there and 1 project.
>
> I now close my application. I checked back the standard .emfstore
> folders whether the project was created correctly and I don't find any
> errors there. The project file exists and has the before mentioned
> contents (see last post).
>
> Now I start my application again and call the SwitchOrgan handler. The
> ListDialog keeps empty and the console output says 0 modelElements, but
> 1 project.
>
> Concerning the helloworld example:
> I ran the example and then ran my application afterwards (so the
> .emfstore folder still had the 2 projects from the helloworld example)
> and my console output said: 3 projects and 0 modelElements for each of
> those projects.
>
> Console output refers to these lines in the OrganSelectionDialog class
> with the ListDialog in it, which should be populated with all Organs
> (i.e. all top level modelElements from all local projects):
>
> List<ESLocalProject> projects = workspace.getLocalProjects();
> System.out.println("# projects: " + projects.size());
> List<Organ> allOrgans = new ArrayList<Organ>();
> for(ESLocalProject p : projects){
> System.out.println("# modelElements: " + p.getModelElements().size());
> for(EObject o : p.getModelElements()){
> if(o instanceof Organ)
> allOrgans.add((Organ) o);
> }
> }
> System.out.println("organs: " + allOrgans.size());
> dialog.setInput(allOrgans);
>
> ---
> The only thing I do during startup is to find the last active Organ (I
> store the ID in the preferences), but already there the modelelements
> are empty, see attached screenshot of debug.
>
> I hope my problem is now clear and you understand what I'm doing. Thanks
> for your help guys.
>
> Am 11.03.2014 10:20, schrieb Edgar Mueller:
>> Hi Marina,
>>
>> Jonas meant whether you called the save() method on the ESLocalProject
>> after you've added your model elements, but this should already be the
>> case when sharing a project.
>>
>> I do not yet entirely understand your application's control flow. When
>> the performFinished method has finished and you restart your
>> application, does anything happen before you iterate through the
>> workspace? Can you check the project's contents right after application
>> has restarted?
>>
>> The helloworld example does work for me (although you'll need to modify
>> the example since it always creates a new empty project). Can you tell
>> me how you checked the helloworld example? Ideally, something
>> reproducable would help us to diagnose the problem.
>>
>> Cheers,
>> Edgar
>>
>> Am 10.03.2014 20:18, schrieb Marina Knieling:
>>> What exactly do you mean?
>>> This is what I do in my performFinish method:
>>>
>>> ESLocalProject organProject =
>>> workspace.createLocalProject(organ.getOrganID());
>>> ESUsersession userSession =
>>> workspace.getServers().get(0).getLastUsersession();
>>> organProject.getModelElements().add(organ);
>>> organProject.shareProject(userSession, new
>>> ESSystemOutProgressMonitor());
>>>
>>> And the xml files also exist in the .emfstore/client and
>>> .emfstore/server folders. The projects get read and the IDs are exactly
>>> as they are displayed in the folder. It's only the model elements that
>>> aren't populated.
>>>
>>> This is one of the xml files (client version):
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <org.eclipse.emf.emfstore.internal.common.model:Project
>>> xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:commamod="http://www.vknie.com/commamod"
>>> xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
>>>
>>>
>>> <modelElements xsi:type="commamod:Organ"
>>> xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel" location="Paderborn"
>>> numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
>>> numberOfPipes="9840" numberOfRanks="4"/>
>>> </org.eclipse.emf.emfstore.internal.common.model:Project>
>>>
>>> So obviously there IS a model element (the Organ) in the file. But
>>> calling localProject.getModelElements().size() returns 0 and debugging
>>> also only displays an empty list.
>>>
>>> Am 10.03.2014 20:00, schrieb Jonas Helming:
>>>> Hi,
>>>>
>>>> do you save the project somewhere?
>>>>
>>>> regards
>>>>
>>>> jonas
>>>>
>>>> Am 10.03.2014 14:18, schrieb Marina Knieling:
>>>>> Hey guys,
>>>>>
>>>>> another problem or strange behaviour just popped up. I'm using the
>>>>> EMFStore API to store my objects. I have a wizard that creates an
>>>>> object
>>>>> and in the performFinish method I create a ESLocalProject, add my own
>>>>> object to the modelElements and share it with the server. This works
>>>>> perfectly fine, the file is created and the object is stored in it.
>>>>>
>>>>> I also have a mechanism to switch the active element to work with
>>>>> (like
>>>>> switching the workspace in eclipse). This is implemented using a JFace
>>>>> ListDialog. The idea was to iterate through all local projects and get
>>>>> the first modelElement out of it (which should be my top object). This
>>>>> works fine, when I do it in the same "session" where I created that
>>>>> object / that local project. But when I shut down my application and
>>>>> start it again, the ListDialog keeps empty and debugging shows, that
>>>>> there are no elements in the modelElements reference from the
>>>>> ESLocalProject. I even tried the projects from the helloworld example
>>>>> and they are also empty.
>>>>>
>>>>> The code is the following:
>>>>>
>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>> for(ESLocalProject p : projects){
>>>>> System.out.println("modelElements: " +
>>>>> p.getModelElements().size());
>>>>> for(EObject o : p.getModelElements()){
>>>>> if(o instanceof Organ)
>>>>> allOrgans.add((Organ) o);
>>>>> }
>>>>>
>>>>> }
>>>>> System.out.println("organs: " + allOrgans.size());
>>>>> dialog.setInput(allOrgans);
>>>>>
>>>>> Is there something wrong with my code? Do I have to do anything else?
>>>>>
>>>>> Thanks in advance
>>>>> Marina
>>>>
>>>
>>
>>
>


--
Edgar Mueller

Get Professional Eclipse Support: http://eclipsesource.com/munich
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1269184 is a reply to message #1269177] Tue, 11 March 2014 13:49 Go to previous messageGo to next message
Marina Knieling is currently offline Marina Knieling
Messages: 78
Registered: February 2013
Member
Hi Edgar,

I just changed my runtime config from features to plugins, now the
helloworld example projects are populated with their modelElements but
my own still aren't. Maybe I even miss something in my runtime config
although I don't get any errors on startup.

However, find attached my Activator. Yes, I do use
ESWorkspaceProvider.INSTANCE.getWorkspace().

Thanks for your help


Am 11.03.2014 14:36, schrieb Edgar Mueller:
> Hi Marina,
>
> from your screenshot I can see that your workspace didn't initialze
> correctly (modCount of the modelElements feature should not be 0), i.e.
> the load function within ESWorkspaceProviderImpl did not get called or
> failed for some reason.
> How do you initialize your workspace reference? Do you use
> ESWorkspaceProvider.INSTANCE? Are you able to send me the complete code
> of your Activator?
>
> Cheers,
> Edgar
>
> Am 11.03.2014 13:36, schrieb Marina Knieling:
>> Ok, let's try again:
>>
>> When the application is started the very first time, the user needs to
>> create an Organ object (this is my top level object in my hierarchy -
>> like the League in the helloworld example). I create this object via a
>> JFace wizard. The performFinish method creates an ESLocalProject, adds
>> the Organ object to its modelelements and shares the project (as already
>> mentioned in the previous post).
>>
>> I have a command to switch the Organ (like switching the workspace in
>> eclipse) and if I call this command/handler now (in the same "session"
>> where I created the Organ object), the recently added Organ gets
>> displayed in the ListDialog and my console output says 1 modelelement is
>> there and 1 project.
>>
>> I now close my application. I checked back the standard .emfstore
>> folders whether the project was created correctly and I don't find any
>> errors there. The project file exists and has the before mentioned
>> contents (see last post).
>>
>> Now I start my application again and call the SwitchOrgan handler. The
>> ListDialog keeps empty and the console output says 0 modelElements, but
>> 1 project.
>>
>> Concerning the helloworld example:
>> I ran the example and then ran my application afterwards (so the
>> .emfstore folder still had the 2 projects from the helloworld example)
>> and my console output said: 3 projects and 0 modelElements for each of
>> those projects.
>>
>> Console output refers to these lines in the OrganSelectionDialog class
>> with the ListDialog in it, which should be populated with all Organs
>> (i.e. all top level modelElements from all local projects):
>>
>> List<ESLocalProject> projects = workspace.getLocalProjects();
>> System.out.println("# projects: " + projects.size());
>> List<Organ> allOrgans = new ArrayList<Organ>();
>> for(ESLocalProject p : projects){
>> System.out.println("# modelElements: " + p.getModelElements().size());
>> for(EObject o : p.getModelElements()){
>> if(o instanceof Organ)
>> allOrgans.add((Organ) o);
>> }
>> }
>> System.out.println("organs: " + allOrgans.size());
>> dialog.setInput(allOrgans);
>>
>> ---
>> The only thing I do during startup is to find the last active Organ (I
>> store the ID in the preferences), but already there the modelelements
>> are empty, see attached screenshot of debug.
>>
>> I hope my problem is now clear and you understand what I'm doing. Thanks
>> for your help guys.
>>
>> Am 11.03.2014 10:20, schrieb Edgar Mueller:
>>> Hi Marina,
>>>
>>> Jonas meant whether you called the save() method on the ESLocalProject
>>> after you've added your model elements, but this should already be the
>>> case when sharing a project.
>>>
>>> I do not yet entirely understand your application's control flow. When
>>> the performFinished method has finished and you restart your
>>> application, does anything happen before you iterate through the
>>> workspace? Can you check the project's contents right after application
>>> has restarted?
>>>
>>> The helloworld example does work for me (although you'll need to modify
>>> the example since it always creates a new empty project). Can you tell
>>> me how you checked the helloworld example? Ideally, something
>>> reproducable would help us to diagnose the problem.
>>>
>>> Cheers,
>>> Edgar
>>>
>>> Am 10.03.2014 20:18, schrieb Marina Knieling:
>>>> What exactly do you mean?
>>>> This is what I do in my performFinish method:
>>>>
>>>> ESLocalProject organProject =
>>>> workspace.createLocalProject(organ.getOrganID());
>>>> ESUsersession userSession =
>>>> workspace.getServers().get(0).getLastUsersession();
>>>> organProject.getModelElements().add(organ);
>>>> organProject.shareProject(userSession, new
>>>> ESSystemOutProgressMonitor());
>>>>
>>>> And the xml files also exist in the .emfstore/client and
>>>> .emfstore/server folders. The projects get read and the IDs are exactly
>>>> as they are displayed in the folder. It's only the model elements that
>>>> aren't populated.
>>>>
>>>> This is one of the xml files (client version):
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <org.eclipse.emf.emfstore.internal.common.model:Project
>>>> xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xmlns:commamod="http://www.vknie.com/commamod"
>>>> xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
>>>>
>>>>
>>>> <modelElements xsi:type="commamod:Organ"
>>>> xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel" location="Paderborn"
>>>> numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
>>>> numberOfPipes="9840" numberOfRanks="4"/>
>>>> </org.eclipse.emf.emfstore.internal.common.model:Project>
>>>>
>>>> So obviously there IS a model element (the Organ) in the file. But
>>>> calling localProject.getModelElements().size() returns 0 and debugging
>>>> also only displays an empty list.
>>>>
>>>> Am 10.03.2014 20:00, schrieb Jonas Helming:
>>>>> Hi,
>>>>>
>>>>> do you save the project somewhere?
>>>>>
>>>>> regards
>>>>>
>>>>> jonas
>>>>>
>>>>> Am 10.03.2014 14:18, schrieb Marina Knieling:
>>>>>> Hey guys,
>>>>>>
>>>>>> another problem or strange behaviour just popped up. I'm using the
>>>>>> EMFStore API to store my objects. I have a wizard that creates an
>>>>>> object
>>>>>> and in the performFinish method I create a ESLocalProject, add my own
>>>>>> object to the modelElements and share it with the server. This works
>>>>>> perfectly fine, the file is created and the object is stored in it.
>>>>>>
>>>>>> I also have a mechanism to switch the active element to work with
>>>>>> (like
>>>>>> switching the workspace in eclipse). This is implemented using a JFace
>>>>>> ListDialog. The idea was to iterate through all local projects and get
>>>>>> the first modelElement out of it (which should be my top object). This
>>>>>> works fine, when I do it in the same "session" where I created that
>>>>>> object / that local project. But when I shut down my application and
>>>>>> start it again, the ListDialog keeps empty and debugging shows, that
>>>>>> there are no elements in the modelElements reference from the
>>>>>> ESLocalProject. I even tried the projects from the helloworld example
>>>>>> and they are also empty.
>>>>>>
>>>>>> The code is the following:
>>>>>>
>>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>>> for(ESLocalProject p : projects){
>>>>>> System.out.println("modelElements: " +
>>>>>> p.getModelElements().size());
>>>>>> for(EObject o : p.getModelElements()){
>>>>>> if(o instanceof Organ)
>>>>>> allOrgans.add((Organ) o);
>>>>>> }
>>>>>>
>>>>>> }
>>>>>> System.out.println("organs: " + allOrgans.size());
>>>>>> dialog.setInput(allOrgans);
>>>>>>
>>>>>> Is there something wrong with my code? Do I have to do anything else?
>>>>>>
>>>>>> Thanks in advance
>>>>>> Marina
>>>>>
>>>>
>>>
>>>
>>
>
>


package com.vknie.comma.app;

import java.util.List;

import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.e4.core.contexts.IContextFunction;
import org.eclipse.e4.ui.internal.workbench.E4Workbench;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.emf.emfstore.client.ESLocalProject;
import org.eclipse.emf.emfstore.client.ESServer;
import org.eclipse.emf.emfstore.client.ESWorkspace;
import org.eclipse.emf.emfstore.client.ESWorkspaceProvider;
import org.eclipse.emf.emfstore.client.exceptions.ESServerNotFoundException;
import org.eclipse.emf.emfstore.client.exceptions.ESServerStartFailedException;
import org.eclipse.emf.emfstore.server.exceptions.ESException;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;

import CombinationManager.Model.Organ;

import com.vknie.comma.core.services.organprovider.OrganProvider;

@SuppressWarnings("restriction")
public class Activator implements BundleActivator {

private static BundleContext context;
OrganProvider organProvider; // OSGi Service
ESServer localServer;
ESWorkspace workspace;
ESLocalProject lastActiveProject = null;

static BundleContext getContext() {
return context;
}

/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
// Start local EMFStore Server
try {
// Create a client representation for a local server and start a local server.
localServer = ESServer.FACTORY.createAndStartLocalServer();
localServer.setPort(8090);
workspace = ESWorkspaceProvider.INSTANCE.getWorkspace();
workspace.addServer(localServer);
for (ESServer existingServer : workspace.getServers()) {
if (existingServer != localServer) {
try {
workspace.removeServer(existingServer);
} catch (ESServerNotFoundException e) {
e.printStackTrace();
}
}
}
localServer.login("super", "super");
} catch (ESServerStartFailedException e) {
// TODO try to recover or at least print a message to the user and shut down the application afterwards
System.out.println("Server start failed!");
e.printStackTrace();
} catch (ESException e) {
System.out.println("Login failed");
e.printStackTrace();
}

// obtain organ provider service
ServiceReference<?> organProviderServiceReference = context.getServiceReference(OrganProvider.class.getName());
organProvider = (OrganProvider) context.getService(organProviderServiceReference);
// get last active organ
Preferences preferences = InstanceScope.INSTANCE.getNode("com.vknie.comma.app"); //$NON-NLS-1$
String lastActiveOrganID = preferences.get("lastActiveOrganID", ""); //$NON-NLS-1$ //$NON-NLS-2$
List<ESLocalProject> projects = workspace.getLocalProjects();
for(ESLocalProject p : projects){
if(p==null) // no project exists = first time start
break;
if(p.getProjectName().equals(lastActiveOrganID)){
lastActiveProject = p;
break;
}
}
if(lastActiveProject!=null && !lastActiveProject.getModelElements().isEmpty())
organProvider.setActiveOrgan((Organ) lastActiveProject.getModelElements().get(0));
}

/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
// save the organID of the last active organ in the preferences
Preferences preferences = InstanceScope.INSTANCE.getNode("com.vknie.comma.app"); //$NON-NLS-1$
preferences.put("lastActiveOrganID", organProvider.getActiveOrgan().getOrganID()); //$NON-NLS-1$
// stop local EMFStore Server
ESServer.FACTORY.stopLocalServer();
try {
// forces the application to save the preferences
preferences.flush();
} catch (BackingStoreException e) {
e.printStackTrace();
}
Activator.context = null;
}

public static EPartService getEPartService() {
try {
final ServiceReference<?> service = context.getServiceReferences(IContextFunction.class.getName(),
"(service.context.key=" + EPartService.class.getName() + ")")[0];
// TODO a "bit" ugly
return (EPartService) ((IContextFunction) context.getService(service)).compute(E4Workbench
.getServiceContext(), null);
} catch (final InvalidSyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}

}
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1269325 is a reply to message #1269184] Tue, 11 March 2014 18:11 Go to previous messageGo to next message
Edgar Mueller is currently offline Edgar Mueller
Messages: 61
Registered: March 2011
Member
Hi Marina,

I think the issue lies within the initialization order of your bundles.
It seems as if your model plugin has not been resolved when the
workspace is initializing. That's why the example project seems to work.
Can you try to make sure your model bundle is loaded before the emfstore
bundles?

Cheers,
Edgar

Am 11.03.2014 14:49, schrieb Marina Knieling:
> Hi Edgar,
>
> I just changed my runtime config from features to plugins, now the
> helloworld example projects are populated with their modelElements but
> my own still aren't. Maybe I even miss something in my runtime config
> although I don't get any errors on startup.
>
> However, find attached my Activator. Yes, I do use
> ESWorkspaceProvider.INSTANCE.getWorkspace().
>
> Thanks for your help
>
>
> Am 11.03.2014 14:36, schrieb Edgar Mueller:
>> Hi Marina,
>>
>> from your screenshot I can see that your workspace didn't initialze
>> correctly (modCount of the modelElements feature should not be 0), i.e.
>> the load function within ESWorkspaceProviderImpl did not get called or
>> failed for some reason.
>> How do you initialize your workspace reference? Do you use
>> ESWorkspaceProvider.INSTANCE? Are you able to send me the complete code
>> of your Activator?
>>
>> Cheers,
>> Edgar
>>
>> Am 11.03.2014 13:36, schrieb Marina Knieling:
>>> Ok, let's try again:
>>>
>>> When the application is started the very first time, the user needs to
>>> create an Organ object (this is my top level object in my hierarchy -
>>> like the League in the helloworld example). I create this object via a
>>> JFace wizard. The performFinish method creates an ESLocalProject, adds
>>> the Organ object to its modelelements and shares the project (as already
>>> mentioned in the previous post).
>>>
>>> I have a command to switch the Organ (like switching the workspace in
>>> eclipse) and if I call this command/handler now (in the same "session"
>>> where I created the Organ object), the recently added Organ gets
>>> displayed in the ListDialog and my console output says 1 modelelement is
>>> there and 1 project.
>>>
>>> I now close my application. I checked back the standard .emfstore
>>> folders whether the project was created correctly and I don't find any
>>> errors there. The project file exists and has the before mentioned
>>> contents (see last post).
>>>
>>> Now I start my application again and call the SwitchOrgan handler. The
>>> ListDialog keeps empty and the console output says 0 modelElements, but
>>> 1 project.
>>>
>>> Concerning the helloworld example:
>>> I ran the example and then ran my application afterwards (so the
>>> .emfstore folder still had the 2 projects from the helloworld example)
>>> and my console output said: 3 projects and 0 modelElements for each of
>>> those projects.
>>>
>>> Console output refers to these lines in the OrganSelectionDialog class
>>> with the ListDialog in it, which should be populated with all Organs
>>> (i.e. all top level modelElements from all local projects):
>>>
>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>> System.out.println("# projects: " + projects.size());
>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>> for(ESLocalProject p : projects){
>>> System.out.println("# modelElements: " +
>>> p.getModelElements().size());
>>> for(EObject o : p.getModelElements()){
>>> if(o instanceof Organ)
>>> allOrgans.add((Organ) o);
>>> }
>>> }
>>> System.out.println("organs: " + allOrgans.size());
>>> dialog.setInput(allOrgans);
>>>
>>> ---
>>> The only thing I do during startup is to find the last active Organ (I
>>> store the ID in the preferences), but already there the modelelements
>>> are empty, see attached screenshot of debug.
>>>
>>> I hope my problem is now clear and you understand what I'm doing. Thanks
>>> for your help guys.
>>>
>>> Am 11.03.2014 10:20, schrieb Edgar Mueller:
>>>> Hi Marina,
>>>>
>>>> Jonas meant whether you called the save() method on the ESLocalProject
>>>> after you've added your model elements, but this should already be the
>>>> case when sharing a project.
>>>>
>>>> I do not yet entirely understand your application's control flow. When
>>>> the performFinished method has finished and you restart your
>>>> application, does anything happen before you iterate through the
>>>> workspace? Can you check the project's contents right after application
>>>> has restarted?
>>>>
>>>> The helloworld example does work for me (although you'll need to modify
>>>> the example since it always creates a new empty project). Can you tell
>>>> me how you checked the helloworld example? Ideally, something
>>>> reproducable would help us to diagnose the problem.
>>>>
>>>> Cheers,
>>>> Edgar
>>>>
>>>> Am 10.03.2014 20:18, schrieb Marina Knieling:
>>>>> What exactly do you mean?
>>>>> This is what I do in my performFinish method:
>>>>>
>>>>> ESLocalProject organProject =
>>>>> workspace.createLocalProject(organ.getOrganID());
>>>>> ESUsersession userSession =
>>>>> workspace.getServers().get(0).getLastUsersession();
>>>>> organProject.getModelElements().add(organ);
>>>>> organProject.shareProject(userSession, new
>>>>> ESSystemOutProgressMonitor());
>>>>>
>>>>> And the xml files also exist in the .emfstore/client and
>>>>> .emfstore/server folders. The projects get read and the IDs are
>>>>> exactly
>>>>> as they are displayed in the folder. It's only the model elements that
>>>>> aren't populated.
>>>>>
>>>>> This is one of the xml files (client version):
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <org.eclipse.emf.emfstore.internal.common.model:Project
>>>>> xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>> xmlns:commamod="http://www.vknie.com/commamod"
>>>>> xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
>>>>>
>>>>>
>>>>>
>>>>> <modelElements xsi:type="commamod:Organ"
>>>>> xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel" location="Paderborn"
>>>>> numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
>>>>> numberOfPipes="9840" numberOfRanks="4"/>
>>>>> </org.eclipse.emf.emfstore.internal.common.model:Project>
>>>>>
>>>>> So obviously there IS a model element (the Organ) in the file. But
>>>>> calling localProject.getModelElements().size() returns 0 and debugging
>>>>> also only displays an empty list.
>>>>>
>>>>> Am 10.03.2014 20:00, schrieb Jonas Helming:
>>>>>> Hi,
>>>>>>
>>>>>> do you save the project somewhere?
>>>>>>
>>>>>> regards
>>>>>>
>>>>>> jonas
>>>>>>
>>>>>> Am 10.03.2014 14:18, schrieb Marina Knieling:
>>>>>>> Hey guys,
>>>>>>>
>>>>>>> another problem or strange behaviour just popped up. I'm using the
>>>>>>> EMFStore API to store my objects. I have a wizard that creates an
>>>>>>> object
>>>>>>> and in the performFinish method I create a ESLocalProject, add my
>>>>>>> own
>>>>>>> object to the modelElements and share it with the server. This works
>>>>>>> perfectly fine, the file is created and the object is stored in it.
>>>>>>>
>>>>>>> I also have a mechanism to switch the active element to work with
>>>>>>> (like
>>>>>>> switching the workspace in eclipse). This is implemented using a
>>>>>>> JFace
>>>>>>> ListDialog. The idea was to iterate through all local projects
>>>>>>> and get
>>>>>>> the first modelElement out of it (which should be my top object).
>>>>>>> This
>>>>>>> works fine, when I do it in the same "session" where I created that
>>>>>>> object / that local project. But when I shut down my application and
>>>>>>> start it again, the ListDialog keeps empty and debugging shows, that
>>>>>>> there are no elements in the modelElements reference from the
>>>>>>> ESLocalProject. I even tried the projects from the helloworld
>>>>>>> example
>>>>>>> and they are also empty.
>>>>>>>
>>>>>>> The code is the following:
>>>>>>>
>>>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>>>> for(ESLocalProject p : projects){
>>>>>>> System.out.println("modelElements: " +
>>>>>>> p.getModelElements().size());
>>>>>>> for(EObject o : p.getModelElements()){
>>>>>>> if(o instanceof Organ)
>>>>>>> allOrgans.add((Organ) o);
>>>>>>> }
>>>>>>>
>>>>>>> }
>>>>>>> System.out.println("organs: " + allOrgans.size());
>>>>>>> dialog.setInput(allOrgans);
>>>>>>>
>>>>>>> Is there something wrong with my code? Do I have to do anything
>>>>>>> else?
>>>>>>>
>>>>>>> Thanks in advance
>>>>>>> Marina
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>


--
Edgar Mueller

Get Professional Eclipse Support: http://eclipsesource.com/munich
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1269913 is a reply to message #1269325] Wed, 12 March 2014 10:04 Go to previous messageGo to next message
Marina Knieling is currently offline Marina Knieling
Messages: 78
Registered: February 2013
Member
Hi Edgar,

I tried to change the start level of my model and model.edit bundle from
default to 3, 2 and 1, but nothing worked. The application only
recognizes the helloworld example projects' modelelements.

Is there any way to "see" when the bundles are loaded? I know about the
OSGi console and I used a breakpoint in my start method from the
app.Activator class I send you, but it seems that it is already too late
as my model bundles are already active/starting and the emfstore bundles
as well.

I don't have the helloworld example in my runtime config, only the
created projects in the .emfstore folder, but nevertheless my
application knows that there is 1 modelelement in it.

Any other ideas? I'm slowly going mad.

Am 11.03.2014 19:11, schrieb Edgar Mueller:
> Hi Marina,
>
> I think the issue lies within the initialization order of your bundles.
> It seems as if your model plugin has not been resolved when the
> workspace is initializing. That's why the example project seems to work.
> Can you try to make sure your model bundle is loaded before the emfstore
> bundles?
>
> Cheers,
> Edgar
>
> Am 11.03.2014 14:49, schrieb Marina Knieling:
>> Hi Edgar,
>>
>> I just changed my runtime config from features to plugins, now the
>> helloworld example projects are populated with their modelElements but
>> my own still aren't. Maybe I even miss something in my runtime config
>> although I don't get any errors on startup.
>>
>> However, find attached my Activator. Yes, I do use
>> ESWorkspaceProvider.INSTANCE.getWorkspace().
>>
>> Thanks for your help
>>
>>
>> Am 11.03.2014 14:36, schrieb Edgar Mueller:
>>> Hi Marina,
>>>
>>> from your screenshot I can see that your workspace didn't initialze
>>> correctly (modCount of the modelElements feature should not be 0), i.e.
>>> the load function within ESWorkspaceProviderImpl did not get called or
>>> failed for some reason.
>>> How do you initialize your workspace reference? Do you use
>>> ESWorkspaceProvider.INSTANCE? Are you able to send me the complete code
>>> of your Activator?
>>>
>>> Cheers,
>>> Edgar
>>>
>>> Am 11.03.2014 13:36, schrieb Marina Knieling:
>>>> Ok, let's try again:
>>>>
>>>> When the application is started the very first time, the user needs to
>>>> create an Organ object (this is my top level object in my hierarchy -
>>>> like the League in the helloworld example). I create this object via a
>>>> JFace wizard. The performFinish method creates an ESLocalProject, adds
>>>> the Organ object to its modelelements and shares the project (as already
>>>> mentioned in the previous post).
>>>>
>>>> I have a command to switch the Organ (like switching the workspace in
>>>> eclipse) and if I call this command/handler now (in the same "session"
>>>> where I created the Organ object), the recently added Organ gets
>>>> displayed in the ListDialog and my console output says 1 modelelement is
>>>> there and 1 project.
>>>>
>>>> I now close my application. I checked back the standard .emfstore
>>>> folders whether the project was created correctly and I don't find any
>>>> errors there. The project file exists and has the before mentioned
>>>> contents (see last post).
>>>>
>>>> Now I start my application again and call the SwitchOrgan handler. The
>>>> ListDialog keeps empty and the console output says 0 modelElements, but
>>>> 1 project.
>>>>
>>>> Concerning the helloworld example:
>>>> I ran the example and then ran my application afterwards (so the
>>>> .emfstore folder still had the 2 projects from the helloworld example)
>>>> and my console output said: 3 projects and 0 modelElements for each of
>>>> those projects.
>>>>
>>>> Console output refers to these lines in the OrganSelectionDialog class
>>>> with the ListDialog in it, which should be populated with all Organs
>>>> (i.e. all top level modelElements from all local projects):
>>>>
>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>> System.out.println("# projects: " + projects.size());
>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>> for(ESLocalProject p : projects){
>>>> System.out.println("# modelElements: " +
>>>> p.getModelElements().size());
>>>> for(EObject o : p.getModelElements()){
>>>> if(o instanceof Organ)
>>>> allOrgans.add((Organ) o);
>>>> }
>>>> }
>>>> System.out.println("organs: " + allOrgans.size());
>>>> dialog.setInput(allOrgans);
>>>>
>>>> ---
>>>> The only thing I do during startup is to find the last active Organ (I
>>>> store the ID in the preferences), but already there the modelelements
>>>> are empty, see attached screenshot of debug.
>>>>
>>>> I hope my problem is now clear and you understand what I'm doing. Thanks
>>>> for your help guys.
>>>>
>>>> Am 11.03.2014 10:20, schrieb Edgar Mueller:
>>>>> Hi Marina,
>>>>>
>>>>> Jonas meant whether you called the save() method on the ESLocalProject
>>>>> after you've added your model elements, but this should already be the
>>>>> case when sharing a project.
>>>>>
>>>>> I do not yet entirely understand your application's control flow. When
>>>>> the performFinished method has finished and you restart your
>>>>> application, does anything happen before you iterate through the
>>>>> workspace? Can you check the project's contents right after application
>>>>> has restarted?
>>>>>
>>>>> The helloworld example does work for me (although you'll need to modify
>>>>> the example since it always creates a new empty project). Can you tell
>>>>> me how you checked the helloworld example? Ideally, something
>>>>> reproducable would help us to diagnose the problem.
>>>>>
>>>>> Cheers,
>>>>> Edgar
>>>>>
>>>>> Am 10.03.2014 20:18, schrieb Marina Knieling:
>>>>>> What exactly do you mean?
>>>>>> This is what I do in my performFinish method:
>>>>>>
>>>>>> ESLocalProject organProject =
>>>>>> workspace.createLocalProject(organ.getOrganID());
>>>>>> ESUsersession userSession =
>>>>>> workspace.getServers().get(0).getLastUsersession();
>>>>>> organProject.getModelElements().add(organ);
>>>>>> organProject.shareProject(userSession, new
>>>>>> ESSystemOutProgressMonitor());
>>>>>>
>>>>>> And the xml files also exist in the .emfstore/client and
>>>>>> .emfstore/server folders. The projects get read and the IDs are
>>>>>> exactly
>>>>>> as they are displayed in the folder. It's only the model elements that
>>>>>> aren't populated.
>>>>>>
>>>>>> This is one of the xml files (client version):
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>> <org.eclipse.emf.emfstore.internal.common.model:Project
>>>>>> xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>>> xmlns:commamod="http://www.vknie.com/commamod"
>>>>>> xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
>>>>>>
>>>>>>
>>>>>>
>>>>>> <modelElements xsi:type="commamod:Organ"
>>>>>> xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel" location="Paderborn"
>>>>>> numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
>>>>>> numberOfPipes="9840" numberOfRanks="4"/>
>>>>>> </org.eclipse.emf.emfstore.internal.common.model:Project>
>>>>>>
>>>>>> So obviously there IS a model element (the Organ) in the file. But
>>>>>> calling localProject.getModelElements().size() returns 0 and debugging
>>>>>> also only displays an empty list.
>>>>>>
>>>>>> Am 10.03.2014 20:00, schrieb Jonas Helming:
>>>>>>> Hi,
>>>>>>>
>>>>>>> do you save the project somewhere?
>>>>>>>
>>>>>>> regards
>>>>>>>
>>>>>>> jonas
>>>>>>>
>>>>>>> Am 10.03.2014 14:18, schrieb Marina Knieling:
>>>>>>>> Hey guys,
>>>>>>>>
>>>>>>>> another problem or strange behaviour just popped up. I'm using the
>>>>>>>> EMFStore API to store my objects. I have a wizard that creates an
>>>>>>>> object
>>>>>>>> and in the performFinish method I create a ESLocalProject, add my
>>>>>>>> own
>>>>>>>> object to the modelElements and share it with the server. This works
>>>>>>>> perfectly fine, the file is created and the object is stored in it.
>>>>>>>>
>>>>>>>> I also have a mechanism to switch the active element to work with
>>>>>>>> (like
>>>>>>>> switching the workspace in eclipse). This is implemented using a
>>>>>>>> JFace
>>>>>>>> ListDialog. The idea was to iterate through all local projects
>>>>>>>> and get
>>>>>>>> the first modelElement out of it (which should be my top object).
>>>>>>>> This
>>>>>>>> works fine, when I do it in the same "session" where I created that
>>>>>>>> object / that local project. But when I shut down my application and
>>>>>>>> start it again, the ListDialog keeps empty and debugging shows, that
>>>>>>>> there are no elements in the modelElements reference from the
>>>>>>>> ESLocalProject. I even tried the projects from the helloworld
>>>>>>>> example
>>>>>>>> and they are also empty.
>>>>>>>>
>>>>>>>> The code is the following:
>>>>>>>>
>>>>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>>>>> for(ESLocalProject p : projects){
>>>>>>>> System.out.println("modelElements: " +
>>>>>>>> p.getModelElements().size());
>>>>>>>> for(EObject o : p.getModelElements()){
>>>>>>>> if(o instanceof Organ)
>>>>>>>> allOrgans.add((Organ) o);
>>>>>>>> }
>>>>>>>>
>>>>>>>> }
>>>>>>>> System.out.println("organs: " + allOrgans.size());
>>>>>>>> dialog.setInput(allOrgans);
>>>>>>>>
>>>>>>>> Is there something wrong with my code? Do I have to do anything
>>>>>>>> else?
>>>>>>>>
>>>>>>>> Thanks in advance
>>>>>>>> Marina
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1269930 is a reply to message #1269913] Wed, 12 March 2014 10:21 Go to previous messageGo to next message
Edgar Mueller is currently offline Edgar Mueller
Messages: 61
Registered: March 2011
Member
Hi Marina,

ok, can you check the registration of your model, i.e.
the org.eclipse.emf.ecore.generated_package extension point? Is the
value of the URI attribute the same as in your model? I think in your
case it should be "http://www.vknie.com/commamod".


Am 12.03.2014 11:04, schrieb Marina Knieling:
> Hi Edgar,
>
> I tried to change the start level of my model and model.edit bundle from
> default to 3, 2 and 1, but nothing worked. The application only
> recognizes the helloworld example projects' modelelements.
>
> Is there any way to "see" when the bundles are loaded? I know about the
> OSGi console and I used a breakpoint in my start method from the
> app.Activator class I send you, but it seems that it is already too late
> as my model bundles are already active/starting and the emfstore bundles
> as well.
>

> I don't have the helloworld example in my runtime config, only the
> created projects in the .emfstore folder, but nevertheless my
> application knows that there is 1 modelelement in it.
>
> Any other ideas? I'm slowly going mad.
>
> Am 11.03.2014 19:11, schrieb Edgar Mueller:
>> Hi Marina,
>>
>> I think the issue lies within the initialization order of your bundles.
>> It seems as if your model plugin has not been resolved when the
>> workspace is initializing. That's why the example project seems to work.
>> Can you try to make sure your model bundle is loaded before the emfstore
>> bundles?
>>
>> Cheers,
>> Edgar
>>
>> Am 11.03.2014 14:49, schrieb Marina Knieling:
>>> Hi Edgar,
>>>
>>> I just changed my runtime config from features to plugins, now the
>>> helloworld example projects are populated with their modelElements but
>>> my own still aren't. Maybe I even miss something in my runtime config
>>> although I don't get any errors on startup.
>>>
>>> However, find attached my Activator. Yes, I do use
>>> ESWorkspaceProvider.INSTANCE.getWorkspace().
>>>
>>> Thanks for your help
>>>
>>>
>>> Am 11.03.2014 14:36, schrieb Edgar Mueller:
>>>> Hi Marina,
>>>>
>>>> from your screenshot I can see that your workspace didn't initialze
>>>> correctly (modCount of the modelElements feature should not be 0), i.e.
>>>> the load function within ESWorkspaceProviderImpl did not get called or
>>>> failed for some reason.
>>>> How do you initialize your workspace reference? Do you use
>>>> ESWorkspaceProvider.INSTANCE? Are you able to send me the complete code
>>>> of your Activator?
>>>>
>>>> Cheers,
>>>> Edgar
>>>>
>>>> Am 11.03.2014 13:36, schrieb Marina Knieling:
>>>>> Ok, let's try again:
>>>>>
>>>>> When the application is started the very first time, the user needs to
>>>>> create an Organ object (this is my top level object in my hierarchy -
>>>>> like the League in the helloworld example). I create this object via a
>>>>> JFace wizard. The performFinish method creates an ESLocalProject, adds
>>>>> the Organ object to its modelelements and shares the project (as
>>>>> already
>>>>> mentioned in the previous post).
>>>>>
>>>>> I have a command to switch the Organ (like switching the workspace in
>>>>> eclipse) and if I call this command/handler now (in the same "session"
>>>>> where I created the Organ object), the recently added Organ gets
>>>>> displayed in the ListDialog and my console output says 1
>>>>> modelelement is
>>>>> there and 1 project.
>>>>>
>>>>> I now close my application. I checked back the standard .emfstore
>>>>> folders whether the project was created correctly and I don't find any
>>>>> errors there. The project file exists and has the before mentioned
>>>>> contents (see last post).
>>>>>
>>>>> Now I start my application again and call the SwitchOrgan handler. The
>>>>> ListDialog keeps empty and the console output says 0 modelElements,
>>>>> but
>>>>> 1 project.
>>>>>
>>>>> Concerning the helloworld example:
>>>>> I ran the example and then ran my application afterwards (so the
>>>>> .emfstore folder still had the 2 projects from the helloworld
>>>>> example)
>>>>> and my console output said: 3 projects and 0 modelElements for each of
>>>>> those projects.
>>>>>
>>>>> Console output refers to these lines in the OrganSelectionDialog class
>>>>> with the ListDialog in it, which should be populated with all Organs
>>>>> (i.e. all top level modelElements from all local projects):
>>>>>
>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>> System.out.println("# projects: " + projects.size());
>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>> for(ESLocalProject p : projects){
>>>>> System.out.println("# modelElements: " +
>>>>> p.getModelElements().size());
>>>>> for(EObject o : p.getModelElements()){
>>>>> if(o instanceof Organ)
>>>>> allOrgans.add((Organ) o);
>>>>> }
>>>>> }
>>>>> System.out.println("organs: " + allOrgans.size());
>>>>> dialog.setInput(allOrgans);
>>>>>
>>>>> ---
>>>>> The only thing I do during startup is to find the last active Organ (I
>>>>> store the ID in the preferences), but already there the modelelements
>>>>> are empty, see attached screenshot of debug.
>>>>>
>>>>> I hope my problem is now clear and you understand what I'm doing.
>>>>> Thanks
>>>>> for your help guys.
>>>>>
>>>>> Am 11.03.2014 10:20, schrieb Edgar Mueller:
>>>>>> Hi Marina,
>>>>>>
>>>>>> Jonas meant whether you called the save() method on the
>>>>>> ESLocalProject
>>>>>> after you've added your model elements, but this should already be
>>>>>> the
>>>>>> case when sharing a project.
>>>>>>
>>>>>> I do not yet entirely understand your application's control flow.
>>>>>> When
>>>>>> the performFinished method has finished and you restart your
>>>>>> application, does anything happen before you iterate through the
>>>>>> workspace? Can you check the project's contents right after
>>>>>> application
>>>>>> has restarted?
>>>>>>
>>>>>> The helloworld example does work for me (although you'll need to
>>>>>> modify
>>>>>> the example since it always creates a new empty project). Can you
>>>>>> tell
>>>>>> me how you checked the helloworld example? Ideally, something
>>>>>> reproducable would help us to diagnose the problem.
>>>>>>
>>>>>> Cheers,
>>>>>> Edgar
>>>>>>
>>>>>> Am 10.03.2014 20:18, schrieb Marina Knieling:
>>>>>>> What exactly do you mean?
>>>>>>> This is what I do in my performFinish method:
>>>>>>>
>>>>>>> ESLocalProject organProject =
>>>>>>> workspace.createLocalProject(organ.getOrganID());
>>>>>>> ESUsersession userSession =
>>>>>>> workspace.getServers().get(0).getLastUsersession();
>>>>>>> organProject.getModelElements().add(organ);
>>>>>>> organProject.shareProject(userSession, new
>>>>>>> ESSystemOutProgressMonitor());
>>>>>>>
>>>>>>> And the xml files also exist in the .emfstore/client and
>>>>>>> .emfstore/server folders. The projects get read and the IDs are
>>>>>>> exactly
>>>>>>> as they are displayed in the folder. It's only the model elements
>>>>>>> that
>>>>>>> aren't populated.
>>>>>>>
>>>>>>> This is one of the xml files (client version):
>>>>>>>
>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>> <org.eclipse.emf.emfstore.internal.common.model:Project
>>>>>>> xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>>>> xmlns:commamod="http://www.vknie.com/commamod"
>>>>>>> xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> <modelElements xsi:type="commamod:Organ"
>>>>>>> xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel"
>>>>>>> location="Paderborn"
>>>>>>> numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
>>>>>>> numberOfPipes="9840" numberOfRanks="4"/>
>>>>>>> </org.eclipse.emf.emfstore.internal.common.model:Project>
>>>>>>>
>>>>>>> So obviously there IS a model element (the Organ) in the file. But
>>>>>>> calling localProject.getModelElements().size() returns 0 and
>>>>>>> debugging
>>>>>>> also only displays an empty list.
>>>>>>>
>>>>>>> Am 10.03.2014 20:00, schrieb Jonas Helming:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> do you save the project somewhere?
>>>>>>>>
>>>>>>>> regards
>>>>>>>>
>>>>>>>> jonas
>>>>>>>>
>>>>>>>> Am 10.03.2014 14:18, schrieb Marina Knieling:
>>>>>>>>> Hey guys,
>>>>>>>>>
>>>>>>>>> another problem or strange behaviour just popped up. I'm using the
>>>>>>>>> EMFStore API to store my objects. I have a wizard that creates an
>>>>>>>>> object
>>>>>>>>> and in the performFinish method I create a ESLocalProject, add my
>>>>>>>>> own
>>>>>>>>> object to the modelElements and share it with the server. This
>>>>>>>>> works
>>>>>>>>> perfectly fine, the file is created and the object is stored in
>>>>>>>>> it.
>>>>>>>>>
>>>>>>>>> I also have a mechanism to switch the active element to work with
>>>>>>>>> (like
>>>>>>>>> switching the workspace in eclipse). This is implemented using a
>>>>>>>>> JFace
>>>>>>>>> ListDialog. The idea was to iterate through all local projects
>>>>>>>>> and get
>>>>>>>>> the first modelElement out of it (which should be my top object).
>>>>>>>>> This
>>>>>>>>> works fine, when I do it in the same "session" where I created
>>>>>>>>> that
>>>>>>>>> object / that local project. But when I shut down my
>>>>>>>>> application and
>>>>>>>>> start it again, the ListDialog keeps empty and debugging shows,
>>>>>>>>> that
>>>>>>>>> there are no elements in the modelElements reference from the
>>>>>>>>> ESLocalProject. I even tried the projects from the helloworld
>>>>>>>>> example
>>>>>>>>> and they are also empty.
>>>>>>>>>
>>>>>>>>> The code is the following:
>>>>>>>>>
>>>>>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>>>>>> for(ESLocalProject p : projects){
>>>>>>>>> System.out.println("modelElements: " +
>>>>>>>>> p.getModelElements().size());
>>>>>>>>> for(EObject o : p.getModelElements()){
>>>>>>>>> if(o instanceof Organ)
>>>>>>>>> allOrgans.add((Organ) o);
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>> System.out.println("organs: " + allOrgans.size());
>>>>>>>>> dialog.setInput(allOrgans);
>>>>>>>>>
>>>>>>>>> Is there something wrong with my code? Do I have to do anything
>>>>>>>>> else?
>>>>>>>>>
>>>>>>>>> Thanks in advance
>>>>>>>>> Marina
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>


--
Edgar Mueller

Get Professional Eclipse Support: http://eclipsesource.com/munich
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1269945 is a reply to message #1269930] Wed, 12 March 2014 10:40 Go to previous messageGo to next message
Marina Knieling is currently offline Marina Knieling
Messages: 78
Registered: February 2013
Member
Edgar, my saviour (you can join Jonas now ;-) )

You did it!!! It wasn't the same. How can that happen and how do I
prevent that from happening again?

Thank you very very much for your patience.

Cheers,
Marina

Am 12.03.2014 11:21, schrieb Edgar Mueller:
> Hi Marina,
>
> ok, can you check the registration of your model, i.e.
> the org.eclipse.emf.ecore.generated_package extension point? Is the
> value of the URI attribute the same as in your model? I think in your
> case it should be "http://www.vknie.com/commamod".
>
>
> Am 12.03.2014 11:04, schrieb Marina Knieling:
>> Hi Edgar,
>>
>> I tried to change the start level of my model and model.edit bundle from
>> default to 3, 2 and 1, but nothing worked. The application only
>> recognizes the helloworld example projects' modelelements.
>>
>> Is there any way to "see" when the bundles are loaded? I know about the
>> OSGi console and I used a breakpoint in my start method from the
>> app.Activator class I send you, but it seems that it is already too late
>> as my model bundles are already active/starting and the emfstore bundles
>> as well.
>>
>
>> I don't have the helloworld example in my runtime config, only the
>> created projects in the .emfstore folder, but nevertheless my
>> application knows that there is 1 modelelement in it.
>>
>> Any other ideas? I'm slowly going mad.
>>
>> Am 11.03.2014 19:11, schrieb Edgar Mueller:
>>> Hi Marina,
>>>
>>> I think the issue lies within the initialization order of your bundles.
>>> It seems as if your model plugin has not been resolved when the
>>> workspace is initializing. That's why the example project seems to work.
>>> Can you try to make sure your model bundle is loaded before the emfstore
>>> bundles?
>>>
>>> Cheers,
>>> Edgar
>>>
>>> Am 11.03.2014 14:49, schrieb Marina Knieling:
>>>> Hi Edgar,
>>>>
>>>> I just changed my runtime config from features to plugins, now the
>>>> helloworld example projects are populated with their modelElements but
>>>> my own still aren't. Maybe I even miss something in my runtime config
>>>> although I don't get any errors on startup.
>>>>
>>>> However, find attached my Activator. Yes, I do use
>>>> ESWorkspaceProvider.INSTANCE.getWorkspace().
>>>>
>>>> Thanks for your help
>>>>
>>>>
>>>> Am 11.03.2014 14:36, schrieb Edgar Mueller:
>>>>> Hi Marina,
>>>>>
>>>>> from your screenshot I can see that your workspace didn't initialze
>>>>> correctly (modCount of the modelElements feature should not be 0), i.e.
>>>>> the load function within ESWorkspaceProviderImpl did not get called or
>>>>> failed for some reason.
>>>>> How do you initialize your workspace reference? Do you use
>>>>> ESWorkspaceProvider.INSTANCE? Are you able to send me the complete code
>>>>> of your Activator?
>>>>>
>>>>> Cheers,
>>>>> Edgar
>>>>>
>>>>> Am 11.03.2014 13:36, schrieb Marina Knieling:
>>>>>> Ok, let's try again:
>>>>>>
>>>>>> When the application is started the very first time, the user needs to
>>>>>> create an Organ object (this is my top level object in my hierarchy -
>>>>>> like the League in the helloworld example). I create this object via a
>>>>>> JFace wizard. The performFinish method creates an ESLocalProject, adds
>>>>>> the Organ object to its modelelements and shares the project (as
>>>>>> already
>>>>>> mentioned in the previous post).
>>>>>>
>>>>>> I have a command to switch the Organ (like switching the workspace in
>>>>>> eclipse) and if I call this command/handler now (in the same "session"
>>>>>> where I created the Organ object), the recently added Organ gets
>>>>>> displayed in the ListDialog and my console output says 1
>>>>>> modelelement is
>>>>>> there and 1 project.
>>>>>>
>>>>>> I now close my application. I checked back the standard .emfstore
>>>>>> folders whether the project was created correctly and I don't find any
>>>>>> errors there. The project file exists and has the before mentioned
>>>>>> contents (see last post).
>>>>>>
>>>>>> Now I start my application again and call the SwitchOrgan handler. The
>>>>>> ListDialog keeps empty and the console output says 0 modelElements,
>>>>>> but
>>>>>> 1 project.
>>>>>>
>>>>>> Concerning the helloworld example:
>>>>>> I ran the example and then ran my application afterwards (so the
>>>>>> .emfstore folder still had the 2 projects from the helloworld
>>>>>> example)
>>>>>> and my console output said: 3 projects and 0 modelElements for each of
>>>>>> those projects.
>>>>>>
>>>>>> Console output refers to these lines in the OrganSelectionDialog class
>>>>>> with the ListDialog in it, which should be populated with all Organs
>>>>>> (i.e. all top level modelElements from all local projects):
>>>>>>
>>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>>> System.out.println("# projects: " + projects.size());
>>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>>> for(ESLocalProject p : projects){
>>>>>> System.out.println("# modelElements: " +
>>>>>> p.getModelElements().size());
>>>>>> for(EObject o : p.getModelElements()){
>>>>>> if(o instanceof Organ)
>>>>>> allOrgans.add((Organ) o);
>>>>>> }
>>>>>> }
>>>>>> System.out.println("organs: " + allOrgans.size());
>>>>>> dialog.setInput(allOrgans);
>>>>>>
>>>>>> ---
>>>>>> The only thing I do during startup is to find the last active Organ (I
>>>>>> store the ID in the preferences), but already there the modelelements
>>>>>> are empty, see attached screenshot of debug.
>>>>>>
>>>>>> I hope my problem is now clear and you understand what I'm doing.
>>>>>> Thanks
>>>>>> for your help guys.
>>>>>>
>>>>>> Am 11.03.2014 10:20, schrieb Edgar Mueller:
>>>>>>> Hi Marina,
>>>>>>>
>>>>>>> Jonas meant whether you called the save() method on the
>>>>>>> ESLocalProject
>>>>>>> after you've added your model elements, but this should already be
>>>>>>> the
>>>>>>> case when sharing a project.
>>>>>>>
>>>>>>> I do not yet entirely understand your application's control flow.
>>>>>>> When
>>>>>>> the performFinished method has finished and you restart your
>>>>>>> application, does anything happen before you iterate through the
>>>>>>> workspace? Can you check the project's contents right after
>>>>>>> application
>>>>>>> has restarted?
>>>>>>>
>>>>>>> The helloworld example does work for me (although you'll need to
>>>>>>> modify
>>>>>>> the example since it always creates a new empty project). Can you
>>>>>>> tell
>>>>>>> me how you checked the helloworld example? Ideally, something
>>>>>>> reproducable would help us to diagnose the problem.
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Edgar
>>>>>>>
>>>>>>> Am 10.03.2014 20:18, schrieb Marina Knieling:
>>>>>>>> What exactly do you mean?
>>>>>>>> This is what I do in my performFinish method:
>>>>>>>>
>>>>>>>> ESLocalProject organProject =
>>>>>>>> workspace.createLocalProject(organ.getOrganID());
>>>>>>>> ESUsersession userSession =
>>>>>>>> workspace.getServers().get(0).getLastUsersession();
>>>>>>>> organProject.getModelElements().add(organ);
>>>>>>>> organProject.shareProject(userSession, new
>>>>>>>> ESSystemOutProgressMonitor());
>>>>>>>>
>>>>>>>> And the xml files also exist in the .emfstore/client and
>>>>>>>> .emfstore/server folders. The projects get read and the IDs are
>>>>>>>> exactly
>>>>>>>> as they are displayed in the folder. It's only the model elements
>>>>>>>> that
>>>>>>>> aren't populated.
>>>>>>>>
>>>>>>>> This is one of the xml files (client version):
>>>>>>>>
>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>> <org.eclipse.emf.emfstore.internal.common.model:Project
>>>>>>>> xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>>>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>> xmlns:commamod="http://www.vknie.com/commamod"
>>>>>>>> xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> <modelElements xsi:type="commamod:Organ"
>>>>>>>> xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel"
>>>>>>>> location="Paderborn"
>>>>>>>> numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
>>>>>>>> numberOfPipes="9840" numberOfRanks="4"/>
>>>>>>>> </org.eclipse.emf.emfstore.internal.common.model:Project>
>>>>>>>>
>>>>>>>> So obviously there IS a model element (the Organ) in the file. But
>>>>>>>> calling localProject.getModelElements().size() returns 0 and
>>>>>>>> debugging
>>>>>>>> also only displays an empty list.
>>>>>>>>
>>>>>>>> Am 10.03.2014 20:00, schrieb Jonas Helming:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> do you save the project somewhere?
>>>>>>>>>
>>>>>>>>> regards
>>>>>>>>>
>>>>>>>>> jonas
>>>>>>>>>
>>>>>>>>> Am 10.03.2014 14:18, schrieb Marina Knieling:
>>>>>>>>>> Hey guys,
>>>>>>>>>>
>>>>>>>>>> another problem or strange behaviour just popped up. I'm using the
>>>>>>>>>> EMFStore API to store my objects. I have a wizard that creates an
>>>>>>>>>> object
>>>>>>>>>> and in the performFinish method I create a ESLocalProject, add my
>>>>>>>>>> own
>>>>>>>>>> object to the modelElements and share it with the server. This
>>>>>>>>>> works
>>>>>>>>>> perfectly fine, the file is created and the object is stored in
>>>>>>>>>> it.
>>>>>>>>>>
>>>>>>>>>> I also have a mechanism to switch the active element to work with
>>>>>>>>>> (like
>>>>>>>>>> switching the workspace in eclipse). This is implemented using a
>>>>>>>>>> JFace
>>>>>>>>>> ListDialog. The idea was to iterate through all local projects
>>>>>>>>>> and get
>>>>>>>>>> the first modelElement out of it (which should be my top object).
>>>>>>>>>> This
>>>>>>>>>> works fine, when I do it in the same "session" where I created
>>>>>>>>>> that
>>>>>>>>>> object / that local project. But when I shut down my
>>>>>>>>>> application and
>>>>>>>>>> start it again, the ListDialog keeps empty and debugging shows,
>>>>>>>>>> that
>>>>>>>>>> there are no elements in the modelElements reference from the
>>>>>>>>>> ESLocalProject. I even tried the projects from the helloworld
>>>>>>>>>> example
>>>>>>>>>> and they are also empty.
>>>>>>>>>>
>>>>>>>>>> The code is the following:
>>>>>>>>>>
>>>>>>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>>>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>>>>>>> for(ESLocalProject p : projects){
>>>>>>>>>> System.out.println("modelElements: " +
>>>>>>>>>> p.getModelElements().size());
>>>>>>>>>> for(EObject o : p.getModelElements()){
>>>>>>>>>> if(o instanceof Organ)
>>>>>>>>>> allOrgans.add((Organ) o);
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> }
>>>>>>>>>> System.out.println("organs: " + allOrgans.size());
>>>>>>>>>> dialog.setInput(allOrgans);
>>>>>>>>>>
>>>>>>>>>> Is there something wrong with my code? Do I have to do anything
>>>>>>>>>> else?
>>>>>>>>>>
>>>>>>>>>> Thanks in advance
>>>>>>>>>> Marina
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>
Re: [EMFStore] Urgent - ModelElements not populated after shutdown and restart of application [message #1270069 is a reply to message #1269945] Wed, 12 March 2014 13:06 Go to previous message
Edgar Mueller is currently offline Edgar Mueller
Messages: 61
Registered: March 2011
Member
Hi Marina,

glad to hear you could solve the problem. I think this error happens if
you already have triggered the generator once and change the nsURI
attribute afterwards, since the changes will not be written to the
plugin.xml.
But it should work, of course, if you delete the plugin.xml before you
trigger the re-generation, such that the whole file will be written again.

Cheers,
Edgar

Am 12.03.2014 11:40, schrieb Marina Knieling:
> Edgar, my saviour (you can join Jonas now ;-) )
>
> You did it!!! It wasn't the same. How can that happen and how do I
> prevent that from happening again?
>
> Thank you very very much for your patience.
>
> Cheers,
> Marina
>
> Am 12.03.2014 11:21, schrieb Edgar Mueller:
>> Hi Marina,
>>
>> ok, can you check the registration of your model, i.e.
>> the org.eclipse.emf.ecore.generated_package extension point? Is the
>> value of the URI attribute the same as in your model? I think in your
>> case it should be "http://www.vknie.com/commamod".
>>
>>
>> Am 12.03.2014 11:04, schrieb Marina Knieling:
>>> Hi Edgar,
>>>
>>> I tried to change the start level of my model and model.edit bundle from
>>> default to 3, 2 and 1, but nothing worked. The application only
>>> recognizes the helloworld example projects' modelelements.
>>>
>>> Is there any way to "see" when the bundles are loaded? I know about the
>>> OSGi console and I used a breakpoint in my start method from the
>>> app.Activator class I send you, but it seems that it is already too late
>>> as my model bundles are already active/starting and the emfstore bundles
>>> as well.
>>>
>>
>>> I don't have the helloworld example in my runtime config, only the
>>> created projects in the .emfstore folder, but nevertheless my
>>> application knows that there is 1 modelelement in it.
>>>
>>> Any other ideas? I'm slowly going mad.
>>>
>>> Am 11.03.2014 19:11, schrieb Edgar Mueller:
>>>> Hi Marina,
>>>>
>>>> I think the issue lies within the initialization order of your bundles.
>>>> It seems as if your model plugin has not been resolved when the
>>>> workspace is initializing. That's why the example project seems to
>>>> work.
>>>> Can you try to make sure your model bundle is loaded before the
>>>> emfstore
>>>> bundles?
>>>>
>>>> Cheers,
>>>> Edgar
>>>>
>>>> Am 11.03.2014 14:49, schrieb Marina Knieling:
>>>>> Hi Edgar,
>>>>>
>>>>> I just changed my runtime config from features to plugins, now the
>>>>> helloworld example projects are populated with their modelElements but
>>>>> my own still aren't. Maybe I even miss something in my runtime config
>>>>> although I don't get any errors on startup.
>>>>>
>>>>> However, find attached my Activator. Yes, I do use
>>>>> ESWorkspaceProvider.INSTANCE.getWorkspace().
>>>>>
>>>>> Thanks for your help
>>>>>
>>>>>
>>>>> Am 11.03.2014 14:36, schrieb Edgar Mueller:
>>>>>> Hi Marina,
>>>>>>
>>>>>> from your screenshot I can see that your workspace didn't initialze
>>>>>> correctly (modCount of the modelElements feature should not be 0),
>>>>>> i.e.
>>>>>> the load function within ESWorkspaceProviderImpl did not get
>>>>>> called or
>>>>>> failed for some reason.
>>>>>> How do you initialize your workspace reference? Do you use
>>>>>> ESWorkspaceProvider.INSTANCE? Are you able to send me the complete
>>>>>> code
>>>>>> of your Activator?
>>>>>>
>>>>>> Cheers,
>>>>>> Edgar
>>>>>>
>>>>>> Am 11.03.2014 13:36, schrieb Marina Knieling:
>>>>>>> Ok, let's try again:
>>>>>>>
>>>>>>> When the application is started the very first time, the user
>>>>>>> needs to
>>>>>>> create an Organ object (this is my top level object in my
>>>>>>> hierarchy -
>>>>>>> like the League in the helloworld example). I create this object
>>>>>>> via a
>>>>>>> JFace wizard. The performFinish method creates an ESLocalProject,
>>>>>>> adds
>>>>>>> the Organ object to its modelelements and shares the project (as
>>>>>>> already
>>>>>>> mentioned in the previous post).
>>>>>>>
>>>>>>> I have a command to switch the Organ (like switching the
>>>>>>> workspace in
>>>>>>> eclipse) and if I call this command/handler now (in the same
>>>>>>> "session"
>>>>>>> where I created the Organ object), the recently added Organ gets
>>>>>>> displayed in the ListDialog and my console output says 1
>>>>>>> modelelement is
>>>>>>> there and 1 project.
>>>>>>>
>>>>>>> I now close my application. I checked back the standard .emfstore
>>>>>>> folders whether the project was created correctly and I don't
>>>>>>> find any
>>>>>>> errors there. The project file exists and has the before mentioned
>>>>>>> contents (see last post).
>>>>>>>
>>>>>>> Now I start my application again and call the SwitchOrgan
>>>>>>> handler. The
>>>>>>> ListDialog keeps empty and the console output says 0 modelElements,
>>>>>>> but
>>>>>>> 1 project.
>>>>>>>
>>>>>>> Concerning the helloworld example:
>>>>>>> I ran the example and then ran my application afterwards (so the
>>>>>>> .emfstore folder still had the 2 projects from the helloworld
>>>>>>> example)
>>>>>>> and my console output said: 3 projects and 0 modelElements for
>>>>>>> each of
>>>>>>> those projects.
>>>>>>>
>>>>>>> Console output refers to these lines in the OrganSelectionDialog
>>>>>>> class
>>>>>>> with the ListDialog in it, which should be populated with all Organs
>>>>>>> (i.e. all top level modelElements from all local projects):
>>>>>>>
>>>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>>>> System.out.println("# projects: " + projects.size());
>>>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>>>> for(ESLocalProject p : projects){
>>>>>>> System.out.println("# modelElements: " +
>>>>>>> p.getModelElements().size());
>>>>>>> for(EObject o : p.getModelElements()){
>>>>>>> if(o instanceof Organ)
>>>>>>> allOrgans.add((Organ) o);
>>>>>>> }
>>>>>>> }
>>>>>>> System.out.println("organs: " + allOrgans.size());
>>>>>>> dialog.setInput(allOrgans);
>>>>>>>
>>>>>>> ---
>>>>>>> The only thing I do during startup is to find the last active
>>>>>>> Organ (I
>>>>>>> store the ID in the preferences), but already there the
>>>>>>> modelelements
>>>>>>> are empty, see attached screenshot of debug.
>>>>>>>
>>>>>>> I hope my problem is now clear and you understand what I'm doing.
>>>>>>> Thanks
>>>>>>> for your help guys.
>>>>>>>
>>>>>>> Am 11.03.2014 10:20, schrieb Edgar Mueller:
>>>>>>>> Hi Marina,
>>>>>>>>
>>>>>>>> Jonas meant whether you called the save() method on the
>>>>>>>> ESLocalProject
>>>>>>>> after you've added your model elements, but this should already be
>>>>>>>> the
>>>>>>>> case when sharing a project.
>>>>>>>>
>>>>>>>> I do not yet entirely understand your application's control flow.
>>>>>>>> When
>>>>>>>> the performFinished method has finished and you restart your
>>>>>>>> application, does anything happen before you iterate through the
>>>>>>>> workspace? Can you check the project's contents right after
>>>>>>>> application
>>>>>>>> has restarted?
>>>>>>>>
>>>>>>>> The helloworld example does work for me (although you'll need to
>>>>>>>> modify
>>>>>>>> the example since it always creates a new empty project). Can you
>>>>>>>> tell
>>>>>>>> me how you checked the helloworld example? Ideally, something
>>>>>>>> reproducable would help us to diagnose the problem.
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> Edgar
>>>>>>>>
>>>>>>>> Am 10.03.2014 20:18, schrieb Marina Knieling:
>>>>>>>>> What exactly do you mean?
>>>>>>>>> This is what I do in my performFinish method:
>>>>>>>>>
>>>>>>>>> ESLocalProject organProject =
>>>>>>>>> workspace.createLocalProject(organ.getOrganID());
>>>>>>>>> ESUsersession userSession =
>>>>>>>>> workspace.getServers().get(0).getLastUsersession();
>>>>>>>>> organProject.getModelElements().add(organ);
>>>>>>>>> organProject.shareProject(userSession, new
>>>>>>>>> ESSystemOutProgressMonitor());
>>>>>>>>>
>>>>>>>>> And the xml files also exist in the .emfstore/client and
>>>>>>>>> .emfstore/server folders. The projects get read and the IDs are
>>>>>>>>> exactly
>>>>>>>>> as they are displayed in the folder. It's only the model elements
>>>>>>>>> that
>>>>>>>>> aren't populated.
>>>>>>>>>
>>>>>>>>> This is one of the xml files (client version):
>>>>>>>>>
>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>> <org.eclipse.emf.emfstore.internal.common.model:Project
>>>>>>>>> xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>>>>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>> xmlns:commamod="http://www.vknie.com/commamod"
>>>>>>>>> xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model">
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> <modelElements xsi:type="commamod:Organ"
>>>>>>>>> xmi:id="_xuZ8gKhUEeOipqjw_3X4mA" name="Domorgel"
>>>>>>>>> location="Paderborn"
>>>>>>>>> numberOfStops="92" organBuilder="Sauer" yearOfConstruction="1876"
>>>>>>>>> numberOfPipes="9840" numberOfRanks="4"/>
>>>>>>>>> </org.eclipse.emf.emfstore.internal.common.model:Project>
>>>>>>>>>
>>>>>>>>> So obviously there IS a model element (the Organ) in the file. But
>>>>>>>>> calling localProject.getModelElements().size() returns 0 and
>>>>>>>>> debugging
>>>>>>>>> also only displays an empty list.
>>>>>>>>>
>>>>>>>>> Am 10.03.2014 20:00, schrieb Jonas Helming:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> do you save the project somewhere?
>>>>>>>>>>
>>>>>>>>>> regards
>>>>>>>>>>
>>>>>>>>>> jonas
>>>>>>>>>>
>>>>>>>>>> Am 10.03.2014 14:18, schrieb Marina Knieling:
>>>>>>>>>>> Hey guys,
>>>>>>>>>>>
>>>>>>>>>>> another problem or strange behaviour just popped up. I'm
>>>>>>>>>>> using the
>>>>>>>>>>> EMFStore API to store my objects. I have a wizard that
>>>>>>>>>>> creates an
>>>>>>>>>>> object
>>>>>>>>>>> and in the performFinish method I create a ESLocalProject,
>>>>>>>>>>> add my
>>>>>>>>>>> own
>>>>>>>>>>> object to the modelElements and share it with the server. This
>>>>>>>>>>> works
>>>>>>>>>>> perfectly fine, the file is created and the object is stored in
>>>>>>>>>>> it.
>>>>>>>>>>>
>>>>>>>>>>> I also have a mechanism to switch the active element to work
>>>>>>>>>>> with
>>>>>>>>>>> (like
>>>>>>>>>>> switching the workspace in eclipse). This is implemented using a
>>>>>>>>>>> JFace
>>>>>>>>>>> ListDialog. The idea was to iterate through all local projects
>>>>>>>>>>> and get
>>>>>>>>>>> the first modelElement out of it (which should be my top
>>>>>>>>>>> object).
>>>>>>>>>>> This
>>>>>>>>>>> works fine, when I do it in the same "session" where I created
>>>>>>>>>>> that
>>>>>>>>>>> object / that local project. But when I shut down my
>>>>>>>>>>> application and
>>>>>>>>>>> start it again, the ListDialog keeps empty and debugging shows,
>>>>>>>>>>> that
>>>>>>>>>>> there are no elements in the modelElements reference from the
>>>>>>>>>>> ESLocalProject. I even tried the projects from the helloworld
>>>>>>>>>>> example
>>>>>>>>>>> and they are also empty.
>>>>>>>>>>>
>>>>>>>>>>> The code is the following:
>>>>>>>>>>>
>>>>>>>>>>> List<ESLocalProject> projects = workspace.getLocalProjects();
>>>>>>>>>>> List<Organ> allOrgans = new ArrayList<Organ>();
>>>>>>>>>>> for(ESLocalProject p : projects){
>>>>>>>>>>> System.out.println("modelElements: " +
>>>>>>>>>>> p.getModelElements().size());
>>>>>>>>>>> for(EObject o : p.getModelElements()){
>>>>>>>>>>> if(o instanceof Organ)
>>>>>>>>>>> allOrgans.add((Organ) o);
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> }
>>>>>>>>>>> System.out.println("organs: " + allOrgans.size());
>>>>>>>>>>> dialog.setInput(allOrgans);
>>>>>>>>>>>
>>>>>>>>>>> Is there something wrong with my code? Do I have to do anything
>>>>>>>>>>> else?
>>>>>>>>>>>
>>>>>>>>>>> Thanks in advance
>>>>>>>>>>> Marina
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>


--
Edgar Mueller

Get Professional Eclipse Support: http://eclipsesource.com/munich
Previous Topic:[Texo] Project status and ease of development
Next Topic:[EMFForms] How to enable creation and linking of Reference Features when embedding the Editor?
Goto Forum:
  


Current Time: Wed Oct 22 15:39:01 GMT 2014

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

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