Issue 15215: QVT1.1: Add an operation Model::getURI() (qvt-rtf) Source: NASA (Dr. Nicolas F. Rouquette, nicolas.f.rouquette(at)jpl.nasa.gov) Nature: Uncategorized Issue Severity: Summary: Sometimes, it is useful to get the URI corresponding to the resource of a given transformation input model parameter. I suggest adding an operation for this purpose in clause 8.3.5 Operations on models. Model::getURI() : String Returns the string of the URI corresponding to the model's resource. This operation produces an empty string for a model corresponding to an output parameter For what it's worth, below is a patch for the Eclipse M2M implementation of QVTOperational where I prototyped such an operation. Resolution: Revised Text: Actions taken: April 20, 2010: received issue July 15, 2014: closed issue Discussion: This seems reasonable but: UML already provides an inherited Package::URI field so Model::getURI() would be confusing. Perhaps getExternalURI() or getDocumentURI(). However this is not a QVT issue; if there is a requirement for contextual knowledge of a Model, surely UML should provide it? A QVT transformation hides its context and for a transformation realized by a cascade communicating through memories or pipes, what would the URI be? Users who understand and control the context can pass the context as a parameter/control model. More generally there is a problem in defining the URI of a transformation that generates a datadependent number of output models. Any get context solution would address this. Disposition: Closed, No Change End of Annotations:===== m: "Rouquette, Nicolas F (316A)" To: "issues@omg.org" CC: Ed Willink , Mariano Belaunde Date: Tue, 20 Apr 2010 11:07:51 -0700 Subject: QVT1.1: Add an operation Model::getURI() Thread-Topic: QVT1.1: Add an operation Model::getURI() Thread-Index: AcrgtGSS+iJV6PswRIuTjxNvKcYhVg== Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US X-Source-IP: altvirehtstap02.jpl.nasa.gov [128.149.137.73] X-Source-Sender: nicolas.f.rouquette@jpl.nasa.gov X-AUTH: Authorized X-MIME-Autoconverted: from quoted-printable to 8bit by amethyst.omg.org id o3KHvuuB000820 Sometimes, it is useful to get the URI corresponding to the resource of a given transformation input model parameter. I suggest adding an operation for this purpose in clause 8.3.5 Operations on models. Model::getURI() : String Returns the string of the URI corresponding to the model's resource. This operation produces an empty string for a model corresponding to an output parameter For what it's worth, below is a patch for the Eclipse M2M implementation of QVTOperational where I prototyped such an operation. - Nicolas. ### Eclipse Workspace Patch 1.0 #P org.eclipse.m2m.qvt.oml Index: src/org/eclipse/m2m/internal/qvt/oml/stdlib/ModelOperations.java =================================================================== RCS file: /cvsroot/modeling/org.eclipse.m2m/org.eclipse.m2m.qvt.oml/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/stdlib/ModelOperations.java,v retrieving revision 1.9 diff -u -r1.9 ModelOperations.java --- src/org/eclipse/m2m/internal/qvt/oml/stdlib/ModelOperations.java 24 Jan 2010 14:21:38 -0000 1.9 +++ src/org/eclipse/m2m/internal/qvt/oml/stdlib/ModelOperations.java 20 Apr 2010 17:50:34 -0000 @@ -11,6 +11,7 @@ *******************************************************************************/ package org.eclipse.m2m.internal.qvt.oml.stdlib; +import java.net.URI; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -18,10 +19,13 @@ import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.m2m.internal.qvt.oml.ast.env.ModelExtentContents; import org.eclipse.m2m.internal.qvt.oml.ast.env.ModelParameterExtent; import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEvaluationEnv; import org.eclipse.m2m.internal.qvt.oml.evaluator.ModelInstance; import org.eclipse.m2m.internal.qvt.oml.evaluator.ModuleInstance; +import org.eclipse.m2m.internal.qvt.oml.expressions.ModelParameter; import org.eclipse.m2m.internal.qvt.oml.expressions.ModelType; import org.eclipse.ocl.ecore.EcoreEnvironment; import org.eclipse.ocl.types.OCLStandardLibrary; @@ -36,6 +40,7 @@ public static final String ROOT_OBJECTS_NAME = "rootObjects"; //$NON-NLS-1$ public static final String OBJECTS_OF_TYPE_NAME = "objectsOfType"; //$NON-NLS-1$ public static final String REMOVE_ELEMENT_NAME = "removeElement"; //$NON-NLS-1$ + public static final String GET_URI_NAME = "getURI"; //$NON-NLS-1$ public ModelOperations(AbstractQVTStdlib library) { super(library, library.getModelClass()); @@ -63,10 +68,34 @@ setOfT, oclStdLibrary.getOclType()), new OwnedOperationProvider(REMOVE_ELEMENT, REMOVE_ELEMENT_NAME, new String[] { "element" }, //$NON-NLS-1$ oclStdLibrary.getOclVoid(), getStdlib().getElementType()), - new OwnedOperationProvider(ROOT_OBJECTS, ROOT_OBJECTS_NAME, setOfElements), + new OwnedOperationProvider(ROOT_OBJECTS, ROOT_OBJECTS_NAME, setOfElements), + new OwnedOperationProvider(GET_URI, GET_URI_NAME, oclStdLibrary.getString()), }; } + private static final CallHandler GET_URI = new CallHandler() { + public Object invoke(ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { + if(source instanceof ModelInstance == false) { + throw new IllegalArgumentException(); + } + + ModelInstance model = (ModelInstance) source; + ModelParameterExtent modelParam = model.getExtent(); + for (EObject rootElement : modelParam.getRootObjects()) { + Resource rootResource = rootElement.eResource(); + if (rootResource == null) + continue; + + org.eclipse.emf.common.util.URI rootURI = rootResource.getURI(); + if (rootURI == null) + return ""; + + return rootURI.toString(); + } + return ""; + } + }; + private static final CallHandler OBJECTS = new CallHandler() { public Object invoke(ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { if(source instanceof ModelInstance == false) {