public List<UTF_EA.AssociationEnd> getDependingAssociationEnds()
{
var dependingAssociationEnds = new List<UTF_EA.AssociationEnd>();
foreach (var currentClass in this.allLogicalClasses)
{
foreach (var association in currentClass.relationships.OfType<UTF_EA.Association>())
{
foreach (UTF_EA.AssociationEnd end in association.memberEnds)
{
if (!currentClass.Equals(end.type)
&& end.type is UTF_EA.Class
&& (end.upper.integerValue.HasValue && end.upper.integerValue == 1))
{
//if both end have an upper value of 1 then we take only the one with {id} or else use the association direction
var otherEnd = association.memberEnds.FirstOrDefault(x => x != end) as UTF_EA.AssociationEnd;
//both have an upper value of 1
if (otherEnd.upper.integerValue.HasValue && otherEnd.upper.integerValue == 1)
{
//this one is the one with ID
if (end.isID)
{
dependingAssociationEnds.Add(end);
break;
}
//the other end is not an ID either,
// then we use the association direction to determine wher the FK should be placed
if (! otherEnd.isID
&& association.targetEnd == end)
{
dependingAssociationEnds.Add(end);
break;
}
}
else
{
dependingAssociationEnds.Add(end);
break;
}
}
}
}
}
return dependingAssociationEnds;
}