Package com.scooterframework.orm.sqldataexpress.object

Examples of com.scooterframework.orm.sqldataexpress.object.Function


    public static Function lookupAndRegisterFunction(String function) {
        if (function == null)
            throw new IllegalArgumentException("Function name is empty.");
       
        String errorMessage = "Failed to get meta data info for function " + function;
        Function f = DBStore.getInstance().getFunction(function);
        if (f == null) {
          UserDatabaseConnection udc = null;
            try {
                udc = SqlExpressUtil.getUserDatabaseConnection();
                f = lookupFunction(udc, function);
View Full Code Here


      Connection connection = udc.getConnection();
     
        if (connection == null || name == null)
            throw new IllegalArgumentException("connection or name is empty.");
       
        Function sp = new Function(name);
        ResultSet rs = null;
       
        try {
            String catalog = sp.getCatalog();
            String schema = sp.getSchema();
            String api = sp.getApi();
            DBAdapter dba = DBAdapterFactory.getInstance().getAdapter(udc.getConnectionName());
           
            boolean foundPlSqlRecord = false;//will skip all output columns when a PL/SQL record is found.//TODO: This code is tied to Oracle. Change it.
            boolean startToRecord = false;
            int previousIndex = -1;
           
            DatabaseMetaData dbmd = connection.getMetaData();
            String vendor = getDatabaseVendor(dbmd);
            rs = dbmd.getProcedureColumns(toUpperCaseIfAllowed(dba, catalog),
                toUpperCaseIfAllowed(dba, schema), toUpperCaseIfAllowed(dba, api), null);
           
            while (rs.next()) {
                catalog = rs.getString("PROCEDURE_CAT");
                schema = rs.getString("PROCEDURE_SCHEM");
                int index = rs.getInt("SEQUENCE");
                String columnName = rs.getString("COLUMN_NAME");
                String mode = rs.getString("COLUMN_TYPE");
                int sqlDataType = rs.getInt("DATA_TYPE");
                String sqlDataTypeName = rs.getString("TYPE_NAME");
               
                // turn on foundPlSqlRecord
                if (Parameter.MODE_OUT.equals(mode) &&
                     Types.OTHER == sqlDataType && //cursor type
                     columnName == null &&
                     "PL/SQL RECORD".equals(sqlDataTypeName)) {//TODO: This code is tied to Oracle. Change it.
                    foundPlSqlRecord = true;
                }
               
                // The next few rows are definition of this ref cursor
                // ignore it as there is no way to detect the end of this
                // cursor columns exactly.
                // will get the output cursor info in other place.
                if (foundPlSqlRecord) {
                    if (Parameter.MODE_OUT.equals(mode)) {
                        continue;
                    }
                    else {
                        // turn off foundPlSqlRecord
                        foundPlSqlRecord = false;
                    }
                }
               
                //check if start to record
                if (index == 1 && Parameter.MODE_RETURN.equals(mode)) {
                    startToRecord = true;
                    previousIndex = -1;//clear position
                }
               
                if (index <= previousIndex) {
                    startToRecord = false;
                }
               
                if (startToRecord) {
                    Parameter p = ParameterFactory.getInstance().createParameter(vendor, index, columnName, mode, sqlDataType, sqlDataTypeName);
                    p.setCatalog(catalog);
                    p.setSchema(schema);
                    sp.addParameter(p);
                }
               
                previousIndex = index;
            }
            sp.setCataloge(catalog);
            sp.setSchema(schema);
           
            rs.close();
        }
        catch(SQLException sqlEx) {
            throw new UnsupportedStoredProcedureAPINameException(sqlEx);
View Full Code Here

   
    public Function getFunction(String name) {
        if (name == null) return null;

        String functionKey = getFunctionKey(name);
        Function function = null;
       
        if (DatabaseConfig.getInstance().isInDevelopmentEnvironment()) {
            function = (Function)CurrentThreadCache.get(functionKey);
            return function;
        }
View Full Code Here

            }
           
            selectedDataProcessor = new StoredProcedureProcessor(storedProcedure);
        }
        else if (DataProcessorTypes.FUNCTION_PROCESSOR.equals(processorType)) {
            Function function = DBStore.getInstance().getFunction(processorName);
           
            if (function == null) {
                //discovery
                function = SqlExpressUtil.lookupFunction(udc, processorName);
               
View Full Code Here

TOP

Related Classes of com.scooterframework.orm.sqldataexpress.object.Function

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.