List of usage examples for org.apache.commons.collections PredicateUtils instanceofPredicate
public static Predicate instanceofPredicate(Class type)
From source file:gov.nih.nci.firebird.service.task.MissingRoleTasksGenerator.java
private boolean containsInvestigatorRegistration(Set<AbstractProtocolRegistration> invitedRegistrations) { return CollectionUtils.exists(invitedRegistrations, PredicateUtils.instanceofPredicate(InvestigatorRegistration.class)); }
From source file:gov.nih.nci.firebird.service.task.MissingRoleTasksGenerator.java
private boolean containsSubInvestigatorRegistration(Set<AbstractProtocolRegistration> invitedRegistrations) { return CollectionUtils.exists(invitedRegistrations, PredicateUtils.instanceofPredicate(SubInvestigatorRegistration.class)); }
From source file:de.hybris.platform.b2bacceleratorfacades.order.impl.DefaultB2BOrderFacade.java
protected void addCommentToWorkflowAction(final WorkflowActionModel workflowActionModel, final String comment) { final PrincipalModel principalAssigned = workflowActionModel.getPrincipalAssigned(); final B2BApprovalProcessModel attachment = (B2BApprovalProcessModel) CollectionUtils.find( workflowActionModel.getAttachmentItems(), PredicateUtils.instanceofPredicate(B2BApprovalProcessModel.class)); final OrderModel order = attachment.getOrder(); final Collection<B2BPermissionResultModel> b2bPermissionResults = order.getPermissionResults(); for (final B2BPermissionResultModel b2bPermissionResultModel : b2bPermissionResults) { if (b2bPermissionResultModel.getApprover().getUid().equals(principalAssigned.getUid())) { b2bPermissionResultModel.setNote(comment); getModelService().save(b2bPermissionResultModel); }/*from ww w .j ava 2 s . com*/ } }
From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultCompanyB2BCommerceFacade.java
protected B2BSelectionData populateRolesForCustomer(final B2BCustomerModel customerModel, final B2BSelectionData b2BSelectionData) { final List<String> roles = new ArrayList<String>(); final Set<PrincipalGroupModel> roleModels = new HashSet<PrincipalGroupModel>(customerModel.getGroups()); CollectionUtils.filter(roleModels,//from w w w.ja va2s. c o m PredicateUtils.notPredicate(PredicateUtils.instanceofPredicate(B2BUnitModel.class))); CollectionUtils.filter(roleModels, PredicateUtils.notPredicate(PredicateUtils.instanceofPredicate(B2BUserGroupModel.class))); for (final PrincipalGroupModel role : roleModels) { roles.add(role.getUid()); } b2BSelectionData.setRoles(roles); return b2BSelectionData; }
From source file:de.hybris.platform.b2badmin.services.impl.B2BUnitServiceTest.java
@Test public void shouldGetParentUnitForCustomerWithMultipleUnitsAssigned() { sessionService.executeInLocalView(new SessionExecutionBody() { @Override//w w w . j av a2s. c o m public void executeWithoutResult() { final B2BCustomerModel user = userService.getUserForUID("GC CEO", B2BCustomerModel.class); // assign user to session login(user); final B2BUnitModel parent = b2bUnitService.getParent(user); Assert.assertNotNull(parent); // try to add the member which the user is already a member of b2bUnitService.addMember(parent, user); modelService.save(user); Assert.assertEquals(1, CollectionUtils .select(user.getGroups(), PredicateUtils.instanceofPredicate(B2BUnitModel.class)).size()); // assign a 2nd unit to GC CEO final B2BUnitModel unitUK = b2bUnitService.getUnitForUid("GC Sales UK"); b2bUnitService.addMember(unitUK, user); modelService.save(user); Assert.assertEquals(2, CollectionUtils .select(user.getGroups(), PredicateUtils.instanceofPredicate(B2BUnitModel.class)).size()); b2bUnitService.updateParentB2BUnit(unitUK, user); modelService.save(user); Assert.assertEquals(unitUK, b2bUnitService.getParent(user)); // make sure user is still belongs to 2 units Assert.assertEquals(2, CollectionUtils .select(user.getGroups(), PredicateUtils.instanceofPredicate(B2BUnitModel.class)).size()); } }, userService.getAdminUser()); }
From source file:com.architexa.diagrams.relo.graph.GraphLayoutManager.java
private void adjustNodeCoords(Graph graph, Map<AbstractGraphicalEditPart, Object> partsToCellMap, Point defaultPos) {// ww w. j a va2 s. com Set<AbstractGraphicalEditPart> newParts = new HashSet<AbstractGraphicalEditPart>(); newParts.addAll(partsToCellMap.keySet()); newParts.removeAll(ageMgr.getOldParts()); Set<AbstractGraphicalEditPart> newEdges = new HashSet<AbstractGraphicalEditPart>(newParts); CollectionUtils.filter(newParts, PredicateUtils.notPredicate(PredicateUtils.instanceofPredicate(AbstractConnectionEditPart.class))); newEdges.removeAll(newParts); for (AbstractGraphicalEditPart edge : new HashSet<AbstractGraphicalEditPart>(newEdges)) { if (nodeConstrainedConn((AbstractConnectionEditPart) edge)) newEdges.remove(edge); } //System.err.println("adjusting graph: " + newNodes.size() + " done: " + oldParts.size()); GraphLayoutRules.assertRulesForNewParts(graph, newParts, newEdges, partsToCellMap, ageMgr, defaultPos, this, rootEditPart); // save for next time //fixedLocationParts.addAll(newNodes); }
From source file:com.architexa.diagrams.relo.jdt.parts.ClassEditPart.java
@Override public void buildMultipleSelectionContextMenu(IMenuManager menu) { super.buildMultipleSelectionContextMenu(menu); // TODO: get this working on methods/ packages also test for ALL cases IAction interactionAction = new Action("Show Interactions") { @SuppressWarnings("unchecked") @Override/*from w w w .j av a2 s .c o m*/ public void run() { List<ArtifactEditPart> selEPs = getViewer().getSelectedEditParts(); CollectionUtils.filter(new ArrayList<ArtifactEditPart>(selEPs), PredicateUtils.instanceofPredicate(ClassEditPart.class)); if (selEPs.size() < 2) return; List<Resource> selResources = new ArrayList<Resource>(); for (ArtifactEditPart selEP : selEPs) { selResources.add(selEP.getElementRes()); } final ReloController rc = getRootController(); CompoundCommand addedInteractionsCC = new CompoundCommand("Show Interactions"); for (ArtifactEditPart aep : selEPs) { for (Artifact child : aep.getArtifact().getArt().queryChildrenArtifacts(getRepo())) { for (Artifact calledArt : child.queryArtList(getRepo(), DirectedRel.getFwd(RJCore.calls))) { Artifact parentOfCalledArt = calledArt.queryParentArtifact(getRepo()); if (parentOfCalledArt == null || aep.getElementRes().equals(parentOfCalledArt.elementRes) // call to same class (not showing these) || !selResources.contains(parentOfCalledArt.elementRes)) // call not made to a selected class { continue; } addedInteractionsCC .add(new FindOrAddNodesAndRelCmd(rc, child, RJCore.calls, calledArt)); } } } rc.execute(addedInteractionsCC); } }; menu.appendToGroup(RSEContextMenuProvider.GROUP_RSE_TOOLS, interactionAction); final List<ArtifactEditPart> selEPs = getViewer().getSelectedEditParts(); if (!allHighlightable(selEPs)) return; addColorAction(menu, selEPs); }
From source file:org.archive.modules.net.CrawlServer.java
/** Update the robotstxt * * @param curi the crawl URI containing the fetched robots.txt * @throws IOException/*from w w w .j a v a 2 s . com*/ */ public synchronized void updateRobots(CrawlURI curi) { robotsFetched = System.currentTimeMillis(); boolean gotSomething = curi.getFetchType() == HTTP_GET && (curi.getFetchStatus() > 0 || curi.getFetchStatus() == S_DEEMED_NOT_FOUND); if (!gotSomething && curi.getFetchAttempts() < MIN_ROBOTS_RETRIES) { // robots.txt lookup failed, still trying, no reason to consider IGNORE yet validRobots = false; return; } // special deeming for a particular kind of connection-lost (empty server response) if (curi.getFetchStatus() == S_CONNECT_LOST && CollectionUtils.exists(curi.getNonFatalFailures(), PredicateUtils.instanceofPredicate(NoHttpResponseException.class))) { curi.setFetchStatus(S_DEEMED_NOT_FOUND); gotSomething = true; } if (!gotSomething) { // robots.txt fetch failed and exceptions (ignore/deeming) don't apply; no valid robots info yet validRobots = false; return; } int fetchStatus = curi.getFetchStatus(); if (fetchStatus < 200 || fetchStatus >= 300) { // Not found or anything but a status code in the 2xx range is // treated as giving access to all of a sites' content. // This is the prevailing practice of Google, since 4xx // responses on robots.txt are usually indicative of a // misconfiguration or blanket-block, not an intentional // indicator of partial blocking. // TODO: consider handling server errors, redirects differently robotstxt = Robotstxt.NO_ROBOTS; validRobots = true; return; } InputStream contentBodyStream = null; try { BufferedReader reader; contentBodyStream = curi.getRecorder().getContentReplayInputStream(); reader = new BufferedReader(new InputStreamReader(contentBodyStream)); robotstxt = new Robotstxt(reader); validRobots = true; } catch (IOException e) { robotstxt = Robotstxt.NO_ROBOTS; logger.log(Level.WARNING, "problem reading robots.txt for " + curi, e); validRobots = true; curi.getNonFatalFailures().add(e); } finally { IOUtils.closeQuietly(contentBodyStream); } }
From source file:org.cesecore.util.query.QueryGenerator.java
/** * Generates the SQL query according to the criteria passed in generator. * /*w w w . java2s.c o m*/ * @return generated Query. */ public String generate() { if (query.isEmpty()) { final List<Elem> elements = criteria.getElements(); final List<Elem> terms = new ArrayList<Elem>(); final List<Elem> clauses = new ArrayList<Elem>(); CollectionUtils.selectRejected(elements, PredicateUtils.instanceofPredicate(Order.class), terms); CollectionUtils.select(elements, PredicateUtils.instanceofPredicate(Order.class), clauses); if (terms.size() > 0) { query.where(); } termTraversal(terms); clauseTraversal(clauses); } return query.toString(); }
From source file:org.signserver.server.cryptotokens.CryptoTokenHelper.java
private static boolean shouldBeIncluded(TokenEntry tokenEntry, QueryCriteria qc) throws QueryException { final List<Elem> terms = new ArrayList<Elem>(); CollectionUtils.selectRejected(qc.getElements(), PredicateUtils.instanceofPredicate(Order.class), terms); if (terms.isEmpty()) { return true; }// w w w .j av a 2s.co m return generate(tokenEntry, terms.iterator().next()); }