Example usage for java.util ArrayList listIterator

List of usage examples for java.util ArrayList listIterator

Introduction

In this page you can find the example usage for java.util ArrayList listIterator.

Prototype

public ListIterator<E> listIterator() 

Source Link

Document

Returns a list iterator over the elements in this list (in proper sequence).

Usage

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetPgSql.CFInternetPgSqlVersionTable.java

public CFInternetVersionBuff[] readDerivedByTenantIdx(CFInternetAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from  w w  w.j a  v  a  2s.  com
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerDbSchemaName()
                + ".sp_read_verndef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFInternetVersionBuff> resultList = new LinkedList<CFInternetVersionBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("VERN")) {
            CFInternetVersionBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MJVR")) {
            CFInternetMajorVersionBuff[] subList = schema.getTableMajorVersion()
                    .readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MNVR")) {
            CFInternetMinorVersionBuff[] subList = schema.getTableMinorVersion()
                    .readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFInternetVersionBuff[] retBuff = new CFInternetVersionBuff[resultList.size()];
    Iterator<CFInternetVersionBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlVersionTable.java

public CFInternetVersionBuff[] readDerivedByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/* w w  w .  j  av a2s.c om*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerDbSchemaName()
                + ".sp_read_verndef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFInternetVersionBuff> resultList = new LinkedList<CFInternetVersionBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("VERN")) {
            CFInternetVersionBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MJVR")) {
            CFInternetMajorVersionBuff[] subList = schema.getTableMajorVersion()
                    .readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MNVR")) {
            CFInternetMinorVersionBuff[] subList = schema.getTableMinorVersion()
                    .readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFInternetVersionBuff[] retBuff = new CFInternetVersionBuff[resultList.size()];
    Iterator<CFInternetVersionBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlVersionTable.java

public CFAccVersionBuff[] readDerivedByTenantIdx(CFAccAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//  w w  w  .j  a  va 2s  . co m
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerSchemaDbName()
                + ".sp_read_verndef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFAccVersionBuff> resultList = new LinkedList<CFAccVersionBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("VERN")) {
            CFAccVersionBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MJVR")) {
            CFAccMajorVersionBuff[] subList = schema.getTableMajorVersion().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MNVR")) {
            CFAccMinorVersionBuff[] subList = schema.getTableMinorVersion().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFAccVersionBuff[] retBuff = new CFAccVersionBuff[resultList.size()];
    Iterator<CFAccVersionBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstPgSql.CFAstPgSqlVersionTable.java

public CFAstVersionBuff[] readDerivedByTenantIdx(CFAstAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from  w w w.  j  ava 2 s  . co  m*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerSchemaDbName()
                + ".sp_read_verndef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFAstVersionBuff> resultList = new LinkedList<CFAstVersionBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("VERN")) {
            CFAstVersionBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MJVR")) {
            CFAstMajorVersionBuff[] subList = schema.getTableMajorVersion().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MNVR")) {
            CFAstMinorVersionBuff[] subList = schema.getTableMinorVersion().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFAstVersionBuff[] retBuff = new CFAstVersionBuff[resultList.size()];
    Iterator<CFAstVersionBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlVersionTable.java

public CFAstVersionBuff[] readDerivedByTenantIdx(CFAstAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }// w  w  w .ja  va2  s .  c o m
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerDbSchemaName()
                + ".sp_read_verndef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFAstVersionBuff> resultList = new LinkedList<CFAstVersionBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("VERN")) {
            CFAstVersionBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MJVR")) {
            CFAstMajorVersionBuff[] subList = schema.getTableMajorVersion().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MNVR")) {
            CFAstMinorVersionBuff[] subList = schema.getTableMinorVersion().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFAstVersionBuff[] retBuff = new CFAstVersionBuff[resultList.size()];
    Iterator<CFAstVersionBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlVersionTable.java

public CFCrmVersionBuff[] readDerivedByTenantIdx(CFCrmAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/* w  w  w .j a  v a2 s  .  co m*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "{ call sp_read_verndef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) }";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        if (resultSet != null) {
            while (resultSet.next()) {
                classCode = resultSet.getString(1);
                classCodeList.add(classCode);
            }
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFCrmVersionBuff> resultList = new LinkedList<CFCrmVersionBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("VERN")) {
            CFCrmVersionBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MJVR")) {
            CFCrmMajorVersionBuff[] subList = schema.getTableMajorVersion().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MNVR")) {
            CFCrmMinorVersionBuff[] subList = schema.getTableMinorVersion().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFCrmVersionBuff[] retBuff = new CFCrmVersionBuff[resultList.size()];
    Iterator<CFCrmVersionBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlRealProjectTable.java

public CFAccRealProjectBuff[] readDerivedByTenantIdx(CFAccAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }// w w w.ja  v  a 2s  . co  m
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerSchemaDbName()
                + ".sp_read_rprjdef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFAccRealProjectBuff> resultList = new LinkedList<CFAccRealProjectBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("RPRJ")) {
            CFAccRealProjectBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TPRJ")) {
            CFAccTopProjectBuff[] subList = schema.getTableTopProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SPRJ")) {
            CFAccSubProjectBuff[] subList = schema.getTableSubProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFAccRealProjectBuff[] retBuff = new CFAccRealProjectBuff[resultList.size()];
    Iterator<CFAccRealProjectBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstPgSql.CFAstPgSqlRealProjectTable.java

public CFAstRealProjectBuff[] readDerivedByTenantIdx(CFAstAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*w  ww .  j  a  va  2  s  .  co  m*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerSchemaDbName()
                + ".sp_read_rprjdef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFAstRealProjectBuff> resultList = new LinkedList<CFAstRealProjectBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("RPRJ")) {
            CFAstRealProjectBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TPRJ")) {
            CFAstTopProjectBuff[] subList = schema.getTableTopProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SPRJ")) {
            CFAstSubProjectBuff[] subList = schema.getTableSubProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFAstRealProjectBuff[] retBuff = new CFAstRealProjectBuff[resultList.size()];
    Iterator<CFAstRealProjectBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlRealProjectTable.java

public CFAstRealProjectBuff[] readDerivedByTenantIdx(CFAstAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/* w  w w  .java  2  s  .  c  om*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerDbSchemaName()
                + ".sp_read_rprjdef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFAstRealProjectBuff> resultList = new LinkedList<CFAstRealProjectBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("RPRJ")) {
            CFAstRealProjectBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TPRJ")) {
            CFAstTopProjectBuff[] subList = schema.getTableTopProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SPRJ")) {
            CFAstSubProjectBuff[] subList = schema.getTableSubProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFAstRealProjectBuff[] retBuff = new CFAstRealProjectBuff[resultList.size()];
    Iterator<CFAstRealProjectBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetPgSql.CFInternetPgSqlRealProjectTable.java

public CFInternetRealProjectBuff[] readDerivedByTenantIdx(CFInternetAuthorization Authorization,
        long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from   ww  w.  j a  v a 2  s. c o m*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerDbSchemaName()
                + ".sp_read_rprjdef_cc_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByTenantIdx == null) {
            stmtReadClassCodeByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByTenantIdx.setLong(argIdx++, TenantId);
        resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
    List<CFInternetRealProjectBuff> resultList = new LinkedList<CFInternetRealProjectBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("RPRJ")) {
            CFInternetRealProjectBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TPRJ")) {
            CFInternetTopProjectBuff[] subList = schema.getTableTopProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SPRJ")) {
            CFInternetSubProjectBuff[] subList = schema.getTableSubProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    int idx = 0;
    CFInternetRealProjectBuff[] retBuff = new CFInternetRealProjectBuff[resultList.size()];
    Iterator<CFInternetRealProjectBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}