Relation.ForeignKey multiplicity = parentNodeLink.getMultiplicity();
if (linkName != null && linkValue != null && !isSharedByPrimaryKey
&& multiplicity.equals(ForeignKey.ONE_TO_MANY))
{
RelationHolder relationHolder = new RelationHolder(linkName, linkValue);
relationsHolder.add(relationHolder);
}
}
}
// Add column value for all child nodes linked to this node
if (children != null && !children.isEmpty())
{
for (NodeLink childNodeLink : children.keySet())
{
String linkName = (String) childNodeLink.getLinkProperty(LinkProperty.LINK_NAME);
Object linkValue = childNodeLink.getLinkProperty(LinkProperty.LINK_VALUE) != null ? childNodeLink
.getLinkProperty(LinkProperty.LINK_VALUE) : children.get(childNodeLink).getEntityId();
boolean isSharedByPrimaryKey = (Boolean) childNodeLink
.getLinkProperty(LinkProperty.IS_SHARED_BY_PRIMARY_KEY);
Relation.ForeignKey multiplicity = childNodeLink.getMultiplicity();
if (linkName != null && linkValue != null && !isSharedByPrimaryKey)
{
if (multiplicity.equals(ForeignKey.ONE_TO_ONE) || multiplicity.equals(ForeignKey.MANY_TO_ONE))
{
RelationHolder relationHolder = new RelationHolder(linkName, linkValue);
relationsHolder.add(relationHolder);
}
else if (multiplicity.equals(ForeignKey.MANY_TO_MANY)
&& ((Field) childNodeLink.getLinkProperty(LinkProperty.PROPERTY)).getType()
.isAssignableFrom(Map.class))
{
Object relationTo = ((Node) children.get(childNodeLink)).getData();
RelationHolder relationHolder = new RelationHolder(linkName, relationTo, linkValue);
relationsHolder.add(relationHolder);
}
}
}
}