Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [rmf-dev] ReqIf: Wrong Type References

Hi Steven,

RMF is currently not able to resolve proxies if the ReqIFResource is not contained in a ReqIFResourceSetImpl. 
Please note, that RMF doesn't resolve proxies during load time: RMF uses lazy proxy resolution (resolve proxies when non-containment references are actually navigated).

I have created a small example that demonstrates how to invoke a QVTO transformation on a ReqIF model. Please invoke as JUnit plugin test.
(The original code was found on the QVT Operational Wiki page).

In addition to the code given in this email, please find attached a working example project (Eclipse Juno) that translates all SpecObjects of a reqif file to EClasses.

kind regards,

Mark


package org.eclipse.rmf.qvto.tests;

import static org.junit.Assert.*;

import java.io.IOException;
import java.util.Collections;
import java.util.List;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.m2m.qvt.oml.BasicModelExtent;
import org.eclipse.m2m.qvt.oml.ExecutionContextImpl;
import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic;
import org.eclipse.m2m.qvt.oml.ModelExtent;
import org.eclipse.m2m.qvt.oml.TransformationExecutor;
import org.eclipse.rmf.serialization.ReqIFResourceSetImpl;
import org.junit.Test;

public class TransformationTests {

@Test
public void test() throws IOException {
// Refer to an existing transformation via URI
URI transformationURI = URI.createPlatformPluginURI("/org.eclipse.rmf.qvto.tests/transforms/Transformation.qvto",true);
// create executor for the given transformation
TransformationExecutor executor = new TransformationExecutor(transformationURI);

// define the transformation input
// Remark: we take the objects from a resource, however
// a list of arbitrary in-memory EObjects may be passed
ResourceSet resourceSet = new ReqIFResourceSetImpl();
Resource inResource = resourceSet.getResource(
URI.createFileURI("input/input.reqif"), true);
EList<EObject> inObjects = inResource.getContents();

// create the input extent with its initial contents
ModelExtent input = new BasicModelExtent(inObjects);
// create an empty extent to catch the output
ModelExtent output = new BasicModelExtent();

// setup the execution environment details -> 
// configuration properties, logger, monitor object etc.
ExecutionContextImpl context = new ExecutionContextImpl();
context.setConfigProperty("keepModeling", true);

// run the transformation assigned to the executor with the given 
// input and output and execution context -> ChangeTheWorld(in, out)
// Remark: variable arguments count is supported
ExecutionDiagnostic result = executor.execute(context, input, output);

// check the result for success
if(result.getSeverity() == Diagnostic.OK) {
// the output objects got captured in the output extent
List<EObject> outObjects = output.getContents();
// let's persist them using a resource 
        ResourceSet resourceSet2 = new ResourceSetImpl();
Resource outResource = resourceSet2.createResource(
URI.createFileURI("output/output.ecore"));
outResource.getContents().addAll(outObjects);
outResource.save(Collections.emptyMap());
} else {
// turn the result diagnostic into status and send it to error log
IStatus status = BasicDiagnostic.toIStatus(result);
System.err.println(status.toString());
}
}

}


Attachment: RMFQvtoExample.zip
Description: Zip archive



Am 10.07.2012 um 16:36 schrieb Ulrich, Steven:

Hi,
 
I would like to transform (with QVTo) a ReqIF model. If i debugging my transformation, any type references of any SpecObjects are new (i think, they will new created on loading by qvto). The same if I loading the reqif file with a ecore Resource.
 
final ResourceSet resourceSet = new ReqIFResourceSetImpl();
final Resource reqifResource = resourceSet.getResource(reqifURI, true);
 
But if I open the reqif file in ProR, all (type) references are right.
 
I hope, you can help me J
 
Best regards, Steven Ulrich
 
################################################
Steven Ulrich
Student
------------------------------------------------
Fraunhofer Institut FOKUS
Modeling und Testing Department
Kaiserin-Augusta-Alle 31
D-10589 Berlin
------------------------------------------------
################################################
 
_______________________________________________
rmf-dev mailing list
rmf-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/rmf-dev

--
Mark Brörkens
Softwarearchitekt, Projekt- und Produktmanager

Telefon:  +49 30 69 535 878
Telefax:  +49 30 62 908 067
Mobil:     +49 151 61301259 (bevorzugt)


itemis AG
Niederlassung Berlin
Ohlauer Straße 43
10999 Berlin

Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Jens Wagener (Vors.), Wolfgang Neuhaus, Dr. Georg Pietrek, Jens Trompeter, Sebastian Neus
Aufsichtsrat: Dr. Burkhard Igel (Vors.), Stephan Grollmann, Michael Neuhaus








Back to the top