// Process sources
m_root.resolveInheritance(base.m_root);
// Process mappings
Lookup mappingMap = m_mappingMap;
Set mappingSet = new HashHolder(m_mappingList.size()); // TransformationMapping[]
mappingSet.addAll(m_mappingList);
m_mappingList.clear();
m_mappingMap = new HashTab(mappingSet.size());
for (int i = 0, nCount = base.m_mappingList.size(); i < nCount; ++i)
{
TransformationMapping baseMapping = (TransformationMapping)base.m_mappingList.get(i);
TransformationMapping mapping = null;
if (baseMapping.getName() != null)
{
mapping = (TransformationMapping)mappingMap.get(baseMapping.getName());
}
if (mapping == null)
{
// Copy base transformation mapping to derived transformation
TransformationMapping copy = (TransformationMapping)baseMapping.clone();
// Argument sources must point to the derived transformation
for (Iterator argItr = copy.getArgumentIterator(); argItr.hasNext(); )
{
TransformationArgument arg = (TransformationArgument)argItr.next();
TransformationSource source = arg.getSource();
TransformationSource newSource = null;
if (source != null)
{
newSource = m_root;
for (int k = 1; k <= source.getLevel(); ++k)
{
newSource = newSource.findChild(source.getPath(k).getPart().getName());
}
arg.setSource(newSource);
if (arg.isNull())
{
newSource.setNull(true);
}
}
}
// Inherited mappings should reference the base script.
if (baseMapping.getScript() != null)
{
copy.setScript(
new Pair(Transformation.BASE, baseMapping)
);
}
addMapping(copy);
}
else
{
// Base transformation mapping overridden in derived transformation, so use
// mapping from derived transformation.
addMapping(mapping);
mappingSet.remove(mapping);
}
}
// Put the mappings defined only in the derived transformation on the end
for (Iterator itr = mappingSet.iterator(); itr.hasNext(); )
{
addMapping((TransformationMapping)itr.next());
}
for (Lookup.Iterator it = base.m_posMap.iterator(); it.hasNext();)