Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo SBH2015-05-06 14:11:52 +0000
committerAdolfo SBH2015-05-08 10:02:03 +0000
commitb1e8d6d054e508368628042bbf302bf965f7891a (patch)
tree894e3586cb193c01e2fe6e91f9fa956d636cd1a6
parent64de3e5dea45243fa2998dde5869696d8055fb96 (diff)
downloadorg.eclipse.qvtd-b1e8d6d054e508368628042bbf302bf965f7891a.tar.gz
org.eclipse.qvtd-b1e8d6d054e508368628042bbf302bf965f7891a.tar.xz
org.eclipse.qvtd-b1e8d6d054e508368628042bbf302bf965f7891a.zip
[ocl2qvti] - Parametrizing the name of the traceability property (Pivot
use "pivot" as the traceability property)
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.java11
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.mwe22
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java3
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java19
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiBroker.java21
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/etl/ocl2qvtp_v2.etl6
-rw-r--r--tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/OCL2QVTiTestCases.java4
7 files changed, 49 insertions, 17 deletions
diff --git a/plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.java b/plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.java
index b9f879c80..db1c9c943 100644
--- a/plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.java
+++ b/plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.java
@@ -42,6 +42,7 @@ public class GenerateCGedQVTiTransformation extends AbstractWorkflowComponent
protected String envClassName;
protected String visitorClassName;
protected String namedElementItfName;
+ protected String traceabilityPropName = "ast";
protected Map<?, ?> savingOptions;
public void checkConfiguration(final Issues issues) {
@@ -72,7 +73,7 @@ public class GenerateCGedQVTiTransformation extends AbstractWorkflowComponent
try {
URI oclDocURI = URI.createURI(oclFileURI);
CS2ASJavaCompilerParameters cgParams = createParameters();
- createCompiler().compileTransformation(oclDocURI, cgParams, resourceSet);
+ createCompiler().compileTransformation(oclDocURI, cgParams, resourceSet, traceabilityPropName);
} catch (Exception e) {
issues.addError(this, "Error while executing " + GenerateCGedQVTiTransformation.class.getName(), null, e, null);
}
@@ -144,5 +145,13 @@ public class GenerateCGedQVTiTransformation extends AbstractWorkflowComponent
this.savingOptions = savingOptions;
}
+
+ /**
+ * An optional CS2AS traceability property name (default is "ast")
+ */
+ public void setTracePropertyName(final String tracePropName) {
+ this.traceabilityPropName = tracePropName;
+ }
+
}
diff --git a/plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.mwe2 b/plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.mwe2
index 217ef70fc..23dac0212 100644
--- a/plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.mwe2
+++ b/plugins/org.eclipse.qvtd.cs2as.build/src/org/eclipse/qvtd/cs2as/build/mwe/GenerateCGedQVTiTransformation.mwe2
@@ -36,6 +36,7 @@ var javaFolder = "src-gen/"
var javaPackage = ""
+var tracePropertyName = "ast"
Workflow {
@@ -48,5 +49,6 @@ Workflow {
environmentClassName = environmentClassName
lookupVisitorClassName = lookupVisitorClassName
namedElementItfName = namedElementItfName
+ tracePropertyName = tracePropertyName
}
}
diff --git a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java
index 7c01de358..4f7c58594 100644
--- a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java
+++ b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java
@@ -9,4 +9,7 @@ import org.eclipse.qvtd.cs2as.runtime.CS2ASTransformation;
public interface OCL2JavaTxCompiler<P extends OCL2JavaTxCompilerParams> {
public Class<? extends CS2ASTransformation> compileTransformation(@NonNull URI oclFileURI, @NonNull P params, @Nullable ResourceSet rset) throws Exception;
+
+ // FIXME use better options/params
+ public Class<? extends CS2ASTransformation> compileTransformation(@NonNull URI oclFileURI, @NonNull P params, @Nullable ResourceSet rset, @NonNull String tracePropName) throws Exception;
}
diff --git a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java
index d06edd89c..955ced578 100644
--- a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java
+++ b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java
@@ -26,9 +26,15 @@ public class OCL2QVTiCGTxCompiler implements OCL2JavaTxCompiler<CS2ASJavaCompile
@Override
public Class<? extends CS2ASTransformation> compileTransformation(@NonNull URI oclDocURI, @NonNull CS2ASJavaCompilerParameters params, @Nullable ResourceSet rSet) throws Exception {
+ return this.compileTransformation(oclDocURI, params, rSet, "ast");
+ }
+
+ @Override
+ public Class<? extends CS2ASTransformation> compileTransformation(@NonNull URI oclDocURI, @NonNull CS2ASJavaCompilerParameters params, @Nullable ResourceSet rSet, @NonNull String tracePropertyName) throws Exception {
+
QVTimperative qvt = QVTimperative.newInstance(BasicProjectManager.CLASS_PATH, rSet);
try {
- PivotModel qvtiTransf = executeOCL2QVTi_MTC(qvt, oclDocURI.trimSegments(1), oclDocURI.lastSegment());
+ PivotModel qvtiTransf = executeOCL2QVTi_MTC(qvt, oclDocURI.trimSegments(1), oclDocURI.lastSegment(), tracePropertyName);
return createCompiler().compileTransformation(qvt, qvtiTransf.getTransformation(), (CS2ASJavaCompilerParameters) params);
} finally {
qvt.dispose();
@@ -38,18 +44,19 @@ public class OCL2QVTiCGTxCompiler implements OCL2JavaTxCompiler<CS2ASJavaCompile
protected CS2ASJavaCompilerImpl createCompiler() {
return new CS2ASJavaCompilerImpl();
}
-
+
/**
- * @param qvt
+ * @param ocl
* @param baseURI
* @param oclDocName
+ * @param tracePropName the name of the CS2AS traceability property
* @return the {@link PivotModel} corresponding to the final QVTi transformation
* @throws Exception
*/
- protected PivotModel executeOCL2QVTi_MTC(OCL qvt, URI baseURI, String oclDocName) throws Exception {
+ protected PivotModel executeOCL2QVTi_MTC(OCL ocl, URI baseURI, String oclDocName, String tracePropName) throws Exception {
- // Map<?, ?> savingOptions = this.savingOptions == null ? XMIUtil.createSaveOptions() : this.savingOptions;
- OCL2QVTiBroker mtc = new OCL2QVTiBroker(baseURI, oclDocName, qvt, null);
+ // FIXME Map<?, ?> savingOptions = this.savingOptions == null ? XMIUtil.createSaveOptions() : this.savingOptions;
+ OCL2QVTiBroker mtc = new OCL2QVTiBroker(baseURI, oclDocName, ocl, null, true, tracePropName);
mtc.execute();
return mtc.getiModel();
}
diff --git a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiBroker.java b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiBroker.java
index cbcff6480..9f95e90a8 100644
--- a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiBroker.java
+++ b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiBroker.java
@@ -11,9 +11,12 @@
package org.eclipse.qvtd.cs2as.compiler.internal;
import java.net.URISyntaxException;
+import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.epsilon.eol.execute.context.Variable;
+import org.eclipse.epsilon.eol.types.EolPrimitiveType;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.utilities.OCL;
@@ -53,6 +56,7 @@ public class OCL2QVTiBroker extends MtcBroker {
private @NonNull URI oclASUri;
private @Nullable URI tracesASUri;
private @NonNull PivotModelUtil pmUtil;
+ private @Nullable String traceabilityPropName;
/**
* @param baseURI the base {@link URI} on which the OCL document resides
@@ -63,8 +67,8 @@ public class OCL2QVTiBroker extends MtcBroker {
*/
public OCL2QVTiBroker(@NonNull URI baseURI, @NonNull String oclDocName, @NonNull OCL ocl, @Nullable Map<?, ?> savingOptions )
throws Exception {
- this(baseURI, oclDocName, ocl, savingOptions, true);
- }
+ this(baseURI, oclDocName, ocl, savingOptions, true, "ast");
+ }
/**
* @param baseURI the base {@link URI} on which the OCL document resides
@@ -72,11 +76,11 @@ public class OCL2QVTiBroker extends MtcBroker {
* @param ocl an {@link OCL} instance to parse the OCL document
* @param savingOptions some optional savingOptions
* @param usesMiddleFoldedInInputs true if the generated QVTp transformation should use middle folded in inputs approach
+ * @param traceabilityPropName the name of the traceability property of CS elements (when using middleFoldedInInputs)
* @throws Exception
*/
-
public OCL2QVTiBroker(@NonNull URI baseURI, @NonNull String oclDocName, @NonNull OCL ocl, @Nullable Map<?, ?> savingOptions,
- boolean usesMiddleFoldedInInputs)
+ boolean usesMiddleFoldedInInputs, @Nullable String traceabilityPropName)
throws Exception {
super(baseURI, oclDocName, ocl.getEnvironmentFactory(), savingOptions);
@@ -86,13 +90,14 @@ public class OCL2QVTiBroker extends MtcBroker {
if (!usesMiddleFoldedInInputs) {
this.tracesASUri = this.oclASUri.trimFileExtension().trimFileExtension().appendFileExtension("ecore.oclas");
}
+ this.traceabilityPropName = traceabilityPropName;
}
@Override
public void execute() throws QvtMtcExecutionException {
- pModel = (tracesASUri == null) ? runOCL2QVTp_MiddleFolded(oclASUri, URI.createURI(partitionUri))
+ pModel = (tracesASUri == null) ? runOCL2QVTp_MiddleFolded(oclASUri, URI.createURI(partitionUri), traceabilityPropName)
: runOCL2QVTp_MiddleModel(oclASUri, URI.createURI(partitionUri), tracesASUri);
prepare();
@@ -125,6 +130,10 @@ public class OCL2QVTiBroker extends MtcBroker {
}
protected PivotModel runOCL2QVTp_MiddleFolded (URI oclDocURI, URI qvtiFileURI) throws QvtMtcExecutionException {
+ return runOCL2QVTp_MiddleFolded(oclDocURI, qvtiFileURI, "ast");
+ }
+
+ protected PivotModel runOCL2QVTp_MiddleFolded (URI oclDocURI, URI qvtiFileURI, String traceabilityPropName) throws QvtMtcExecutionException {
try {
EtlTask etl = new EtlTask(OCL2QVTiBroker.class.getResource(OCL2QVTP_MIDDLE_FOLDED).toURI());
@@ -132,7 +141,7 @@ public class OCL2QVTiBroker extends MtcBroker {
etl.addModel(createOCLModel(oclDocURI));
etl.addModel(pModel);
etl.addModel(createOclStdLibModel());
- etl.execute();
+ etl.execute(Collections.singletonList(new Variable("traceabilityPropName", traceabilityPropName, EolPrimitiveType.String)));
} catch (URISyntaxException e) {
throw new QvtMtcExecutionException("Exception launching OCL 2 QVTp transformation", e);
diff --git a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/etl/ocl2qvtp_v2.etl b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/etl/ocl2qvtp_v2.etl
index d9312749d..f4d536723 100644
--- a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/etl/ocl2qvtp_v2.etl
+++ b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/etl/ocl2qvtp_v2.etl
@@ -1,6 +1,8 @@
-- Transformation model parameters:
-- OCL - A CompleteOCL document
-- QVTi - The output QVTi model
+-- Transformation variables
+-- traceabilityPropName - the name of the traceability property
import 'ocl2qvtiUtils.eol';
@@ -323,12 +325,12 @@ operation OCL!Element isAstOpCallExp() : Boolean {
operation OCL!ShadowPart getAstCalls() : Collection(OCL!OperationCallExpression) {
return self.ownedInit.getAllContents().including(self.ownedInit)
- .select(x | x.isKindOf(OCL!OperationCallExp) and x.referredOperation.name = "ast" );
+ .select(x | x.isKindOf(OCL!OperationCallExp) and x.referredOperation.name = 'ast' );
}
operation OCL!Type getTraceabilityProperty() : OCL!Property {
// return self.ownedAttribute.selectOne(x | x.name = 'ast'); // FIXME can we parameterize the traceability property name ?
- return self.asSequence().closure(x | x.superClasses).ownedProperties.flatten().selectOne(x | x.name = 'ast');
+ return self.asSequence().closure(x | x.superClasses).ownedProperties.flatten().selectOne(x | x.name = traceabilityPropName);
}
operation getOclAnyEqualsOp() : OCL!Operation {
diff --git a/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/OCL2QVTiTestCases.java b/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/OCL2QVTiTestCases.java
index 1245ed477..e3b9fb9d2 100644
--- a/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/OCL2QVTiTestCases.java
+++ b/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/OCL2QVTiTestCases.java
@@ -85,7 +85,7 @@ public class OCL2QVTiTestCases extends LoadTestCase {
public OCL2QVTiBrokerTester(URI baseURI, String oclDocName, OCL metaModelManager, boolean middleFolded)
throws Exception {
- super(baseURI, oclDocName, metaModelManager, TestsXMLUtil.defaultSavingOptions, middleFolded);
+ super(baseURI, oclDocName, metaModelManager, TestsXMLUtil.defaultSavingOptions, middleFolded, null);
}
// For testing purpose
@@ -268,7 +268,7 @@ public class OCL2QVTiTestCases extends LoadTestCase {
URI oclDocURI = baseURI.appendSegment("classescs2as.ocl.oclas");
URI qvtpFileURI = baseURI.appendSegment("classescs2as.qvtp.qvtias");
- OCL2QVTiBrokerTester mtc = new OCL2QVTiBrokerTester(baseURI, "classescs2as.ocl", myQVT, false);
+ OCL2QVTiBrokerTester mtc = new OCL2QVTiBrokerTester(baseURI, "classescs2as.ocl", myQVT);
mtc.runOCL2QVTp_MiddleFolded(oclDocURI, qvtpFileURI);
// Test the QVTp transformation can be loaded
assertValidQVTiModel(qvtpFileURI);

Back to the top