public AssociationClassCallExp createAssociationClassCallExp( OclExpression source, CoreAssociationClass referredAssociationClass, CoreAssociationEnd navigationSource, List <object> qualifiers, bool isMarkedPre) { AssociationClassCallExpImpl exp = new AssociationClassCallExpImpl(); exp.setFactory(this); exp.setReferredAssociationClass(referredAssociationClass); exp.setNavigationSource(navigationSource); exp.setSource(isMarkedPre ? createAtPreOperation(source) : source); if (qualifiers != null) { foreach (OclExpression qualifier in qualifiers) { ((OclExpressionImpl)qualifier).setNavigationCallExp(exp); ((AssociationClassCallExpImpl)exp).addQualifier(qualifier); } } CoreAssociationEnd assocEnd = navigationSource != null ? navigationSource : referredAssociationClass.lookupAssociationEnd(source.getType()); exp.setType(((AssociationClassCallExpImpl)exp).getExpressionType(source, assocEnd, referredAssociationClass)); ((OclExpressionImpl)source).setAppliedProperty(exp); return(exp); }
public CoreClassifier getExpressionType(CoreClassifier sourceType, CoreAssociationEnd associationEnd, CoreClassifier elementType) { if (sourceType is CollectionTypeImpl) { if ((sourceType is SetTypeImpl || sourceType is BagTypeImpl) && (!associationEnd.isOrdered()) ) { return(getFactory().createBagType(elementType)); } else { return(getFactory().createSequenceType(elementType)); } } else { if (isSingleElementAccess(sourceType, associationEnd)) { return(elementType); } else if (associationEnd.isOrdered()) { return(getFactory().createOrderedSetType(elementType)); } else { return(getFactory().createSetType(elementType)); } } }
private bool isSingleElementAccess(CoreClassifier sourceType, CoreAssociationEnd associationEnd) { return ((sourceType is CoreAssociationClassImpl) || (associationEnd.isOneMultiplicity() && !associationEndHasQualifiers(associationEnd)) || (associationEnd.isOneMultiplicity() && associationEndHasQualifiers(associationEnd) && getQualifiers().Count > 0)); }
private void getTargetAssociationReference(AssociationEndCallExp exp, CoreAssociationEnd associationEnd, out string otherTypeName, out string otherKeyName, out string otherName, out string typeName, out string name) { var otherType = associationEnd.getType(); otherTypeName = otherType.getName(); var otherKeyAttribute = (CoreAttributeImpl)otherType.getAllAttributes().FirstOrDefault(a => ((CoreAttributeImpl)a).hasStereotype("Id")) ?? (CoreAttributeImpl)otherType.getAllAttributes().FirstOrDefault(); otherKeyName = otherKeyAttribute != null?otherKeyAttribute.getName() : ""; var participant = associationEnd.getTheParticipant(); var association = associationEnd.getAssociation(); var otherAssociationEnd = (CoreAssociationEndImpl)association.getTheAssociationEnds(participant).FirstOrDefault(); otherName = otherAssociationEnd != null?otherAssociationEnd.getName() : ""; var expsource = (VariableExp)exp.getSource(); var variable = expsource.getReferredVariable(); var type = variable.getType(); typeName = type.getName(); var keyAttribute = (CoreAttributeImpl)type.getAllAttributes().FirstOrDefault(a => ((CoreAttributeImpl)a).hasStereotype("Id")) ?? (CoreAttributeImpl)type.getAllAttributes().FirstOrDefault(); name = keyAttribute != null?keyAttribute.getName() : ""; }
public void testAssociationEndCallExp_08() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Allocation"), null); VariableExp source = factory1.createVariableExp(variable); CoreAssociationEnd assocEnd = getClassifier("Allocation").lookupAssociationEnd("films"); AssociationEndCallExp exp1 = factory1.createAssociationEndCallExp(source, assocEnd, null, null, false); Assert.AreEqual("abc.films", exp1.ToString()); Assert.AreEqual("SpecialFilm", exp1.getType().getName()); }
public void testAssociationEndCallExp_07() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Reservation"), null); VariableExp source = factory1.createVariableExp(variable); CoreAssociationEnd assocEnd = getClassifier("Reservation").lookupAssociationEnd("Person"); AssociationEndCallExp exp1 = factory1.createAssociationEndCallExp(source, assocEnd, null, null, true); Assert.AreEqual("abc.Person@pre", exp1.ToString()); Assert.AreEqual("Person", exp1.getType().getName()); }
public void testAssociationEndCallExp_06() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Person"), null); VariableExp source = factory1.createVariableExp(variable); CoreAssociationEnd bosses = getClassifier("Person").lookupAssociationEnd("bosses"); CoreAssociationEnd employees = getClassifier("Person").lookupAssociationEnd("employees"); AssociationEndCallExp sourceExp = factory1.createAssociationEndCallExp(source, bosses, employees, null, false); CoreAssociationEnd assocEnd = getClassifier("Person").lookupAssociationEnd("Reservation"); AssociationEndCallExp exp = factory1.createAssociationEndCallExp(sourceExp, assocEnd, null, null, false); Assert.AreEqual("abc.bosses.Reservation", exp.ToString()); Assert.AreEqual("Sequence(Reservation)", exp.getType().getName()); }
public CoreClassifier getExpressionType(OclExpression source, CoreAssociationEnd associationEnd, CoreAssociationClass associationClass) { return(base.getExpressionType(source.getType(), associationEnd, associationClass)); }
/** * @param navigationSource The navigationSource to set. */ public void setNavigationSource(CoreAssociationEnd navigationSource) { this.navigationSource = navigationSource; }
private bool associationEndHasQualifiers(CoreAssociationEnd associationEnd) { return(associationEnd.getTheQualifiers() != null && associationEnd.getTheQualifiers().Count > 0); }
/** * @param referredAssociationEnd The referredAssociationEnd to set. */ public void setReferredAssociationEnd( CoreAssociationEnd referredAssociationEnd) { this.referredAssociationEnd = referredAssociationEnd; }
public CoreClassifier getExpressionType(OclExpression source, CoreAssociationEnd associationEnd) { return(base.getExpressionType(source.getType(), associationEnd, associationEnd.getTheParticipant())); }
private void getOneMultiplicityAssociationReference(AssociationEndCallExp exp, CoreAssociationEnd associationEnd, out string otherTypeName, out string otherKeyName, out string typeName, out string name) { var otherType = associationEnd.getType(); otherTypeName = otherType.getName(); var otherKeyAttribute = (CoreAttributeImpl)otherType.getAllAttributes().FirstOrDefault(a => ((CoreAttributeImpl)a).hasStereotype("Id")) ?? (CoreAttributeImpl)otherType.getAllAttributes().FirstOrDefault(); otherKeyName = otherKeyAttribute != null?otherKeyAttribute.getName() : ""; var expsource = (VariableExp)exp.getSource(); var variable = expsource.getReferredVariable(); var type = variable.getType(); typeName = type.getName(); name = associationEnd.getName(); }
public OclConstraint createAssociationEndInitConstraint(string source, CoreClassifier contextualClassifier, CoreAssociationEnd assocEnd, ExpressionInOcl initialValue) { OclAssocEndInitConstraint constraint = new OclAssocEndInitConstraintImpl(); constraint.setSource(source); constraint.setContextualClassifier(contextualClassifier); constraint.setInitializedAssocEnd(assocEnd); constraint.setExpression(initialValue); contextualClassifier.addInitConstraint(assocEnd.getName(), constraint); // cachedObjects.add(constraint); return(constraint); }