Skip to content

Commit

Permalink
Fixed bug on atl one-to-one
Browse files Browse the repository at this point in the history
  • Loading branch information
nmacedo committed Mar 19, 2014
1 parent c1f6333 commit a8fe3a5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<details key="gen_linear" value="self.classes->one(x | x.super->isEmpty())"/>
<details key="lkm" value="self.classes->size() = 3"/>
</eAnnotations>
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL_">
<details key="unique_names" value="self.classes->forAll(x | self.classes->forAll(y | x = y or x.name &lt;> y.name))"/>
</eAnnotations>
<eOperations name="addClass">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@
<columns
name="name"/>
</tables>
<tables name="Employee">
<columns
name="name"/>
<columns
name="X"/>
</tables>
</rdbms:Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
xmlns:uml="UML"
xsi:schemaLocation="UML /pt.uminho.haslab.echo.examples/metamodels/uml2rdbms_simple/UML.ecore"
name="Company">
<classes name="Employee"
persistent="true"
super="//@classes.1"/>
<classes name="Person"
child="//@classes.0 //@classes.2">
child="//@classes.1 //@classes.2">
<attributes
name="name"
type="Float"/>
</classes>
<classes name="Employer"
persistent="true"
super="//@classes.1"/>
super="//@classes.0"/>
<classes name="Employee"
persistent="true"
super="//@classes.0"/>
<classes name="Employee"
persistent="true"/>
</uml:Package>
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ private IFormula calculateConstraint() throws EchoError {

IFormula targetFormula = translateCondition(targetdomain.getCondition());
targetFormula = targetFormula.and(postFormula);

if (mode == Mode.TOP_TRACEABILITY) {
// targetFormula := exists targetVars : targetPred & postPred & (srcRoot,trgRoot) in field
List<IExpression> params = new ArrayList<>();
for (IDecl d : rootVar2engineDecl.values())
params.add(d.variable());
targetFormula = targetFormula.and(transformation.callRelation(relation, context, params));
}

if (targetVar2engineDecl.size() == 1)
targetFormula = targetFormula.forSome(targetVar2engineDecl.values().iterator().next());
Expand All @@ -265,6 +273,12 @@ else if (targetVar2engineDecl.size() > 1) {
targetFormula = targetFormula.forSome(tempDecls[0],
Arrays.copyOfRange(tempDecls, 1, tempDecls.length));
}

if (mode == Mode.TOP_TRACEABILITY) {
// targetFormula := one rgtRoot : exists targetVars : targetPred & postPred & (srcRoot,trgRoot) in field
for (IDecl d : rootVarT2engineDecl.values())
targetFormula = targetFormula.forOne(d);
}

// sourceFormula := forall sourceVars : sourcePreds => targetFormula
for (EModelDomain dom : sourcedomains) {
Expand Down Expand Up @@ -294,14 +308,7 @@ else if (sourceVar2engineDecl.size() > 1) {
}

if (mode == Mode.TOP_TRACEABILITY) {
// formula := forall srcRoot : one trgRoot : formula && (srcRoot,trgRoot) in field
List<IExpression> params = new ArrayList<>();
for (IDecl d : rootVar2engineDecl.values())
params.add(d.variable());

formula = formula.and(transformation.callRelation(relation, context, params));
for (IDecl d : rootVarT2engineDecl.values())
formula = formula.forOne(d);
// formula := forall srcRoot : forall preVars : prePred => sourceFormula
for (IDecl d : rootVarS2engineDecl.values())
formula = formula.forAll(d);
}
Expand Down

0 comments on commit a8fe3a5

Please sign in to comment.