List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:com.norconex.jefmon.settings.panels.JobActionsPanel.java
private void remove(List<IJobAction> target, IJobAction... removeme) { List<IJobAction> matches = new ArrayList<>(); for (IJobAction removeAction : removeme) { for (IJobAction targetAction : target) { if (removeAction.getClass().equals(targetAction.getClass())) { matches.add(targetAction); }/*from w ww . ja v a 2s .c o m*/ } } target.removeAll(matches); }
From source file:org.openmrs.module.providermanagement.fragment.controller.ProviderSearchFragmentController.java
public List<SimpleObject> getProviders(@RequestParam(value = "searchValue", required = true) String searchValue, @RequestParam(value = "includeRetired", required = false) Boolean includeRetired, @RequestParam(value = "excludeSuperviseesOf", required = false) Person excludeSuperviseesOf, @RequestParam(value = "excludeProvider", required = false) Person excludeProvider, @RequestParam(value = "providerRoles[]", required = false) ProviderRole[] providerRoles, @RequestParam(value = "resultFields[]", required = false) String[] resultFields, UiUtils ui) throws PersonIsNotProviderException { if (resultFields == null || resultFields.length == 0) { resultFields = new String[] { "personName" }; }//w w w .j a va2s . c o m // default is to not include retired providers includeRetired = includeRetired != null ? includeRetired : false; List<ProviderRole> providerRoleList = null; if (providerRoles != null && providerRoles.length > 0) { providerRoleList = Arrays.asList(providerRoles); } else if (ProviderManagementGlobalProperties .GLOBAL_PROPERTY_RESTRICT_SEARCH_TO_PROVIDERS_WITH_PROVIDER_ROLES() != null && ProviderManagementGlobalProperties .GLOBAL_PROPERTY_RESTRICT_SEARCH_TO_PROVIDERS_WITH_PROVIDER_ROLES()) { providerRoleList = Context.getService(ProviderManagementService.class).getAllProviderRoles(true); } // now fetch the results List<Person> persons = Context.getService(ProviderManagementService.class) .getProvidersAsPersons(searchValue, providerRoleList, includeRetired); // exclude supervisees of a provider if needed if (excludeSuperviseesOf != null) { List<Person> supervisees = Context.getService(ProviderManagementService.class) .getSuperviseesForSupervisor(excludeSuperviseesOf, new Date()); persons.removeAll(supervisees); } // exclude any specified provider if (excludeProvider != null) { persons.remove(excludeProvider); } // convert to a simple object list return ProviderManagementWebUtil.convertPersonListToSimpleObjectList(persons, ui, resultFields); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.professorship.CreateProfessorshipDispatchAction.java
private void prepareThirdStep(DynaValidatorForm personExecutionCourseForm, HttpServletRequest request) throws FenixServiceException { prepareSecondStep(personExecutionCourseForm, request); String executionDegreeId = (String) personExecutionCourseForm.get("executionDegreeId"); String executionPeriodId = (String) personExecutionCourseForm.get("executionPeriodId"); List executionCourses = ReadExecutionCoursesByExecutionDegreeService.run(executionDegreeId, executionPeriodId);//from w w w .j a va 2 s . c o m String personId = (String) personExecutionCourseForm.get("teacherId"); List executionCoursesToRemove = ReadExecutionCoursesByTeacherResponsibility.run(personId); executionCourses.removeAll(executionCoursesToRemove); Collections.sort(executionCourses, new BeanComparator("nome")); request.setAttribute("executionCourses", executionCourses); }
From source file:com.infinity.controller.ElasticController.java
@RequestMapping(value = { "/elastic/update" }, method = RequestMethod.POST) public ModelAndView updateCandidat(@ModelAttribute("candidat") Candidat candidat) throws IOException, InterruptedException, ExecutionException { Candidat candidatFromDb = candidatService.getById(candidat.getId()); float nbYearExp = 0; ArrayList<Experiences> byId1 = expService.getByIdSearhText(candidat.getId()); for (Experiences byId11 : byId1) { float duration = byId11.getDuration(); nbYearExp += duration;//from w w w .j a v a 2 s .c o m } SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); if (candidat.getMobilite() != null) { List<String> mobilite = candidat.getMobilite(); List<String> remove = new ArrayList<>(); for (String value : mobilite) { if (value.isEmpty()) { remove.add(value); } } mobilite.removeAll(remove); } if (candidat.getLanguage() != null) { List<String> lang = candidat.getLanguage(); List<String> remove = new ArrayList<>(); for (String value : lang) { if (value.isEmpty()) { remove.add(value); } } lang.removeAll(remove); } if (candidatFromDb != null) { candidat.setSendTo(candidatFromDb.getSendTo()); } candidat.setNbYearExp(nbYearExp); candidat.setUpdateDate(simpleDateFormat.format(date)); long updateOneById = candidatService.updateOneById(candidat); String valueOf = String.valueOf(updateOneById); LOG.debug(valueOf); ModelAndView mv = new ModelAndView("redirect:/elastic/get/" + candidat.getId()); return mv; }
From source file:com.redhat.rhn.manager.rhnpackage.PackageManager.java
/** * Throw exception, if any of the packages aren't accessible by user or * aren't compatible with provided channel arch * @param user user//w w w . java2 s.c om * @param channel channel * @param packageIds package ids * @param checkArchCompat optionally arch compatibility doesn't have to be checked * (f.e. when removing packages, only orgt access is important) */ public static void verifyPackagesChannelArchCompatAndOrgAccess(User user, Channel channel, List<Long> packageIds, boolean checkArchCompat) { Long orgId = user.getOrg().getId(); DataResult dr = PackageFactory.getPackagesChannelArchCompatAndOrgAccess(orgId, channel.getId(), packageIds); List<Long> found = new ArrayList<Long>(); List<Long> archNonCompat = new ArrayList<Long>(); List<Long> orgNoAccess = new ArrayList<Long>(); for (Iterator i = dr.iterator(); i.hasNext();) { Map m = (Map) i.next(); found.add((Long) m.get("id")); if (m.get("package_arch_id") == null) { archNonCompat.add((Long) m.get("id")); } if ((m.get("org_package") == null || orgId.compareTo((Long) m.get("org_package")) != 0) && m.get("org_access") == null && m.get("shared_access") == null) { orgNoAccess.add((Long) m.get("id")); } } List<Long> missing = new ArrayList<Long>(packageIds); missing.removeAll(found); orgNoAccess.addAll(missing); if (!orgNoAccess.isEmpty()) { StringBuilder msg = new StringBuilder("User: "); msg.append(user.getLogin()); msg.append(" does not have access to packages: "); msg.append(orgNoAccess); LocalizationService ls = LocalizationService.getInstance(); PermissionException pex = new PermissionException(msg.toString()); pex.setLocalizedTitle(ls.getMessage("permission.jsp.title.package")); pex.setLocalizedSummary(ls.getMessage("permission.jsp.summary.package")); throw pex; } if (checkArchCompat && !archNonCompat.isEmpty()) { throw new IncompatibleArchException(channel.getChannelArch(), archNonCompat); } }
From source file:eu.europa.esig.dss.client.crl.OnlineCRLSource.java
/** * if {@code preferredProtocol} is set then the list of urls is prioritize. * NOTE: This is not standard conformant! However in the major number of cases LDAP is much slower then HTTP! * * @param urls {@code List} of urls to prioritize *//* ww w. j a va 2 s .com*/ private void prioritize(final List<String> urls) { if (preferredProtocol != null) { final List<String> priorityUrls = new ArrayList<String>(); for (final String url : urls) { if (preferredProtocol.isTheSame(url)) { priorityUrls.add(url); } } urls.removeAll(priorityUrls); for (int ii = priorityUrls.size() - 1; ii >= 0; ii--) { urls.add(0, priorityUrls.get(ii)); } } }
From source file:io.github.jeddict.jpa.modeler.widget.JavaClassWidget.java
public void scanDuplicateClass(String previousName, String newName) { int previousNameCount = 0, newNameCount = 0; List<JavaClassWidget> javaClassList = this.getModelerScene().getJavaClassWidges(); EntityMappings entityMappings = this.getModelerScene().getBaseElementSpec(); List<JavaClass> hiddenJavaClasses = new ArrayList<>(entityMappings.getJavaClass()); hiddenJavaClasses .removeAll(javaClassList.stream().map(JavaClassWidget::getBaseElementSpec).collect(toList())); for (JavaClass javaClass : hiddenJavaClasses) { if (javaClass.getClazz().equals(previousName)) { ++previousNameCount;//www. ja v a2 s. c o m } if (javaClass.getClazz().equals(newName)) { ++newNameCount; } } for (JavaClassWidget<JavaClass> javaClassWidget : javaClassList) { JavaClass javaClass = javaClassWidget.getBaseElementSpec(); if (javaClass.getClazz().equals(previousName)) { if (++previousNameCount > 1) { javaClassWidget.getSignalManager().fire(ERROR, ClassValidator.NON_UNIQUE_JAVA_CLASS); } else if (!javaClassWidget.getSignalManager().getSignalList(ERROR).isEmpty()) { javaClassWidget.getSignalManager().clear(ERROR, ClassValidator.NON_UNIQUE_JAVA_CLASS); } } if (javaClass.getClazz().equals(newName)) { if (++newNameCount > 1) { javaClassWidget.getSignalManager().fire(ERROR, ClassValidator.NON_UNIQUE_JAVA_CLASS); } else if (!javaClassWidget.getSignalManager().getSignalList(ERROR).isEmpty()) { javaClassWidget.getSignalManager().clear(ERROR, ClassValidator.NON_UNIQUE_JAVA_CLASS); } } } }
From source file:com.all.ultrapeer.UltrapeerService.java
private List<UltrapeerNode> getDeprecatedUltrapeers(List<UltrapeerNode> clientList) { clientList.removeAll(currentUltrapeers); return clientList.isEmpty() ? null : clientList; }
From source file:org.sipfoundry.sipxconfig.homer.HomerDbManager.java
/** * Ensure each proxy is listed in homer's hosts table. * NOTE: Records in node table are not removed, it's unclear if an admin would want that --Douglas */// w ww . ja v a 2 s.co m public void syncNodes() { if (!m_featureManager.isFeatureEnabled(MySql.FEATURE)) { return; } // sync node info String sipxSql = "select fqdn || '@' || ip_address from location l inner join feature_local f on l.location_id = f.location_id and f.feature_id = ?"; List<String> sipxHosts = m_configJdbcTemplate.queryForList(sipxSql, String.class, ProxyManager.FEATURE.getId()); String homerSql = "select concat(name, '@', host) from homer_hosts"; JdbcTemplate homerDb = (JdbcTemplate) m_beanFactory.getBean("homerDb"); List<String> homerHosts = homerDb.queryForList(homerSql, String.class); sipxHosts.removeAll(homerHosts); if (!sipxHosts.isEmpty()) { List<String> add = new ArrayList<String>(); for (String missingNode : sipxHosts) { String[] decode = StringUtils.split(missingNode, '@'); String name = decode[0]; String host = decode[1]; String checkHostSql = "select count(0) from homer_hosts where host = ?"; boolean hostExists = homerDb.queryForInt(checkHostSql, host) > 0; String sql; if (hostExists) { sql = format("update homer_hosts set name='%s' where host='%s'", name, host); } else { sql = format("insert into homer_hosts (name, host, status) values ('%s', '%s', 1)", name, host); } add.add(sql); } homerDb.batchUpdate(add.toArray(new String[0])); } // sync db info String dbhost = "127.0.0.1"; int dbport = 3306; String dbname = "homer_db"; String dbuser = "root"; String dbpass = ""; String dbtables = "sip_capture"; String name = "local"; int status = 1; // must have lowest ID to ensure it's the default node for statistics String nodeSql = "select 1 from homer_nodes where host = ? and dbport = ? and dbname = ? and dbpassword = ? " + "and dbusername = ? and dbtables = ? and name = ? and status = ? and id = 1"; List<Integer> found = homerDb.queryForList(nodeSql, Integer.class, dbhost, dbport, dbname, dbpass, dbuser, dbtables, name, status); if (found.size() == 0) { String[] hosts = new String[2]; hosts[0] = "delete from homer_nodes"; String addNode = "insert into homer_nodes (id, host, dbport, dbname, dbpassword, dbusername, dbtables, name, status) " + "values (1, '%s',%d,'%s','%s','%s','%s','%s','%d')"; hosts[1] = format(addNode, dbhost, dbport, dbname, dbpass, dbuser, dbtables, name, status); homerDb.batchUpdate(hosts); } }