use of org.jooq.util.xml.jaxb.Parameter in project jOOQ by jOOQ.
the class XMLRoutineDefinition method init0.
@Override
protected void init0() {
for (Parameter parameter : info.getParameters()) {
Name parameterRoutineName = name(parameter.getSpecificCatalog(), parameter.getSpecificSchema(), parameter.getSpecificPackage(), parameter.getSpecificName());
if (getQualifiedNamePart().equals(parameterRoutineName)) {
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), parameter.getDataType(), parameter.getCharacterMaximumLength(), parameter.getNumericPrecision(), parameter.getNumericScale(), null, parameter.getParameterDefault());
ParameterDefinition p = new DefaultParameterDefinition(this, parameter.getParameterName(), parameter.getOrdinalPosition(), type, !StringUtils.isBlank(parameter.getParameterDefault()), StringUtils.isBlank(parameter.getParameterName()));
switch(parameter.getParameterMode()) {
case IN:
addParameter(InOutDefinition.IN, p);
break;
case INOUT:
addParameter(InOutDefinition.INOUT, p);
break;
case OUT:
addParameter(InOutDefinition.OUT, p);
break;
}
}
}
}
use of org.jooq.util.xml.jaxb.Parameter in project jOOQ by jOOQ.
the class XMLGenerator method exportRoutine.
private void exportRoutine(InformationSchema is, RoutineDefinition r, String catalogName, String schemaName) {
String specificName = r.getName() + (isBlank(r.getOverload()) ? "" : "_" + r.getOverload());
Routine routine = new Routine();
routine.setRoutineCatalog(catalogName);
routine.setSpecificCatalog(catalogName);
routine.setRoutineSchema(schemaName);
routine.setSpecificSchema(schemaName);
if (r.getPackage() != null) {
routine.setRoutinePackage(r.getPackage().getName());
routine.setSpecificPackage(r.getPackage().getName());
}
routine.setRoutineName(r.getName());
routine.setSpecificName(specificName);
if (r.getReturnValue() == null) {
routine.setRoutineType(RoutineType.PROCEDURE);
} else {
routine.setRoutineType(RoutineType.FUNCTION);
routine.setDataType(r.getReturnType().getType());
routine.setCharacterMaximumLength(r.getReturnType().getLength());
routine.setNumericPrecision(r.getReturnType().getPrecision());
routine.setNumericScale(r.getReturnType().getScale());
}
is.getRoutines().add(routine);
int i = 1;
for (ParameterDefinition p : r.getAllParameters()) {
if (p != r.getReturnValue()) {
Parameter parameter = new Parameter();
parameter.setSpecificCatalog(catalogName);
parameter.setSpecificSchema(schemaName);
if (r.getPackage() != null)
parameter.setSpecificPackage(r.getPackage().getName());
parameter.setSpecificName(specificName);
parameter.setOrdinalPosition(i++);
parameter.setParameterName(p.getName());
boolean in = r.getInParameters().contains(p);
boolean out = r.getOutParameters().contains(p);
if (in && out)
parameter.setParameterMode(ParameterMode.INOUT);
else if (in)
parameter.setParameterMode(ParameterMode.IN);
else if (out)
parameter.setParameterMode(ParameterMode.OUT);
parameter.setDataType(p.getType().getType());
parameter.setCharacterMaximumLength(p.getType().getLength());
parameter.setNumericPrecision(p.getType().getPrecision());
parameter.setNumericScale(p.getType().getScale());
parameter.setParameterDefault(p.getType().getDefaultValue());
is.getParameters().add(parameter);
}
}
}
Aggregations