use of org.jooq.util.xml.jaxb.Routine in project jOOQ by jOOQ.
the class XMLRoutineDefinition method overload.
private static String overload(InformationSchema info, Routine routine) {
Name routineName = name(routine.getRoutineCatalog(), routine.getRoutineSchema(), routine.getRoutinePackage(), routine.getRoutineName());
String result = null;
int count = 0;
// TODO: Better algorithm by pre-calculating
for (Routine r : info.getRoutines()) {
Name rName = name(r.getRoutineCatalog(), r.getRoutineSchema(), r.getRoutinePackage(), r.getRoutineName());
if (routineName.equals(rName)) {
count++;
if (routine == r) {
result = "" + count;
}
if (count > 1 && result != null)
break;
}
}
return count > 1 ? result : null;
}
use of org.jooq.util.xml.jaxb.Routine 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);
}
}
}
use of org.jooq.util.xml.jaxb.Routine in project jOOQ by jOOQ.
the class XMLDatabase method getPackages0.
@Override
protected List<PackageDefinition> getPackages0() {
List<PackageDefinition> result = new ArrayList<PackageDefinition>();
Set<String> packages = new HashSet<String>();
for (Routine routine : info().getRoutines()) {
String schemaName = defaultIfBlank(routine.getSpecificSchema(), routine.getRoutineSchema());
if (getInputSchemata().contains(schemaName)) {
SchemaDefinition schema = getSchema(schemaName);
String packageName = defaultIfBlank(routine.getSpecificPackage(), routine.getRoutinePackage());
if (!isBlank(packageName) && packages.add(packageName)) {
result.add(new XMLPackageDefinition(schema, info(), packageName));
}
}
}
return result;
}
use of org.jooq.util.xml.jaxb.Routine in project jOOQ by jOOQ.
the class XMLDatabase method getRoutines0.
@Override
protected List<RoutineDefinition> getRoutines0() {
List<RoutineDefinition> result = new ArrayList<RoutineDefinition>();
for (Routine routine : info().getRoutines()) {
if (isBlank(routine.getSpecificPackage()) && isBlank(routine.getRoutinePackage())) {
String schemaName = defaultIfBlank(routine.getSpecificSchema(), routine.getRoutineSchema());
if (getInputSchemata().contains(schemaName)) {
SchemaDefinition schema = getSchema(schemaName);
result.add(new XMLRoutineDefinition(schema, null, info(), routine));
}
}
}
return result;
}
Aggregations