protected AssociationClassCallExp checkAssociationClassCallExp(OclExpression oclExpression, String roleName, String typeName) { Assert.IsTrue(oclExpression is AssociationClassCallExp); AssociationClassCallExp exp = (AssociationClassCallExp)oclExpression; Assert.AreEqual(roleName, exp.getReferredAssociationClass().getName()); Assert.AreEqual(typeName, exp.getType().getName()); return(exp); }
private IExpression GetExpression(SelectContext context, AssociationClassCallExp association) { switch (association.Source) { case VariableExp variableRef: var variable = variableRef.ReferredVariable.Name; var associationEnd = association.ReferredAssociationEnds; var alias = variable + "_" + associationEnd.Association; context.Body.Joins.Add(new Join { Left = false, RightItem = new Table { Name = associationEnd.Association, Alias = new Alias { Name = alias } }, OnExp = new EqualsToExpression { LeftExp = new Column { Table = new Table { Name = context.Variables[variable], Alias = new Alias { Name = variable } }, Name = context.Variables[variable] + "_id", }, RightExp = new Column { Table = new Table { Name = associationEnd.Association, Alias = new Alias { Name = alias } }, Name = associationEnd.Opp.Name, } } }); context.LastJoin = Tuple.Create(variable, associationEnd); return(null); default: throw new NotSupportedException(); } }
public void testAssociationClassExp_02() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("SpecialFilm"), null); VariableExp source = factory1.createVariableExp(variable); CoreAssociationClass assocClass = getClassifier("SpecialFilm").lookupAssociationClass("Allocation"); CoreAssociationEnd dist = getClassifier("SpecialFilm").lookupAssociationEnd("dist"); AssociationClassCallExp exp1 = factory1.createAssociationClassCallExp(source, assocClass, dist, null, false); Assert.AreEqual("abc.Allocation", exp1.ToString()); Assert.AreEqual("Set(Allocation)", exp1.getType().getName()); }