final String sReadPrefix = sURLPrefix + ".read." + m_nOrdinal;
Object whereExpr = m_helper.parse(
XMLUtil.getStringAttr(element, "where"),
false, sReadPrefix + "$where", mapping.getTextPositionMap(), Symbol.ELSE, metadata.getGlobalEnvironment()
);
Pair variables = (Pair)m_helper.parse(
XMLUtil.getStringAttr(element, "variables"),
true, mapping.getTextPositionMap(), null, metadata.getGlobalEnvironment()
);
final ReadMappingCase readMappingCase = new ReadMappingCase();
readMappingCase.setWhere(whereExpr);
readMappingCase.setVariables(variables);
XMLUtil.withFirstChildElement(element, "Read", true, new XMLUtil.ElementHandler()
{
public void handleElement(Element element)
{
readMappingCase.setReadScript(loadScript(element, sReadPrefix + "$read", mapping.getTextPositionMap()));
}
});
XMLUtil.withFirstChildElement(element, "Close", false, new XMLUtil.ElementHandler()
{
public void handleElement(Element element)
{
readMappingCase.setCloseScript(loadScript(element, sReadPrefix + "$close", mapping.getTextPositionMap()));
}
});
readMapping.addCase(readMappingCase);
m_nOrdinal += 1;
}
});
}
});
XMLUtil.withFirstChildElement(element, "CreateMapping", false,
new XMLUtil.ElementHandler()
{
public void handleElement(Element element)
{
final WorkMapping operation = new WorkMapping(metaclass);
operation.setBatch(XMLUtil.getBooleanAttr(element, "batch", operation.isBatch()));
operation.setScript(loadScript(element, sURLPrefix + ".create", mapping.getTextPositionMap()));
mapping.setCreateMapping(operation);
}
});
XMLUtil.withFirstChildElement(element, "UpdateMapping", false,
new XMLUtil.ElementHandler()
{
public void handleElement(Element element)
{
final UpdateMapping updateMapping = new UpdateMapping(mapping);
XMLUtil.forEachChildElement(element, "Case", new XMLUtil.ElementHandler()
{
private int m_nOrdinal = 0;
public void handleElement(Element element)
{
final UpdateMappingCase update = new UpdateMappingCase(metaclass);
update.setBatch(XMLUtil.getBooleanAttr(element, "batch", update.isBatch()));
update.setDirty(XMLUtil.getBooleanAttr(element, "dirty", update.isDirty()));
update.setFull(XMLUtil.getBooleanAttr(element, "full", update.isFull()));
Pair attributes = (Pair)m_helper.parse(
XMLUtil.getStringAttr(element, "attributes"),
true, mapping.getTextPositionMap(), null, metadata.getGlobalEnvironment()
);
update.setScript(loadScript(element, sURLPrefix + ".update." + m_nOrdinal, mapping.getTextPositionMap()));