Search in sources :

Example 1 with ArgumentType

use of org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType in project eclipselink by eclipse-ee4j.

the class BaseDBWSBuilderHelper method buildTypesList.

/**
 * Uses a custom visitor to traverse each procedure/function argument and build
 * a list of required Types.  Only on instance of a given type will exist in
 * the list.
 */
public List<CompositeDatabaseType> buildTypesList(List<OperationModel> operations) {
    EnclosedTypeVisitor etVisitor = new EnclosedTypeVisitor();
    for (OperationModel opModel : operations) {
        if (opModel.isProcedureOperation()) {
            ProcedureOperationModel procedureOperation = (ProcedureOperationModel) opModel;
            if (procedureOperation.isPLSQLProcedureOperation() || procedureOperation.isAdvancedJDBCProcedureOperation()) {
                for (ProcedureType procType : procedureOperation.getDbStoredProcedures()) {
                    // build list of arguments to process (i.e. build descriptors for)
                    List<ArgumentType> args = new ArrayList<ArgumentType>();
                    // return argument
                    if (procType.isFunctionType()) {
                        // assumes that a function MUST have a return type
                        args.add(((FunctionType) procType).getReturnArgument());
                    }
                    args.addAll(procType.getArguments());
                    // now visit each argument
                    for (ArgumentType arg : args) {
                        // handle ROWTYPETypes
                        if (arg.getEnclosedType().isROWTYPEType()) {
                            ROWTYPEType rType = (ROWTYPEType) arg.getEnclosedType();
                            TableType tableType = (TableType) rType.getEnclosedType();
                            PLSQLRecordType plsqlRec = new PLSQLRecordType(rType.getTypeName());
                            plsqlRec.setParentType(new PLSQLPackageType());
                            for (FieldType col : tableType.getColumns()) {
                                FieldType ft = new FieldType(col.getFieldName());
                                ft.setEnclosedType(col.getEnclosedType());
                                plsqlRec.addField(ft);
                            }
                            arg.setEnclosedType(plsqlRec);
                        }
                        // now visit each, adding types (only one instance of each) to the list
                        if (arg.isComposite()) {
                            etVisitor.visit((CompositeDatabaseType) arg);
                        }
                    }
                }
            }
        }
    }
    // gather Complex types to hand into XMLEntityMappingsGenerator
    List<CompositeDatabaseType> types = etVisitor.getCompositeDatabaseTypes();
    for (CompositeDatabaseType type : types) {
        complextypes.add(type);
    }
    return etVisitor.getCompositeDatabaseTypes();
}
Also used : ProcedureType(org.eclipse.persistence.tools.oracleddl.metadata.ProcedureType) TableType(org.eclipse.persistence.tools.oracleddl.metadata.TableType) ObjectTableType(org.eclipse.persistence.tools.oracleddl.metadata.ObjectTableType) PLSQLRecordType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLRecordType) PLSQLPackageType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLPackageType) ArrayList(java.util.ArrayList) ArgumentType(org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType) FieldType(org.eclipse.persistence.tools.oracleddl.metadata.FieldType) EnclosedTypeVisitor(org.eclipse.persistence.tools.oracleddl.metadata.visit.EnclosedTypeVisitor) ROWTYPEType(org.eclipse.persistence.tools.oracleddl.metadata.ROWTYPEType) CompositeDatabaseType(org.eclipse.persistence.tools.oracleddl.metadata.CompositeDatabaseType)

Example 2 with ArgumentType

use of org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType in project eclipselink by eclipse-ee4j.

the class JPAMetadataGenerator method processPLSQLProcedureType.

/**
 * Generate a PL/SQL stored procedure query based on the given ProcedureType.
 */
protected NamedPLSQLStoredProcedureQueryMetadata processPLSQLProcedureType(ProcedureType pType, PLSQLPackageType pkgType) {
    NamedPLSQLStoredProcedureQueryMetadata storedProc = new NamedPLSQLStoredProcedureQueryMetadata();
    storedProc.setName(getQueryNameForProcedureType(pType));
    storedProc.setProcedureName(pkgType.getPackageName() + DOT + pType.getProcedureName());
    // process the procedure's arguments
    if (pType.getArguments().size() > 0) {
        List<PLSQLParameterMetadata> params = new ArrayList<PLSQLParameterMetadata>();
        for (ArgumentType arg : pType.getArguments()) {
            params.add(processPLSQLArgument(arg));
        }
        storedProc.setParameters(params);
    }
    return storedProc;
}
Also used : ArrayList(java.util.ArrayList) NamedPLSQLStoredProcedureQueryMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.NamedPLSQLStoredProcedureQueryMetadata) ArgumentType(org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType) PLSQLParameterMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.PLSQLParameterMetadata)

Example 3 with ArgumentType

use of org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType in project eclipselink by eclipse-ee4j.

the class JPAMetadataGenerator method processPLSQLFunctionType.

/**
 * Generate a PL/SQL stored function query based on the given FunctionType.
 */
