List of usage examples for org.apache.commons.collections CollectionUtils forAllDo
public static void forAllDo(Collection collection, Closure closure)
From source file:org.squashtest.tm.web.internal.controller.milestone.MilestoneModelUtils.java
public static String milestoneLabelsOrderByDate(Set<Milestone> milestones) { final StringBuilder sb = new StringBuilder(); ArrayList<Milestone> liste = new ArrayList<>(milestones); Collections.sort(liste, new Comparator<Milestone>() { @Override/*from w ww . j av a 2 s . co m*/ public int compare(Milestone m1, Milestone m2) { return m1.getEndDate().after(m2.getEndDate()) ? 1 : -1; } }); CollectionUtils.forAllDo(liste, new Closure() { @Override public void execute(Object input) { Milestone m = (Milestone) input; sb.append(m.getLabel()); sb.append(SEPARATOR); } }); sb.delete(Math.max(sb.length() - SEPARATOR.length(), 0), sb.length()); return sb.toString(); }
From source file:org.xlcloud.console.virtualClusters.controllers.wizard.VirtualClusterTypeBean.java
private void collectAvailableTags() { availableTags = new HashSet<String>(); CollectionUtils.forAllDo(vcDefinitions, new VirtualClusterDefinitionTagCollectorClosure(availableTags)); }
From source file:pl.edu.icm.cermine.bibref.transformers.BibTeXToBibEntryReaderTest.java
@Before public void setUp() { reader = new BibTeXToBibEntryReader(); bibtex = StandardDataExamples.getReferencesAsBibTeX(); entries = StandardDataExamples.getReferencesAsBibEntry(); CollectionUtils.forAllDo(entries, new Closure() { @Override/*from ww w . ja v a 2 s .co m*/ public void execute(Object input) { removeTextAndIndexes((BibEntry) input); } }); }
From source file:ru.org.linux.spring.boxlets.TopTenBoxlet.java
@Override @RequestMapping("/top10.boxlet") protected ModelAndView getData(HttpServletRequest request) { ProfileProperties profile = Template.getTemplate(request).getProf(); final int itemsPerPage = profile.getMessages(); String style = profile.getStyle(); List<TopTenDao.TopTenMessageDTO> list = topTenDao.getMessages(); CollectionUtils.forAllDo(list, new Closure() { @Override/*from w w w . j a v a 2 s. c o m*/ public void execute(Object o) { TopTenDao.TopTenMessageDTO dto = (TopTenDao.TopTenMessageDTO) o; int tmp = dto.getAnswers() / itemsPerPage; tmp = (dto.getAnswers() % itemsPerPage > 0) ? tmp + 1 : tmp; dto.setPages(tmp); } }); Map<String, Object> params = new HashMap<String, Object>(); params.put("messages", list); params.put("style", style); return new ModelAndView("boxlets/top10", params); }
From source file:ru.org.linux.spring.boxlets.TopTenBoxletImpl.java
@Override @RequestMapping("/top10.boxlet") protected ModelAndView getData(HttpServletRequest request) { ProfileProperties profile = Template.getTemplate(request).getProf(); final int itemsPerPage = profile.getMessages(); String style = profile.getStyle(); List<TopTenDaoImpl.TopTenMessageDTO> list = topTenDao.getMessages(); CollectionUtils.forAllDo(list, new Closure() { @Override/*from ww w .j a v a 2s .com*/ public void execute(Object o) { TopTenDaoImpl.TopTenMessageDTO dto = (TopTenDaoImpl.TopTenMessageDTO) o; int tmp = dto.getAnswers() / itemsPerPage; tmp = (dto.getAnswers() % itemsPerPage > 0) ? tmp + 1 : tmp; dto.setPages(tmp); } }); Map<String, Object> params = new HashMap<String, Object>(); params.put("messages", list); params.put("style", style); return new ModelAndView("boxlets/top10", params); }
From source file:ru.org.linux.spring.dao.TagDaoImpl.java
public List<TagDTO> getTags(int tagcount) { String sql = "select value,counter from tags_values where counter>0 order by counter desc limit ?"; final MutableDouble maxc = new MutableDouble(1); final MutableDouble minc = new MutableDouble(-1); List<TagDTO> result = jdbcTemplate.query(sql, new RowMapper<TagDTO>() { @Override/*from w w w .j a v a 2 s . c o m*/ public TagDTO mapRow(ResultSet rs, int rowNum) throws SQLException { TagDTO result = new TagDTO(); result.setValue(rs.getString("value")); double counter = Math.log(rs.getInt("counter")); result.setCounter(counter); if (maxc.doubleValue() < counter) { maxc.setValue(counter); } if (minc.doubleValue() < 0 || counter < minc.doubleValue()) { minc.setValue(counter); } return result; } }, tagcount); if (minc.doubleValue() < 0) { minc.setValue(0); } CollectionUtils.forAllDo(result, new Closure() { @Override public void execute(Object o) { TagDTO tag = (TagDTO) o; tag.setWeight((int) Math.round( 10 * (tag.getCounter() - minc.doubleValue()) / (maxc.doubleValue() - minc.doubleValue()))); } }); Collections.sort(result); return result; }
From source file:tds.websim.dal.test.SessionDaoTest.java
/** * Tests getClients using a valid {@code userId}: expect to return a list of * clients with identical values as they are specified at the beginning of the * test (orders don't matter).//from w ww . ja v a 2s.co m */ @Test public void testGetClients_validUserId() { final List<String> expectedResults = new ArrayList<>(); expectedResults.add("Hawaii"); expectedResults.add("Ohio"); expectedResults.add("oregon"); final String userId = "paul"; Clients clients = this.doGetClient(userId); CollectionUtils.forAllDo(clients, new Closure() { @Override public void execute(Object input) { // TODO Auto-generated method stub Client c = (Client) input; Assert.assertTrue(String.format("%1$s should exist in the returned list given userId = %2$s.", c.getName(), userId), expectedResults.contains(c.getName())); } }); }