break;
}
}
if (nameAndModel != null) {
DatabaseQuery dq = null;
StoredProcedureCall spCall = null;
List<MethodArgHelper> args = methodHelper.args();
int startIdx = 0;
int len = args.size();
if (methodHelper.isFunc()) {
startIdx = 1;
MethodArgHelper returnArg = args.get(0);
if (returnArg.isComplex()) {
String javaClassName = returnArg.typeName();
if (returnArg.nestedType() != null) {
ObjectRelationalDatabaseField nestedField =
new ObjectRelationalDatabaseField("");
nestedField.setSqlTypeName(returnArg.nestedType());
nestedField.setSqlType(returnArg.nestedTypecode());
nestedField.setTypeName(returnArg.nestedTypeName());
spCall = new StoredFunctionCall(returnArg.typecode(),
returnArg.sqlTypeName(), javaClassName, nestedField);
}
else {
spCall = new StoredFunctionCall(returnArg.typecode(),
returnArg.sqlTypeName(), javaClassName);
}
}
else {
spCall = new StoredFunctionCall();
((StoredFunctionCall)spCall).setResult(null, OBJECT);
}
}
else {
spCall = new StoredProcedureCall();
}
String returnType = nameAndModel.procOpModel.getReturnType();
boolean hasResponse = returnType != null;
if (hasResponse) {
if (nameAndModel.procOpModel.isCollection()) {
dq = new DataReadQuery();
}
else {
dq = new ValueReadQuery();
}
}
else {
dq = new ValueReadQuery();
}
dq.bindAllParameters();
dq.setName(nameAndModel.name);
for (int i = startIdx; i < len; i++) {
MethodArgHelper arg = args.get(i);
String argName = arg.argName();
String javaClassName = null;
if (arg.isComplex()) {
javaClassName = (packageName + "." + arg.sqlTypeName()).toLowerCase();
}
if (arg.direction().equalsIgnoreCase("IN")) {
dq.addArgument(argName);
if (arg.isComplex()) {
spCall.addNamedArgument(argName, argName,
Types.STRUCT, arg.sqlTypeName(), javaClassName);
}
else {
spCall.addNamedArgument(argName, argName);
}
}
else if (arg.direction().equalsIgnoreCase("OUT")) {
if (arg.isComplex()) {
spCall.addNamedOutputArgument(argName, argName,
Types.STRUCT, arg.sqlTypeName());
}
else {
spCall.addNamedOutputArgument(argName, argName);
}
}
else if (arg.direction().equalsIgnoreCase("IN OUT")) {
dq.addArgument(argName);
spCall.addNamedInOutputArgument(argName);
}
}
String catalogPrefix = null;
String cat = targetProcedure.getCatalog();
if (cat == null | cat.length() == 0) {
catalogPrefix = "";
}
else {
catalogPrefix = cat + ".";
}
spCall.setProcedureName(catalogPrefix + targetProcedure.getName());
dq.setCall(spCall);
queryMap.put(methodName, dq);
}
stac.pop();
}