List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:gov.nasa.arc.geocam.talk.service.TalkServer.java
/** * Gets the talk messages from the server. * * @return the talk messages found on the server * @throws SQLException the sQL exception * @throws ClientProtocolException the client protocol exception * @throws AuthenticationFailedException the authentication failed exception * @throws IOException Signals that an I/O exception has occurred. *//*from w w w. ja v a 2 s . c o m*/ public void getTalkMessages() throws SQLException, ClientProtocolException, AuthenticationFailedException, IOException { // let's check the server and add any new messages to the database String jsonString = null; String url = String.format(urlMessageList, maxMessageId); ServerResponse sr = siteAuth.get(url, null); if (sr.getResponseCode() == 200) { jsonString = sr.getContent(); List<GeoCamTalkMessage> newMessages = jsonConverter.deserializeList(jsonString); List<GeoCamTalkMessage> existingMessages = messageStore.getAllMessages(); newMessages.removeAll(existingMessages); if (newMessages.size() > 0) { for (GeoCamTalkMessage message : newMessages) { message.setSynchronized(true); } messageStore.addMessage(newMessages); intentHelper.BroadcastNewMessages(); } } else { Log.e("Talk", "Could not get messages, invalid response"); } maxMessageId = messageStore.getNewestMessageId(); Log.i("Talk", "MaxMessageIdNow:" + maxMessageId); }
From source file:com.pinterest.deployservice.db.DBEnvironDAOImpl.java
@Override public List<String> getTotalCapacityHosts(String envId, String envName, String envStage) throws Exception { List<String> totalHosts = new QueryRunner(dataSource).query(GET_HOSTS_BY_CAPACITY, SingleResultSetHandlerFactory.<String>newListObjectHandler(), envId, envId); List<String> overrideHosts = getOverrideHosts(envId, envName, envStage); if (!overrideHosts.isEmpty()) { totalHosts.removeAll(new HashSet<String>(overrideHosts)); }//from ww w . j a v a 2 s .co m return totalHosts; }
From source file:com.orange.cepheus.cep.EsperEventProcessor.java
/** * Update the CEP event types by adding new types and removing the older ones. * * @param oldList the previous list of event types * @param newList the new list of event types * @param operations the CEP configuration */// ww w . java 2 s . c o m private void updateEventTypes(Collection<EventType> oldList, Collection<EventType> newList, ConfigurationOperations operations) { List<EventType> eventTypesToRemove = new LinkedList<>(oldList); eventTypesToRemove.removeAll(newList); List<EventType> eventTypesToAdd = new LinkedList<>(newList); eventTypesToAdd.removeAll(oldList); // List all statements depending on the event types to remove Set<String> statementsToDelete = new HashSet<>(); for (EventType eventType : eventTypesToRemove) { statementsToDelete.addAll(operations.getEventTypeNameUsedBy(eventType.getType())); } // Delete all the statements depending on the event types to remove for (String statementName : statementsToDelete) { EPStatement statement = epServiceProvider.getEPAdministrator().getStatement(statementName); if (statement != null) { logger.info("Removing unused statement: " + statement.getText()); statement.stop(); statement.destroy(); } } // Finally remove the event types for (EventType eventType : eventTypesToRemove) { logger.info("Removing unused event: " + eventType); operations.removeEventType(eventType.getType(), false); } for (EventType eventType : eventTypesToAdd) { logger.info("Add new event type: {}", eventType); // Add event type mapped to esper representation String eventTypeName = eventType.getType(); operations.addEventType(eventTypeName, eventMapper.esperTypeFromEventType(eventType)); } }
From source file:nl.opengeogroep.filesetsync.client.plugin.SetFileXpathToHttpRequestHeaderPlugin.java
@Override public void beforeStart(Fileset config, SyncJobState state) { updateAllHeaders();//w w w . j av a 2s .c om Map<String, Header> validHeaders = new HashMap(); for (String header : headers.keySet()) { Properties props = headers.get(header); if (props.containsKey("lastValue")) { validHeaders.put(header, new BasicHeader(header, props.getProperty("lastValue"))); } } List<Header> existingHeaders = state.getRequestHeaders(); List<Header> toRemove = new ArrayList(); for (Header existingHeader : existingHeaders) { if (validHeaders.containsKey(existingHeader.getName())) { toRemove.add(existingHeader); } } existingHeaders.removeAll(toRemove); existingHeaders.addAll(validHeaders.values()); }
From source file:de.fau.amos4.web.EmployeeFormController.java
@RequestMapping("/employee/edit/submit") public ModelAndView EmployeeEditSubmit(@ModelAttribute Employee employee, Principal principal) { ModelAndView mav = new ModelAndView(); FormGenerator generator = new FormGenerator(); mav.addObject("formInfo", generator.Generate(Employee.class, employee)); CheckDataInput cdi = new CheckDataInput(); // Fields with ValidFormat annotation and no content. List<String> emptyFields = cdi.listEmptyFields(employee); // Fields with ValidFormat annotation and not valid content based on the annotation regex. List<String> invalidFields = cdi.listInvalidFields(employee); // List of invalid and not empty fields List<String> invalidNonEmptyFields = new ArrayList<String>(); invalidNonEmptyFields.addAll(invalidFields); invalidNonEmptyFields.removeAll(emptyFields); // If there is a not empty, invalid field, can't accept input. if (invalidNonEmptyFields.size() > 0) { mav.addObject("invalidFieldErrorMessages", invalidNonEmptyFields); mav.setViewName("employee/edit"); mav.addObject("preview", false); return mav; // Display "/employee/edit" with error messages } else {//from w w w. ja v a 2 s . c o m // There is no invalid and non empty field. -> Accept input. // Display warnings because of empty fields: mav.addObject("emptyFields", emptyFields); if (principal == null) { mav.addObject("allDisabled", YesNo.values()); mav.addObject("allMarital", MaritalStatus.values()); mav.addObject("allSex", Sex.values()); mav.addObject("allDenomination", Denomination.values()); mav.addObject("allTypeOfContract", TypeOfFixedTermContract.values()); mav.addObject("allHealthInsurance", HealthInsurance.values()); mav.addObject("allNursingCareInsurance", NursingCareInsurance.values()); mav.addObject("allPensionInsurance", PensionInsurance.values()); mav.addObject("addUnemploymentInsurance", UnemploymentInsurance.values()); mav.addObject("allParenthood", Parenthood.values()); ; mav.addObject("preview", true); mav.setViewName("employee/edit"); return mav; } else { final String currentUser = principal.getName(); System.out.println("not null"); Client client = clientService.getClientByEmail(currentUser); employee.setClient(client); client.getEmployees().add(employee); employeeRepository.save(employee); clientRepository.save(client); mav.setViewName("redirect:/client/dashboard"); // Redirect to AccountPage page return mav; } } }
From source file:de.metas.procurement.webui.ui.model.ProductQtyReportRepository.java
public List<Product> getProductsContractedButNotFavorite() { final List<Product> productsNotSelected = new ArrayList<>(getProductsContracted()); productsNotSelected.removeAll(getProductsFavorite()); Collections.sort(productsNotSelected, Product.comparatorByName(i18n.getLocale())); return productsNotSelected; }
From source file:com.threewks.thundr.bigmetrics.service.BigMetricsServiceImpl.java
/** * Ensures that all required event tables exist. Tables that don't exist will cause issues with recording events. *//*from www . j ava 2 s. c o m*/ @Override public void ensureTablesExist() { List<String> allTables = bigQueryService.listTables(); List<String> requiredTables = EventMetadata.Transformers.ToTableNames.from(eventCache.values()); requiredTables.removeAll(allTables); if (!requiredTables.isEmpty()) { // Remaining required tables need to be created. Map<String, EventMetadata> lookup = EventMetadata.Transformers.ToTableNameLookup .from(eventCache.values()); for (String table : requiredTables) { EventMetadata eventMetadata = lookup.get(table); createTable(eventMetadata); } } }
From source file:org.openmrs.module.providermanagement.fragment.controller.PatientSearchFragmentController.java
public List<SimpleObject> getPatients(@RequestParam(value = "searchValue", required = true) String searchValue, @RequestParam(value = "excludePatientsOf", required = false) Person excludePatientsOf, @RequestParam(value = "existingRelationshipTypeToExclude", required = false) RelationshipType existingRelationshipTypeToExclude, @RequestParam(value = "resultFields[]", required = true) String[] resultFields, UiUtils ui) throws PersonIsNotProviderException, InvalidRelationshipTypeException { if (resultFields == null || resultFields.length == 0) { resultFields = new String[] { "personName" }; }//from www. j ava 2 s .c om // always want to return the id of the result objects resultFields = ArrayUtils.add(resultFields, "id"); // now fetch the results List<Patient> patients = Context.getPatientService().getPatients(searchValue); // exclude any patients if specified if (excludePatientsOf != null && existingRelationshipTypeToExclude != null) { List<Patient> patientsToExclude = Context.getService(ProviderManagementService.class) .getPatientsOfProvider(excludePatientsOf, existingRelationshipTypeToExclude, new Date()); patients.removeAll(patientsToExclude); } return SimpleObject.fromCollection(patients, ui, resultFields); }
From source file:com.alibaba.jstorm.schedule.FollowerRunnable.java
private int update_nimbus_detail() throws Exception { //update count = count of zk's binary files - count of nimbus's binary files StormClusterState zkClusterState = data.getStormClusterState(); String master_stormdist_root = StormConfig.masterStormdistRoot(data.getConf()); List<String> code_ids = PathUtils.read_dir_contents(master_stormdist_root); List<String> assignments_ids = data.getStormClusterState().assignments(callback); assignments_ids.removeAll(code_ids); Map mtmp = zkClusterState.get_nimbus_detail(hostPort, false); if (mtmp == null) { mtmp = new HashMap(); }/*from ww w. ja v a 2s . c o m*/ mtmp.put(NIMBUS_DIFFER_COUNT_ZK, assignments_ids.size()); zkClusterState.update_nimbus_detail(hostPort, mtmp); LOG.debug("update nimbus's detail " + mtmp); return assignments_ids.size(); }
From source file:org.apache.taverna.activities.rest.RESTActivity.java
protected void configurePorts() { // all input ports are dynamic and depend on the configuration // of the particular instance of the REST activity // now process the URL signature - extract all placeholders and create // an input data type for each Map<String, Class<?>> activityInputs = new HashMap<>(); List<String> placeholders = URISignatureHandler.extractPlaceholders(configBean.getUrlSignature()); String acceptsHeaderValue = configBean.getAcceptsHeaderValue(); if (acceptsHeaderValue != null && !acceptsHeaderValue.isEmpty()) try {//from w ww . ja va2 s .c o m List<String> acceptsPlaceHolders = URISignatureHandler.extractPlaceholders(acceptsHeaderValue); acceptsPlaceHolders.removeAll(placeholders); placeholders.addAll(acceptsPlaceHolders); } catch (URISignatureParsingException e) { logger.error(e); } for (ArrayList<String> httpHeaderNameValuePair : configBean.getOtherHTTPHeaders()) try { List<String> headerPlaceHolders = URISignatureHandler .extractPlaceholders(httpHeaderNameValuePair.get(1)); headerPlaceHolders.removeAll(placeholders); placeholders.addAll(headerPlaceHolders); } catch (URISignatureParsingException e) { logger.error(e); } for (String placeholder : placeholders) // these inputs will have a dynamic name each; // the data type is string as they are the values to be // substituted into the URL signature at the execution time activityInputs.put(placeholder, String.class); // all inputs have now been configured - store the resulting set-up in // the config bean; // this configuration will be reused during the execution of activity, // so that existing // set-up could simply be referred to, rather than "re-calculated" configBean.setActivityInputs(activityInputs); // ---- CREATE OUTPUTS ---- // all outputs are of depth 0 - i.e. just a single value on each; // output ports for Response Body and Status are static - they don't // depend on the configuration of the activity; addOutput(OUT_RESPONSE_BODY, 0); addOutput(OUT_STATUS, 0); if (configBean.getShowActualUrlPort()) addOutput(OUT_COMPLETE_URL, 0); if (configBean.getShowResponseHeadersPort()) addOutput(OUT_RESPONSE_HEADERS, 1); // Redirection port may be hidden/shown if (configBean.getShowRedirectionOutputPort()) addOutput(OUT_REDIRECTION, 0); }