Examples of OmniDTO


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

     */
    public static int executeSQL(String sql, Map<String, Object> inputs) {
        int rowCount = -1;
       
        try {
            OmniDTO returnTO =
                getSqlService().execute(inputs, DataProcessorTypes.DIRECT_SQL_STATEMENT_PROCESSOR, sql);
           
            rowCount = returnTO.getUpdatedRowCount();
        }
        catch (Exception ex) {
            throw new BaseSQLException(ex);
        }
        return rowCount;
View Full Code Here

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

     */
    public static int executeSQLByKey(String sqlKey, Map<String, Object> inputs) {
        int rowCount = -1;
       
        try {
            OmniDTO returnTO =
                getSqlService().execute(inputs, DataProcessorTypes.NAMED_SQL_STATEMENT_PROCESSOR, sqlKey);
           
            rowCount = returnTO.getUpdatedRowCount();
        }
        catch (Exception ex) {
            throw new BaseSQLException(ex);
        }
        return rowCount;
View Full Code Here

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

            throw new IllegalArgumentException("processorType or processorName is null.");

        if (inputs == null) inputs = new HashMap<String, Object>();

        ImplicitTransactionManager tm = TransactionManagerUtil.getImplicitTransactionManager();
        OmniDTO returnTO = null;

        try {
            tm.beginTransactionImplicit();

            //if (log.isDebugEnabled()) displayDS((String)inputs.get(DataProcessor.input_key_database_connection_name), "beforeConnection");
View Full Code Here

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

        try {
            tm.beginTransactionImplicit();

            for (InputInfo ip : inputInfoList) {
                UserDatabaseConnection connection = findOrCreateConnection(ip);
                OmniDTO returnTO = executeKeepConnection(connection, ip.getInputs(), ip.getProcessorType(), ip.getProcessorName(), ip.getOutputFilters());
                returnTOList.add(returnTO);

                //now execute child InputInfo
                Collection<InputInfo> childList = ip.getChildInputInfoObjects();
                for (InputInfo childIp : childList) {
                    OmniDTO returnTO2 = executeKeepConnection(connection, childIp.getInputs(), childIp.getProcessorType(), childIp.getProcessorName(), childIp.getOutputFilters());
                    returnTO.addChildrenOmniDTOToList(returnTO2);
                }
            }

            tm.commitTransactionImplicit();
View Full Code Here

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

    throws BaseSQLException {
        if (inputInfo == null)
            throw new IllegalArgumentException("inputInfo is null.");

        ImplicitTransactionManager tm = TransactionManagerUtil.getImplicitTransactionManager();
        OmniDTO returnTO = null;

        try {
            tm.beginTransactionImplicit();

            InputInfo ip = inputInfo;
            UserDatabaseConnection udc = findOrCreateConnection(ip);
            udc.getConnection().setReadOnly(true);

            returnTO = executeKeepConnection(udc, ip.getInputs(), ip.getProcessorType(), ip.getProcessorName(), ip.getOutputFilters());
            log.debug("parent: " + returnTO);

            //now execute child InputInfo
            Collection<InputInfo> childList = ip.getChildInputInfoObjects();
            for (InputInfo childIp : childList) {
                // find all input parameters in childIp that need data from parent
                List<String> connectorList = new ArrayList<String>();
                Map<String, Object> childInputs = childIp.getInputs();
                childInputs = convertKeyCase(childInputs);
                for (Map.Entry<String, Object> entry : childInputs.entrySet()) {
                    String key = entry.getKey();
                    String value = (String)childInputs.get(key);
                    if (key != null && key.startsWith("&")) connectorList.add(value);
                }

                // create a select union query
                String query = null;
                if (DataProcessorTypes.NAMED_SQL_STATEMENT_PROCESSOR.equals(childIp.getProcessorType())) {
                    query = SqlConfig.getInstance().getSql(childIp.getProcessorName());
                }
                else
                if (DataProcessorTypes.DIRECT_SQL_STATEMENT_PROCESSOR.equals(childIp.getProcessorType())) {
                    query = childIp.getProcessorName();
                }

                log.debug("child query1: " + query);

                // check if parent has data
                boolean parentHasData = false;
                TableData parentRt = null;
                if (returnTO != null) {
                    parentRt = returnTO.getTableData(ip.getProcessorName());
                    if (parentRt != null) {
                        int size = parentRt.getAllRows().size();
                        if (size > 0) parentHasData = true;
                    }
                }

                // construct child query
                String childQuery = "";
                if (query != null && connectorList.size() > 0 && parentHasData) {
                    childQuery = getNewChildQuery(query, childIp, parentRt.getAllRows());
                }
                else {
                    childQuery = query;
                }

                log.debug("child query2: " + childQuery);

                if (parentHasData) {
                    udc = findOrCreateConnection(childIp);

                    OmniDTO returnTO2 =
                        executeKeepConnection(udc,
                                              childIp.getInputs(),
                                              DataProcessorTypes.DIRECT_SQL_STATEMENT_PROCESSOR,
                                              childQuery,
                                              childIp.getOutputFilters());

                    // merge child records with corresponding parent record
                    if (returnTO2 != null) {
                        linkParentWithChild(parentRt,
                                            returnTO2.getTableData(childQuery),
                                            childIp.getProcessorName(),
                                            connectorList);
                    }

                    log.debug("returnTO2: " + returnTO2);
View Full Code Here

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

        if (inputs == null) inputs = new HashMap<String, Object>();

        inputs.put(DataProcessor.input_key_records_offset, Integer.valueOf(offset));
        inputs.put(DataProcessor.input_key_records_limit, Integer.valueOf(limitOrFixed));

        OmniDTO dto = execute(inputs, processorType, processorName);
        TableData td = dto.getTableData(processorName);

        if (limitOrFixed != DataProcessor.NO_ROW_LIMIT) {
            boolean requireFixed = Util.getBooleanValue(inputs, DataProcessor.input_key_records_fixed, false);
            if (requireFixed) {
                if (td.getTableSize() != 0 && td.getTableSize() != limitOrFixed) {
View Full Code Here

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

     * @return int              number of rows deleted
     * @throws com.scooterframework.orm.sqldataexpress.exception.BaseSQLException
     */
    public int delete(Map<String, Object> inputs, String processorType, String processorName)
    throws BaseSQLException {
        OmniDTO dto = execute(inputs, processorType, processorName);
        return dto.getUpdatedRowCount();
    }
View Full Code Here

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

     * @return int              number of rows updated
     * @throws com.scooterframework.orm.sqldataexpress.exception.BaseSQLException
     */
    public int update(Map<String, Object> inputs, String processorType, String processorName)
    throws BaseSQLException {
        OmniDTO dto = execute(inputs, processorType, processorName);
        return dto.getUpdatedRowCount();
    }
View Full Code Here

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

            throw new IllegalArgumentException("processorType or processorName is null.");

        cleanUpInputs(inputs);
        if (inputs == null) inputs = new HashMap<String, Object>();

        OmniDTO returnTO = null;

        try {
            DataProcessor dp = DataProcessorFactory.getInstance().getDataProcessor(udc, processorType, processorName);
            returnTO = dp.execute(udc, convertKeyCase(inputs), outputFilters);
            if (returnTO != null) {
                returnTO.setProcessorType(processorType);
                returnTO.setProcessorName(processorName);
            }
        }
        catch(UnsupportedDataProcessorTypeException udptEx) {
            throw new BaseSQLException("Unsupported DataProcessor Type: " + processorType);
        }
View Full Code Here

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

    public OmniDTO execute(UserDatabaseConnection udc, Map<String, Object> inputs, Map<String, String> outputFilters)
    throws BaseSQLException {
      Connection connection = udc.getConnection();
      DBAdapter dba = DBAdapterFactory.getInstance().getAdapter(udc.getConnectionName());
     
        OmniDTO returnTO = new OmniDTO();
        PreparedStatement pstmt = null;
        ResultSet rs = null;
       
        try {
            String stName = st.getName();
            autoFill(udc, inputs);
           
            JdbcStatement jstat = st;
            String originalSql = st.getOriginalJdbcStatementString();
            if(checkPagination(inputs)) {
              String pagedSql = dba.preparePaginationSql(originalSql, inputs, outputFilters);
              jstat = SqlExpressUtil.createJdbcStatementDirect(pagedSql);
            }
           
            String executableSql = jstat.getExecutableJdbcStatementString();
            executableSql = autoReplace(executableSql, inputs);
           
            log.debug("execute - parsed expecutable sql: " + executableSql);
            log.debug("execute - parsed inputs: " + inputs);
            log.debug("execute - outputFilters: " + outputFilters);
           
            boolean supportsGetGeneratedKeys = supportsGetGeneratedKeys();
            if (supportsGetGeneratedKeys && !jstat.isSelectStatement()) {
                pstmt = connection.prepareStatement(executableSql, Statement.RETURN_GENERATED_KEYS);
            }
            else {
                pstmt = connection.prepareStatement(executableSql);
            }
           
            // check if need to load parameter properties
//            if (supportParameterMetaData()) {
//                if (!jstat.hasLoadedParameterMetaData()) {
//                    //get parameter meta data if it has not been loaded
//                    ParameterMetaData pmd = pstmt.getParameterMetaData();
//                    ParameterMetaDataLoader pmdl = new ParameterMetaDataLoader(pmd, jstat);
//                    pmdl.loadParameterMetaData();
//                }
//            }
//            else {
                if (!jstat.hasLoadedParameterProperties()) {
                  synchronized(jstat) {
                    if (!jstat.hasLoadedParameterProperties()) {
                            JdbcStatementParser parser = new JdbcStatementParser(udc, jstat);
                            parser.parse();
                    }
                  }
                }
//            }
           
            Collection<Parameter> parameters = jstat.getParameters();
            log.debug("execute - parameters: " + parameters);
            Iterator<Parameter> pit = parameters.iterator();
            while(pit.hasNext()) {
                Parameter p = pit.next();
               
                String key = p.getName();
                if (!inputs.containsKey(key)) {
                  throw new Exception("There " +
                    "must be a key/value pair corresponding to key named " + key +
                    " in input parameters: " + inputs.keySet());
                }
               
                if (Parameter.MODE_IN.equals(p.getMode())) {
                    Object obj = inputs.get(key);
                    if (obj == null ||
                        "".equals(obj.toString().trim()) &&
                        p.getSqlDataType() != Types.CHAR &&
                        p.getSqlDataType() != Types.VARCHAR &&
                        p.getSqlDataType() != Types.LONGVARCHAR) {
                        setNull(pstmt, p.getIndex(), p.getSqlDataType());
                    }
                    else {
                        if(!dba.vendorSpecificSetObject(pstmt, obj, p, inputs)) {
                            if (Parameter.UNKNOWN_SQL_DATA_TYPE != p.getSqlDataType()) {
                                setObject(pstmt, obj, p);
                            }
                            else {
                                //It is up to JDBC driver's PreparedStatement implementation
                                //class to deal with. Usually the class will make a decision
                                //on which setXXX(Type) method to call based on the java
                                //class type of the obj instance.
                                pstmt.setObject(p.getIndex(), obj);
                            }
                        }
                    }
                }
            }
           
            if (jstat.isSelectStatement()) {
                rs = pstmt.executeQuery();
               
                // handle out cursors or other outputs if there is any
                if (rs != null) {
                    if (outputFilters == null || outputFilters.size() == 0) {
                        handleResultSet(jstat, dba, stName, returnTO, rs, inputs);
                    }
                    else {
                        handleFilteredResultSet(jstat, dba, stName, returnTO, rs, inputs, outputFilters);
                    }
                }
            }
            else {
                int rowCount = pstmt.executeUpdate();
                returnTO.setUpdatedRowCount(rowCount);
               
                //get generated key if the underlying database permitted
                if (supportsGetGeneratedKeys) {
                    ResultSet rsg = null;
                    try {
                        rsg = pstmt.getGeneratedKeys();
                        if(rsg.next()) {
                            returnTO.setGeneratedKey(rsg.getLong(1));
                        }
                    }
                    catch(Throwable ex) {
                        DAOUtil.closeResultSet(rsg);
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.