Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMFStore] Export project to xmi file on server
[EMFStore] Export project to xmi file on server [message #1386396] Tue, 17 June 2014 10:23 Go to next message
Kristof Zalecki is currently offline Kristof ZaleckiFriend
Messages: 23
Registered: October 2013
Junior Member
Hi,

I am currently trying to get my projects into xmi files on my server. I
need this to be able to commit them to my SVN repository.

The plugin I've created receives a ProjectHistory object containing the
information about the project. The problem is that this object does not
contain the project itself, but the information about it and therefore
the resulting xmi file is pretty much empty.
How can I get the project itself exported?

Regards,
Kristof
Re: [EMFStore] Export project to xmi file on server [message #1386551 is a reply to message #1386396] Wed, 18 June 2014 08:46 Go to previous messageGo to next message
Maximilian Koegel is currently offline Maximilian KoegelFriend
Messages: 253
Registered: July 2009
Senior Member
Hi,

if you use the default backend all data is already stored in XMI files
on the server. Maybe I do not understand your requirements, but to me it
seems you could just put the whole EMFStore data folder into an SVN?

Best regards,
Maximilian

Am 17.06.2014 12:23, schrieb Zalecki, Kristof:
> Hi,
>
> I am currently trying to get my projects into xmi files on my server. I
> need this to be able to commit them to my SVN repository.
>
> The plugin I've created receives a ProjectHistory object containing the
> information about the project. The problem is that this object does not
> contain the project itself, but the information about it and therefore
> the resulting xmi file is pretty much empty.
> How can I get the project itself exported?
>
> Regards,
> Kristof


--
Maximilian Kögel

Get Professional Eclipse Support: http://eclipsesource.com/munich
Re: [EMFStore] Export project to xmi file on server [message #1386580 is a reply to message #1386551] Wed, 18 June 2014 11:29 Go to previous messageGo to next message
Kristof Zalecki is currently offline Kristof ZaleckiFriend
Messages: 23
Registered: October 2013
Junior Member
Hi Maximilian,

the projects in the .emfstore folder are saved with all the operations
etc, but I only need the current head version of the project which
should look like the xmi files you get when exporting a project from the
ECP Client. Those files are needed for an automated maven deployment
process later on.

Right now I am trying to create a local client based on your hello world
example, which checks out the needed project and saves it into an xmi file.
I attached the method in a file if you like to have a look.
The problem is, that it gets stuck at the following line:
ESWorkspace workspace = ESWorkspaceProvider.INSTANCE.getWorkspace();

I reused the code from a test plugin, where I tested the programmatic
check out. Strangely the same code works perfectly fine in the test
plugin but does not in my current plugin.
Could it have something to do with the fact, that the plugin is part of
my server instance?

Regards,
Kristof

Am 18.06.2014 10:46, schrieb Maximilian Koegel:
> Hi,
>
> if you use the default backend all data is already stored in XMI files
> on the server. Maybe I do not understand your requirements, but to me it
> seems you could just put the whole EMFStore data folder into an SVN?
>
> Best regards,
> Maximilian
>
> Am 17.06.2014 12:23, schrieb Zalecki, Kristof:
>> Hi,
>>
>> I am currently trying to get my projects into xmi files on my server. I
>> need this to be able to commit them to my SVN repository.
>>
>> The plugin I've created receives a ProjectHistory object containing the
>> information about the project. The problem is that this object does not
>> contain the project itself, but the information about it and therefore
>> the resulting xmi file is pretty much empty.
>> How can I get the project itself exported?
>>
>> Regards,
>> Kristof
>
>


private static String saveProjectToFile(String projectId) {
final String serverURL = "localhost";
final int serverPort = 8080;
final String serverCertificate = "emfstoreserver";
String fileName = "";

try {
ESServer remoteServer = ESServer.FACTORY.createServer(serverURL, serverPort, serverCertificate);

ESWorkspace workspace = ESWorkspaceProvider.INSTANCE.getWorkspace();
workspace.addServer(remoteServer);
for(ESServer existingServer: workspace.getServers()) {
if(existingServer != remoteServer) {
try {
workspace.removeServer(existingServer);
} catch (ESServerNotFoundException e) {
e.printStackTrace();
}
}
}

ESUsersession usersession = remoteServer.login("super", "super");

List<ESRemoteProject> remoteBuildProjects = remoteServer.getRemoteProjects();

for(ESRemoteProject singleProject: remoteBuildProjects) {
if(singleProject.getGlobalProjectId().getId().equals(projectId)) {
final String projectName = singleProject.getProjectName();
ESLocalProject localProject = singleProject.checkout(projectName, usersession, null);
fileName = "C:/" + projectName + ".xmi";
ResourceSet rs = new ResourceSetImpl();

XMIResourceImpl xmiResourceImpl = new XMIResourceImpl();
xmiResourceImpl.getDefaultSaveOptions().put(XMIResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);

rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());

URI fileURI = URI.createFileURI(fileName);
Resource resource = rs.createResource(fileURI);

EObject projectObject = (EObject) localProject;

resource.getContents().add(projectObject);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
} catch (ESException e) {
e.printStackTrace();
}
return fileName;
}
Re: [EMFStore] Export project to xmi file on server [message #1386999 is a reply to message #1386580] Mon, 23 June 2014 12:45 Go to previous messageGo to next message
Maximilian Koegel is currently offline Maximilian KoegelFriend
Messages: 253
Registered: July 2009
Senior Member
Hi Kristof,

comments inline...

> the projects in the .emfstore folder are saved with all the operations
> etc, but I only need the current head version of the project which
> should look like the xmi files you get when exporting a project from the
> ECP Client. Those files are needed for an automated maven deployment
> process later on.
OK, I see.

> Right now I am trying to create a local client based on your hello world
> example, which checks out the needed project and saves it into an xmi file.
> I attached the method in a file if you like to have a look.
> The problem is, that it gets stuck at the following line:
> ESWorkspace workspace = ESWorkspaceProvider.INSTANCE.getWorkspace();
What does exactly happens, exception?

> I reused the code from a test plugin, where I tested the programmatic
> check out. Strangely the same code works perfectly fine in the test
> plugin but does not in my current plugin.
> Could it have something to do with the fact, that the plugin is part of
> my server instance?

The project (state) of the current head version is always available in a
file called projectstate-x.ups where x is the current head version.
Maybe this is good enough for you?

Cheers,
Maximilian

>
> Regards,
> Kristof
>
> Am 18.06.2014 10:46, schrieb Maximilian Koegel:
>> Hi,
>>
>> if you use the default backend all data is already stored in XMI files
>> on the server. Maybe I do not understand your requirements, but to me it
>> seems you could just put the whole EMFStore data folder into an SVN?
>>
>> Best regards,
>> Maximilian
>>
>> Am 17.06.2014 12:23, schrieb Zalecki, Kristof:
>>> Hi,
>>>
>>> I am currently trying to get my projects into xmi files on my server. I
>>> need this to be able to commit them to my SVN repository.
>>>
>>> The plugin I've created receives a ProjectHistory object containing the
>>> information about the project. The problem is that this object does not
>>> contain the project itself, but the information about it and therefore
>>> the resulting xmi file is pretty much empty.
>>> How can I get the project itself exported?
>>>
>>> Regards,
>>> Kristof
>>
>>
>


--
Maximilian Kögel

Get Professional Eclipse Support: http://eclipsesource.com/munich
Re: [EMFStore] Export project to xmi file on server [message #1389336 is a reply to message #1386999] Fri, 27 June 2014 17:03 Go to previous message
Edgar Mueller is currently offline Edgar MuellerFriend
Messages: 89
Registered: March 2011
Member
Hi Kristof,

have you tried to reuse the ExportImportControllerFactory like this?

File temp =
File.createTempFile("project",
ExportImportDataUnits.Project.getExtension());

new ExportImportControllerExecutor(
temp,
new NullProgressMonitor()
).execute(ExportImportControllerFactory
.Export
.getExportProjectController(getProjectSpace()));

This will only export the project itself and not its operation or other
meta data about the project. You might also want to check the other
controllers in case you need something else.

Hope this helps!

Cheers,
Edgar


Am 23.06.2014 14:45, schrieb Maximilian Koegel:
> Hi Kristof,
>
> comments inline...
>

> OK, I see.
>
>> Right now I am trying to create a local client based on your hello world
>> example, which checks out the needed project and saves it into an xmi file.
>> I attached the method in a file if you like to have a look.
>> The problem is, that it gets stuck at the following line:
>> ESWorkspace workspace = ESWorkspaceProvider.INSTANCE.getWorkspace();
> What does exactly happens, exception?
>
>> I reused the code from a test plugin, where I tested the programmatic
>> check out. Strangely the same code works perfectly fine in the test
>> plugin but does not in my current plugin.
>> Could it have something to do with the fact, that the plugin is part of
>> my server instance?
>
> The project (state) of the current head version is always available in a
> file called projectstate-x.ups where x is the current head version.
> Maybe this is good enough for you?
>
> Cheers,
> Maximilian
>
>>
>> Regards,
>> Kristof
>>
>> Am 18.06.2014 10:46, schrieb Maximilian Koegel:
>>> Hi,
>>>
>>> if you use the default backend all data is already stored in XMI files
>>> on the server. Maybe I do not understand your requirements, but to me it
>>> seems you could just put the whole EMFStore data folder into an SVN?
>>>
>>> Best regards,
>>> Maximilian
>>>
>>> Am 17.06.2014 12:23, schrieb Zalecki, Kristof:
>>>> Hi,
>>>>
>>>> I am currently trying to get my projects into xmi files on my server. I
>>>> need this to be able to commit them to my SVN repository.
>>>>
>>>> The plugin I've created receives a ProjectHistory object containing the
>>>> information about the project. The problem is that this object does not
>>>> contain the project itself, but the information about it and therefore
>>>> the resulting xmi file is pretty much empty.
>>>> How can I get the project itself exported?
>>>>
>>>> Regards,
>>>> Kristof
>>>
>>>
>>
>
>


--
Edgar Mueller

Get Professional Eclipse Support: http://eclipsesource.com/munich
Previous Topic:[EMF Forms]NPE on Start of Application every time
Next Topic:[EMF Form] Implementing Reference Service - Need Help ??
Goto Forum:
  


Current Time: Fri Apr 26 13:02:23 GMT 2024

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

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

Back to the top