*/
protected void seed(String sTransformation, final Function enabled, final Function delete, ResourceLoader loader)
{
final Metadata metadata = m_context.getMetadata();
final MessageParser parser = (MessageParser)metadata.getFormat("XML").getParser().getInstance(m_context);
final MessageFormatter formatter = (MessageFormatter)metadata.getFormat("Object").getFormatter().getInstance(m_context);
final Transformation transformation = metadata.getTransformation(sTransformation);
final Transformer transformer = new Transformer(m_context);
final UnitOfWork uow = m_context.getUnitOfWork();
final boolean bRawSaved = uow.isRaw();
try
{
uow.setRaw(true);
final List tobjList = new ArrayList();
loader.seedResources(((XMLMetadata)metadata).getHelper(), new CharacterStreamHandler()
{
public void handleCharacterStream(Reader reader, String sName) throws IOException
{
try
{
TransferObject tobj = parser.parse(new ReaderInput(reader), (Message)transformation.getSource());
tobj.setValue("name", sName);
if (enabled != null && !Intrinsic.isTrue(m_context.getMachine().invoke(enabled, tobj, (Object[])null)))
{
return;
}
if (delete != null)
{
m_context.getMachine().invoke(delete, tobj, (Object[])null);
}
tobj = transformer.transform(tobj, transformation);
tobjList.add(tobj);
}
catch (Exception e)
{
s_logger.error("Unable to seed resource \"" + sName + "\"", e);
if (e instanceof RuntimeException)
{
throw (RuntimeException)e;
}
throw new UncheckedException("err.runtime.seed", new Object[]{sName}, e);
}
}
});
// Commit the deletes
uow.commit(false);
for (Iterator itr = tobjList.iterator(); itr.hasNext();)
{
formatter.format((TransferObject)itr.next(), (Message)transformation.getDestination(), new ObjectOutput());
}
// Commit the inserts/updates
uow.commit(false);
}