List of usage examples for org.apache.commons.collections IteratorUtils toList
public static List toList(Iterator iterator)
From source file:org.kuali.kfs.coa.service.impl.AccountServiceImpl.java
/** * get all accounts in the system. This is needed by a sufficient funds rebuilder job * * @return iterator of all accounts//from w ww .ja va 2s .c om */ @Override public Iterator getAllAccounts() { LOG.debug("getAllAccounts() started"); Iterator accountIter = accountDao.getAllAccounts(); // FIXME: this loads all accounts into memory - could blow server return IteratorUtils.toList(accountIter).iterator(); }
From source file:org.kuali.kfs.gl.service.impl.AccountBalanceServiceImpl.java
/** * This method gets the number of the available account balances according to input fields and values * /* w w w. java 2 s .c o m*/ * @param fieldValues the input fields and values * @param isConsolidated determine whether the search results are consolidated * @return the number of the available account balances * @see org.kuali.kfs.gl.service.AccountBalanceService#getAvailableAccountBalanceCount(java.util.Map, boolean) */ public Integer getAvailableAccountBalanceCount(Map fieldValues, boolean isConsolidated) { Integer recordCount = null; if (!isConsolidated) { recordCount = OJBUtility.getResultSizeFromMap(fieldValues, new AccountBalance()).intValue(); } else { Iterator recordCountIterator = accountBalanceDao.findConsolidatedAvailableAccountBalance(fieldValues); // TODO: WL: why build a list and waste time/memory when we can just iterate through the iterator and do a count? List recordCountList = IteratorUtils.toList(recordCountIterator); recordCount = recordCountList.size(); } return recordCount; }
From source file:org.kuali.kfs.gl.service.impl.BalanceServiceImpl.java
/** * This method finds the summary records of balance entries according to input fields and values * * @param fieldValues the input fields and values * @param isConsolidated consolidation option is applied or not * @return the summary records of balance entries * @see org.kuali.kfs.gl.service.BalanceService#getBalanceRecordCount(java.util.Map, boolean) *//*from w w w . jav a 2 s. c o m*/ @Override public Integer getBalanceRecordCount(Map fieldValues, boolean isConsolidated) { LOG.debug("getBalanceRecordCount() started"); Integer recordCount = null; if (!isConsolidated) { recordCount = OJBUtility.getResultSizeFromMap(fieldValues, new Balance()).intValue(); } else { Iterator recordCountIterator = balanceDao.getConsolidatedBalanceRecordCount(fieldValues, getEncumbranceBalanceTypes(fieldValues)); // TODO: WL: why build a list and waste time/memory when we can just iterate through the iterator and do a count? List recordCountList = IteratorUtils.toList(recordCountIterator); recordCount = recordCountList.size(); } return recordCount; }
From source file:org.kuali.kfs.module.ld.service.impl.LaborLedgerBalanceServiceImpl.java
/** * @see org.kuali.kfs.module.ld.service.LaborLedgerBalanceService#getBalanceRecordCount(Map, boolean, List) *//*from w w w . j a v a 2 s .c o m*/ @Override @NonTransactional public Integer getBalanceRecordCount(Map fieldValues, boolean isConsolidated, List<String> encumbranceBalanceTypes, boolean noZeroAmounts) { LOG.debug("getBalanceRecordCount() started"); Integer recordCount = null; if (!isConsolidated) { recordCount = OJBUtility.getResultSizeFromMap(fieldValues, new LedgerBalance()).intValue(); } else { Iterator recordCountIterator = laborLedgerBalanceDao.getConsolidatedBalanceRecordCount(fieldValues, encumbranceBalanceTypes, noZeroAmounts); List recordCountList = IteratorUtils.toList(recordCountIterator); recordCount = recordCountList.size(); } return recordCount; }
From source file:org.kuali.kfs.module.ld.service.impl.LaborLedgerBalanceServiceImpl.java
@Override @NonTransactional/*from w w w .j av a2s .co m*/ @Deprecated public Integer getBalanceRecordCount(Map fieldValues, boolean isConsolidated, List<String> encumbranceBalanceTypes) { LOG.debug("getBalanceRecordCount() started"); Integer recordCount = null; if (!isConsolidated) { recordCount = OJBUtility.getResultSizeFromMap(fieldValues, new LedgerBalance()).intValue(); } else { Iterator recordCountIterator = laborLedgerBalanceDao.getConsolidatedBalanceRecordCount(fieldValues, encumbranceBalanceTypes); List recordCountList = IteratorUtils.toList(recordCountIterator); recordCount = recordCountList.size(); } return recordCount; }
From source file:org.kuali.kfs.sys.util.TransactionalServiceUtils.java
/** * Copys iterators so that they may be used outside of this class. Often, the DAO may * return iterators that may not be used outside of this class because the transaction/ * connection may be automatically closed by Spring. * //from ww w .java2 s .c om * This method copies all of the elements in the OJB backed iterators into list-based iterators * by placing the returned BOs into a list * * @param iter an OJB backed iterator to copy * @return an Iterator that may be used outside of this class */ public static <E> Iterator<E> copyToExternallyUsuableIterator(Iterator<E> iter) { return IteratorUtils.toList(iter).iterator(); }
From source file:org.kuali.ole.gl.service.impl.BalanceServiceImpl.java
/** * This method finds the summary records of balance entries according to input fields and values * //w w w.j a v a2 s. c o m * @param fieldValues the input fields and values * @param isConsolidated consolidation option is applied or not * @return the summary records of balance entries * @see org.kuali.ole.gl.service.BalanceService#getBalanceRecordCount(java.util.Map, boolean) */ public Integer getBalanceRecordCount(Map fieldValues, boolean isConsolidated) { LOG.debug("getBalanceRecordCount() started"); Integer recordCount = null; if (!isConsolidated) { recordCount = OJBUtility.getResultSizeFromMap(fieldValues, new Balance()).intValue(); } else { Iterator recordCountIterator = balanceDao.getConsolidatedBalanceRecordCount(fieldValues, getEncumbranceBalanceTypes(fieldValues)); // TODO: WL: why build a list and waste time/memory when we can just iterate through the iterator and do a count? List recordCountList = IteratorUtils.toList(recordCountIterator); recordCount = recordCountList.size(); } return recordCount; }
From source file:org.metaabm.impl.SContextImpl.java
@SuppressWarnings("unchecked") public List<SAgent> getAllSubAgents() { List<SAgent> res = IteratorUtils.toList(allAgentsTree()); res.remove(this); return res;//from w ww . ja v a2 s . c o m }
From source file:org.onosproject.drivers.utilities.YangXmlUtilsTest.java
/** * Tests getting a single object configuration via passing the path and the map of the desired values. * * @throws ConfigurationException if the testing xml file is not there. *///www. j av a 2 s . com @Test public void testGetXmlConfigurationFromMap() throws ConfigurationException { Map<String, String> pathAndValues = new HashMap<>(); pathAndValues.put("capable-switch.id", "openvswitch"); pathAndValues.put("switch.id", "ofc-bridge"); pathAndValues.put("controller.id", "tcp:1.1.1.1:1"); pathAndValues.put("controller.ip-address", "1.1.1.1"); XMLConfiguration cfg = utils.getXmlConfiguration(OF_CONFIG_XML_PATH, pathAndValues); testCreateConfig.load(getClass().getResourceAsStream("/testCreateSingleYangConfig.xml")); assertNotEquals("Null testConfiguration", new XMLConfiguration(), testCreateConfig); assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()), IteratorUtils.toList(cfg.getKeys())); assertEquals("Wrong string configuaration", utils.getString(testCreateConfig), utils.getString(cfg)); }
From source file:org.onosproject.drivers.utilities.YangXmlUtilsTest.java
/** * Tests getting a multiple object nested configuration via passing the path * and a list of YangElements containing with the element and desired value. * * @throws ConfigurationException//w w w .j av a 2s . c o m */ @Test public void getXmlConfigurationFromYangElements() throws ConfigurationException { assertNotEquals("Null testConfiguration", new XMLConfiguration(), testCreateConfig); testCreateConfig.load(getClass().getResourceAsStream("/testYangConfig.xml")); List<YangElement> elements = new ArrayList<>(); elements.add(new YangElement("capable-switch", ImmutableMap.of("id", "openvswitch"))); elements.add(new YangElement("switch", ImmutableMap.of("id", "ofc-bridge"))); List<ControllerInfo> controllers = ImmutableList.of( new ControllerInfo(IpAddress.valueOf("1.1.1.1"), 1, "tcp"), new ControllerInfo(IpAddress.valueOf("2.2.2.2"), 2, "tcp")); controllers.forEach(cInfo -> { elements.add(new YangElement("controller", ImmutableMap.of("id", cInfo.target(), "ip-address", cInfo.ip().toString()))); }); XMLConfiguration cfg = new XMLConfiguration( YangXmlUtils.getInstance().getXmlConfiguration(OF_CONFIG_XML_PATH, elements)); assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()), IteratorUtils.toList(cfg.getKeys())); assertEquals("Wrong string configuaration", utils.getString(testCreateConfig), utils.getString(cfg)); }