protected NamedPLSQLStoredFunctionQueryMetadata processPLSQLFunctionType(FunctionType fType, PLSQLPackageType pkgType) {
    NamedPLSQLStoredFunctionQueryMetadata storedFunc = new NamedPLSQLStoredFunctionQueryMetadata();
    storedFunc.setName(getQueryNameForProcedureType(fType));
    storedFunc.setProcedureName(pkgType.getPackageName() + DOT + fType.getProcedureName());
    List<PLSQLParameterMetadata> params = new ArrayList<PLSQLParameterMetadata>();
    // set the return parameter
    storedFunc.setReturnParameter(processPLSQLArgument(fType.getReturnArgument()));
    // process the function's arguments
    if (fType.getArguments().size() > 0) {
        for (ArgumentType arg : fType.getArguments()) {
            params.add(processPLSQLArgument(arg));
        }
    }
    storedFunc.setParameters(params);
    return storedFunc;
}
Also used : ArrayList(java.util.ArrayList) ArgumentType(org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType) NamedPLSQLStoredFunctionQueryMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.NamedPLSQLStoredFunctionQueryMetadata) PLSQLParameterMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.PLSQLParameterMetadata)

Example 4 with ArgumentType

use of org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType in project eclipselink by eclipse-ee4j.

the class JPAMetadataGenerator method processFunctionType.

/**
 * Generate a stored function query based on the given FunctionType.
 */
protected NamedStoredFunctionQueryMetadata processFunctionType(FunctionType fType) {
    NamedStoredFunctionQueryMetadata storedFunc = new NamedStoredFunctionQueryMetadata();
    storedFunc.setName(getQueryNameForProcedureType(fType));
    storedFunc.setProcedureName(fType.getProcedureName());
    // set the return parameter
    storedFunc.setReturnParameter(processArgument(fType.getReturnArgument()));
    // process the function's arguments
    if (fType.getArguments().size() > 0) {
        List<StoredProcedureParameterMetadata> params = new ArrayList<StoredProcedureParameterMetadata>();
        for (ArgumentType arg : fType.getArguments()) {
            params.add(processArgument(arg));
        }
        storedFunc.setParameters(params);
    }
    return storedFunc;
}
Also used : NamedStoredFunctionQueryMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.NamedStoredFunctionQueryMetadata) ArrayList(java.util.ArrayList) ArgumentType(org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType) StoredProcedureParameterMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.StoredProcedureParameterMetadata)

Example 5 with ArgumentType

use of org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType in project eclipselink by eclipse-ee4j.

the class JPAMetadataGenerator method processProcedureType.

/**
 * Generate a stored procedure query based on the given ProcedureType.
 */
protected NamedStoredProcedureQueryMetadata processProcedureType(ProcedureType pType) {
    NamedStoredProcedureQueryMetadata storedProc = new NamedStoredProcedureQueryMetadata();
    storedProc.setName(getQueryNameForProcedureType(pType));
    storedProc.setProcedureName(pType.getProcedureName());
    storedProc.setReturnsResultSet(false);
    // process the procedure's arguments
    if (pType.getArguments().size() > 0) {
        List<StoredProcedureParameterMetadata> params = new ArrayList<StoredProcedureParameterMetadata>();
        for (ArgumentType arg : pType.getArguments()) {
            params.add(processArgument(arg));
        }
        storedProc.setParameters(params);
    }
    return storedProc;
}
Also used : NamedStoredProcedureQueryMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.NamedStoredProcedureQueryMetadata) ArrayList(java.util.ArrayList) ArgumentType(org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType) StoredProcedureParameterMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.StoredProcedureParameterMetadata)

Aggregations

ArgumentType (org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType)10 ArrayList (java.util.ArrayList)7 ProcedureType (org.eclipse.persistence.tools.oracleddl.metadata.ProcedureType)5 Util.qNameFromString (org.eclipse.persistence.tools.dbws.Util.qNameFromString)4 CompositeDatabaseType (org.eclipse.persistence.tools.oracleddl.metadata.CompositeDatabaseType)4 DatabaseQuery (org.eclipse.persistence.queries.DatabaseQuery)3 ArgumentTypeDirection (org.eclipse.persistence.tools.oracleddl.metadata.ArgumentTypeDirection)3 DatabaseType (org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType)3 FunctionType (org.eclipse.persistence.tools.oracleddl.metadata.FunctionType)3 QName (javax.xml.namespace.QName)2 ComplexDatabaseType (org.eclipse.persistence.internal.helper.ComplexDatabaseType)2 PLSQLParameterMetadata (org.eclipse.persistence.internal.jpa.metadata.queries.PLSQLParameterMetadata)2 StoredProcedureParameterMetadata (org.eclipse.persistence.internal.jpa.metadata.queries.StoredProcedureParameterMetadata)2 Attachment (org.eclipse.persistence.internal.xr.Attachment)2 CollectionResult (org.eclipse.persistence.internal.xr.CollectionResult)2 NamedQueryHandler (org.eclipse.persistence.internal.xr.NamedQueryHandler)2 Parameter (org.eclipse.persistence.internal.xr.Parameter)2 ProcedureArgument (org.eclipse.persistence.internal.xr.ProcedureArgument)2 ProcedureOutputArgument (org.eclipse.persistence.internal.xr.ProcedureOutputArgument)2 QueryHandler (org.eclipse.persistence.internal.xr.QueryHandler)2