Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-01-24 06:50:10 +0000
committerEd Willink2016-02-02 15:52:10 +0000
commit577e7b36f3e2fce85712ba8d06954f067155ab3f (patch)
treec7279647f0facb8d99a2117dcffc3b3cdd4bfa27
parentb62743452c894a8edfc7957a1fe18e676b6e9887 (diff)
downloadorg.eclipse.qvtd-577e7b36f3e2fce85712ba8d06954f067155ab3f.tar.gz
org.eclipse.qvtd-577e7b36f3e2fce85712ba8d06954f067155ab3f.tar.xz
org.eclipse.qvtd-577e7b36f3e2fce85712ba8d06954f067155ab3f.zip
[486722] Tidy TracePackages
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/QVTrCompilerChain.java4
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QVTr2QVTcRelations.java182
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QvtrToQvtcTransformation.java181
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/InvokedRelationToMappingForEnforcement.java60
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToMappingTransformation.java14
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToTracePackage.java120
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TROppositeDomainsToMappingForEnforcement.java10
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TopLevelRelationToMappingForEnforcement.java8
-rw-r--r--tests/org.eclipse.qvtd.build.qvtrtoqvtc.tests/src/org/eclipse/qvtd/build/qvtrtoqvtc/tests/QvtrToQvtcTests.java4
9 files changed, 233 insertions, 350 deletions
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/QVTrCompilerChain.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/QVTrCompilerChain.java
index 1398632c3..01067e120 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/QVTrCompilerChain.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/QVTrCompilerChain.java
@@ -55,9 +55,9 @@ public class QVTrCompilerChain extends AbstractCompilerChain
QvtrToQvtcTransformation t = new QvtrToQvtcTransformation(environmentFactory, rResource, cResource, qvtcTraceResource);
t.prepare();
t.execute();
-// t.saveTrace(qvtcTraceResource, XMIUtil.createSaveOptions());
+ t.saveTrace(qvtcTraceResource, XMIUtil.createSaveOptions());
assertNoResourceErrors("Trace save", qvtcTraceResource);
-// t.saveCore(cResource, XMIUtil.createSaveOptions());
+ t.saveCore(cResource, XMIUtil.createSaveOptions());
assertNoResourceErrors("Core save", cResource);
return cResource;
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QVTr2QVTcRelations.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QVTr2QVTcRelations.java
index 61d7e4adf..e4c5abcfc 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QVTr2QVTcRelations.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QVTr2QVTcRelations.java
@@ -18,7 +18,6 @@ import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.ocl.pivot.Class;
import org.eclipse.ocl.pivot.EnumLiteralExp;
import org.eclipse.ocl.pivot.OCLExpression;
import org.eclipse.ocl.pivot.Operation;
@@ -59,65 +58,13 @@ import org.eclipse.qvtd.pivot.qvttemplate.TemplateExp;
public class QVTr2QVTcRelations
{
- public static @NonNull DomainPattern getDomainPattern(@NonNull Domain d) {
- List<@NonNull DomainPattern> pattern = ClassUtil.nullFree(((RelationDomain) d).getPattern());
- assert pattern.size() == 1;
- DomainPattern domainPattern = pattern.get(0);
- assert domainPattern != null;
- return domainPattern;
- }
-
private @NonNull final QvtrToQvtcTransformation transformation;
-
-// private @NonNull final String OPPOSITE_UPPER_SOURCE = "http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper";
-// private @NonNull final String OPPOSITE_ROLE_NAME_SOURCE = "http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName";
-// private @NonNull final String EMF_ANNOTATION_DETAIL_KEY = "body";
-// private @NonNull final String OPPOSITE_UPPER_VALUE = "1";
-// private @NonNull final String OPPOSITE_ROLE_NAME_VALUE = "middle";
-
-
public QVTr2QVTcRelations(@NonNull QvtrToQvtcTransformation transformation) {
this.transformation = transformation;
}
/*
- * Add oppositeUpper and oppositeRoleName annotations
- *
- private void zzaddMiddleSynthesisAnnotations(Property p) {
- Annotation oppositeUpper = PivotFactory.eINSTANCE.createAnnotation();
- oppositeUpper.setName(OPPOSITE_UPPER_SOURCE);
- Detail oppositeUpperDetail = PivotFactory.eINSTANCE.createDetail();
- oppositeUpperDetail.setName(EMF_ANNOTATION_DETAIL_KEY);
- oppositeUpperDetail.getValues().add("OPPOSITE_UPPER_VALUE");
- oppositeUpper.getOwnedDetails().add(oppositeUpperDetail);
- p.getOwnedAnnotations().add(oppositeUpper);
- Annotation oppositeRoleName = PivotFactory.eINSTANCE.createAnnotation();
- oppositeRoleName.setName(OPPOSITE_ROLE_NAME_SOURCE);
- Detail oppositeRoleNameDetail = PivotFactory.eINSTANCE.createDetail();
- oppositeRoleNameDetail.setName(EMF_ANNOTATION_DETAIL_KEY);
- oppositeRoleNameDetail.getValues().add("OPPOSITE_ROLE_NAME_VALUE");
- oppositeRoleName.getOwnedDetails().add(oppositeRoleNameDetail);
- p.getOwnedAnnotations().add(oppositeRoleName);
- } */
-
- /* ============= Queries ============= */
- // TODO bug 453863
- public @NonNull Set<@NonNull Variable> getSharedDomainVars(Relation r) {
-
- Set<@NonNull Variable> vars = new HashSet<@NonNull Variable>();
- for (Domain d : ClassUtil.nullFree(r.getDomain())) {
- List<@NonNull Variable> bt = ClassUtil.nullFree(QVTr2QVTcRelations.getDomainPattern(d).getBindsTo());
- if (vars.isEmpty()) {
- vars.addAll(bt);
- } else {
- vars.retainAll(bt);
- }
- }
- return vars;
- }
-
- /*
* Get variables occurring in an OCL expression
*/
// FIXME this function is not complete! It needs to be completed for other
@@ -339,7 +286,7 @@ public class QVTr2QVTcRelations
pe.setReferredProperty(pep);
pe.setType(pep.getType());
ee.setOwnedSource(pe);
- ee.setReferredOperation(getEqualsOPeration());
+ ee.setReferredOperation(getEqualsOperation());
ee.setType(transformation.getStandardLibrary().getBooleanType());
ave.setReferredVariable(mv);
ave.setType(mv.getType());
@@ -460,103 +407,6 @@ public class QVTr2QVTcRelations
}
}
}
-
- public void doRelationToTraceClass(@NonNull Relation r, org.eclipse.ocl.pivot.@NonNull Class rc) {
- transformation.putRelationTrace(r, rc);
- // check
- String rn = r.getName();
- assert rn != null;
- rc.setName("T"+rn);
- Set<Variable> sharedDomainVars = getSharedDomainVars(r);
- doRVarSetToTraceClassProps(new ArrayList<Variable>(sharedDomainVars), rc);
- for (Domain d : ClassUtil.nullFree(r.getDomain())) {
- DomainPattern rdp = getDomainPattern(d);
- TemplateExp t = rdp.getTemplateExpression();
- assert t != null;
- doSubObjectTemplateToTraceClassProps(t, rc);
- doSubCollectionTemplateToTraceClassProps(t, rc);
- }
- }
-
- private void doRVarSetToTraceClassProps(@NonNull ArrayList<Variable> rvSeq, @NonNull Class rc) {
-
- if (!rvSeq.isEmpty()) {
- // check
- Variable rv = rvSeq.remove(0);
- assert rv != null;
- // when
- RVarToTraceClassProp(rv, rc);
- doRVarSetToTraceClassProps(rvSeq, rc);
- }
- }
-
- private void RVarToTraceClassProp(@NonNull Variable rv, @NonNull Class rc) {
-
- Type c = rv.getType();
- assert c != null;
- String vn = rv.getName();
- assert vn != null;
- // init
- /*Property a =*/ transformation.whenTraceProperty(rc, vn, c);
-// addMiddleSynthesisAnnotations(a);
-// assert a != null;
- // assign
-// a.setType(c);
- }
-
- private void doSubObjectTemplateToTraceClassProps(@NonNull TemplateExp t, org.eclipse.ocl.pivot.@NonNull Class rc) {
- // check
- if (t instanceof ObjectTemplateExp) {
- doObjectTemplateToTraceClassProps((ObjectTemplateExp) t, rc);
- }
-
- }
-
- private void doObjectTemplateToTraceClassProps(@NonNull ObjectTemplateExp t, org.eclipse.ocl.pivot.@NonNull Class rc) {
- // check
- Variable tv = t.getBindsTo();
- assert tv != null;
- Type c = tv.getType();
- assert c != null;
- String vn = tv.getName();
- assert vn != null;
- // init
- Property a = transformation.whenTraceProperty(rc, vn, c);
- assert a != null;
-// addMiddleSynthesisAnnotations(a);
- // where
- for (PropertyTemplateItem pt : t.getPart()) {
- OCLExpression value = pt.getValue();
- assert value != null;
- if (value instanceof TemplateExp) {
- TemplateExp tp = (TemplateExp) value;
- doSubObjectTemplateToTraceClassProps(tp, rc);
- doSubCollectionTemplateToTraceClassProps(tp, rc);
- }
- }
- // assign
-// a.setType(c);
- }
-
- private void doSubCollectionTemplateToTraceClassProps(@NonNull TemplateExp t, org.eclipse.ocl.pivot.@NonNull Class rc) {
- // check
- if (t instanceof CollectionTemplateExp) {
- doCollectionTemplateToTraceClassProps((CollectionTemplateExp) t, rc);
- }
- }
-
-
- private void doCollectionTemplateToTraceClassProps(@NonNull CollectionTemplateExp t, org.eclipse.ocl.pivot.@NonNull Class rc) {
- // check
- for (OCLExpression m : t.getMember()) {
- if (m instanceof TemplateExp) {
- TemplateExp tp = (TemplateExp) m;
- // Dont add trace attributes for collections, just for the members
- doSubObjectTemplateToTraceClassProps(tp, rc);
- doSubCollectionTemplateToTraceClassProps(tp, rc);
- }
- }
- }
// 47
public void doTROppositeDomainsToMappingForEnforcement(@NonNull Relation r,
@@ -569,7 +419,7 @@ public class QVTr2QVTcRelations
rds.remove(rd); // guard
for (RelationDomain ord : rds) {
// check
- DomainPattern dp = getDomainPattern(ord);
+ DomainPattern dp = transformation.getDomainPattern(ord);
if (dp.getTemplateExpression() instanceof ObjectTemplateExp) {
String dn = ord.getName();
assert dn != null;
@@ -604,7 +454,7 @@ public class QVTr2QVTcRelations
whenVars.addAll(r.getWhen().getBindsTo());
Set<Variable> domainTopVars = new HashSet<Variable>(domainVars);
domainTopVars.retainAll(whenVars);
- Set<Variable> sharedDomainVars = getSharedDomainVars(r);
+ Set<Variable> sharedDomainVars = transformation.getSharedDomainVars(r);
Set<Variable> domainBottomUnSharedVars = new HashSet<Variable>(domainVars);
domainBottomUnSharedVars.removeAll(whenVars);
domainBottomUnSharedVars.removeAll(sharedDomainVars);
@@ -654,7 +504,7 @@ public class QVTr2QVTcRelations
@NonNull OCLExpression e, @NonNull BottomPattern mb) {
// when
- Set<Variable> sharedDomainVars = getSharedDomainVars(r);
+ Set<Variable> sharedDomainVars = transformation.getSharedDomainVars(r);
// check
if ((e instanceof VariableExp) && sharedDomainVars.contains(((VariableExp)e).getReferredVariable()) ) {
String pn = pp.getName();
@@ -717,7 +567,7 @@ public class QVTr2QVTcRelations
@NonNull BottomPattern db) {
// when
- Set<Variable> sharedDomainVars = getSharedDomainVars(r);
+ Set<Variable> sharedDomainVars = transformation.getSharedDomainVars(r);
// check
if (e instanceof ObjectTemplateExp) {
final Variable rev = ((ObjectTemplateExp)e).getBindsTo();
@@ -751,7 +601,7 @@ public class QVTr2QVTcRelations
@NonNull OCLExpression e, @NonNull BottomPattern db) {
// when
- Set<Variable> sharedDomainVars = getSharedDomainVars(r);
+ Set<Variable> sharedDomainVars = transformation.getSharedDomainVars(r);
// check
if ((e instanceof VariableExp) && !sharedDomainVars.contains(((VariableExp)e).getReferredVariable()) ) {
String pn = pp.getName();
@@ -868,7 +718,7 @@ public class QVTr2QVTcRelations
@NonNull BottomPattern mb) {
// when
- Set<Variable> sharedDomainVars = getSharedDomainVars(r);
+ Set<Variable> sharedDomainVars = transformation.getSharedDomainVars(r);
// check
Variable vte = te.getBindsTo();
assert vte != null;
@@ -911,7 +761,7 @@ public class QVTr2QVTcRelations
@NonNull Relation r, @NonNull ObjectTemplateExp te,
@NonNull BottomPattern db) {
// when
- Set<Variable> sharedDomainVars = getSharedDomainVars(r);
+ Set<Variable> sharedDomainVars = transformation.getSharedDomainVars(r);
// check
Variable vte = te.getBindsTo();
assert vte != null;
@@ -963,7 +813,7 @@ public class QVTr2QVTcRelations
}
assert mt != null;
// guard
- DomainPattern rdp = getDomainPattern(rd);
+ DomainPattern rdp = transformation.getDomainPattern(rd);
TemplateExp rdt = rdp.getTemplateExpression();
if ((e instanceof VariableExp) && (rdt instanceof ObjectTemplateExp)) {
// check
@@ -1003,7 +853,7 @@ public class QVTr2QVTcRelations
pe.setReferredProperty(tp);
pe.setType(tp.getType());
ee.setOwnedSource(pe);
- ee.setReferredOperation(getEqualsOPeration());
+ ee.setReferredOperation(getEqualsOperation());
ee.setType(transformation.getStandardLibrary().getBooleanType());
ve2.setReferredVariable(mv);
ve2.setType(mv.getType());
@@ -1229,7 +1079,7 @@ public class QVTr2QVTcRelations
assert pep != null;
pe.setReferredProperty(pep);
pe.setType(pep.getType());
- ee.setReferredOperation(getEqualsOPeration());
+ ee.setReferredOperation(getEqualsOperation());
ee.setType(transformation.getStandardLibrary().getBooleanType());
ave.setReferredVariable(mv);
ave.setType(mv.getType());
@@ -1312,7 +1162,7 @@ public class QVTr2QVTcRelations
rds.remove(rd); // guard
for (RelationDomain ord : rds) {
// check
- DomainPattern dp = getDomainPattern(ord);
+ DomainPattern dp = transformation.getDomainPattern(ord);
if (dp.getTemplateExpression() instanceof ObjectTemplateExp) {
String dn = ord.getName();
assert dn != null;
@@ -1349,7 +1199,7 @@ public class QVTr2QVTcRelations
Set<Variable> domainTopVars = new HashSet<Variable>(domainVars);
domainTopVars.retainAll(whenVars);
domainTopVars.add(tev);
- Set<Variable> sharedDomainVars = getSharedDomainVars(r);
+ Set<Variable> sharedDomainVars = transformation.getSharedDomainVars(r);
Set<Variable> domainBottomUnSharedVars = new HashSet<Variable>(domainVars);
domainBottomUnSharedVars.removeAll(whenVars);
domainBottomUnSharedVars.removeAll(sharedDomainVars);
@@ -1431,7 +1281,7 @@ public class QVTr2QVTcRelations
assert pep != null;
pe.setReferredProperty(pep);
pe.setType(pep.getType());
- ee.setReferredOperation(getEqualsOPeration());
+ ee.setReferredOperation(getEqualsOperation());
ee.setType(transformation.getStandardLibrary().getBooleanType());
ave.setReferredVariable(mdv);
ave.setType(mdv.getType());
@@ -1459,13 +1309,13 @@ public class QVTr2QVTcRelations
public @NonNull Set<@NonNull Variable> getAllDomainVars(@NonNull Relation r) {
Set<@NonNull Variable> allDomainVars = new HashSet<@NonNull Variable>();
for (Domain d : ClassUtil.nullFree(r.getDomain())) {
- DomainPattern domainPattern = getDomainPattern(d);
+ DomainPattern domainPattern = transformation.getDomainPattern(d);
allDomainVars.addAll(ClassUtil.nullFree(domainPattern.getBindsTo()));
}
return allDomainVars;
}
- private @NonNull Operation getEqualsOPeration() {
+ private @NonNull Operation getEqualsOperation() {
for (Operation o : transformation.getStandardLibrary().getOclAnyType().getOwnedOperations()) {
if (o.getName().equals("=")) {
return o;
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QvtrToQvtcTransformation.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QvtrToQvtcTransformation.java
index 6b7214eb4..6eaf021a3 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QvtrToQvtcTransformation.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/QvtrToQvtcTransformation.java
@@ -47,6 +47,7 @@ import org.eclipse.qvtd.compiler.internal.qvtr2qvtc.impl.RuleBindings;
import org.eclipse.qvtd.compiler.internal.qvtr2qvtc.impl.TopLevelRelationToMappingForEnforcement;
import org.eclipse.qvtd.compiler.internal.qvtr2qvtc.utilities.TransformationTraceData;
import org.eclipse.qvtd.compiler.internal.qvtr2qvtc.utilities.TransformationTraceDataImpl;
+import org.eclipse.qvtd.pivot.qvtbase.Domain;
import org.eclipse.qvtd.pivot.qvtbase.Pattern;
import org.eclipse.qvtd.pivot.qvtbase.Predicate;
import org.eclipse.qvtd.pivot.qvtbase.QVTbaseFactory;
@@ -66,6 +67,7 @@ import org.eclipse.qvtd.pivot.qvtrelation.DomainPattern;
import org.eclipse.qvtd.pivot.qvtrelation.Key;
import org.eclipse.qvtd.pivot.qvtrelation.Relation;
import org.eclipse.qvtd.pivot.qvtrelation.RelationCallExp;
+import org.eclipse.qvtd.pivot.qvtrelation.RelationDomain;
import org.eclipse.qvtd.pivot.qvtrelation.RelationModel;
import org.eclipse.qvtd.pivot.qvtrelation.RelationalTransformation;
import org.eclipse.qvtd.pivot.qvttemplate.ObjectTemplateExp;
@@ -78,12 +80,11 @@ public class QvtrToQvtcTransformation
private final @NonNull Resource qvtrResource;
private final @NonNull Resource qvtcResource;
- private final @NonNull List<EObject> potentialOrphans = new ArrayList<EObject>();
- private final @NonNull List<EObject> traceRoots = new ArrayList<EObject>();
- private final @NonNull List<EObject> coreRoots = new ArrayList<EObject>();
- private final @NonNull Map<Variable, Variable> variableTrace = new HashMap<Variable, Variable>();
- private final @NonNull Map<Relation, org.eclipse.ocl.pivot.Class> relationToTraceClass = new HashMap<Relation, org.eclipse.ocl.pivot.Class>();
- private final @NonNull Map<RelationalTransformation, org.eclipse.ocl.pivot.Package> transformationToPackage = new HashMap<RelationalTransformation, org.eclipse.ocl.pivot.Package>();
+ private final @NonNull List<@NonNull EObject> potentialOrphans = new ArrayList<@NonNull EObject>();
+ private final @NonNull List<org.eclipse.ocl.pivot.@NonNull Package> tracePackages = new ArrayList<org.eclipse.ocl.pivot.@NonNull Package>();
+ private final @NonNull List<@NonNull EObject> coreRoots = new ArrayList<@NonNull EObject>();
+ private final @NonNull Map<@NonNull Variable, @NonNull Variable> variableTrace = new HashMap<@NonNull Variable, @NonNull Variable>();
+ private final @NonNull Map<@NonNull Relation, org.eclipse.ocl.pivot.@NonNull Class> relationToTraceClass = new HashMap<@NonNull Relation, org.eclipse.ocl.pivot.@NonNull Class>();
// Un-navigable opposites
//
// The Key that identifies each Class.
@@ -139,7 +140,7 @@ public class QvtrToQvtcTransformation
= new HashMap<org.eclipse.qvtd.pivot.qvtbase.@NonNull Rule, @NonNull Map<@NonNull String, @NonNull CoreDomain>>();
/**
- * The lazily created named Trace Properties in each Tracee Class.
+ * The lazily created named Trace Properties in each Trace Class.
*/
private @NonNull Map<org.eclipse.ocl.pivot.@NonNull Class, @NonNull Map<@NonNull String, @NonNull Property>> traceClass2name2traceProperty
= new HashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull Map<@NonNull String, @NonNull Property>>();
@@ -148,7 +149,10 @@ public class QvtrToQvtcTransformation
* The lazily created named Core mappings for each transformation.
*/
private @NonNull Map<@NonNull Transformation, @NonNull Map<@NonNull String, @NonNull Mapping>> transformation2name2mapping
- = new HashMap<@NonNull Transformation, @NonNull Map<@NonNull String, @NonNull Mapping>>();
+ = new HashMap<@NonNull Transformation, @NonNull Map<@NonNull String, @NonNull Mapping>>();
+
+ private @NonNull Map<@NonNull RelationalTransformation, org.eclipse.ocl.pivot.@NonNull Package> relationalTransformation2tracePackage
+ = new HashMap<@NonNull RelationalTransformation, org.eclipse.ocl.pivot.@NonNull Package>();
public QvtrToQvtcTransformation(@NonNull EnvironmentFactory environmentFactory, @NonNull Resource qvtrResource, @NonNull Resource qvtcResource, @Nullable Resource traceResource) {
this.environmentFactory = environmentFactory;
@@ -271,16 +275,9 @@ public class QvtrToQvtcTransformation
public void execute() {
for (EObject eObject : qvtrResource.getContents()) {
if (eObject instanceof RelationModel) {
- execute(ClassUtil.nullFree(((RelationModel)eObject).getOwnedPackages()));
- }
- }
-// executeFactory(RelationalTransformationToTracePackage.FACTORY);
- for (EObject eObject : potentialOrphans) {
- if (eObject.eContainer() == null) {
- traceRoots.add(eObject);
+ transformToTracePackages(tracePackages, ClassUtil.nullFree(((RelationModel)eObject).getOwnedPackages()));
}
}
- potentialOrphans.clear();
executeFactory(RelationalTransformationToMappingTransformation.FACTORY);
executeFactory(TopLevelRelationToMappingForEnforcement.FACTORY);
executeFactory(InvokedRelationToMappingForEnforcement.FACTORY);
@@ -290,23 +287,6 @@ public class QvtrToQvtcTransformation
}
}
}
-
- private void execute(@NonNull Iterable<org.eclipse.ocl.pivot.@NonNull Package> relationPackages) {
- for (org.eclipse.ocl.pivot.Package relationPackage : relationPackages) {
- for (org.eclipse.ocl.pivot.Class relationClass : relationPackage.getOwnedClasses()) {
- if (relationClass instanceof RelationalTransformation) {
- execute((RelationalTransformation)relationClass);
- }
- }
- execute(ClassUtil.nullFree(relationPackage.getOwnedPackages()));
- }
- }
-
- private void execute(@NonNull RelationalTransformation relationTransformation) {
- Rule rule = new RelationalTransformationToTracePackage(this, relationTransformation);
- executeTopLevelRule(rule);
- }
-
public void executeFactory(Rule.@NonNull Factory factory) {
for (Rule rule : factory.getRules(this, qvtrResource)) {
@@ -354,6 +334,15 @@ public class QvtrToQvtcTransformation
return coreRoots;
}
+ public @NonNull DomainPattern getDomainPattern(@NonNull Domain d) {
+ List<@NonNull DomainPattern> pattern = ClassUtil.nullFree(((RelationDomain) d).getPattern());
+ assert pattern.size() == 1;
+ DomainPattern domainPattern = pattern.get(0);
+ assert domainPattern != null;
+ return domainPattern;
+ }
+
+
public @Nullable Relation getInvokingRelationForRelationCallExp(@NonNull RelationCallExp e) {
return invokingRelationsForRelationCallExp.get(e);
@@ -399,40 +388,47 @@ public class QvtrToQvtcTransformation
}
- public @Nullable List<RelationCallExp> getRelationCallExpsForRelation(@NonNull Relation r) {
-
+ public @Nullable List<RelationCallExp> getRelationCallExpsForRelation(@NonNull Relation r) {
return relationCallExpsForRelation.get(r);
}
- public org.eclipse.ocl.pivot.@Nullable Class getRelationTrace(@NonNull Relation relation) {
-
+ public org.eclipse.ocl.pivot.@Nullable Class getRelationTrace(@NonNull Relation relation) {
return relationToTraceClass.get(relation);
}
-
-
- /**
- * @return the metamodelManager
- */
- // public MetamodelManager getMetamodelManager() {
- // return metamodelManager;
- //}
- public @NonNull StandardLibrary getStandardLibrary() {
- return environmentFactory.getStandardLibrary();
+
+ /* ============= Queries ============= */
+ // TODO bug 453863
+ public @NonNull Set<@NonNull Variable> getSharedDomainVars(@NonNull Relation r) {
+ Set<@NonNull Variable> vars = new HashSet<@NonNull Variable>();
+ for (Domain d : ClassUtil.nullFree(r.getDomain())) {
+ for (DomainPattern domainPattern : ClassUtil.nullFree(((RelationDomain) d).getPattern())) {
+ List<@NonNull Variable> bt = ClassUtil.nullFree(domainPattern.getBindsTo());
+ if (vars.isEmpty()) {
+ vars.addAll(bt);
+ } else {
+ vars.retainAll(bt);
+ }
+ }
}
+ return vars;
+ }
+ public org.eclipse.ocl.pivot.@NonNull Package getTracePackage(@NonNull RelationalTransformation rt) {
+ Package tracePackage = relationalTransformation2tracePackage.get(rt);
+ assert tracePackage != null;
+ return tracePackage;
+ }
+
+ public @NonNull StandardLibrary getStandardLibrary() {
+ return environmentFactory.getStandardLibrary();
+ }
public @Nullable TemplateExp getTemplateExpression(@NonNull Variable dv) {
return variable2templateExp.get(dv);
}
-
public @NonNull Collection<? extends EObject> getTraceRoots() {
- return traceRoots;
- }
-
- public org.eclipse.ocl.pivot.@Nullable Package getTransformationToPackageTrace(RelationalTransformation rt) {
-
- return transformationToPackage.get(rt);
+ return tracePackages;
}
public @Nullable Variable getVariableTrace(@NonNull Variable referredVariable) {
@@ -440,7 +436,6 @@ public class QvtrToQvtcTransformation
return variableTrace.get(referredVariable);
}
-
private @NonNull Set<@NonNull Variable> getVarsOfExp(@NonNull OCLExpression e) {
QVTr2QVTcRelations rels = new QVTr2QVTcRelations(this);
return rels.getVarsOfExp(e);
@@ -466,18 +461,15 @@ public class QvtrToQvtcTransformation
}
}
- public void putRelationTrace(@NonNull Relation r, org.eclipse.ocl.pivot.@NonNull Class rc) {
-
+ public void putRelationTrace(@NonNull Relation r, org.eclipse.ocl.pivot.@NonNull Class rc) {
relationToTraceClass.put(r, rc);
}
- public void putTransformationToPackageTrace(RelationalTransformation rt, org.eclipse.ocl.pivot.Package p) {
-
- transformationToPackage.put(rt, p);
+ public void putTracePackage(@NonNull RelationalTransformation rt, org.eclipse.ocl.pivot.@NonNull Package tracePackage) {
+ relationalTransformation2tracePackage.put(rt, tracePackage);
}
public void putVariableTrace(@NonNull Variable rv, @NonNull Variable mv) {
-
Variable oldVal = variableTrace.put(rv, mv);
// Variables should only be traced once
if (oldVal != null) {
@@ -485,15 +477,14 @@ public class QvtrToQvtcTransformation
}
}
-
- public void saveCore(@NonNull Resource asResource, @NonNull Collection<@NonNull ? extends EObject> eObjects, @NonNull Map<?, ?> options) throws IOException {
+ public void saveCore(@NonNull Resource asResource, @NonNull Map<?, ?> options) throws IOException {
this.coreModel.setExternalURI(asResource.getURI().toString());
// Copy imports
Package capsule = PivotFactory.eINSTANCE.createPackage();
this.coreModel.getOwnedPackages().add(capsule);
asResource.getContents().add(this.coreModel);
- for (EObject eObject : eObjects) {
+ for (EObject eObject : coreRoots) {
if (eObject instanceof org.eclipse.qvtd.pivot.qvtbase.Transformation) {
capsule.getOwnedClasses().add((org.eclipse.qvtd.pivot.qvtbase.Transformation) eObject);
}
@@ -504,27 +495,37 @@ public class QvtrToQvtcTransformation
asResource.save(options);
}
- public void saveTrace(@NonNull Resource asResource, @NonNull Collection<@NonNull ? extends EObject> eObjects, @NonNull Map<?, ?> options) throws IOException {
+ public void saveTrace(@NonNull Resource asResource, @NonNull Map<?, ?> options) throws IOException {
Model root = PivotFactory.eINSTANCE.createModel();
root.setExternalURI(asResource.getURI().toString());
asResource.getContents().add(root);
- for (EObject eObject : eObjects) {
- if (eObject instanceof org.eclipse.ocl.pivot.Package) {
- org.eclipse.ocl.pivot.Package p = (org.eclipse.ocl.pivot.Package)eObject;
- root.getOwnedPackages().add(p);
- // Add the package to the CoreModel imports, there should be only one!!
- Import i = PivotFactory.eINSTANCE.createImport();
- i.setName(p.getName());
- i.setImportedNamespace(p);
- this.coreModel.getOwnedImports().add(i);
- }
- else {
- asResource.getContents().add(eObject);
- }
+ for (org.eclipse.ocl.pivot.Package p : tracePackages) {
+ root.getOwnedPackages().add(p);
+ // Add the package to the CoreModel imports, there should be only one!!
+ Import i = PivotFactory.eINSTANCE.createImport();
+ i.setName(p.getName());
+ i.setImportedNamespace(p);
+ coreModel.getOwnedImports().add(i);
}
asResource.save(options);
}
+ private void transformToTracePackages(@NonNull List<org.eclipse.ocl.pivot.@NonNull Package> tracePackages, @NonNull Iterable<org.eclipse.ocl.pivot.@NonNull Package> relationPackages) {
+ for (org.eclipse.ocl.pivot.Package relationPackage : relationPackages) {
+ for (org.eclipse.ocl.pivot.Class relationClass : relationPackage.getOwnedClasses()) {
+ if (relationClass instanceof RelationalTransformation) {
+ RelationalTransformationToTracePackage relationalTransformationToTracePackage = new RelationalTransformationToTracePackage(this);
+ org.eclipse.ocl.pivot.Package tracePackage = relationalTransformationToTracePackage.doRelationalTransformationToTracePackage((RelationalTransformation)relationClass);
+ tracePackages.add(tracePackage);
+ }
+ }
+ transformToTracePackages(tracePackages, ClassUtil.nullFree(relationPackage.getOwnedPackages()));
+ }
+ }
+
+ /**
+ * Lazily create the BottomPattern for a coreArea.
+ */
public @NonNull BottomPattern whenBottomPattern(@NonNull Area coreArea) {
BottomPattern bottomPattern = area2bottomPattern.get(coreArea);
if (bottomPattern == null) {
@@ -536,6 +537,9 @@ public class QvtrToQvtcTransformation
return bottomPattern;
}
+ /**
+ * Lazily create the name CoreDomain for a coreRule.
+ */
public @NonNull CoreDomain whenCoreDomain(org.eclipse.qvtd.pivot.qvtbase.@NonNull Rule coreRule, @NonNull String name) {
Map<@NonNull String, @NonNull CoreDomain> name2coreDomain = rule2name2coreDomain.get(coreRule);
if (name2coreDomain == null) {
@@ -552,6 +556,9 @@ public class QvtrToQvtcTransformation
return coreDomain;
}
+ /**
+ * Lazily create the GuardPattern for a coreArea.
+ */
public @NonNull GuardPattern whenGuardPattern(@NonNull Area coreArea) {
GuardPattern guardPattern = area2guardPattern.get(coreArea);
if (guardPattern == null) {
@@ -562,6 +569,9 @@ public class QvtrToQvtcTransformation
return guardPattern;
}
+ /**
+ * Lazily create the name Mapping for a coreTransformation.
+ */
public @NonNull Mapping whenMapping(@NonNull Transformation coreTransformation, @NonNull String name) {
Map<@NonNull String, @NonNull Mapping> name2mapping = transformation2name2mapping.get(coreTransformation);
if (name2mapping == null) {
@@ -578,6 +588,9 @@ public class QvtrToQvtcTransformation
return coreMapping;
}
+ /**
+ * Lazily create the RealizedVariable for a corePattern corresponding to a relationVariable.
+ */
public @NonNull RealizedVariable whenRealizedVariable(@NonNull CorePattern corePattern, @NonNull Variable relationVariable) {
Map<@NonNull Variable, @NonNull RealizedVariable> variable2realizedVariable = pattern2variable2realizedVariable.get(corePattern);
if (variable2realizedVariable == null) {
@@ -599,6 +612,9 @@ public class QvtrToQvtcTransformation
return realizedVariable;
}
+ /**
+ * Lazily create the name RealizedVariable for a corePattern with a type.
+ */
public @NonNull RealizedVariable whenRealizedVariable(@NonNull CorePattern corePattern, @NonNull String name, @NonNull Type type) {
Map<@NonNull String, @NonNull RealizedVariable> name2realizedVariable = pattern2name2realizedVariable.get(corePattern);
if (name2realizedVariable == null) {
@@ -619,6 +635,9 @@ public class QvtrToQvtcTransformation
return realizedVariable;
}
+ /**
+ * Lazily create the name Property for a traceClass with a type.
+ */
public @NonNull Property whenTraceProperty(org.eclipse.ocl.pivot.@NonNull Class traceClass, @NonNull String name, @NonNull Type type) {
Map<@NonNull String, @NonNull Property> name2traceProperty = traceClass2name2traceProperty.get(traceClass);
if (name2traceProperty == null) {
@@ -650,6 +669,9 @@ public class QvtrToQvtcTransformation
return traceProperty;
}
+ /**
+ * Lazily create the Variable for a corePattern corresponding to a relationVariable.
+ */
public @NonNull Variable whenVariable(@NonNull CorePattern corePattern, @NonNull Variable relationVariable) {
Map<@NonNull Variable, @NonNull Variable> variable2variable = pattern2variable2variable.get(corePattern);
if (variable2variable == null) {
@@ -671,6 +693,9 @@ public class QvtrToQvtcTransformation
return coreVariable;
}
+ /**
+ * Lazily create the name Variable for a corePattern with a type.
+ */
public @NonNull Variable whenVariable(@NonNull CorePattern corePattern, @NonNull String name, @NonNull Type type) {
Map<@NonNull String, @NonNull Variable> name2variable = pattern2name2variable.get(corePattern);
if (name2variable == null) {
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/InvokedRelationToMappingForEnforcement.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/InvokedRelationToMappingForEnforcement.java
index 71d39847c..3a8657c62 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/InvokedRelationToMappingForEnforcement.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/InvokedRelationToMappingForEnforcement.java
@@ -146,7 +146,7 @@ public class InvokedRelationToMappingForEnforcement extends AbstractRule {
assert irn != null;
for (Domain d : ClassUtil.nullFree(r.getDomain())) {
RelationDomain rd = (RelationDomain)d;
- DomainPattern dp = QVTr2QVTcRelations.getDomainPattern(rd);
+ DomainPattern dp = transformation.getDomainPattern(rd);
if (rd.isIsEnforceable() && dp.getTemplateExpression() instanceof ObjectTemplateExp) {
//Mapping m = QVTcoreFactory.eINSTANCE.createMapping();
String dn = rd.getName();
@@ -185,37 +185,35 @@ public class InvokedRelationToMappingForEnforcement extends AbstractRule {
assert mt != null;
for (SubRecord subRecord : subRecords) {
final Transformation mt2 = mt;
- if (mt2 != null) {
- Mapping m = transformation.whenMapping(mt2, rn+'_'+subRecord.irn+'_'+subRecord.dn);
- assert m != null;
- subRecord.m = m;
- GuardPattern mg = transformation.whenGuardPattern(m);
- assert mg != null;
- subRecord.mg = mg;
- BottomPattern mb = transformation.whenBottomPattern(m);
- assert mb != null;
- subRecord.mb = mb;
- CoreDomain md = transformation.whenCoreDomain(m, subRecord.dn);
- assert md != null;
- subRecord.md = md;
- TypedModel mdir = null;
- for (TypedModel tm : mt2.getModelParameter()) {
- if (tm.getName() == subRecord.tmn) {
- if (tm.getUsedPackage().equals(subRecord.up)) {
- mdir = tm;
- break;
- }
+ Mapping m = transformation.whenMapping(mt2, rn+'_'+subRecord.irn+'_'+subRecord.dn);
+ assert m != null;
+ subRecord.m = m;
+ GuardPattern mg = transformation.whenGuardPattern(m);
+ assert mg != null;
+ subRecord.mg = mg;
+ BottomPattern mb = transformation.whenBottomPattern(m);
+ assert mb != null;
+ subRecord.mb = mb;
+ CoreDomain md = transformation.whenCoreDomain(m, subRecord.dn);
+ assert md != null;
+ subRecord.md = md;
+ TypedModel mdir = null;
+ for (TypedModel tm : mt2.getModelParameter()) {
+ if (tm.getName() == subRecord.tmn) {
+ if (tm.getUsedPackage().equals(subRecord.up)) {
+ mdir = tm;
+ break;
}
}
- assert mdir != null;
- subRecord.mdir = mdir;
- GuardPattern dg = transformation.whenGuardPattern(md);
- assert dg != null;
- subRecord.dg = dg;
- BottomPattern db = transformation.whenBottomPattern(md);
- assert db != null;
- subRecord.db = db;
}
+ assert mdir != null;
+ subRecord.mdir = mdir;
+ GuardPattern dg = transformation.whenGuardPattern(md);
+ assert dg != null;
+ subRecord.dg = dg;
+ BottomPattern db = transformation.whenBottomPattern(md);
+ assert db != null;
+ subRecord.db = db;
}
}
@@ -277,7 +275,7 @@ public class InvokedRelationToMappingForEnforcement extends AbstractRule {
rpSet.addAll(relations.rejectRelationCallPredicates(ClassUtil.nullFree(r.getWhere().getPredicate())));
whereVars.addAll(ClassUtil.nullFree(r.getWhere().getBindsTo()));
}
- Set<Variable> sharedDomainVars = relations.getSharedDomainVars(r);
+ Set<Variable> sharedDomainVars = transformation.getSharedDomainVars(r);
Set<Variable> unsharedWhereVars = new HashSet<Variable>(whereVars);
unsharedWhereVars.removeAll(whenVars);
unsharedWhereVars.removeAll(allDomainVars);
@@ -287,7 +285,7 @@ public class InvokedRelationToMappingForEnforcement extends AbstractRule {
for (SubRecord subRecord : subRecords) {
Set<Variable> oppositeDomainVars = new HashSet<Variable>();
for (Domain d : ClassUtil.nullFree(subRecord.rOppositeDomains)) {
- oppositeDomainVars.addAll(QVTr2QVTcRelations.getDomainPattern(d).getBindsTo());
+ oppositeDomainVars.addAll(transformation.getDomainPattern(d).getBindsTo());
}
Set<Variable> domainBottomUnSharedVars = new HashSet<Variable>(subRecord.domainVars);
domainBottomUnSharedVars.removeAll(whenVars);
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToMappingTransformation.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToMappingTransformation.java
index 2498ef46a..efa80890f 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToMappingTransformation.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToMappingTransformation.java
@@ -97,7 +97,7 @@ public class RelationalTransformationToMappingTransformation extends AbstractRul
public void check() {
rtn = rt.getName();
assert (rt != null) && (mt == null);
- p = transformation.getTransformationToPackageTrace(rt);
+ p = transformation.getTracePackage(rt);
assert p != null;
for (TypedModel rtm : rt.getModelParameter()) {
@NonNull List<org.eclipse.ocl.pivot.Package> usedPackage = rtm.getUsedPackage();
@@ -151,15 +151,9 @@ public class RelationalTransformationToMappingTransformation extends AbstractRul
*/
@Override
public boolean when() {
- RelationalTransformationToTracePackage whenRule = new RelationalTransformationToTracePackage(transformation, rt);
- RuleBindings whenBindings = whenRule.getRuleBindings();
- RelationalTransformationToTracePackage whenRuleRecord = (RelationalTransformationToTracePackage) transformation.getRecord(whenBindings);
- if (whenRuleRecord != null && whenRuleRecord.hasExecuted()) {
- p = whenRuleRecord.getCore();
- assert p != null;
- return true;
- }
- return false;
+ p = transformation.getTracePackage(rt);
+ assert p != null;
+ return true;
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToTracePackage.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToTracePackage.java
index 64ce0b4f3..64aa8ecea 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToTracePackage.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/RelationalTransformationToTracePackage.java
@@ -10,78 +10,100 @@
******************************************************************************/
package org.eclipse.qvtd.compiler.internal.qvtr2qvtc.impl;
-import java.util.HashMap;
-import java.util.Map;
-
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.ocl.pivot.OCLExpression;
import org.eclipse.ocl.pivot.PivotFactory;
+import org.eclipse.ocl.pivot.Type;
+import org.eclipse.ocl.pivot.Variable;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
-import org.eclipse.qvtd.compiler.internal.qvtr2qvtc.QVTr2QVTcRelations;
import org.eclipse.qvtd.compiler.internal.qvtr2qvtc.QvtrToQvtcTransformation;
+import org.eclipse.qvtd.pivot.qvtbase.Domain;
+import org.eclipse.qvtd.pivot.qvtbase.Rule;
+import org.eclipse.qvtd.pivot.qvtrelation.DomainPattern;
import org.eclipse.qvtd.pivot.qvtrelation.Relation;
+import org.eclipse.qvtd.pivot.qvtrelation.RelationDomain;
import org.eclipse.qvtd.pivot.qvtrelation.RelationalTransformation;
+import org.eclipse.qvtd.pivot.qvttemplate.CollectionTemplateExp;
+import org.eclipse.qvtd.pivot.qvttemplate.ObjectTemplateExp;
+import org.eclipse.qvtd.pivot.qvttemplate.PropertyTemplateItem;
+import org.eclipse.qvtd.pivot.qvttemplate.TemplateExp;
-public class RelationalTransformationToTracePackage extends AbstractRule
+public class RelationalTransformationToTracePackage
{
- // Relation
- private final @NonNull RelationalTransformation rt;
-
- // Core
- private org.eclipse.ocl.pivot.Package p;
-
- // Primitives
- private String rtn;
-
- // Mapping
- private final @NonNull Map<@NonNull Relation, org.eclipse.ocl.pivot.@NonNull Class> relation2class = new HashMap<@NonNull Relation, org.eclipse.ocl.pivot.@NonNull Class>();
+ protected final@NonNull QvtrToQvtcTransformation transformation;
- public RelationalTransformationToTracePackage(@NonNull QvtrToQvtcTransformation transformation, @NonNull RelationalTransformation rt) {
- super(transformation);
- this.rt = rt;
+ public RelationalTransformationToTracePackage(@NonNull QvtrToQvtcTransformation transformation) {
+ this.transformation = transformation;
}
- @Override
- public void check() {
- rtn = rt.getName();
- for (org.eclipse.qvtd.pivot.qvtbase.Rule r : ClassUtil.nullFree(rt.getRule())) {
+ public org.eclipse.ocl.pivot.@NonNull Package doRelationalTransformationToTracePackage(@NonNull RelationalTransformation rt) {
+ org.eclipse.ocl.pivot.Package p = PivotFactory.eINSTANCE.createPackage();
+ assert p != null;
+ p.setName("P" + rt.getName());
+ p.setURI(p.getName());
+ transformation.putTracePackage(rt, p);
+ for (Rule r : ClassUtil.nullFree(rt.getRule())) {
if (r instanceof Relation) {
org.eclipse.ocl.pivot.Class rc = PivotFactory.eINSTANCE.createClass();
assert rc != null;
- relation2class.put((Relation)r, rc);
+ p.getOwnedClasses().add(rc);
+ doRelationToTraceClass((Relation)r, rc);
}
}
- }
-
- public org.eclipse.ocl.pivot.@Nullable Package getCore() {
return p;
}
- @Override
- public void instantiateOutput() {
- p = PivotFactory.eINSTANCE.createPackage();
- assert p != null;
- transformation.addOrphan(p);
- transformation.putTransformationToPackageTrace(rt, p);
- for (Relation r : relation2class.keySet()) {
- org.eclipse.ocl.pivot.Class rc = relation2class.get(r);
- p.getOwnedClasses().add(rc);
+ private void doRelationToTraceClass(@NonNull Relation r, org.eclipse.ocl.pivot.@NonNull Class rc) {
+ transformation.putRelationTrace(r, rc);
+ String rn = r.getName();
+ assert rn != null;
+ rc.setName("T"+rn);
+ for (Variable rv : transformation.getSharedDomainVars(r)) {
+ String vn = rv.getName();
+ Type c = rv.getType();
+ assert (vn != null) && (c != null);
+ transformation.whenTraceProperty(rc, vn, c);
+ }
+ for (Domain d : ClassUtil.nullFree(r.getDomain())) {
+ for (DomainPattern rdp : ClassUtil.nullFree(((RelationDomain) d).getPattern())) {
+ TemplateExp t = rdp.getTemplateExpression();
+ assert t != null;
+ doSubTemplateToTraceClassProps(t, rc);
+ }
}
}
- @Override
- public void setAttributes() {
- p.setName("P" + rtn);
- p.setURI(p.getName());
+ private void doSubTemplateToTraceClassProps(@NonNull TemplateExp t, org.eclipse.ocl.pivot.@NonNull Class rc) {
+ if (t instanceof CollectionTemplateExp) {
+ doCollectionTemplateToTraceClassProps((CollectionTemplateExp) t, rc);
+ }
+ if (t instanceof ObjectTemplateExp) {
+ doObjectTemplateToTraceClassProps((ObjectTemplateExp) t, rc);
+ }
+ }
+
+ private void doCollectionTemplateToTraceClassProps(@NonNull CollectionTemplateExp t, org.eclipse.ocl.pivot.@NonNull Class rc) {
+ for (OCLExpression m : t.getMember()) {
+ if (m instanceof TemplateExp) {
+ // Don't add trace attributes for collections, just for the members
+ doSubTemplateToTraceClassProps((TemplateExp) m, rc);
+ }
+ }
}
-
- @Override
- public void where() {
- QVTr2QVTcRelations relations = new QVTr2QVTcRelations(transformation);
- for (Relation r : relation2class.keySet()) {
- org.eclipse.ocl.pivot.Class rc = relation2class.get(r);
- assert rc != null;
- relations.doRelationToTraceClass(r, rc);
+
+ private void doObjectTemplateToTraceClassProps(@NonNull ObjectTemplateExp t, org.eclipse.ocl.pivot.@NonNull Class rc) {
+ Variable tv = t.getBindsTo();
+ assert tv != null;
+ String vn = tv.getName();
+ Type c = tv.getType();
+ assert (vn != null) && (c != null);
+ transformation.whenTraceProperty(rc, vn, c);
+ for (PropertyTemplateItem pt : t.getPart()) {
+ OCLExpression value = pt.getValue();
+ assert value != null;
+ if (value instanceof TemplateExp) {
+ doSubTemplateToTraceClassProps((TemplateExp) value, rc);
+ }
}
}
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TROppositeDomainsToMappingForEnforcement.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TROppositeDomainsToMappingForEnforcement.java
index 1002d9065..f326866e5 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TROppositeDomainsToMappingForEnforcement.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TROppositeDomainsToMappingForEnforcement.java
@@ -13,14 +13,8 @@ package org.eclipse.qvtd.compiler.internal.qvtr2qvtc.impl;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.qvtd.compiler.internal.qvtr2qvtc.QvtrToQvtcTransformation;
-public class TROppositeDomainsToMappingForEnforcement extends AbstractRule {
-
-
-
-// private class SubRecord {
-//
-// }
-
+public class TROppositeDomainsToMappingForEnforcement extends AbstractRule
+{
protected TROppositeDomainsToMappingForEnforcement(@NonNull QvtrToQvtcTransformation transformation) {
super(transformation);
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TopLevelRelationToMappingForEnforcement.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TopLevelRelationToMappingForEnforcement.java
index 40e158f3a..19718e228 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TopLevelRelationToMappingForEnforcement.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtr2qvtc/impl/TopLevelRelationToMappingForEnforcement.java
@@ -132,7 +132,7 @@ public class TopLevelRelationToMappingForEnforcement extends AbstractRule
if (r.isIsTopLevel()) {
for (Domain d : r.getDomain()) {
RelationDomain rd = (RelationDomain) d;
- if (rd.isIsEnforceable() && QVTr2QVTcRelations.getDomainPattern(rd).getTemplateExpression() instanceof ObjectTemplateExp) {
+ if (rd.isIsEnforceable() && transformation.getDomainPattern(rd).getTemplateExpression() instanceof ObjectTemplateExp) {
//Mapping m = QVTcoreFactory.eINSTANCE.createMapping();
String dn = rd.getName();
assert dn != null;
@@ -141,7 +141,7 @@ public class TopLevelRelationToMappingForEnforcement extends AbstractRule
assert tmn != null;
List<org.eclipse.ocl.pivot.Package> up = dir.getUsedPackage();
assert up != null;
- DomainPattern dp = QVTr2QVTcRelations.getDomainPattern(rd);
+ DomainPattern dp = transformation.getDomainPattern(rd);
List<Variable> domainVars = dp.getBindsTo();
ObjectTemplateExp te = (ObjectTemplateExp) dp.getTemplateExpression();
Variable tev = te.getBindsTo();
@@ -250,7 +250,7 @@ public class TopLevelRelationToMappingForEnforcement extends AbstractRule
rpSet.addAll(relations.rejectRelationCallPredicates(ClassUtil.nullFree(rWhere.getPredicate())));
whereVars.addAll(ClassUtil.nullFree(rWhere.getBindsTo()));
}
- Set<@NonNull Variable> sharedDomainVars = relations.getSharedDomainVars(r);
+ Set<@NonNull Variable> sharedDomainVars = transformation.getSharedDomainVars(r);
Set<@NonNull Variable> allDomainVars = relations.getAllDomainVars(r);
Set<@NonNull Variable> unsharedWhereVars = new HashSet<@NonNull Variable>(whereVars);
unsharedWhereVars.removeAll(whenVars);
@@ -261,7 +261,7 @@ public class TopLevelRelationToMappingForEnforcement extends AbstractRule
for (SubRecord subRecord : subRecords) {
Set<Variable> oppositeDomainVars = new HashSet<Variable>();
for (Domain d : subRecord.rOppositeDomains) {
- oppositeDomainVars.addAll(QVTr2QVTcRelations.getDomainPattern(d).getBindsTo());
+ oppositeDomainVars.addAll(transformation.getDomainPattern(d).getBindsTo());
}
Set<@NonNull Variable> domainBottomUnSharedVars = new HashSet<@NonNull Variable>(subRecord.domainVars);
domainBottomUnSharedVars.removeAll(whenVars);
diff --git a/tests/org.eclipse.qvtd.build.qvtrtoqvtc.tests/src/org/eclipse/qvtd/build/qvtrtoqvtc/tests/QvtrToQvtcTests.java b/tests/org.eclipse.qvtd.build.qvtrtoqvtc.tests/src/org/eclipse/qvtd/build/qvtrtoqvtc/tests/QvtrToQvtcTests.java
index ab40c4f7f..40cce9994 100644
--- a/tests/org.eclipse.qvtd.build.qvtrtoqvtc.tests/src/org/eclipse/qvtd/build/qvtrtoqvtc/tests/QvtrToQvtcTests.java
+++ b/tests/org.eclipse.qvtd.build.qvtrtoqvtc.tests/src/org/eclipse/qvtd/build/qvtrtoqvtc/tests/QvtrToQvtcTests.java
@@ -109,9 +109,9 @@ public class QvtrToQvtcTests extends LoadTestCase {
QvtrToQvtcTransformation t = new QvtrToQvtcTransformation(ocl.getEnvironmentFactory(), qvtrResource, qvtcResource, qvtcTraceResource);
t.prepare();
t.execute();
- t.saveTrace(qvtcTraceResource, t.getTraceRoots(), TestsXMLUtil.defaultSavingOptions);
+ t.saveTrace(qvtcTraceResource, TestsXMLUtil.defaultSavingOptions);
assertNoResourceErrors("Trace save", qvtcTraceResource);
- t.saveCore(qvtcResource, t.getCoreRoots(), TestsXMLUtil.defaultSavingOptions);
+ t.saveCore(qvtcResource, TestsXMLUtil.defaultSavingOptions);
assertNoResourceErrors("Core save", qvtcResource);
ocl.dispose();
}

Back to the top