Search in sources :

Example 1 with PLSQLPackageType

use of org.eclipse.persistence.tools.oracleddl.metadata.PLSQLPackageType 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 PLSQLPackageType

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

the class ProcedureOverloadTestSuite method setUp.

@SuppressWarnings({ "rawtypes", "unchecked" })
@BeforeClass
public static void setUp() throws ClassNotFoundException, SQLException {
    AllTests.setUp();
    String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    if (ddlCreate) {
        runDdl(conn, CREATE_PACKAGEX_PACKAGE, ddlDebug);
    }
    String schema = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
    List<String> procedurePatterns = new ArrayList<String>();
    procedurePatterns.add("P1");
    procedurePatterns.add("P1_1");
    procedurePatterns.add("P1_2");
    procedurePatterns.add("F1");
    procedurePatterns.add("F1_1");
    // use DatabaseTypeBuilder to generate a list of PackageTypes
    dbTypeBuilder = new DatabaseTypeBuilder();
    dbProcedures = new ArrayList();
    try {
        // process the package
        List<PLSQLPackageType> packages = dbTypeBuilder.buildPackages(conn, schema, "PACKAGEX");
        for (PLSQLPackageType pkgType : packages) {
            // now get the desired procedures/functions from the processed package
            for (ProcedureType procType : pkgType.getProcedures()) {
                if (procedurePatterns.contains(procType.getProcedureName())) {
                    dbProcedures.add(procType);
                }
            }
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
}
Also used : ProcedureType(org.eclipse.persistence.tools.oracleddl.metadata.ProcedureType) DatabaseTypeBuilder(org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilder) PLSQLPackageType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLPackageType) ArrayList(java.util.ArrayList) AllTests.documentToString(org.eclipse.persistence.tools.metadata.generation.test.AllTests.documentToString) ParseException(org.eclipse.persistence.tools.oracleddl.parser.ParseException) BeforeClass(org.junit.BeforeClass)

Example 3 with PLSQLPackageType

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

the class TypeRowTypeTestSuite method setUp.

@SuppressWarnings({ "unchecked", "rawtypes" })
@BeforeClass
public static void setUp() throws ClassNotFoundException, SQLException {
    AllTests.setUp();
    String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    if (ddlCreate) {
        runDdl(conn, CREATE_EMPTYPE_TABLE, ddlDebug);
        runDdl(conn, CREATE_EMPREC_TYPE, ddlDebug);
        runDdl(conn, CREATE_EMP_RECORD_PACKAGE, ddlDebug);
        runDdl(conn, CREATE_ROWTYPE_TEST_PACKAGE, ddlDebug);
    }
    String schema = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
    List<String> procedurePatterns = new ArrayList<String>();
    procedurePatterns.add("get_emp_record");
    procedurePatterns.add("testProc");
    procedurePatterns.add("testFunc");
    // use DatabaseTypeBuilder to generate a lists of TableTypes and PackageTypes
    dbTypeBuilder = new DatabaseTypeBuilder();
    try {
        // process the table
        List<TableType> dbTables = dbTypeBuilder.buildTables(conn, schema, "EMPTYPEX");
        // process the "EMP_RECORD_PACKAGE" package
        List<ProcedureType> empRecPkgProcedures = new ArrayList<ProcedureType>();
        List<PLSQLPackageType> packages = dbTypeBuilder.buildPackages(conn, schema, "EMP_RECORD_PACKAGE");
        for (PLSQLPackageType pkgType : packages) {
            // now get the desired procedures/functions from the processed package
            for (ProcedureType procType : pkgType.getProcedures()) {
                if (procedurePatterns.contains(procType.getProcedureName())) {
                    empRecPkgProcedures.add(procType);
                }
            }
        }
        // process the "RTYPE_PKG" package
        List<ProcedureType> rtypePkgProcedures = new ArrayList<ProcedureType>();
        packages = dbTypeBuilder.buildPackages(conn, schema, "RTYPE_PKG");
        for (PLSQLPackageType pkgType : packages) {
            // now get the desired procedures/functions from the processed package
            for (ProcedureType procType : pkgType.getProcedures()) {
                if (procedurePatterns.contains(procType.getProcedureName())) {
                    rtypePkgProcedures.add(procType);
                }
            }
        }
        // combine tables and procedures to pass to the metadata generator
        dbTypes = new ArrayList();
        dbTypes.addAll(dbTables);
        dbTypes.addAll(empRecPkgProcedures);
        dbTypes.addAll(rtypePkgProcedures);
    } catch (ParseException e) {
        e.printStackTrace();
        fail("An unexpected exception occurred: " + e.getMessage());
    }
}
Also used : ProcedureType(org.eclipse.persistence.tools.oracleddl.metadata.ProcedureType) DatabaseTypeBuilder(org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilder) TableType(org.eclipse.persistence.tools.oracleddl.metadata.TableType) PLSQLPackageType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLPackageType) ArrayList(java.util.ArrayList) AllTests.documentToString(org.eclipse.persistence.tools.metadata.generation.test.AllTests.documentToString) ParseException(org.eclipse.persistence.tools.oracleddl.parser.ParseException) BeforeClass(org.junit.BeforeClass)

Example 4 with PLSQLPackageType

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

the class CursorTypeTestSuite method setUp.

