{
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");