protected AssociationEndCallExp checkAssociationEndCallExp(OclExpression oclExpression, String roleName, String typeName) { Assert.IsTrue(oclExpression is AssociationEndCallExp); AssociationEndCallExp exp = (AssociationEndCallExp)oclExpression; Assert.AreEqual(roleName, exp.getReferredAssociationEnd().getName()); Assert.AreEqual(typeName, exp.getType().getName()); return(exp); }
public void visitAssociationEndCallExp(AssociationEndCallExp exp) { var associationEnd = exp.getReferredAssociationEnd(); bool isOneMultiplicity = associationEnd.isOneMultiplicity(); string otherTypeName, otherKeyName, typeName, name; if (isOneMultiplicity) { getOneMultiplicityAssociationReference(exp, associationEnd, out otherTypeName, out otherKeyName, out typeName, out name); otherFormula = string.Format("=INDEX({0},MATCH([{1}],{0}[{2}],0)", otherTypeName, name, otherKeyName); } else { string otherName; getTargetAssociationReference(exp, associationEnd, out otherTypeName, out otherKeyName, out otherName, out typeName, out name); if (navigationLevel == 0) { // add reference to key column of associated table formula += string.Format("{0}[{1}],{2}[{3}]", otherTypeName, otherName, typeName, name); } else { // create new column on target table (where expression is based on) var columnName = string.Format("{0}_{1}", typeName.ToLower(), name.ToLower()); formula += string.Format("{0}[{1}],{2}[{3}]", currentClassifier.getName(), columnName, typeName, name); otherFormula = string.Format("=INDEX({4},MATCH(INDEX({0},MATCH([{1}],{0}[{2}],0),COL({0}[{3}])),{4}[{5}],0),COL({4}[{5}]))", otherTypeName, firstNavigationName, otherKeyName, otherName, typeName, name); columnToFormula.Add(columnName, otherFormula); } } navigationLevel++; }