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.cfacc.v2_0.CFAccMySql.CFAccMySqlProjectBaseTable.java

public CFAccProjectBaseBuff[] 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 v  a 2s  .  com*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_bprjdef_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);
        try {
            resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        while ((resultSet != null) && 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<CFAccProjectBaseBuff> resultList = new LinkedList<CFAccProjectBaseBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("BPRJ")) {
            CFAccProjectBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("RPRJ")) {
            CFAccRealProjectBuff[] subList = schema.getTableRealProject().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 if (classCode.equals("VERN")) {
            CFAccVersionBuff[] subList = schema.getTableVersion().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;
    CFAccProjectBaseBuff[] retBuff = new CFAccProjectBaseBuff[resultList.size()];
    Iterator<CFAccProjectBaseBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstMySql.CFAstMySqlProjectBaseTable.java

public CFAstProjectBaseBuff[] 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  ww.  j a v  a  2s. c  om
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_bprjdef_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);
        try {
            resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        while ((resultSet != null) && 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<CFAstProjectBaseBuff> resultList = new LinkedList<CFAstProjectBaseBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("BPRJ")) {
            CFAstProjectBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("RPRJ")) {
            CFAstRealProjectBuff[] subList = schema.getTableRealProject().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 if (classCode.equals("VERN")) {
            CFAstVersionBuff[] subList = schema.getTableVersion().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;
    CFAstProjectBaseBuff[] retBuff = new CFAstProjectBaseBuff[resultList.size()];
    Iterator<CFAstProjectBaseBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstMySql.CFAstMySqlProjectBaseTable.java

public CFAstProjectBaseBuff[] readDerivedByTenantIdx(CFAstAuthorization 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 2s . c  om
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_bprjdef_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);
        try {
            resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        while ((resultSet != null) && 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<CFAstProjectBaseBuff> resultList = new LinkedList<CFAstProjectBaseBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("BPRJ")) {
            CFAstProjectBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("RPRJ")) {
            CFAstRealProjectBuff[] subList = schema.getTableRealProject().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 if (classCode.equals("VERN")) {
            CFAstVersionBuff[] subList = schema.getTableVersion().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;
    CFAstProjectBaseBuff[] retBuff = new CFAstProjectBaseBuff[resultList.size()];
    Iterator<CFAstProjectBaseBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswMySql.CFFswMySqlProjectBaseTable.java

public CFFswProjectBaseBuff[] readDerivedByTenantIdx(CFFswAuthorization 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 .  ja  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 = "call " + schema.getLowerDbSchemaName() + ".sp_read_bprjdef_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);
        try {
            resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        while ((resultSet != null) && 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<CFFswProjectBaseBuff> resultList = new LinkedList<CFFswProjectBaseBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("BPRJ")) {
            CFFswProjectBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("RPRJ")) {
            CFFswRealProjectBuff[] subList = schema.getTableRealProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TPRJ")) {
            CFFswTopProjectBuff[] subList = schema.getTableTopProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SPRJ")) {
            CFFswSubProjectBuff[] subList = schema.getTableSubProject().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("VERN")) {
            CFFswVersionBuff[] subList = schema.getTableVersion().readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MJVR")) {
            CFFswMajorVersionBuff[] subList = schema.getTableMajorVersion().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("MNVR")) {
            CFFswMinorVersionBuff[] 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;
    CFFswProjectBaseBuff[] retBuff = new CFFswProjectBaseBuff[resultList.size()];
    Iterator<CFFswProjectBaseBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetMySql.CFInternetMySqlProjectBaseTable.java

public CFInternetProjectBaseBuff[] readDerivedByTenantIdx(CFInternetAuthorization 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  a  2  s.  c o  m
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_bprjdef_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);
        try {
            resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        while ((resultSet != null) && 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<CFInternetProjectBaseBuff> resultList = new LinkedList<CFInternetProjectBaseBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("BPRJ")) {
            CFInternetProjectBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("RPRJ")) {
            CFInternetRealProjectBuff[] subList = schema.getTableRealProject()
                    .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 if (classCode.equals("VERN")) {
            CFInternetVersionBuff[] subList = schema.getTableVersion().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;
    CFInternetProjectBaseBuff[] retBuff = new CFInternetProjectBaseBuff[resultList.size()];
    Iterator<CFInternetProjectBaseBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskMySql.CFAsteriskMySqlProjectBaseTable.java

public CFInternetProjectBaseBuff[] readDerivedByTenantIdx(CFSecurityAuthorization Authorization,
        long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/* w ww.  j av a2 s  .c  o m*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_bprjdef_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);
        try {
            resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        while ((resultSet != null) && 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<CFInternetProjectBaseBuff> resultList = new LinkedList<CFInternetProjectBaseBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("BPRJ")) {
            CFInternetProjectBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("RPRJ")) {
            CFInternetRealProjectBuff[] subList = schema.getTableRealProject()
                    .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 if (classCode.equals("VERN")) {
            CFInternetVersionBuff[] subList = schema.getTableVersion().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;
    CFInternetProjectBaseBuff[] retBuff = new CFInternetProjectBaseBuff[resultList.size()];
    Iterator<CFInternetProjectBaseBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstDb2LUW.CFAstDb2LUWConfigurationFileTable.java

public CFAstConfigurationFileBuff[] readDerivedByClusterIdx(CFAstAuthorization Authorization, long ClusterId) {
    final String S_ProcName = "readDerivedByClusterIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }// ww w. ja  va 2  s  .c  o  m
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_read_conf_file_cc_by_clusteridx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadClassCodeByClusterIdx == null) {
            stmtReadClassCodeByClusterIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadClassCodeByClusterIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByClusterIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByClusterIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByClusterIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByClusterIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadClassCodeByClusterIdx.setLong(argIdx++, ClusterId);
        resultSet = stmtReadClassCodeByClusterIdx.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<CFAstConfigurationFileBuff> resultList = new LinkedList<CFAstConfigurationFileBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("CONF")) {
            CFAstConfigurationFileBuff[] subList = readBuffByClusterIdx(Authorization, ClusterId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("CASC")) {
            CFAstAsteriskConfBuff[] subList = schema.getTableAsteriskConf().readBuffByClusterIdx(Authorization,
                    ClusterId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("CSIP")) {
            CFAstSipConfBuff[] subList = schema.getTableSipConf().readBuffByClusterIdx(Authorization,
                    ClusterId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("CEXT")) {
            CFAstExtensionsConfBuff[] subList = schema.getTableExtensionsConf()
                    .readBuffByClusterIdx(Authorization, ClusterId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("CVOM")) {
            CFAstVoicemailConfBuff[] subList = schema.getTableVoicemailConf()
                    .readBuffByClusterIdx(Authorization, ClusterId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("CECC")) {
            CFAstExtConfigConfBuff[] subList = schema.getTableExtConfigConf()
                    .readBuffByClusterIdx(Authorization, ClusterId);
            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;
    CFAstConfigurationFileBuff[] retBuff = new CFAstConfigurationFileBuff[resultList.size()];
    Iterator<CFAstConfigurationFileBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:edu.unc.lib.dl.util.ContainerContentsHelper.java

/**
 * Adds new children to the content index. If there is an order specified for a new child, then it will insert the
 * child at the specified position. Any existing children after the specified position will be shifted if neccessary.
 * //from ww w.  j a va 2  s  . c  o  m
 * @param reordered
 * 
 * @param oldContents
 *           bytes for the old XML CONTENTS stream
 * @param topPid
 *           new child pid
 * @param containerOrder
 * @return
 * @throws JDOMException
 * @throws IOException
 */
public static Document addChildContentAIPInCustomOrder(Document result, PID containerPID,
        Collection<ContainerPlacement> placements, List<PID> reordered) {
    log.debug("adding child content to MD_CONTENTS XML doc");

    // first build a list of existing pid order in the container
    Element parentDiv = result.getRootElement().getChild("div", JDOMNamespaceUtil.METS_NS);
    List<Element> childDivs = parentDiv.getContent(Filters.element());
    int maxExistingOrder = 5;
    if (childDivs.size() > 0) {
        maxExistingOrder = Integer.parseInt(childDivs.get(childDivs.size() - 1).getAttributeValue("ORDER"));
    }
    ArrayList<PID> order = new ArrayList<PID>(maxExistingOrder + 1);
    try {
        for (Element child : childDivs) {
            int ord = Integer.parseInt(child.getAttributeValue("ORDER"));
            PID pid = new PID(child.getAttributeValue("ID"));
            if (ord >= order.size()) {
                while (ord > order.size()) { // insert nulls
                    order.add(null);
                }
                order.add(pid);
            } else {
                order.add(ord, pid);
            }
        }
    } catch (NullPointerException e) {
        throw new IllegalRepositoryStateException("Invalid container contents XML (MD_CONTENTS) on: ", e);
    }

    // FIXME: put all the old children in reordered pile, for now
    for (PID p : order) {
        if (p != null) {
            reordered.add(p);
        }
    }

    // clear out the current children
    parentDiv.removeContent();

    // build a list of things with designated order and things with only sip
    // order
    List<ContainerPlacement> designatedOrder = new ArrayList<ContainerPlacement>();
    List<ContainerPlacement> sipOrdered = new ArrayList<ContainerPlacement>();
    List<ContainerPlacement> unordered = new ArrayList<ContainerPlacement>();
    for (ContainerPlacement place : placements) {
        if (containerPID.equals(place.parentPID)) { // only place those objects that go in this container
            if (place.designatedOrder != null) {
                designatedOrder.add(place);
            } else if (place.sipOrder != null) {
                sipOrdered.add(place);
            } else {
                unordered.add(place);
            }
        }
    }
    // order.ensureCapacity(order.size() + designatedOrder.size() +
    // sipOrdered.size());

    // sort designated ordered stuff by that order
    Comparator<ContainerPlacement> designatedSort = new Comparator<ContainerPlacement>() {
        @Override
        public int compare(ContainerPlacement o1, ContainerPlacement o2) {
            if (o1.designatedOrder > o2.designatedOrder) {
                return 1;
            } else if (o1.designatedOrder < o2.designatedOrder) {
                return -1;
            }
            return 0;
        }
    };
    // ensure capacity for max of designated and existing, plus count of
    // sipOrdered and a buffer for collisions
    int maxDesignatedOrder = 0;
    if (designatedOrder.size() > 0) {
        Collections.sort(designatedOrder, designatedSort);
        maxDesignatedOrder = designatedOrder.get(designatedOrder.size() - 1).designatedOrder.intValue();
    }
    int capacityEstimate = Math.max(maxDesignatedOrder, maxExistingOrder) + sipOrdered.size() + 10;
    order.ensureCapacity(capacityEstimate);
    // insert the objects with designated order
    for (ContainerPlacement place : designatedOrder) {
        int pos = place.designatedOrder.intValue();
        if (pos >= order.size()) {
            while (pos > order.size()) { // index out of bounds, insert nulls
                order.add(null);
            }
            order.add(place.pid);
        } else {
            order.add(pos, place.pid);
        }
    }

    // append the objects with sip sibling order
    // sort sip ordered stuff by that order
    Comparator<ContainerPlacement> sipSort = new Comparator<ContainerPlacement>() {
        @Override
        public int compare(ContainerPlacement o1, ContainerPlacement o2) {
            if (o2.sipOrder == null || o1.sipOrder > o2.sipOrder) {
                return 1;
            } else if (o1.sipOrder == null || o1.sipOrder < o2.sipOrder) {
                return -1;
            }
            return 0;
        }
    };
    Collections.sort(sipOrdered, sipSort);
    // add SIP ordered
    for (ContainerPlacement place : sipOrdered) {
        order.add(place.pid);
    }
    // add unordered
    for (ContainerPlacement place : unordered) {
        order.add(place.pid);
    }

    for (ListIterator<PID> li = order.listIterator(); li.hasNext();) {
        int ord = li.nextIndex();
        PID pid = li.next();
        if (pid != null) {
            Element el = new Element("div", parentDiv.getNamespace()).setAttribute("ID", pid.getPid())
                    .setAttribute("ORDER", String.valueOf(ord));
            parentDiv.addContent(el);
        }
    }
    return result;
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetMySql.CFInternetMySqlDomainBaseTable.java

public CFInternetDomainBaseBuff[] readDerivedByTenantIdx(CFInternetAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*w  ww.  j av a  2  s .  co  m*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_bdomdef_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);
        try {
            resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        while ((resultSet != null) && 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<CFInternetDomainBaseBuff> resultList = new LinkedList<CFInternetDomainBaseBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("BDOM")) {
            CFInternetDomainBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDOM")) {
            CFInternetTopDomainBuff[] subList = schema.getTableTopDomain().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DOMN")) {
            CFInternetDomainBuff[] subList = schema.getTableDomain().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BPRJ")) {
            CFInternetProjectBaseBuff[] subList = schema.getTableProjectBase()
                    .readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("RPRJ")) {
            CFInternetRealProjectBuff[] subList = schema.getTableRealProject()
                    .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 if (classCode.equals("VERN")) {
            CFInternetVersionBuff[] subList = schema.getTableVersion().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;
    CFInternetDomainBaseBuff[] retBuff = new CFInternetDomainBaseBuff[resultList.size()];
    Iterator<CFInternetDomainBaseBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlDomainBaseTable.java

public CFAccDomainBaseBuff[] readDerivedByTenantIdx(CFAccAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from   ww w.  ja v a2 s.  co m*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_bdomdef_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);
        try {
            resultSet = stmtReadClassCodeByTenantIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        while ((resultSet != null) && 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<CFAccDomainBaseBuff> resultList = new LinkedList<CFAccDomainBaseBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("BDOM")) {
            CFAccDomainBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDOM")) {
            CFAccTopDomainBuff[] subList = schema.getTableTopDomain().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DOMN")) {
            CFAccDomainBuff[] subList = schema.getTableDomain().readBuffByTenantIdx(Authorization, TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BPRJ")) {
            CFAccProjectBaseBuff[] subList = schema.getTableProjectBase().readBuffByTenantIdx(Authorization,
                    TenantId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("RPRJ")) {
            CFAccRealProjectBuff[] subList = schema.getTableRealProject().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 if (classCode.equals("VERN")) {
            CFAccVersionBuff[] subList = schema.getTableVersion().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;
    CFAccDomainBaseBuff[] retBuff = new CFAccDomainBaseBuff[resultList.size()];
    Iterator<CFAccDomainBaseBuff> iter = resultList.iterator();
    while (iter.hasNext()) {
        retBuff[idx++] = iter.next();
    }
    return (retBuff);

}