@SuppressWarnings({ "rawtypes", "unchecked" })
@BeforeClass
public static void setUp() throws ClassNotFoundException, SQLException {
    AllTests.setUp();
    String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    if (ddlCreate) {
        runDdl(conn, CREATE_EMPTABLE, ddlDebug);
        runDdl(conn, CREATE_CURSORTYPE_PACKAGE, ddlDebug);
    }
    String schema = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
    List<String> procedurePatterns = new ArrayList<String>();
    procedurePatterns.add("GET_EMP");
    procedurePatterns.add("GET_EMP_FUNC");
    // use DatabaseTypeBuilder to generate a list of PackageTypes
    dbTypeBuilder = new DatabaseTypeBuilder();
    dbProcedures = new ArrayList();
    try {
        // process the package
        List<PLSQLPackageType> packages = dbTypeBuilder.buildPackages(conn, schema, "CURSORTYPE");
        for (PLSQLPackageType pkgType : packages) {
            // now get the desired procedures/functions from the processed package
            for (ProcedureType procType : pkgType.getProcedures()) {
                if (procedurePatterns.contains(procType.getProcedureName())) {
                    dbProcedures.add(procType);
                }
            }
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
}
Also used : ProcedureType(org.eclipse.persistence.tools.oracleddl.metadata.ProcedureType) DatabaseTypeBuilder(org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilder) PLSQLPackageType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLPackageType) ArrayList(java.util.ArrayList) AllTests.documentToString(org.eclipse.persistence.tools.metadata.generation.test.AllTests.documentToString) ParseException(org.eclipse.persistence.tools.oracleddl.parser.ParseException) BeforeClass(org.junit.BeforeClass)

Example 5 with PLSQLPackageType

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

the class PLSQLCollectionTypeTestSuite method setUp.

@SuppressWarnings({ "rawtypes", "unchecked" })
@BeforeClass
public static void setUp() throws ClassNotFoundException, SQLException {
    AllTests.setUp();
    String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    if (ddlCreate) {
        runDdl(conn, CREATE_A_PHONE_TYPE, ddlDebug);
        runDdl(conn, CREATE_PACKAGE2_PACKAGE, ddlDebug);
        runDdl(conn, CREATE_PACKAGE2_TAB1_TYPE, ddlDebug);
        runDdl(conn, CREATE_A_PHONE_COLLECTION_TYPE, ddlDebug);
    }
    String schema = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
    List<String> procedurePatterns = new ArrayList<String>();
    procedurePatterns.add("COPYTABLE");
    procedurePatterns.add("COPYTABLE_FUNC");
    procedurePatterns.add("COPYPHONECOLLECTION");
    procedurePatterns.add("SETRECORD");
    procedurePatterns.add("COPYBOOLEANTABLE");
    // use DatabaseTypeBuilder to generate a list of PackageTypes
    dbTypeBuilder = new DatabaseTypeBuilder();
    dbProcedures = new ArrayList();
    try {
        // process the package
        List<PLSQLPackageType> packages = dbTypeBuilder.buildPackages(conn, schema, "PACKAGE2");
        for (PLSQLPackageType pkgType : packages) {
            // now get the desired procedures/functions from the processed package
            for (ProcedureType procType : pkgType.getProcedures()) {
                if (procedurePatterns.contains(procType.getProcedureName())) {
                    dbProcedures.add(procType);
                }
            }
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
}
Also used : ProcedureType(org.eclipse.persistence.tools.oracleddl.metadata.ProcedureType) DatabaseTypeBuilder(org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilder) PLSQLPackageType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLPackageType) ArrayList(java.util.ArrayList) AllTests.documentToString(org.eclipse.persistence.tools.metadata.generation.test.AllTests.documentToString) ParseException(org.eclipse.persistence.tools.oracleddl.parser.ParseException) BeforeClass(org.junit.BeforeClass)

Aggregations

PLSQLPackageType (org.eclipse.persistence.tools.oracleddl.metadata.PLSQLPackageType)11 ProcedureType (org.eclipse.persistence.tools.oracleddl.metadata.ProcedureType)10 ArrayList (java.util.ArrayList)9 ParseException (org.eclipse.persistence.tools.oracleddl.parser.ParseException)7 AllTests.documentToString (org.eclipse.persistence.tools.metadata.generation.test.AllTests.documentToString)6 DatabaseTypeBuilder (org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilder)6 BeforeClass (org.junit.BeforeClass)6 CompositeDatabaseType (org.eclipse.persistence.tools.oracleddl.metadata.CompositeDatabaseType)4 TableType (org.eclipse.persistence.tools.oracleddl.metadata.TableType)4 ObjectTableType (org.eclipse.persistence.tools.oracleddl.metadata.ObjectTableType)3 HashSet (java.util.HashSet)2 ArgumentType (org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType)2 DatabaseType (org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType)2 FieldType (org.eclipse.persistence.tools.oracleddl.metadata.FieldType)2 FunctionType (org.eclipse.persistence.tools.oracleddl.metadata.FunctionType)2 PLSQLRecordType (org.eclipse.persistence.tools.oracleddl.metadata.PLSQLRecordType)2 ROWTYPEType (org.eclipse.persistence.tools.oracleddl.metadata.ROWTYPEType)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1