{
return null;
}
ObjectMessagePartMapping mapping = (ObjectMessagePartMapping)composite.getMapping();
CompositeMessagePart derivedComposite = getPolymorphic(composite, tobj);
ObjectMessagePartMapping derivedMapping = (ObjectMessagePartMapping)derivedComposite.getMapping();
Metaclass derivedClass = (derivedMapping == null) ? null : derivedMapping.getMetaclass();
// If any message part is mapped to special attributes ATTR_EVENT and ATTR_OID,
// it overrides the event or oid set on message.
String sEventName = (String)getSystemAttributeValue(derivedComposite, tobj, ObjectMessagePartMapping.ATTR_EVENT);
OID oid = (OID)getSystemAttributeValue(derivedComposite, tobj, ObjectMessagePartMapping.ATTR_OID);
if (sEventName != null)
{
setEventName(tobj, sEventName);
}
if (oid != null)
{
tobj.setOID(oid);
}
boolean bDelete = "delete".equals(tobj.getEventName());
adjustEventName(tobj, derivedClass);
Instance instance = (Instance)m_instanceByTobjMap.get(tobj);
if (instance == null)
{
deleteInstanceState(tobj, derivedClass);
if ("create".equals(tobj.getEventName())
&& (!derivedMapping.hasAlternativeSyncKey() || !isRootSynchronized(tobj)))
{
// The internal instance corresponding to the transfer object will be created during instantiation.
m_instanceByTobjMap.put(tobj, null);
}
else
{
if (derivedClass != null)
{
if (derivedClass.getPersistenceMapping() == null)
{
if (tobj.getEventName() == null)
{
if (parentTobj == null)
{
throw new IntegrationException("err.integration.object.missingEvent",
new Object[]{derivedComposite.getFullPath()});
}
setEventName(tobj, "create");
}
m_instanceByTobjMap.put(tobj, null);
}
else if (!mapping.isLocal() || m_instanceByTobjMap.contains(parentTobj))
{
Pair where = getWhere1(tobj, composite, parentTobj, parentComposite, null, true);
InstanceList list = null;
if (where != EMPTY && !(mapping.isLocal() && m_instanceByTobjMap.get(parentTobj) == null))
{
if (mapping.isLocal())
{
Pair eq = Pair.list(Symbol.ATAT, ((ObjectMessagePartMapping)
parentComposite.getMapping()).getMetaclass().getSymbol(),
mapping.getAttribute().getSymbol()).eq(m_instanceByTobjMap.get(parentTobj));
if (where != null)
{
where = where.and(eq);
}
else
{
where = eq;
}
}
if (where != null)
{
list = (InstanceList)m_queryMap.get(derivedComposite, where);
if (list == null)
{
list = Query.createRead(derivedClass, getAttributes(derivedComposite), where, null,
2, 0, false, Query.SEC_NONE, m_context).read();
m_queryMap.put(derivedComposite, where, list);
}
}
else
{
where = EMPTY;
}
}
if (where != EMPTY && list != null && list.size() != 0)
{
if (list.size() > 1)
{
throw new IntegrationException("err.integration.object.ambiguousMatch",
new Object[]{derivedComposite.getFullPath()});
}
instance = list.getInstance(0);
m_instanceByTobjMap.put(tobj, instance);
}
else if (!bDelete)
{
if (tobj.getEventName() != null && (!mapping.isLocal() || m_instanceByTobjMap.get(parentTobj) == null) ||
!mapping.isCreate() && !mapping.isKey())
{
throw new IntegrationException("err.integration.object.noMatch",
new Object[]{derivedComposite.getFullPath()});
}
setEventName(tobj, (!mapping.isCreate() ||
where == EMPTY && !isKeyAvailable(tobj, derivedComposite)) ? "delete" : "create");
m_instanceByTobjMap.put(tobj, null);
}
}
}
}
}
for (int i = 0, n = derivedComposite.getPartCount(); i != n; ++i)
{
MessagePart part = derivedComposite.getPart(i);
if (part instanceof CompositeMessagePart)
{
findInstance(tobj.findValue(part.getName()), (CompositeMessagePart)part, tobj, derivedComposite);
}