/**
* @see nexj.core.meta.integration.MessagePartMapping#finish(nexj.core.meta.integration.MessagePart)
*/
public void finish(MessagePart part)
{
MessagePart parent = part.getParent();
if (m_attribute != null)
{
if (m_attribute.isStatic())
{
throw new MetadataException("err.meta.integration.object.mapping.staticAttribute",
new Object[]{part.getFullPath()});
}
if ((part instanceof PrimitiveMessagePart) != m_attribute.getType().isPrimitive())
{
throw new MetadataException("err.meta.integration.object.mapping.attributeTypeMismatch",
new Object[]{part.getFullPath()});
}
if (m_bLocal && part instanceof CompositeMessagePart && m_attribute.getReverse() == null)
{
throw new MetadataException("err.meta.integration.object.mapping.missingLocalReverseAssoc",
new Object[]{m_attribute.getName(), part.getFullPath()});
}
}
if (m_metaclass != null)
{
if (part instanceof PrimitiveMessagePart)
{
throw new MetadataException("err.meta.integration.object.mapping.misplacedClass");
}
if (m_attribute != null && !((Metaclass)m_attribute.getType()).isUpcast(m_metaclass))
{
throw new MetadataException("err.meta.integration.object.mapping.classTypeMismatch",
new Object[]{m_metaclass.getName()});
}
}
else
{
if (parent == null)
{
if (m_message.getDerivation() != Message.DERIVATION_ABSTRACT)
{
throw new MetadataException("err.meta.integration.object.mapping.missingClass");
}
}
if (m_attribute != null && !m_attribute.getType().isPrimitive())
{
m_metaclass = (Metaclass)m_attribute.getType();
}
}
if (part instanceof PrimitiveMessagePart)
{
if (part.isCollection())
{
throw new MetadataException("err.meta.integration.object.mapping.primitiveCollection");
}
if (m_where != Boolean.TRUE)
{
throw new MetadataException("err.meta.integration.object.mapping.primitivePartWhere",
new Object[]{part.getFullPath()});
}
}
if (parent == null)
{
m_bLocal = false;
}
else
{
ObjectMessagePartMapping mapping = (ObjectMessagePartMapping)parent.getMapping();
if (mapping != null)
{
mapping.setSystemPart(part);
}
}
if (m_bSubKey)
{
ObjectMessagePartMapping mapping = (parent == null) ? null : (ObjectMessagePartMapping)parent.getMapping();
if (mapping != null)
{
mapping.m_bSubKeyParent = true;
}
}
if (m_accessAttribute != null && m_accessAttribute.getType() != Primitive.BOOLEAN)
{
throw new MetadataException("err.meta.integration.object.mapping.accessAttributeType",
new Object[]{m_accessAttribute.getName()});
}
if (parent == null && m_metaclass != null &&
(m_message.getBaseMessage() != null || m_message.getDerivedMessageCount() > 0))
{
addClassMessage(m_metaclass, m_message);
}
if (part instanceof CompositeMessagePartInstance)
{
CompositeMessagePart composite = (CompositeMessagePartInstance)part;
for (int i = 0, nCount = composite.getPartCount(); i < nCount; i++)
{
MessagePart child = composite.getPart(i);
MessagePartMapping mapping = child.getMapping();
if (mapping != null)
{
mapping.finish(child);
}
}
}
if (part.equals(part.getRoot()) && part instanceof CompositeMessagePart)
{
CompositeMessagePart rootComposite = (CompositeMessagePart)part;
ObjectMessagePartMapping rootMapping = (ObjectMessagePartMapping)rootComposite.getMapping();
MessagePart syncKeyPart = rootMapping.getSystemPart(ATTR_SYNC_KEY);
if (syncKeyPart != null)
{
for (int i = 0, nCount = rootComposite.getPartCount(); i < nCount; i++)
{
MessagePart childPart = rootComposite.getPart(i);
if (syncKeyPart != childPart)
{
ObjectMessagePartMapping childMapping = (ObjectMessagePartMapping)childPart.getMapping();
if (childMapping.isKey())
{
rootMapping.m_bAlternativeSyncKey = true;
}