Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2015-10-22 20:53:27 +0000
committerEd Willink2015-10-22 21:33:39 +0000
commit3474c5b5f2cd83b893d80ff1d3a842d184946ab4 (patch)
tree2032a52b8b674dadc9c20a32d11a3212128d046d
parent37876bbd6f7079d36ee489a739009e95ea56fc08 (diff)
downloadorg.eclipse.qvtd-3474c5b5f2cd83b893d80ff1d3a842d184946ab4.tar.gz
org.eclipse.qvtd-3474c5b5f2cd83b893d80ff1d3a842d184946ab4.tar.xz
org.eclipse.qvtd-3474c5b5f2cd83b893d80ff1d3a842d184946ab4.zip
[460467] Derive VariablePredicate from guard 'init' not predicateI201510221752
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEvaluationVisitor.java9
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java83
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/as2cs/QVTimperativeDeclarationVisitor.java32
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSContainmentVisitor.java17
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPostOrderVisitor.java70
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/ManualUML2RDBMS/ManualUML2RDBMS.qvti40
6 files changed, 175 insertions, 76 deletions
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEvaluationVisitor.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEvaluationVisitor.java
index 36abaf625..3868ac390 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEvaluationVisitor.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiEvaluationVisitor.java
@@ -169,10 +169,15 @@ public class QVTiEvaluationVisitor extends BasicEvaluationVisitor implements IQV
return null;
}
}
- context.pushEvaluationEnvironment(mappingCall.getReferredMapping(), mappingCall);
+ Mapping referredMapping = mappingCall.getReferredMapping();
+ if (referredMapping == null) {
+ return null;
+ }
+ context.pushEvaluationEnvironment(referredMapping, mappingCall);
try {
for (Map.Entry<Variable,Object> entry : variable2value.entrySet()) {
- context.replace(entry.getKey(), entry.getValue());
+ @SuppressWarnings("null")@NonNull Variable variable = entry.getKey();
+ context.replace(variable, entry.getValue());
}
return executor.internalExecuteMappingCall(mappingCall, undecoratedVisitor);
}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java
index 565be227a..362141f1b 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java
@@ -10,16 +10,30 @@
*******************************************************************************/
package org.eclipse.qvtd.pivot.qvtimperative.utilities;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.Variable;
+import org.eclipse.ocl.pivot.VariableDeclaration;
+import org.eclipse.ocl.pivot.VariableExp;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
+import org.eclipse.ocl.pivot.utilities.NameUtil;
+import org.eclipse.qvtd.pivot.qvtbase.Domain;
+import org.eclipse.qvtd.pivot.qvtcorebase.CoreDomain;
import org.eclipse.qvtd.pivot.qvtcorebase.utilities.QVTcoreBaseUtil;
import org.eclipse.qvtd.pivot.qvtimperative.Mapping;
import org.eclipse.qvtd.pivot.qvtimperative.MappingCallBinding;
+import org.eclipse.qvtd.pivot.qvtimperative.VariablePredicate;
public class QVTimperativeUtil extends QVTcoreBaseUtil
{
@@ -48,4 +62,73 @@ public class QVTimperativeUtil extends QVTcoreBaseUtil
}
return null;
}
+
+ /**
+ * Return a copy of asVariablePredicates sorted to avoid reverse references from the predicate expressions.
+ */
+ public static @NonNull List<VariablePredicate> sortVariablePredicates(@NonNull Mapping asMapping, @NonNull List<VariablePredicate> asVariablePredicates) {
+ Set<Variable> asGuardVariables = new HashSet<Variable>();
+ asGuardVariables.addAll(asMapping.getGuardPattern().getVariable());
+ for (Domain asDomain : asMapping.getDomain()) {
+ asGuardVariables.addAll(((CoreDomain)asDomain).getGuardPattern().getVariable());
+ }
+ List<VariableDeclaration> pendingVariables = new ArrayList<VariableDeclaration>();
+ Map<VariableDeclaration, VariablePredicate> variable2predicate = new HashMap<VariableDeclaration, VariablePredicate>();
+ Map<VariableDeclaration, Set<VariablePredicate>> variable2predicates = new HashMap<VariableDeclaration, Set<VariablePredicate>>();
+ Map<VariablePredicate, Set<VariableDeclaration>> predicate2variables = new HashMap<VariablePredicate, Set<VariableDeclaration>>();
+ for (VariablePredicate asVariablePredicate : asVariablePredicates) {
+ for (TreeIterator<EObject> tit = asVariablePredicate.eAllContents(); tit.hasNext(); ) {
+ EObject eObject = tit.next();
+ if (eObject instanceof VariableExp) {
+ VariableDeclaration asVariable = ((VariableExp)eObject).getReferredVariable();
+ if ((asVariable != null) && asGuardVariables.contains(asVariable)) {
+ Set<VariablePredicate> predicates = variable2predicates.get(asVariable);
+ if (predicates == null){
+ predicates = new HashSet<VariablePredicate>();
+ variable2predicates.put(asVariable, predicates);
+ }
+ predicates.add(asVariablePredicate);
+ Set<VariableDeclaration> variables = predicate2variables.get(asVariablePredicate);
+ if (variables == null){
+ variables = new HashSet<VariableDeclaration>();
+ predicate2variables.put(asVariablePredicate, variables);
+ }
+ variables.add(asVariable);
+ pendingVariables.add(asVariablePredicate.getTargetVariable());
+ variable2predicate.put(asVariablePredicate.getTargetVariable(), asVariablePredicate);
+ }
+ }
+ }
+ }
+ int oldSize;
+ List<VariablePredicate> asSortedVariablePredicates = new ArrayList<VariablePredicate>();
+ Collections.sort(pendingVariables, NameUtil.NAMEABLE_COMPARATOR); // Ensure deterministic order
+ while (pendingVariables.size() > 0) {
+ oldSize = asSortedVariablePredicates.size();
+ for (VariableDeclaration asVariable : pendingVariables) {
+ VariablePredicate asVariablePredicate1 = variable2predicate.get(asVariable);
+ Set<VariableDeclaration> variables = predicate2variables.get(asVariablePredicate1);
+ variables.retainAll(pendingVariables);
+ if (variables.size() <= 0) {
+ asSortedVariablePredicates.add(asVariablePredicate1);
+ Set<VariablePredicate> predicates = variable2predicates.get(asVariable);
+ if (predicates != null) {
+ for (VariablePredicate asVariablePredicate2 : predicates) {
+ predicate2variables.get(asVariablePredicate2).remove(asVariable);
+ }
+ }
+ pendingVariables.remove(asVariable);
+ predicate2variables.remove(asVariablePredicate1);
+ break;
+ }
+ }
+ if (asSortedVariablePredicates.size() == oldSize) {
+ for (VariablePredicate asVariablePredicate : predicate2variables.keySet()) {
+ asSortedVariablePredicates.add(asVariablePredicate);
+ }
+ break; // FIXME error message for cycle
+ }
+ }
+ return asSortedVariablePredicates;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/as2cs/QVTimperativeDeclarationVisitor.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/as2cs/QVTimperativeDeclarationVisitor.java
index af14698aa..dc27deaba 100644
--- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/as2cs/QVTimperativeDeclarationVisitor.java
+++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/as2cs/QVTimperativeDeclarationVisitor.java
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.pivot.CollectionType;
import org.eclipse.ocl.pivot.Element;
+import org.eclipse.ocl.pivot.OCLExpression;
import org.eclipse.ocl.pivot.Operation;
import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.Variable;
@@ -30,10 +31,9 @@ import org.eclipse.ocl.xtext.basecs.PathNameCS;
import org.eclipse.ocl.xtext.basecs.TypedRefCS;
import org.eclipse.ocl.xtext.essentialoclcs.EssentialOCLCSPackage;
import org.eclipse.ocl.xtext.essentialoclcs.ExpCS;
-import org.eclipse.ocl.xtext.essentialoclcs.InfixExpCS;
-import org.eclipse.ocl.xtext.essentialoclcs.NameExpCS;
import org.eclipse.ocl.xtext.essentialoclcs.VariableCS;
import org.eclipse.qvtd.pivot.qvtbase.Function;
+import org.eclipse.qvtd.pivot.qvtbase.Predicate;
import org.eclipse.qvtd.pivot.qvtbase.Rule;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
@@ -50,6 +50,7 @@ import org.eclipse.qvtd.pivot.qvtimperative.MappingSequence;
import org.eclipse.qvtd.pivot.qvtimperative.MappingStatement;
import org.eclipse.qvtd.pivot.qvtimperative.VariablePredicate;
import org.eclipse.qvtd.pivot.qvtimperative.util.QVTimperativeVisitor;
+import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperativeUtil;
import org.eclipse.qvtd.xtext.qvtcorebase.as2cs.QVTcoreBaseDeclarationVisitor;
import org.eclipse.qvtd.xtext.qvtcorebasecs.BottomPatternCS;
import org.eclipse.qvtd.xtext.qvtcorebasecs.DomainCS;
@@ -291,6 +292,25 @@ public class QVTimperativeDeclarationVisitor extends QVTcoreBaseDeclarationVisit
// refreshList(csElement.getOwnedConstraint(), visitDeclarations(ConstraintCS.class, object.getOwnedRule(), null));
return csVariable;
}
+ else if (asVariable.eContainer() instanceof GuardPattern){
+ Mapping containingMapping = QVTimperativeUtil.getContainingMapping(asVariable);
+ assert containingMapping != null;
+ UnrealizedVariableCS csUnrealizedVariable = context.refreshNamedElement(UnrealizedVariableCS.class, QVTcoreBaseCSPackage.Literals.UNREALIZED_VARIABLE_CS, asVariable);
+ csUnrealizedVariable.setPivot(asVariable);
+ csUnrealizedVariable.setOwnedType(createTypeRefCS(asVariable.getType(), getScope(asVariable)));
+ OCLExpression ownedInit = null;
+ for (Predicate asPredicate : containingMapping.getGuardPattern().getPredicate()) {
+ if (asPredicate instanceof VariablePredicate) {
+ VariablePredicate asVariablePredicate = (VariablePredicate)asPredicate;
+ if (asVariablePredicate.getTargetVariable() == asVariable) {
+ ownedInit = asVariablePredicate.getConditionExpression();
+ break;
+ }
+ }
+ }
+ csUnrealizedVariable.setOwnedInitExpression(context.visitDeclaration(ExpCS.class, ownedInit));
+ return csUnrealizedVariable;
+ }
else {
return super.visitVariable(asVariable);
}
@@ -298,12 +318,6 @@ public class QVTimperativeDeclarationVisitor extends QVTcoreBaseDeclarationVisit
@Override
public ElementCS visitVariablePredicate(@NonNull VariablePredicate asVariablePredicate) {
- PredicateCS csPredicate = context.refreshElement(PredicateCS.class, QVTcoreBaseCSPackage.Literals.PREDICATE_CS, asVariablePredicate);
- csPredicate.setPivot(asVariablePredicate);
- NameExpCS csVariableExp = createNameExpCS(asVariablePredicate.getTargetVariable());
- ExpCS csValueExp = createExpCS(asVariablePredicate.getConditionExpression());
- InfixExpCS csConditionExp = createInfixExpCS(csVariableExp, "=", csValueExp);
- csPredicate.setOwnedCondition(csConditionExp);
- return csPredicate;
+ return null;
}
}
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSContainmentVisitor.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSContainmentVisitor.java
index 43f5ca2f8..bb81b709c 100644
--- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSContainmentVisitor.java
+++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSContainmentVisitor.java
@@ -29,7 +29,6 @@ import org.eclipse.ocl.xtext.base.cs2as.Continuation;
import org.eclipse.ocl.xtext.base.utilities.BaseCSResource;
import org.eclipse.ocl.xtext.basecs.PathNameCS;
import org.eclipse.ocl.xtext.essentialoclcs.ExpCS;
-import org.eclipse.ocl.xtext.essentialoclcs.InfixExpCS;
import org.eclipse.ocl.xtext.essentialoclcs.NameExpCS;
import org.eclipse.qvtd.pivot.qvtbase.Function;
import org.eclipse.qvtd.pivot.qvtbase.Predicate;
@@ -57,7 +56,6 @@ import org.eclipse.qvtd.pivot.qvtimperative.MappingSequence;
import org.eclipse.qvtd.pivot.qvtimperative.MappingStatement;
import org.eclipse.qvtd.pivot.qvtimperative.QVTimperativeFactory;
import org.eclipse.qvtd.pivot.qvtimperative.QVTimperativePackage;
-import org.eclipse.qvtd.pivot.qvtimperative.VariablePredicate;
import org.eclipse.qvtd.xtext.qvtcorebasecs.BottomPatternCS;
import org.eclipse.qvtd.xtext.qvtcorebasecs.DirectionCS;
import org.eclipse.qvtd.xtext.qvtcorebasecs.DomainCS;
@@ -179,13 +177,7 @@ public class QVTimperativeCSContainmentVisitor extends AbstractQVTimperativeCSCo
@Override
public Continuation<?> visitPredicateCS(@NonNull PredicateCS csElement) {
- ExpCS csCondition = csElement.getOwnedCondition();
- if ((csCondition instanceof InfixExpCS) && "=".equals(((InfixExpCS)csCondition).getName()) && (((InfixExpCS)csCondition).getOwnedLeft() instanceof NameExpCS)) {
- context.refreshModelElement(VariablePredicate.class, QVTimperativePackage.Literals.VARIABLE_PREDICATE, csElement);
- }
- else {
- context.refreshModelElement(Predicate.class, QVTbasePackage.Literals.PREDICATE, csElement);
- }
+ context.refreshModelElement(Predicate.class, QVTbasePackage.Literals.PREDICATE, csElement);
return null;
}
@@ -194,12 +186,7 @@ public class QVTimperativeCSContainmentVisitor extends AbstractQVTimperativeCSCo
ExpCS csTarget = csElement.getOwnedTarget();
EObject eContainer = csElement.eContainer();
if ((csElement.getOwnedInitExpression() == null) || (eContainer instanceof GuardPatternCS)) {
- if (csTarget instanceof NameExpCS) {
- context.refreshModelElement(VariablePredicate.class, QVTimperativePackage.Literals.VARIABLE_PREDICATE, csElement);
- }
- else {
- context.refreshModelElement(Predicate.class, QVTbasePackage.Literals.PREDICATE, csElement);
- }
+ context.refreshModelElement(Predicate.class, QVTbasePackage.Literals.PREDICATE, csElement);
}
else if (csTarget instanceof NameExpCS) {
context.refreshModelElement(VariableAssignment.class, QVTcoreBasePackage.Literals.VARIABLE_ASSIGNMENT, csElement);
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPostOrderVisitor.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPostOrderVisitor.java
index 0fba8b5d3..6f1e29254 100644
--- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPostOrderVisitor.java
+++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPostOrderVisitor.java
@@ -10,18 +10,16 @@
*******************************************************************************/
package org.eclipse.qvtd.xtext.qvtimperative.cs2as;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.CollectionType;
import org.eclipse.ocl.pivot.OCLExpression;
-import org.eclipse.ocl.pivot.OperationCallExp;
import org.eclipse.ocl.pivot.PropertyCallExp;
import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.Variable;
-import org.eclipse.ocl.pivot.VariableDeclaration;
-import org.eclipse.ocl.pivot.VariableExp;
import org.eclipse.ocl.pivot.utilities.PivotUtil;
import org.eclipse.ocl.xtext.base.cs2as.BasicContinuation;
import org.eclipse.ocl.xtext.base.cs2as.CS2ASConversion;
@@ -31,11 +29,17 @@ import org.eclipse.ocl.xtext.essentialoclcs.ExpCS;
import org.eclipse.qvtd.pivot.qvtbase.Predicate;
import org.eclipse.qvtd.pivot.qvtcorebase.Assignment;
import org.eclipse.qvtd.pivot.qvtcorebase.PropertyAssignment;
+import org.eclipse.qvtd.pivot.qvtimperative.Mapping;
import org.eclipse.qvtd.pivot.qvtimperative.MappingCallBinding;
import org.eclipse.qvtd.pivot.qvtimperative.MappingLoop;
+import org.eclipse.qvtd.pivot.qvtimperative.QVTimperativeFactory;
import org.eclipse.qvtd.pivot.qvtimperative.VariablePredicate;
+import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperativeUtil;
+import org.eclipse.qvtd.xtext.qvtcorebasecs.DomainCS;
+import org.eclipse.qvtd.xtext.qvtcorebasecs.GuardPatternCS;
import org.eclipse.qvtd.xtext.qvtcorebasecs.PredicateCS;
import org.eclipse.qvtd.xtext.qvtcorebasecs.PredicateOrAssignmentCS;
+import org.eclipse.qvtd.xtext.qvtcorebasecs.UnrealizedVariableCS;
import org.eclipse.qvtd.xtext.qvtimperativecs.MappingCS;
import org.eclipse.qvtd.xtext.qvtimperativecs.MappingCallBindingCS;
import org.eclipse.qvtd.xtext.qvtimperativecs.MappingLoopCS;
@@ -88,6 +92,39 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost
@Override
public Continuation<?> visitMappingCS(@NonNull MappingCS csElement) {
+ Mapping asMapping = PivotUtil.getPivot(Mapping.class, csElement);
+ if (asMapping != null) {
+ List<VariablePredicate> asVariablePredicates = null;
+ for (DomainCS csDomain : csElement.getOwnedDomains()) {
+ GuardPatternCS csGuardPattern = csDomain.getOwnedGuardPattern();
+ for (UnrealizedVariableCS csVariable : csGuardPattern.getOwnedUnrealizedVariables()) {
+ Variable asVariable = PivotUtil.getPivot(Variable.class, csVariable);
+ if (asVariable != null) {
+ ExpCS csGuardExpression = csVariable.getOwnedInitExpression();
+ if (csGuardExpression != null) {
+ OCLExpression asExpression = context.visitLeft2Right(OCLExpression.class, csGuardExpression);
+ if (asExpression != null) {
+ VariablePredicate asVariablePredicate = QVTimperativeFactory.eINSTANCE.createVariablePredicate();
+ asVariablePredicate.setTargetVariable(asVariable);
+ asVariablePredicate.setConditionExpression(asExpression);
+ if (asVariablePredicates == null) {
+ asVariablePredicates = new ArrayList<VariablePredicate>();
+ }
+ asVariablePredicates.add(asVariablePredicate);
+ }
+ }
+ }
+ }
+ }
+ if (asVariablePredicates != null) {
+ List<Predicate> asPredicates = asMapping.getGuardPattern().getPredicate();
+ List<VariablePredicate> asSortedPredicates = QVTimperativeUtil.sortVariablePredicates(asMapping, asVariablePredicates);
+ int j = 0;
+ for (VariablePredicate asVariablePredicate : asSortedPredicates) {
+ asPredicates.add(j++, asVariablePredicate);
+ }
+ }
+ }
return null;
}
@@ -125,31 +162,11 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost
Predicate asPredicate = PivotUtil.getPivot(Predicate.class, csElement);
if (asPredicate != null) {
OCLExpression asCondition = null;
- Variable asVariable = null;
ExpCS csCondition = csElement.getOwnedCondition();
if (csCondition != null) {
asCondition = context.visitLeft2Right(OCLExpression.class, csCondition);
- if (asCondition instanceof OperationCallExp) {
- OperationCallExp asConditionCall = (OperationCallExp)asCondition;
- if ((asConditionCall.getOwnedArguments().size() == 1) && "=".equals(asConditionCall.getName())) {
- OCLExpression sourceExp = asConditionCall.getOwnedSource();
- if (sourceExp instanceof VariableExp) {
- VariableDeclaration referredVariable = ((VariableExp)sourceExp).getReferredVariable();
- if (referredVariable instanceof Variable) {
- asVariable = (Variable) referredVariable;
- asCondition = asConditionCall.getOwnedArguments().get(0);
- }
- }
- }
- }
}
asPredicate.setConditionExpression(asCondition);
- if (asPredicate instanceof VariablePredicate) {
- ((VariablePredicate)asPredicate).setTargetVariable(asVariable);
- }
- else {
- assert asVariable == null;
- }
}
return null;
}
@@ -158,4 +175,11 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost
public Continuation<?> visitTopLevelCS(@NonNull TopLevelCS object) {
return null;
}
+ @Override
+ public Continuation<?> visitUnrealizedVariableCS(@NonNull UnrealizedVariableCS csElement) {
+ if (csElement.eContainer() instanceof GuardPatternCS) {
+ return null; // 'initExpression' is a guardExpression resolved by MappingCS
+ }
+ return super.visitUnrealizedVariableCS(csElement);
+ }
}
diff --git a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/ManualUML2RDBMS/ManualUML2RDBMS.qvti b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/ManualUML2RDBMS/ManualUML2RDBMS.qvti
index baad20d79..4c0e1b0d1 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/ManualUML2RDBMS/ManualUML2RDBMS.qvti
+++ b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/ManualUML2RDBMS/ManualUML2RDBMS.qvti
@@ -339,22 +339,18 @@ map classToTableMR_2_2 in ManualUML2RDBMS {
}
map associationToForeignKeyLM in ManualUML2RDBMS {
- check uml (p:Package, sc:Class, dc:Class, a:Association) {
+ check uml (p:Package, sc:Class := a.source, dc:Class := a.destination, a:Association) {
-- sc.namespace = p;
}
- enforce middle (p2s:PackageToSchema, sc2t:ClassToTable, dc2t:ClassToTable) {
+ enforce middle (p2s:PackageToSchema, sc2t:ClassToTable := sc.ClassToTable, dc2t:ClassToTable := dc.ClassToTable) {
realize a2f:AssociationToForeignKey
}
where (
a.namespace = p;
- sc = a.source;
- dc = a.destination;
sc.namespace = p;
-- getAllForwards(sc)->includes(a);
-- getAllSupers(dc)->includes(a.destination);
p2s.umlPackage = p;
- sc2t = sc.ClassToTable;
- dc2t = dc.ClassToTable;
) {
sc2t.owner := p2s;
a2f.owner := sc2t;
@@ -429,17 +425,15 @@ map associationToForeignKeyMR_2 in ManualUML2RDBMS {
}
map classPrimitiveAttributesLM in ManualUML2RDBMS {
- check uml (c:Class, t:PrimitiveDataType, a:Attribute) {
+ check uml (c:Class, t:PrimitiveDataType := a.type, a:Attribute) {
}
- enforce middle (fao:ClassToTable, p2n:PrimitiveToName) {
+ enforce middle (fao:ClassToTable, p2n:PrimitiveToName := t.PrimitiveToName) {
realize atc:AttributeToColumn
}
where (
a.owner = c;
--getAllAttributes(c)->includes(a);
- t = a.type;
fao.umlClass = c;
- p2n = t.PrimitiveToName;
) {
atc.attribute := a;
@@ -452,7 +446,7 @@ map classPrimitiveAttributesLM in ManualUML2RDBMS {
}
map classComplexAttributesLM in ManualUML2RDBMS {
- check uml (c:Class, t:Class, a:Attribute) {
+ check uml (c:Class, t:Class := a.type, a:Attribute) {
}
enforce middle (fao:ClassToTable) {
realize fa:NonLeafAttribute
@@ -460,7 +454,6 @@ map classComplexAttributesLM in ManualUML2RDBMS {
where (
a.owner = c;
--getAllAttributes(c)->includes(a);
- t = a.type;
fao.umlClass=c;
) {
fa.attribute := a;
@@ -474,11 +467,10 @@ map classComplexAttributesLM in ManualUML2RDBMS {
map complexAttributePrimitiveAttributesLM in ManualUML2RDBMS {
check uml (c:Class, ca:Attribute) {
}
- enforce middle (fao:NonLeafAttribute) {}
+ enforce middle (fao:NonLeafAttribute := ca.FromAttribute) {}
where (
ca.type = c;
-- getAllAttributes(c)->includes(a);
- fao = ca.FromAttribute;
) {}
for anAttribute in c.attributes {
call complexAttributePrimitiveAttributesLM_1 {
@@ -491,17 +483,15 @@ map complexAttributePrimitiveAttributesLM in ManualUML2RDBMS {
}
map complexAttributePrimitiveAttributesLM_1 in ManualUML2RDBMS {
- check uml (c_1:Class, t_1:PrimitiveDataType, a_1:Attribute, ca_1:Attribute) {
+ check uml (c_1:Class, t_1:PrimitiveDataType := a_1.type, a_1:Attribute, ca_1:Attribute) {
}
- enforce middle (fao_1:NonLeafAttribute, p2n_1:PrimitiveToName)
+ enforce middle (fao_1:NonLeafAttribute, p2n_1:PrimitiveToName := t_1.PrimitiveToName)
{
realize fa:AttributeToColumn
}
where (
- t_1 = a_1.type;
--getAllAttributes(c)->includes(a);
- p2n_1 = t_1.PrimitiveToName;
- ) {
+ ) {
fa.owner := fao_1;
fa.leafs := Set(AttributeToColumn) {fa};
fa.attribute := a_1;
@@ -514,11 +504,10 @@ map complexAttributePrimitiveAttributesLM_1 in ManualUML2RDBMS {
map complexAttributeComplexAttributesLM in ManualUML2RDBMS {
check uml (c:Class, ca:Attribute) {
}
- enforce middle (fao:NonLeafAttribute) {}
+ enforce middle (fao:NonLeafAttribute := ca.FromAttribute) {}
where (
ca.type = c;
--getAllAttributes(c)->includes(a);
- fao = ca.FromAttribute;
) {}
for anAttribute in c.attributes {
call complexAttributeComplexAttributesLM_1 {
@@ -531,7 +520,7 @@ map complexAttributeComplexAttributesLM in ManualUML2RDBMS {
}
map complexAttributeComplexAttributesLM_1 in ManualUML2RDBMS {
- check uml (c_1:Class, ca_1:Attribute, t_1:Class, a_1:Attribute) {
+ check uml (c_1:Class, ca_1:Attribute, t_1:Class := a_1.type, a_1:Attribute) {
}
enforce middle (fao_1:NonLeafAttribute) {
realize fa:NonLeafAttribute
@@ -539,7 +528,6 @@ map complexAttributeComplexAttributesLM_1 in ManualUML2RDBMS {
where (
a_1.owner = c_1;
--getAllAttributes(c)->includes(a);
- t_1 = a_1.type;
) {
fa.owner := fao_1;
fa.leafs := fao_1.fromAttributes.leafs->asSet();
@@ -552,16 +540,14 @@ map complexAttributeComplexAttributesLM_1 in ManualUML2RDBMS {
map attributeColumnsMR in ManualUML2RDBMS {
- check middle (c2t:ClassToTable, a2c:AttributeToColumn, p2n:PrimitiveToName) {}
- enforce rdbms (t:Table, ct:String) {
+ check middle (c2t:ClassToTable, a2c:AttributeToColumn, p2n:PrimitiveToName := a2c.type) {}
+ enforce rdbms (t:Table, ct:String := p2n.typeName) {
realize c:Column
}
where (
-- c2t.fromAttributes.leafs->includes(a2c); -- need to go deeper in the recursion
-- a2c.owner = c2t; NOT ALL a2c are owned by c2t (complex attributes)
c2t.table = t;
- p2n = a2c.type;
- ct = p2n.typeName;
) {
c.owner := t;
}

Back to the top