List of usage examples for org.apache.commons.collections CollectionUtils collect
public static Collection collect(Iterator inputIterator, final Transformer transformer, final Collection outputCollection)
From source file:org.kuali.mobility.events.service.EventsServiceImpl.java
@GET @Path("/byCategory/{categoryId}") @Override//from w w w . j a v a 2 s . c o m public List<EventImpl> getAllEvents(@QueryParam(value = "campus") String campus, @PathParam(value = "categoryId") String categoryId) { getDao().initData(campus, categoryId); List<Event> events = (List<Event>) CollectionUtils.select(getDao().getEvents(), new EventPredicate(campus, categoryId, null)); Collections.sort(events, new EventComparator()); List<EventImpl> eventList = new ArrayList<EventImpl>(); CollectionUtils.collect(events, new EventTransform(), eventList); return eventList; }
From source file:org.kuali.mobility.events.service.EventsServiceImpl.java
@GET @Path("/categories") @Override//from w w w . j a v a 2 s . co m public List<CategoryImpl> getCategoriesByCampus(@QueryParam(value = "campus") String campus) { List<Category> categories = new ArrayList<Category>(); LOG.debug("Loading categories for campus [" + campus + "]"); getDao().initData(campus); categories = (List<Category>) CollectionUtils.select(getDao().getCategories(), new CategoryPredicate(campus, null)); LOG.debug("Number of categories for campus [" + campus + "] = " + categories.size()); List<CategoryImpl> categoryObjs = new ArrayList<CategoryImpl>(); for (int i = 0; i < categories.size(); i++) { Collection events = CollectionUtils.select(getDao().getEvents(), new EventPredicate(campus, categories.get(i).getCategoryId(), null)); if (events.size() > 0) { categories.get(i).setHasEvents(true); } else { categories.get(i).setHasEvents(false); } } CollectionUtils.collect(categories, new CategoryTransform(), categoryObjs); return categoryObjs; }
From source file:org.kuali.mobility.events.service.EventsServiceImpl.java
@GET @Deprecated/*from w w w. j a va2 s . c o m*/ @Path("/current/{campus}/{categoryId}") @Override public List<EventImpl> getAllEventsByDateCurrent(@QueryParam(value = "campus") String campus, @QueryParam(value = "categoryId") String categoryId, @QueryParam(value = "mon-dd-yy") Date dateCurrent) { List<EventImpl> events = getAllEvents(campus, categoryId); List<Event> resultEvents = new ArrayList<Event>(); Iterator it = events.iterator(); while (it.hasNext()) { Event obj = (Event) it.next(); Date obtainedDate = obj.getStartDate(); if (obtainedDate.equals(dateCurrent)) { resultEvents.add(obj); } } List<EventImpl> resultEventObjs = new ArrayList<EventImpl>(); CollectionUtils.collect(resultEvents, new EventTransform(), resultEventObjs); return resultEventObjs; }
From source file:org.kuali.mobility.events.service.EventsServiceImpl.java
@GET @Path("/between/{campus}/{categoryId}") @Deprecated// w ww .j ava2 s. c o m @Override public List<EventImpl> getAllEventsByDateFromTo(@QueryParam(value = "campus") String campus, @QueryParam(value = "categoryId") String categoryId, @QueryParam(value = "from-mon-dd-yy") Date from, @QueryParam(value = "to-mon-dd-yy") Date to) { List<EventImpl> events = getAllEvents(campus, categoryId); List<Event> resultEvents = new ArrayList<Event>(); Iterator it = events.iterator(); while (it.hasNext()) { Event obj = (Event) it.next(); if (!obj.getStartDate().before(from) || !obj.getEndDate().after(to)) { resultEvents.add(obj); } } List<EventImpl> resultEventObjs = new ArrayList<EventImpl>(); CollectionUtils.collect(resultEvents, new EventTransform(), resultEventObjs); return resultEventObjs; }
From source file:org.kuali.mobility.events.service.EventsServiceImpl.java
@GET @Path("/fordate/{campus}/{categoryId}") @Deprecated/* ww w .ja v a 2 s . co m*/ @Override public List<EventImpl> getAllEventsByDateSpecific(@QueryParam(value = "campus") String campus, @QueryParam(value = "categoryId") String categoryId, @QueryParam(value = "yyyy-mm-dd") String specific) { List<? extends Event> events = getAllEvents(campus, categoryId); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List<Event> resultEvents = new ArrayList<Event>(); try { for (Event e : events) { String startDate = sdf.format(e.getStartDate()); if (specific.equalsIgnoreCase(startDate)) { LOG.debug("Found match for event date [" + startDate + "] to [" + specific + "]."); resultEvents.add(e); } } } catch (Exception ex) { LOG.info("Failure from getAllEventsByDateSpecific method"); ex.printStackTrace(); } LOG.debug("Number of events matching date: " + resultEvents.size()); List<EventImpl> resultEventObjs = new ArrayList<EventImpl>(); CollectionUtils.collect(resultEvents, new EventTransform(), resultEventObjs); LOG.debug("Number of events after transform: " + resultEventObjs.size()); return resultEventObjs; }
From source file:org.kuali.mobility.events.util.CategoryTransform.java
@Override public CategoryImpl transform(Object obj) { CategoryImpl proxy = null;/* w w w. java 2s .c o m*/ if (obj instanceof Category) { proxy = new CategoryImpl(); proxy.setCategoryId(((Category) obj).getCategoryId()); proxy.setCampus(((Category) obj).getCampus()); proxy.setOrder(((Category) obj).getOrder()); proxy.setReturnPage(((Category) obj).getReturnPage()); proxy.setTitle(((Category) obj).getTitle()); proxy.setUrlString(((Category) obj).getUrlString()); proxy.setHasEvents(((Category) obj).getHasEvents()); List<DayImpl> days = new ArrayList<DayImpl>(); CollectionUtils.collect(((Category) obj).getDays(), new DayTransform(), days); proxy.setDays(days); } return proxy; }
From source file:org.kuali.mobility.events.util.DayTransform.java
@Override public Object transform(Object obj) { DayImpl proxy = null;/* w ww .j av a 2 s . c o m*/ if (obj instanceof Day) { proxy = (DayImpl) obj; proxy.setDate(((Day) obj).getDate()); List<EventImpl> events = new ArrayList<EventImpl>(); CollectionUtils.collect(((Day) obj).getEvents(), new EventTransform(), events); proxy.setEvents(events); } return proxy; }
From source file:org.kuali.mobility.events.util.EventTransform.java
@Override public Object transform(Object obj) { EventImpl proxy = null;//from ww w. ja v a2 s . c o m if (obj instanceof EventImpl) { proxy = (EventImpl) obj; } else if (obj instanceof Event) { proxy = new EventImpl(); proxy.setEventId(((Event) obj).getEventId()); proxy.setType(((Event) obj).getType()); proxy.setTitle(((Event) obj).getTitle()); proxy.setStartDate(((Event) obj).getStartDate()); proxy.setEndDate(((Event) obj).getEndDate()); proxy.setDisplayStartTime(((Event) obj).getDisplayStartTime()); proxy.setDisplayEndTime(((Event) obj).getDisplayEndTime()); proxy.setDisplayStartDate(((Event) obj).getDisplayStartDate()); proxy.setDisplayEndDate(((Event) obj).getDisplayEndDate()); proxy.setLink(((Event) obj).getLink()); proxy.setLocation(((Event) obj).getLocation()); proxy.setAllDay(((Event) obj).isAllDay()); proxy.setCategory(((Event) obj).getCategory()); proxy.setCost(((Event) obj).getCost()); proxy.setDescription(((Event) obj).getDescription()); proxy.setOtherInfo(((Event) obj).getOtherInfo()); List<EventContactImpl> contacts = new ArrayList<EventContactImpl>(); CollectionUtils.collect(((Event) obj).getContact(), new EventContactTransform(), contacts); proxy.setContact(contacts); } return proxy; }
From source file:org.kuali.mobility.news.service.NewsServiceImpl.java
@Override @GET/*from w w w.ja v a2 s . c o m*/ @Path("/sources/getAll") public List<NewsSourceImpl> getAllNewsSources(@QueryParam("compact") Boolean compact) { LOG.debug("Called getAllNewsSources web service."); List<NewsSourceImpl> sources = new ArrayList<NewsSourceImpl>(); if (null != compact && compact.booleanValue()) { CollectionUtils.collect(getDao().findAllNewsSources(), new CompactNewsSourceTransform(), sources); } else { CollectionUtils.collect(getDao().findAllNewsSources(), new NewsSourceTransform(), sources); } Collections.sort(sources, new NewsServiceSort()); return sources; }
From source file:org.kuali.mobility.news.service.NewsServiceImpl.java
@GET @Path("/sources/getAllArticles") public List<NewsArticleImpl> getAllNewsArticles(@QueryParam("compact") Boolean compact) { List<NewsArticleImpl> articles = new ArrayList<NewsArticleImpl>(); List<NewsArticleImpl> articleList = new ArrayList<NewsArticleImpl>(); List<NewsArticleImpl> fullArticleList = new ArrayList<NewsArticleImpl>(); List<NewsSourceImpl> sources = new ArrayList<NewsSourceImpl>(); if (null != compact && compact.booleanValue()) { CollectionUtils.collect(getDao().findAllNewsSources(), new CompactNewsSourceTransform(), sources); } else {// w w w . ja v a 2 s . c o m CollectionUtils.collect(getDao().findAllNewsSources(), new NewsSourceTransform(), sources); } Collections.sort(sources, new NewsServiceSort()); for (NewsSourceImpl source : sources) { articles = (List<NewsArticleImpl>) source.getArticles(); if (articles != null && !articles.isEmpty()) { articleList.addAll(articles); } } CollectionUtils.collect(articleList, new NewsArticleTransform(), fullArticleList); Collections.sort(fullArticleList, new Comparator<NewsArticleImpl>() { public int compare(final NewsArticleImpl object1, final NewsArticleImpl object2) { return object1.getPublishDate().after(object2.getPublishDate()) ? 1 : -1; } }); Collections.reverse(fullArticleList); return fullArticleList; }