List of usage examples for java.util List retainAll
boolean retainAll(Collection<?> c);
From source file:opennlp.tools.parse_thicket.external_rst.ExternalRSTImporter.java
private Integer findCommonAncestor(Integer rstNodeFrom, Integer rstNodeTo, List<RstNode> rstNodes) { List<Integer> ancestorsFrom = new ArrayList<Integer>(), ancestorsTo = new ArrayList<Integer>(); ancestorsFrom.add(rstNodeFrom);//w ww.j av a2 s . c o m ancestorsTo.add(rstNodeTo); int curLevel = rstNodes.get(rstNodeTo).level; Integer rstNodeFromCurrent = rstNodeFrom, rstNodeToCurrent = rstNodeTo; while (curLevel > 0) { if (rstNodeFromCurrent != null) { rstNodeFromCurrent = findAncestorForRSTnode(rstNodeFromCurrent, rstNodes); } if (rstNodeToCurrent != null) { rstNodeToCurrent = findAncestorForRSTnode(rstNodeToCurrent, rstNodes); } if (rstNodeFromCurrent != null) { ancestorsFrom.add(rstNodeFromCurrent); } if (rstNodeToCurrent != null) ancestorsTo.add(rstNodeToCurrent); List<Integer> ancestorsFromCurr = new ArrayList<Integer>(ancestorsFrom); ancestorsFromCurr.retainAll(ancestorsTo); if (!ancestorsFromCurr.isEmpty()) { System.out.println("Found comm ancestor " + rstNodes.get(ancestorsFromCurr.get(0)).toString() + " id = " + ancestorsFromCurr.get(0) + " for two RST nodes | id = " + rstNodeFrom + "'" + rstNodes.get(rstNodeFrom).toString() + "' and | id = " + rstNodeTo + "'" + rstNodes.get(rstNodeTo).toString() + "'"); String rel2par = rstNodes.get(ancestorsFromCurr.get(0)).rel2par; // if common ancestor is trivial, return null and do not form a // link if (rel2par == null) // || rel2par.equals("span")) return null; else return ancestorsFromCurr.get(0); } curLevel--; } return null; }
From source file:org.openmrs.module.pihmalawi.metadata.ChronicCareMetadata.java
public List<Location> getChronicCareSystemLocations() { List<Location> l = getLocationsForTag(LocationTags.CHRONIC_CARE_LOCATION.name()); l.retainAll(getSystemLocations()); return l;/* w ww. j a va 2s. c o m*/ }
From source file:net.sourceforge.fenixedu.presentationTier.Action.pedagogicalCouncil.TutorManagementDispatchAction.java
protected boolean validateCoordinationAccessRestrictions(final Person person, final ExecutionDegree executionDegree) { List<Coordinator> coordinators = new ArrayList<Coordinator>(); coordinators.addAll(person.getCoordinatorsSet()); coordinators.retainAll(executionDegree.getCoordinatorsListSet()); return !coordinators.isEmpty(); }
From source file:edu.cmu.tetrad.graph.LayeredDrawing.java
private int numCrossings(List<Node> tier1, List<Node> tier2, Graph graph) { if (tier2.size() < 2) { return 0; }//from ww w . j a v a 2 s . c o m ChoiceGenerator cg = new ChoiceGenerator(tier2.size(), 2); int[] choice; int numCrossings = 0; while ((choice = cg.next()) != null) { List<Node> list1 = graph.getAdjacentNodes(tier2.get(choice[0])); List<Node> list2 = graph.getAdjacentNodes(tier2.get(choice[1])); list1.retainAll(tier1); list2.retainAll(tier1); for (Node node0 : list1) { for (Node node1 : list2) { if (list1.indexOf(node0) > list1.indexOf(node1)) { numCrossings++; } } } } return numCrossings; }
From source file:org.openhab.tools.analysis.checkstyle.ServiceComponentManifestCheck.java
private void verifyManifestExplicitlyDeclaredServices() { // list in which we will store all the common elements of // manifestServiceComponents and componentXmlFiles List<String> intersection = new ArrayList<>(manifestServiceComponents); intersection.retainAll(componentXmlFiles); // log a message for every not included service in the manifest componentXmlFiles.removeAll(intersection); for (String service : componentXmlFiles) { logMessage(serviceComponentHeaderLineNumber, String.format("The service %s is not included in the MANIFEST.MF file. " + "Are you sure that there is no need to be included?", service)); }//from ww w . j ava 2 s . c o m // log a message for every service component definition, // that does not have a corresponding service manifestServiceComponents.removeAll(intersection); for (String service : manifestServiceComponents) { logMessage(serviceComponentHeaderLineNumber, String.format("The service %s does not exist in the OSGI-INF folder.", service)); } }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.IntroduceGroupByForSubplanRule.java
protected Set<LogicalVariable> computeGbyVars(AbstractLogicalOperator op, Set<LogicalVariable> freeVars, IOptimizationContext context) throws AlgebricksException { PhysicalOptimizationsUtil.computeFDsAndEquivalenceClasses(op, context); List<FunctionalDependency> fdList = context.getFDList(op); if (fdList == null) { return null; }/*w w w. j ava 2s. c om*/ // check if any of the FDs is a key List<LogicalVariable> all = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(op, all); all.retainAll(freeVars); for (FunctionalDependency fd : fdList) { if (fd.getTail().containsAll(all)) { return new HashSet<LogicalVariable>(fd.getHead()); } } return null; }
From source file:org.apache.directory.fortress.core.impl.GroupP.java
/** * Creates a Session using given Group and its members, if Group type is ROLE * @param group a group to create Session for * @return Session object/*from w ww .j a va 2s.c o m*/ * @throws SecurityException */ Session createSession(Group group) throws SecurityException { // Create the impl session without authentication of password. Session session = createSessionTrusted(group); // Did the caller pass in a set of roles for selective activation? if (CollectionUtils.isNotEmpty(group.getMembers())) { // Process selective activation of user's RBAC roles into session: List<String> availableRoles = session.getGroup().getMembers(); availableRoles.retainAll(group.getMembers()); } // Fill aux field 'roles' with Role entities fillRoles(session.getGroup()); // Check role temporal constraints + activate roles: VUtil.getInstance().validateConstraints(session, VUtil.ConstraintType.ROLE, true); return session; }
From source file:org.beangle.emsapp.security.action.MenuNavAction.java
public String search() { User user = entityDao.get(User.class, getUserId()); Long categoryId = getLong("security.categoryId"); if (null == categoryId) { categoryId = getUserCategoryId(); }//w w w . j av a 2s.co m List<MenuProfile> profile = getMenuProfile(categoryId); List<Menu> menus = menuService.getMenus(profile, user); List<Menu> menuPath = CollectUtils.newArrayList(); Long menuId = getLong("menu.id"); if (null != menuId) { Menu menu = entityDao.get(Menu.class, menuId); menus.retainAll(HierarchyEntityUtil.getFamily(menu)); menus.remove(menu); menuPath = HierarchyEntityUtil.getPath(menu); } put("menuPath", menuPath); if (null != profile) { put("menus", menus); } else { put("menus", Collections.EMPTY_LIST); } put("tops", HierarchyEntityUtil.getRoots(menus)); put("user", user); return forward(); }
From source file:org.xdi.oxauth.service.FederationCheckTimer.java
private void cleanUpByMetadata(Map.Entry<Pair<String, String>, List<FederationTrust>> p_entry) { try {//from w ww. j a v a 2 s .c o m final Pair<String, String> pair = p_entry.getKey(); if (StringUtils.isNotBlank(pair.getFirst()) && StringUtils.isNotBlank(pair.getSecond()) && p_entry.getValue() != null && !p_entry.getValue().isEmpty()) { final FederationMetadataClient client = new FederationMetadataClient(pair.getFirst()); final FederationMetadataResponse response = client.execGetMetadataById(pair.getSecond()); if (response != null && response.getMetadata() != null) { final FederationMetadata metadata = response.getMetadata(); log.trace("Check trusts against metadata: {0}", metadata.toString()); for (FederationTrust t : p_entry.getValue()) { if (t.getRedirectUris() != null && !t.getRedirectUris().isEmpty()) { final List<String> redirectUris = new ArrayList<String>(t.getRedirectUris()); final List<String> collectedMetadataUriList = metadata.collectAllRedirectUris(); if (redirectUris.retainAll(collectedMetadataUriList)) { final List<String> outdatedList = new ArrayList<String>(t.getRedirectUris()); outdatedList.removeAll(collectedMetadataUriList); log.trace("Removed outdated redirectUris {0}, trust dn: {1}", outdatedList, t.getDn()); t.setRedirectUris(redirectUris); ldapEntryManager.merge(t); } } } } else { setStatusToInactiveByChecker(p_entry); } } } catch (Exception e) { // catch all exceptions, due to unavailability (or other reason) of meta data service // exception may occur, so we interrupt handling for this particular metadata endpoint but not for // other endpoints log.trace(e.getMessage(), e); setStatusToInactiveByChecker(p_entry); } }
From source file:org.jblogcms.core.post.service.PostServiceImpl.java
@Override @Transactional//from w w w . j av a 2 s .co m @PreAuthorize("#post.account.id == principal.id") public Post editPost(Post post) { Post oldPost = postRepository.findPostById(post.getId()); List<Long> oldPostBlogIds = getBlogsIds(oldPost.getBlogs()); List<Long> oldPostBlogIdsCheckSimilar = getBlogsIds(oldPost.getBlogs()); List<Long> blogIds = getBlogsIds(post.getBlogs()); oldPostBlogIdsCheckSimilar.retainAll(blogIds); oldPostBlogIds.removeAll(oldPostBlogIdsCheckSimilar); blogIds.removeAll(oldPostBlogIdsCheckSimilar); Account account = accountRepository.getOne(post.getAccount().getId()); post.setAccount(account); Post editedPost = postRepository.save(post); if (editedPost != null) { if (!oldPostBlogIds.isEmpty()) { blogRepository.updateNoOfPosts(oldPostBlogIds, NUMBER_OF_POSTS_DECREMENT); } blogRepository.flush(); if (!blogIds.isEmpty()) { blogRepository.updateNoOfPosts(blogIds, NUMBER_OF_POSTS_INCREMENT); } } return editedPost; }