Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Requirements Modeling Framework  » RMF Standalone
RMF Standalone [message #997246] Fri, 04 January 2013 11:43 Go to next message
Peter Pedron is currently offline Peter Pedron
Messages: 3
Registered: January 2013
Junior Member
Hi all,

I want to create a standalone app, which uses *only* the RMF core to create a Model (programmatically) and to save it in an appropriate reqif-file.

My code so far looks like this:

//Register ReqIF in EMF
Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put("reqif", new ReqIF10FactoryImpl());
EPackage.Registry.INSTANCE.put(ReqIF10Package.eNS_URI, ReqIF10Package.eINSTANCE);

//create ReqIF Model
ReqIF reqif = createReqIF(...);
ResourceSet set = new ResourceSetImpl();
Resource res =set.createResource(URI.createFileURI("C:\\dummy.reqif"));
res.getContents().add(reqif);
try {
	res.save(null);
} catch (IOException e) {e.printStackTrace();}


Actually a valid reqif file should be written, but I get instead a serialized xmi-file of the created model (which is indeed reqif). Somehow it seems that the appropriate Serializer does not get invoked. Could somebody help me?

Regards, Peter
Re: RMF Standalone [message #997320 is a reply to message #997246] Sat, 05 January 2013 14:26 Go to previous messageGo to next message
Michael Jastram is currently offline Michael Jastram
Messages: 148
Registered: April 2010
Location: Düsseldorf, Germany
Senior Member
Hi Peter,

What you did is not enough, as it will invoke the default persister (which writes xmi, as you have noticed). We have a few unit tests that write .reqif and don't even need to run as Eclipse Plug-In-Tests. If you look at them, you should be able to figure it out fairly quickly.

Specifically, have a look at the following, which is a very simple example that does exactly what you want (I believe):

org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/uc000/tc1000

Hope this helps!

- Michael
Re: RMF Standalone [message #997348 is a reply to message #997246] Sun, 06 January 2013 12:52 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas Graf
Messages: 151
Registered: July 2009
Senior Member
Hi Peter,

without having checked if that still works, here is a fragment that I used for Excel2ReqIf conversion last year:

 ResourceSet rs = new ReqIFResourceSetImpl();


Regards,

Andreas
Re: RMF Standalone [message #997448 is a reply to message #997348] Mon, 07 January 2013 09:51 Go to previous message
Peter Pedron is currently offline Peter Pedron
Messages: 3
Registered: January 2013
Junior Member
OK some findings I found out during testing:
In order to serialize a ReqIF model in a standalone app, you have to use the ReqIFResourceSetImpl. That is NOT enough though: you have to register as well the appropriate ResourceFactory to the ResourceSet:
ResourceSet set = new ReqIFResourceSetImpl();
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new ReqIFResourceFactoryImpl());

Using an eclipse-plugin project environment, everything is well initilialized and works transparently if the plugin depends on the pror.editor plugin.
There you can use the simple ResourcSetImpl without any factory registrations.

It would be interesting to know what the pror.editor does in order to enable this transparent use of the resourceset, I haven't figured it out yet...

Cheers,
Peter

[Updated on: Tue, 08 January 2013 08:38]

Report message to a moderator

Previous Topic:xmi serialization of reqif model
Next Topic:RIF <-> ReqIF
Goto Forum:
  


Current Time: Sat Aug 23 05:32:51 EDT 2014

Powered by FUDForum. Page generated in 0.03114 seconds