List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstMySql.CFAstMySqlDomainBaseTable.java
public CFAstDomainBaseBuff[] readDerivedByTenantIdx(CFAstAuthorization Authorization, long TenantId) { final String S_ProcName = "readDerivedByTenantIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//ww w. j av 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_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<CFAstDomainBaseBuff> resultList = new LinkedList<CFAstDomainBaseBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("BDOM")) { CFAstDomainBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TDOM")) { CFAstTopDomainBuff[] subList = schema.getTableTopDomain().readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DOMN")) { CFAstDomainBuff[] subList = schema.getTableDomain().readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("BPRJ")) { CFAstProjectBaseBuff[] subList = schema.getTableProjectBase().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; CFAstDomainBaseBuff[] retBuff = new CFAstDomainBaseBuff[resultList.size()]; Iterator<CFAstDomainBaseBuff> iter = resultList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstMySql.CFAstMySqlDomainBaseTable.java
public CFAstDomainBaseBuff[] 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 av 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_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<CFAstDomainBaseBuff> resultList = new LinkedList<CFAstDomainBaseBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("BDOM")) { CFAstDomainBaseBuff[] subList = readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TDOM")) { CFAstTopDomainBuff[] subList = schema.getTableTopDomain().readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DOMN")) { CFAstDomainBuff[] subList = schema.getTableDomain().readBuffByTenantIdx(Authorization, TenantId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("BPRJ")) { CFAstProjectBaseBuff[] subList = schema.getTableProjectBase().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; CFAstDomainBaseBuff[] retBuff = new CFAstDomainBaseBuff[resultList.size()]; Iterator<CFAstDomainBaseBuff> iter = resultList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); }
From source file:org.opennms.ng.services.collectd.Collectd.java
private void unscheduleNodeAndMarkForDeletion(Long nodeId) { // Iterate over the collectable service list and mark any entries // which match the deleted nodeId for deletion. synchronized (getCollectableServices()) { CollectableService cSvc = null;/*from www.ja v a 2 s .c o m*/ final ListIterator<CollectableService> liter = getCollectableServices().listIterator(); while (liter.hasNext()) { cSvc = liter.next(); // Only interested in entries with matching nodeId if (!(cSvc.getNodeId() == nodeId)) { continue; } synchronized (cSvc) { // Retrieve the CollectorUpdates object associated // with this CollectableService. CollectorUpdates updates = cSvc.getCollectorUpdates(); // Now set the update's deletion flag so the next // time it is selected for execution by the scheduler // the collection will be skipped and the service will not // be rescheduled. LOG.debug( "Marking CollectableService for deletion because a node was deleted: Service nodeid={}, deleted node:{}", cSvc.getNodeId(), nodeId); updates.markForDeletion(); } // Now safe to remove the collectable service from // the collectable services list liter.remove(); } } }
From source file:org.opennms.ng.services.collectd.Collectd.java
/** * This method is responsible for handling interfaceDeleted events. * * @param event The event to process./*from ww w.j a v a 2s . c o m*/ * @throws InsufficientInformationException */ private void handleInterfaceDeleted(Event event) throws InsufficientInformationException { EventUtils.checkNodeId(event); String ipAddr = event.getInterface(); if (EventUtils.isNonIpInterface(ipAddr)) { LOG.debug("handleInterfaceDeleted: the deleted interface was a non-ip interface. Nothing to do here."); return; } Long nodeId = event.getNodeid(); // Iterate over the collectable services list and mark any entries // which match the deleted nodeId/IP address pair for deletion synchronized (getCollectableServices()) { CollectableService cSvc = null; ListIterator<CollectableService> liter = getCollectableServices().listIterator(); while (liter.hasNext()) { cSvc = liter.next(); // Only interested in entries with matching nodeId and IP // address InetAddress addr = (InetAddress) cSvc.getAddress(); if (!(cSvc.getNodeId() == nodeId && addr.getHostName().equals(ipAddr))) { continue; } synchronized (cSvc) { // Retrieve the CollectorUpdates object associated with // this CollectableService if one exists. CollectorUpdates updates = cSvc.getCollectorUpdates(); // Now set the update's deletion flag so the next // time it is selected for execution by the scheduler // the collection will be skipped and the service will not // be rescheduled. LOG.debug( "Marking CollectableService for deletion because an interface was deleted: Service nodeid={}, " + "deleted node:{}service address:{}deleted interface:{}", cSvc.getNodeId(), nodeId, addr.getHostName(), ipAddr); updates.markForDeletion(); } // Now safe to remove the collectable service from // the collectable services list liter.remove(); } } LOG.debug("interfaceDeletedHandler: processing of interfaceDeleted event for {}/{} completed", nodeId, ipAddr); }
From source file:org.opennms.ng.services.collectd.Collectd.java
/** * This method is responsible for handling serviceDeleted events. * * @param event The event to process.// w w w .j av a 2 s .c om * @throws InsufficientInformationException */ private void handleServiceDeleted(Event event) throws InsufficientInformationException { EventUtils.checkNodeId(event); EventUtils.checkInterface(event); EventUtils.checkService(event); //INCORRECT; we now support all *sorts* of data collection. This is *way* out of date // Currently only support SNMP data collection. // //if (!event.getService().equals("SNMP")) // return; Long nodeId = event.getNodeid(); String ipAddr = event.getInterface(); String svcName = event.getService(); // Iterate over the collectable services list and mark any entries // which match the nodeId/ipAddr of the deleted service // for deletion. synchronized (getCollectableServices()) { CollectableService cSvc = null; ListIterator<CollectableService> liter = getCollectableServices().listIterator(); while (liter.hasNext()) { cSvc = liter.next(); // Only interested in entries with matching nodeId, IP address // and service InetAddress addr = (InetAddress) cSvc.getAddress(); //WATCH the brackets; there used to be an extra close bracket after the ipAddr comparison which borked this whole expression if (!(cSvc.getNodeId() == nodeId && addr.getHostName().equals(ipAddr) && cSvc.getServiceName().equals(svcName))) { continue; } synchronized (cSvc) { // Retrieve the CollectorUpdates object associated with // this CollectableService if one exists. CollectorUpdates updates = cSvc.getCollectorUpdates(); // Now set the update's deletion flag so the next // time it is selected for execution by the scheduler // the collection will be skipped and the service will not // be rescheduled. LOG.debug( "Marking CollectableService for deletion because a service was deleted: Service nodeid={}, deleted node:{}, " + "service address:{}, deleted interface:{}, service servicename:{}, deleted service name:{}, event source {}", cSvc.getNodeId(), nodeId, addr.getHostName(), ipAddr, cSvc.getServiceName(), svcName, event.getSource()); updates.markForDeletion(); } // Now safe to remove the collectable service from // the collectable services list liter.remove(); } } LOG.debug("serviceDeletedHandler: processing of serviceDeleted event for {}/{}/{} completed.", nodeId, ipAddr, svcName); }
From source file:org.opennms.ng.services.collectd.Collectd.java
/** * Process the 'primarySnmpInterfaceChanged' event. Extract the old and * new primary SNMP interface addresses from the event parms. Any * CollectableService objects located in the collectable services list * which match the IP address of the old primary interface and have a * service name of "SNMP" are flagged for deletion. This will ensure that * the old primary interface is no longer collected against. Finally the * new primary SNMP interface is scheduled. The packages are examined and * new CollectableService objects are created, initialized and scheduled * for collection.//from w w w . j a v a 2s .c o m * * @param event The event to process. * @throws InsufficientInformationException */ private void handlePrimarySnmpInterfaceChanged(Event event) throws InsufficientInformationException { EventUtils.checkNodeId(event); EventUtils.checkInterface(event); LOG.debug("primarySnmpInterfaceChangedHandler: processing primary SNMP interface changed event..."); // Currently only support SNMP data collection. // if (!event.getService().equals("SNMP")) { return; } // Extract the old and new primary SNMP interface addresses from the // event parms. // String oldPrimaryIfAddr = null; String parmName = null; Value parmValue = null; String parmContent = null; for (Parm parm : event.getParmCollection()) { parmName = parm.getParmName(); parmValue = parm.getValue(); if (parmValue == null) { continue; } else { parmContent = parmValue.getContent(); } // old primary SNMP interface (optional parameter) if (parmName.equals(EventConstants.PARM_OLD_PRIMARY_SNMP_ADDRESS)) { oldPrimaryIfAddr = parmContent; } } if (oldPrimaryIfAddr != null) { // Mark the service for deletion so that it will not be // rescheduled // for // collection. // // Iterate over the CollectableService objects in the service // updates map // and mark any which have the same interface address as the old // primary SNMP interface and a service name of "SNMP" for // deletion. // synchronized (getCollectableServices()) { CollectableService cSvc = null; ListIterator<CollectableService> liter = getCollectableServices().listIterator(); while (liter.hasNext()) { cSvc = liter.next(); final InetAddress addr = (InetAddress) cSvc.getAddress(); final String addrString = str(addr); if (addrString != null && addrString.equals(oldPrimaryIfAddr)) { synchronized (cSvc) { // Got a match! Retrieve the CollectorUpdates // object // associated // with this CollectableService. CollectorUpdates updates = cSvc.getCollectorUpdates(); // Now set the deleted flag updates.markForDeletion(); LOG.debug("primarySnmpInterfaceChangedHandler: marking {} as deleted for service SNMP.", oldPrimaryIfAddr); } // Now safe to remove the collectable service from // the collectable services list liter.remove(); } } } } // Now we can schedule the new service... // scheduleForCollection(event); LOG.debug( "primarySnmpInterfaceChangedHandler: processing of primarySnmpInterfaceChanged event for nodeid {} completed.", event.getNodeid()); }
From source file:de.unijena.bioinf.FragmentationTreeConstruction.computation.FragmentationPatternAnalysis.java
/** * Step 6: Decomposition//from www. j av a 2 s.c om * Decompose each peak as well as the parent peak */ public ProcessedInput performDecomposition(ProcessedInput input) { final FormulaConstraints constraints = input.getMeasurementProfile().getFormulaConstraints(); final Ms2Experiment experiment = input.getExperimentInformation(); final Deviation parentDeviation = input.getMeasurementProfile().getAllowedMassDeviation(); // sort again... final ArrayList<ProcessedPeak> processedPeaks = new ArrayList<ProcessedPeak>(input.getMergedPeaks()); Collections.sort(processedPeaks, new ProcessedPeak.MassComparator()); final ProcessedPeak parentPeak = processedPeaks.get(processedPeaks.size() - 1); // decompose peaks final PeakAnnotation<DecompositionList> decompositionList = input .getOrCreatePeakAnnotation(DecompositionList.class); final MassToFormulaDecomposer decomposer = decomposers.getDecomposer(constraints.getChemicalAlphabet()); final Ionization ion = experiment.getPrecursorIonType().getIonization(); final Deviation fragmentDeviation = input.getMeasurementProfile().getAllowedMassDeviation(); final List<MolecularFormula> pmds = decomposer.decomposeToFormulas( experiment.getPrecursorIonType().subtractIonAndAdduct(parentPeak.getOriginalMz()), parentDeviation, constraints); // add adduct to molecular formula of the ion - because the adduct might get lost during fragmentation { final MolecularFormula adduct = experiment.getPrecursorIonType().getAdduct(); final ListIterator<MolecularFormula> iter = pmds.listIterator(); while (iter.hasNext()) { final MolecularFormula f = iter.next(); iter.set(f.add(adduct)); } } decompositionList.set(parentPeak, DecompositionList.fromFormulas(pmds)); int j = 0; for (ProcessedPeak peak : processedPeaks.subList(0, processedPeaks.size() - 1)) { peak.setIndex(j++); decompositionList.set(peak, DecompositionList.fromFormulas( decomposer.decomposeToFormulas(peak.getUnmodifiedMass(), fragmentDeviation, constraints))); } parentPeak.setIndex(processedPeaks.size() - 1); assert parentPeak == processedPeaks.get(processedPeaks.size() - 1); // important: for each two peaks which are within 2*massrange: // => make decomposition list disjoint final Deviation window = fragmentDeviation.multiply(2); for (int i = 1; i < processedPeaks.size() - 1; ++i) { if (window.inErrorWindow(processedPeaks.get(i).getMz(), processedPeaks.get(i - 1).getMz())) { final HashSet<MolecularFormula> right = new HashSet<MolecularFormula>( decompositionList.get(processedPeaks.get(i)).getFormulas()); final ArrayList<MolecularFormula> left = new ArrayList<MolecularFormula>( decompositionList.get(processedPeaks.get(i - 1)).getFormulas()); final double leftMass = ion.subtractFromMass(processedPeaks.get(i - 1).getMass()); final double rightMass = ion.subtractFromMass(processedPeaks.get(i).getMass()); final Iterator<MolecularFormula> leftIter = left.iterator(); while (leftIter.hasNext()) { final MolecularFormula leftFormula = leftIter.next(); if (right.contains(leftFormula)) { if (Math.abs(leftFormula.getMass() - leftMass) < Math .abs(leftFormula.getMass() - rightMass)) { right.remove(leftFormula); } else { leftIter.remove(); } } } decompositionList.set(processedPeaks.get(i - 1), DecompositionList.fromFormulas(left)); decompositionList.set(processedPeaks.get(i), DecompositionList.fromFormulas(right)); } } return postProcess(PostProcessor.Stage.AFTER_DECOMPOSING, input); }
From source file:javazoom.jlgui.player.amp.PlayerUI.java
/** * Play files from a list.//from w ww .ja va2 s . c om * @param files */ protected void playFiles(List files) { if (files.size() > 0) { // Clean the playlist. playlist.removeAllItems(); // Add all dropped files to playlist. ListIterator li = files.listIterator(); while (li.hasNext()) { File file = (File) li.next(); PlaylistItem pli = null; if (file != null) { pli = new PlaylistItem(file.getName(), file.getAbsolutePath(), -1, true); if (pli != null) playlist.appendItem(pli); } } // Start the playlist from the top. playlist.nextCursor(); playlistUI.initPlayList(); setCurrentSong(playlist.getCursor()); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleProjectBaseTable.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 w w. ja v a 2 s . c om ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; ResultSet resultSet = null; CallableStatement stmtReadClassCodeByTenantIdx = null; try { Connection cnx = schema.getCnx(); stmtReadClassCodeByTenantIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".rd_bprjdefccbytenantidx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadClassCodeByTenantIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); 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); stmtReadClassCodeByTenantIdx.execute(); resultSet = (ResultSet) stmtReadClassCodeByTenantIdx.getObject(1); if (resultSet != null) { try { while (resultSet.next()) { classCode = resultSet.getString(1); classCodeList.add(classCode); } } catch (SQLException e) { } } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadClassCodeByTenantIdx != null) { try { stmtReadClassCodeByTenantIdx.close(); } catch (SQLException e) { } stmtReadClassCodeByTenantIdx = 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.cfacc.v2_0.CFAccOracle.CFAccOracleProjectBaseTable.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"); }/*from www . j a v a 2 s . com*/ ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; ResultSet resultSet = null; CallableStatement stmtReadClassCodeByTenantIdx = null; try { Connection cnx = schema.getCnx(); stmtReadClassCodeByTenantIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".rd_bprjdefccbytenantidx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadClassCodeByTenantIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); 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); stmtReadClassCodeByTenantIdx.execute(); resultSet = (ResultSet) stmtReadClassCodeByTenantIdx.getObject(1); if (resultSet != null) { try { while (resultSet.next()) { classCode = resultSet.getString(1); classCodeList.add(classCode); } } catch (SQLException e) { } } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadClassCodeByTenantIdx != null) { try { stmtReadClassCodeByTenantIdx.close(); } catch (SQLException e) { } stmtReadClassCodeByTenantIdx = 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); }