// process statements
Iterator statementIter = mediator.getStatementList().iterator();
while (statementIter.hasNext()) {
Statement statement = (Statement) statementIter.next();
OMElement stmntElt = fac.createOMElement(
AbstractDBMediatorFactory.STMNT_Q.getLocalPart(), synNS);
OMElement sqlElt = fac.createOMElement(
AbstractDBMediatorFactory.SQL_Q.getLocalPart(), synNS);
OMText sqlText = fac.createOMText(statement.getRawStatement(), XMLStreamConstants.CDATA);
sqlElt.addChild(sqlText);
stmntElt.addChild(sqlElt);
// serialize parameters of the statement
for (Iterator it = statement.getParameters().iterator(); it.hasNext(); ) {
Statement.Parameter param = (Statement.Parameter) it.next();
OMElement paramElt = fac.createOMElement(
AbstractDBMediatorFactory.PARAM_Q.getLocalPart(), synNS);
if (param.getPropertyName() != null) {
paramElt.addAttribute(
fac.createOMAttribute("value", nullNS, param.getPropertyName()));
}
if (param.getXpath() != null) {
SynapseXPathSerializer.serializeXPath(param.getXpath(), paramElt, "expression");
}
switch (param.getType()) {
case Types.CHAR: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "CHAR"));
break;
}
case Types.VARCHAR: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "VARCHAR"));
break;
}
case Types.LONGVARCHAR: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "LONGVARCHAR"));
break;
}
case Types.NUMERIC: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "NUMERIC"));
break;
}
case Types.DECIMAL: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "DECIMAL"));
break;
}
case Types.BIT: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "BIT"));
break;
}
case Types.TINYINT: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "TINYINT"));
break;
}
case Types.SMALLINT: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "SMALLINT"));
break;
}
case Types.INTEGER: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "INTEGER"));
break;
}
case Types.BIGINT: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "BIGINT"));
break;
}
case Types.REAL: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "REAL"));
break;
}
case Types.FLOAT: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "FLOAT"));
break;
}
case Types.DOUBLE: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "DOUBLE"));
break;
}
case Types.DATE: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "DATE"));
break;
}
case Types.TIME: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "TIME"));
break;
}
case Types.TIMESTAMP: {
paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "TIMESTAMP"));
break;
}
default: {
throw new SynapseException("Unknown or unsupported JDBC type : " +
param.getType());
}
}
stmntElt.addChild(paramElt);
}
// serialize any optional results of the statement
for (Iterator it = statement.getResultsMap().keySet().iterator(); it.hasNext(); ) {
String name = (String) it.next();
String columnStr = (String) statement.getResultsMap().get(name);
OMElement resultElt = fac.createOMElement(
AbstractDBMediatorFactory.RESULT_Q.getLocalPart(), synNS);
resultElt.addAttribute(