Search in sources :

Example 1 with Parameter

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;
            }
        }
    }
}
Also used : DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) Parameter(org.jooq.util.xml.jaxb.Parameter) DefaultParameterDefinition(org.jooq.util.DefaultParameterDefinition) DataTypeDefinition(org.jooq.util.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) Name(org.jooq.Name) DefaultParameterDefinition(org.jooq.util.DefaultParameterDefinition) ParameterDefinition(org.jooq.util.ParameterDefinition)

Example 2 with Parameter

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);
        }
    }
}
Also used : Parameter(org.jooq.util.xml.jaxb.Parameter) Routine(org.jooq.util.xml.jaxb.Routine) ReferentialConstraint(org.jooq.util.xml.jaxb.ReferentialConstraint) TableConstraint(org.jooq.util.xml.jaxb.TableConstraint)

Aggregations

Parameter (org.jooq.util.xml.jaxb.Parameter)2 Name (org.jooq.Name)1 DataTypeDefinition (org.jooq.util.DataTypeDefinition)1 DefaultDataTypeDefinition (org.jooq.util.DefaultDataTypeDefinition)1 DefaultParameterDefinition (org.jooq.util.DefaultParameterDefinition)1 ParameterDefinition (org.jooq.util.ParameterDefinition)1 ReferentialConstraint (org.jooq.util.xml.jaxb.ReferentialConstraint)1 Routine (org.jooq.util.xml.jaxb.Routine)1 TableConstraint (org.jooq.util.xml.jaxb.TableConstraint)1