List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:com.projity.reports.view.ReportView.java
private void makeViewer() throws JRException { if (!dirty)/*from www.ja v a 2 s . co m*/ return; documentFrame.showWaitCursor(true); if (cache != null) { // remove old listener cache.removeNodeModelListener(this); } DataSource dataSource; SpreadSheetFieldArray fa = null; if (fieldArray != null) { fa = (SpreadSheetFieldArray) fieldArray.clone(); CollectionUtils.filter(fa, new Predicate() { public boolean evaluate(Object arg0) { return !((Field) arg0).isGraphical(); // get rid of fields that can't be shown } }); } JasperReport report = ReportUtil.getReport(reportDefinition, coord.getProjectTimeIterator(), fa); viewName = DataSourceProvider.getViewName(report); //System.out.println("viewName="+viewName); documentFrame.setComboBoxesViewName(viewName); NodeModel model = null; PredicatedNodeFilterIterator iterator; if (viewName == DataSourceProvider.REPORT_VIEW) { // special case to just use project cache = null; ArrayList list = new ArrayList(); list.add(project); iterator = GeneralFilteredIterator.instance(list.iterator()); } else { model = updateCacheForView(viewName); if (cache == null) { iterator = GeneralFilteredIterator.instance(model.iterator()); //for (Iterator i=GeneralFilteredIterator.instance(model.iterator());i.hasNext();) System.out.println("Report model iterator: "+i.next()); } else { iterator = GeneralFilteredIterator.instance(cache.getIterator()); //for (Iterator i=GeneralFilteredIterator.instance(cache.getIterator());i.hasNext();) System.out.println("Report cache iterator: "+i.next()); } } dataSource = DataSourceProvider.createDataSource(report, project, iterator, model); // projet name is used as report's title // and passed as a parameter HashMap params = new HashMap(); params.put("projectName", project.getName()); //$NON-NLS-1$ JasperPrint jasperPrint = JasperFillManager.fillReport(report, params, dataSource); if (viewer != null) { viewer.changeReport(jasperPrint); } else { viewer = new ReportViewer(jasperPrint); add(viewer, BorderLayout.CENTER); } // add new listener if (cache != null) { cache.addNodeModelListener(this); } dirty = false; documentFrame.showWaitCursor(false); }
From source file:net.sourceforge.fenixedu.domain.teacher.TeacherService.java
public List<OtherService> getOtherServices() { return (List<OtherService>) CollectionUtils.select(getServiceItemsSet(), new Predicate() { @Override/*from w w w .j a v a2 s. com*/ public boolean evaluate(Object arg0) { return arg0 instanceof OtherService; } }); }
From source file:gov.nih.nci.caarray.application.permissions.PermissionsManagementServiceTest.java
/** * @see http://gforge.nci.nih.gov/tracker/index.php?func=detail&aid=12306 *//*from ww w.j av a 2 s. c om*/ @Test public void testAddUserKeepsAnonUserInAnonGroup() throws CSTransactionException, CSObjectNotFoundException { final Predicate anonUserExists = new Predicate() { @Override public boolean evaluate(Object o) { return ((User) o).getLoginName().equals(SecurityUtils.ANONYMOUS_USERNAME); } }; final Group g = (Group) hibernateHelper.getCurrentSession().load(Group.class, SecurityUtils.findGroupByName(SecurityUtils.ANONYMOUS_GROUP).getGroupId()); assertTrue(CollectionUtils.exists(g.getUsers(), anonUserExists)); this.permissionsManagementService.addUsers(SecurityUtils.ANONYMOUS_GROUP, "biostatistician"); hibernateHelper.getCurrentSession().refresh(g); assertTrue(CollectionUtils.exists(g.getUsers(), anonUserExists)); }
From source file:com.epam.cme.storefront.controllers.pages.AccountPageController.java
@RequestMapping(value = "/profile", method = RequestMethod.GET) public String profile(final Model model) throws CMSItemNotFoundException { final List<TitleData> titles = userFacade.getTitles(); final CustomerData customerData = customerFacade.getCurrentCustomer(); if (customerData.getTitleCode() != null) { model.addAttribute("title", CollectionUtils.find(titles, new Predicate() { @Override/*ww w .j a v a 2s . co m*/ public boolean evaluate(final Object object) { if (object instanceof TitleData) { return customerData.getTitleCode().equals(((TitleData) object).getCode()); } return false; } })); } model.addAttribute("customerData", customerData); storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute("breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile")); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountProfilePage; }
From source file:net.sf.wickedshell.ui.shell.ShellView.java
/** * Initializes the menubar of this <code>ShellView</code>. *///from w ww .j a v a 2 s. c o m private void initMenuBar() { IMenuManager manager = getViewSite().getActionBars().getMenuManager(); manager.add(new Separator(ShellID.SHELL_VIEW_MENU_GROUP_MANAGE_INTERNAL)); final IMenuManager subMenuManager = new MenuManager("Active Shell", ShellID.SHELL_VIEW_SUBMENU_ACTIVE_SHELL); manager.add(subMenuManager); manager.addMenuListener(new IMenuListener() { /** * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ @SuppressWarnings("unchecked") public void menuAboutToShow(IMenuManager manager) { subMenuManager.removeAll(); subMenuManager.add(new GroupMarker(ShellID.SHELL_VIEW_SUBMENU_GROUP_AVAILABLE_SHELLS)); Collection<IShellDescriptor> availableOSShellDescriptors = CollectionUtils .select(IShellDescriptor.Manager.getKnownShellDescriptors(), new Predicate() { /** * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object) */ public boolean evaluate(Object object) { IShellDescriptor shellDescriptor = (IShellDescriptor) object; return shellDescriptor.isCurrentOSSupported(); } }); for (Iterator descriptorIterator = availableOSShellDescriptors.iterator(); descriptorIterator .hasNext();) { SetShellDescriptorAction setShellDescriptorAction = new SetShellDescriptorAction( (IShellDescriptor) descriptorIterator.next()); setShellDescriptorAction.setChecked(setShellDescriptorAction.getShellDescriptor().getId() .equals(getShellViewer().getShellFacade().getShellDescriptor().getId())); subMenuManager.appendToGroup(ShellID.SHELL_VIEW_SUBMENU_GROUP_AVAILABLE_SHELLS, setShellDescriptorAction); } } }); manager.add(new RenameShellAction()); manager.add(new Separator(ShellID.SHELL_VIEW_MENU_GROUP_MANAGE_EXTERNAL)); manager.add(new Separator(ShellID.SHELL_VIEW_MENU_GROUP_EXPORT)); manager.add(new Separator(ShellID.SHELL_VIEW_MENU_GROUP_GENERAL)); manager.add(new OpenShellErrorDisplayAction(errorDisplay)); getViewSite().getActionBars().updateActionBars(); }
From source file:net.sourceforge.fenixedu.domain.teacher.TeacherService.java
public List<InstitutionWorkTime> getInstitutionWorkTimes() { return (List<InstitutionWorkTime>) CollectionUtils.select(getServiceItemsSet(), new Predicate() { @Override// w w w . j a va2 s . c om public boolean evaluate(Object arg0) { return arg0 instanceof InstitutionWorkTime; } }); }
From source file:com.jaspersoft.jasperserver.api.security.externalAuth.processors.ExternalUserSetupProcessor.java
protected void alignInternalAndExternalUser(Set remoteExternalUserRoles, User user) { Set<Role> jrsUserRoles = user.getRoles(); logger.info("Starting align for user: " + user.getFullName() + " with remoteExternalUserRoles at size of " + remoteExternalUserRoles.size()); Collection jrsInternalUserRoles = CollectionUtils.select(jrsUserRoles, new Predicate() { public boolean evaluate(Object input) { if (!(input instanceof Role)) { return false; }//from w ww . ja v a 2 s . com return !((Role) input).isExternallyDefined(); } }); if (logger.isDebugEnabled()) { logger.debug("jrsInternalUserRoles: " + roleCollectionToString(jrsInternalUserRoles)); } Collection<Role> jrsInternalRolesNotInRoleMap = CollectionUtils.select(jrsInternalUserRoles, new Predicate() { public boolean evaluate(Object input) { return !getOrganizationRoleMap().containsValue(((Role) input).getRoleName()) && !getOrganizationRoleMap() .containsValue(((Role) input).getRoleName() + ROLE_SUFFIX); } }); if (logger.isDebugEnabled()) { logger.debug("jrsInternalRolesNotInRoleMap: " + roleCollectionToString(jrsInternalRolesNotInRoleMap)); } //assign default internal roles if needed Collection<Role> defaultInternalRolesToAdd = CollectionUtils .subtract(getNewDefaultInternalRoles(user.getUsername()), jrsInternalRolesNotInRoleMap); jrsInternalRolesNotInRoleMap.addAll(defaultInternalRolesToAdd); Collection<Role> newUserRoles = remoteExternalUserRoles; newUserRoles.addAll(jrsInternalRolesNotInRoleMap); if (logger.isDebugEnabled()) { logger.debug("internal and external roles to persist: " + roleCollectionToString(newUserRoles)); } persistRoles(new HashSet<Role>(newUserRoles)); user.setRoles(new HashSet<Role>(newUserRoles)); updateUserAttributes(user); getUserAuthorityService().putUser(new ExecutionContextImpl(), user); }
From source file:com.dp2345.entity.Cart.java
/** * ??//from w w w . j a va 2 s .c o m * * @return ? */ @Transient public Set<GiftItem> getGiftItems() { Set<GiftItem> giftItems = new HashSet<GiftItem>(); for (Promotion promotion : getPromotions()) { if (promotion.getGiftItems() != null) { for (final GiftItem giftItem : promotion.getGiftItems()) { GiftItem target = (GiftItem) CollectionUtils.find(giftItems, new Predicate() { public boolean evaluate(Object object) { GiftItem other = (GiftItem) object; return other != null && other.getGift().equals(giftItem.getGift()); } }); if (target != null) { target.setQuantity(target.getQuantity() + giftItem.getQuantity()); } else { giftItems.add(giftItem); } } } } return giftItems; }
From source file:com.cyberway.issue.crawler.extractor.ExtractorHTMLTest.java
/** * Test a particular <embed src=...> construct that was suspicious in * the No10GovUk crawl.// ww w .ja va 2s . c om * * @throws URIException */ public void testEmbedSrc() throws URIException { CrawlURI curi = new CrawlURI(UURIFactory.getInstance("http://www.example.org")); // An example from http://www.records.pro.gov.uk/documents/prem/18/1/default.asp?PageId=62&qt=true CharSequence cs = "<embed src=\"/documents/prem/18/1/graphics/qtvr/" + "hall.mov\" width=\"320\" height=\"212\" controller=\"true\" " + "CORRECTION=\"FULL\" pluginspage=\"http://www.apple.com/" + "quicktime/download/\" /> "; this.extractor.extract(curi, cs); assertTrue(CollectionUtils.exists(curi.getOutLinks(), new Predicate() { public boolean evaluate(Object object) { return ((Link) object).getDestination().toString() .indexOf("/documents/prem/18/1/graphics/qtvr/hall.mov") >= 0; } })); }
From source file:net.sourceforge.fenixedu.domain.teacher.TeacherService.java
public ReductionService getReductionService() { return (ReductionService) CollectionUtils.find(getServiceItemsSet(), new Predicate() { @Override/* w ww.jav a 2 s .com*/ public boolean evaluate(Object arg0) { return arg0 instanceof ReductionService; } }); }