List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:services.echannel.EchannelServiceImpl.java
@Override public DataSyndicationAgreementLink submitAgreementLink(String masterPrincipalUid, Long agreementId, String name, String description, List<Long> agreementItemIds, String dataType, Long masterObjectId) throws EchannelException { SubmitDataSyndicationAgreementLinkRequest submitAgreementLinkRequest = new SubmitDataSyndicationAgreementLinkRequest(); submitAgreementLinkRequest.masterPrincipalUid = masterPrincipalUid; submitAgreementLinkRequest.agreementId = agreementId; submitAgreementLinkRequest.name = name; submitAgreementLinkRequest.description = description; agreementItemIds.removeAll(Collections.singleton(null)); submitAgreementLinkRequest.agreementItemIds = agreementItemIds; submitAgreementLinkRequest.dataType = dataType; submitAgreementLinkRequest.masterObjectId = masterObjectId; JsonNode content = getMapper().valueToTree(submitAgreementLinkRequest); JsonNode response = this.call(HttpMethod.POST, DATA_SYNDICATION_AGREEMENT_LINK_ACTION + "/submit", null, content);//from ww w .j a v a 2 s. c om return getMapper().convertValue(response, DataSyndicationAgreementLink.class); }
From source file:languageTools.analyzer.mas.MASValidator.java
@Override public Void visitLaunchRule(LaunchRuleContext ctx) { if (ctx.basicRule() != null) { List<Launch> launches = visitBasicRule(ctx.basicRule()); // A basic launch rule should not use wild cards. List<Launch> usesWildCard = new ArrayList<Launch>(); for (Launch launch : launches) { if (launch.getGivenName("*", 0).equals("*")) { reportWarning(MASWarning.LAUNCH_INVALID_WILDCARD, ctx, ctx.getText().substring(0, ctx.getText().length() - 1)); usesWildCard.add(launch); }// w ww. jav a2 s. com } launches.removeAll(usesWildCard); // A launch rule cannot have an empty list of launch instructions. if (!launches.isEmpty()) { getProgram().addLaunchRule(new LaunchRule(launches)); } } if (ctx.conditionalRule() != null) { LaunchRule rule = visitConditionalRule(ctx.conditionalRule()); if (rule != null) { getProgram().addLaunchRule(rule); } } return null; // Java says must return something even when Void }
From source file:mx.edu.um.mateo.activos.web.ActivoController.java
@SuppressWarnings("unchecked") @RequestMapping//ww w. j a va 2s . c o m public String lista(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String filtro, @RequestParam(required = false) Long pagina, @RequestParam(required = false) String tipo, @RequestParam(required = false) String correo, @RequestParam(required = false) String order, @RequestParam(required = false) String sort, Model modelo) throws ParseException { log.debug("Mostrando lista de activos"); modelo.addAttribute("centroCosto", ambiente.obtieneUsuario().getEmpresa().getCentroCosto()); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Map<String, Object> params = this.convierteParams(request.getParameterMap()); Long empresaId = (Long) request.getSession().getAttribute("empresaId"); params.put("empresa", empresaId); if (params.containsKey("fechaIniciado")) { log.debug("FechaIniciado: {}", params.get("fechaIniciado")); params.put("fechaIniciado", sdf.parse((String) params.get("fechaIniciado"))); } if (params.containsKey("fechaTerminado")) { params.put("fechaTerminado", sdf.parse((String) params.get("fechaTerminado"))); } if (StringUtils.isNotBlank(tipo)) { params.put("reporte", true); params = activoDao.lista(params); try { generaReporte(tipo, (List<Activo>) params.get("activos"), response, "activos", Constantes.EMP, empresaId); return null; } catch (ReporteException e) { log.error("No se pudo generar el reporte", e); } } if (StringUtils.isNotBlank(correo)) { params.put("reporte", true); params = activoDao.lista(params); params.remove("reporte"); try { enviaCorreo(correo, (List<Activo>) params.get("activos"), request, "activos", Constantes.EMP, empresaId); modelo.addAttribute("message", "lista.enviado.message"); modelo.addAttribute("messageAttrs", new String[] { messageSource.getMessage("activo.lista.label", null, request.getLocale()), ambiente.obtieneUsuario().getUsername() }); } catch (ReporteException e) { log.error("No se pudo enviar el reporte por correo", e); } } params = activoDao.lista(params); modelo.addAttribute("activos", params.get("activos")); modelo.addAttribute("resumen", params.get("resumen")); this.pagina(params, modelo, "activos", pagina); List<TipoActivo> tiposDeActivo = tipoActivoDao.lista(ambiente.obtieneUsuario()); if (params.containsKey("tipoActivoIds")) { List<Long> ids = (List<Long>) params.get("tipoActivoIds"); List<TipoActivo> seleccionados = new ArrayList<>(); for (TipoActivo tipoActivo : tiposDeActivo) { if (ids.contains(tipoActivo.getId())) { seleccionados.add(tipoActivo); } } tiposDeActivo.removeAll(seleccionados); modelo.addAttribute("seleccionados", seleccionados); } modelo.addAttribute("disponibles", tiposDeActivo); return "activoFijo/activo/lista"; }
From source file:com.swiftcorp.portal.question.web.QuestionDispatchAction.java
public ActionForward modifyQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws SystemException, BusinessRuleViolationException, Exception { log.info("modifyQuestion() : Enter"); request.setCharacterEncoding("UTF-16"); String mcqOptionNumber = request.getParameter("mcqOptionNumber"); int mcqNo = 0; if (mcqOptionNumber != null && !mcqOptionNumber.equals("null") && mcqOptionNumber.length() > 0) { mcqNo = Integer.parseInt(mcqOptionNumber); }//from w w w. j a v a 2 s. c o m DynaValidatorActionForm questionForm = (DynaValidatorActionForm) form; QuestionDTO questionsessDTO = (QuestionDTO) request.getSession() .getAttribute(SESSION_KEYS.QUESTION_TO_MODIFY); QuestionDTO questionDTO = (QuestionDTO) questionForm.get("question"); questionDTO = (QuestionDTO) this.questionService.get(questionDTO.getComponentId()); long categoryId = (Long) questionForm.get("category"); // set question id String questionId = request.getParameter("question.questionId"); String questionName = (String) request.getParameter("question.questionName"); questionDTO.setQuestionName(questionName); questionDTO.setQuestionId("" + questionId); // now get the role dto from the database CategoryTypeDTO categoryTypeDTO = (CategoryTypeDTO) questionService.getCategory(categoryId); if (categoryTypeDTO == null) { throw new SystemException("Category is found null"); } questionDTO.setCategoryType(categoryTypeDTO); long answerTypeId = (Long) questionForm.get("answerType"); AnswerTypeDTO answerTypeDTO = (AnswerTypeDTO) questionService.getAnswerType(answerTypeId); if (answerTypeDTO == null) { throw new SystemException("Answer is found null"); } questionDTO.setAnswerType(answerTypeDTO); List<ValidationDTO> validationDTOList = questionDTO.getValidationDTOList(); if (validationDTOList != null && validationDTOList.size() > 0) { ValidationDTO validationDTO = validationDTOList.get(0); // mcqoptions.remove ( mcqOptionDTO ); questionService.deleteValidation(validationDTO); } validationDTOList = this.populateValidationDTOFromReq(questionDTO, request, answerTypeDTO); questionDTO.setValidationDTOList(validationDTOList); /* * String searchSqlQuery * ="select componentId,name,questionId,questionOrder from mcqOption"; * searchSqlQuery += " where questionId= "+questionDTO.getComponentId * ()+" order by questionOrder asc"; System.out.println * ("search query::"+searchSqlQuery ); SearchOperationResult * searchOperationResult = questionService.search ( searchSqlQuery ); */ // encode the question name questionName = questionDTO.getQuestionName(); String utfQuestionName = new String(questionName.getBytes("UTF-16"), "UTF-16"); System.out.println("Converted: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + questionName + " to:" + utfQuestionName); questionDTO.setQuestionName(utfQuestionName); List<MCQOptionDTO> mcqoptions = questionDTO.getMcqOptionList(); for (MCQOptionDTO mcqOptionDTO : mcqoptions) { if (mcqOptionDTO != null) { // mcqoptions.remove ( mcqOptionDTO ); questionService.deleteMcqOption(mcqOptionDTO); } } mcqoptions.removeAll(mcqoptions); MCQOptionDTO mcqOptionDTO = null; for (int i = 0; i < mcqNo; i++) { // mcqoptions.add(questionService.getMCQDTO(Long.parseLong(request.getParameter("mcq"+i)))); mcqOptionDTO = new MCQOptionDTO(); mcqOptionDTO.setName(request.getParameter("mcq" + i)); mcqOptionDTO.setValue(request.getParameter("value" + i)); // mcqOptionDTO.setValue ( i ); mcqOptionDTO.setQuestionDTO(questionDTO); mcqoptions.add(mcqOptionDTO); } // mcqoptions = questionDTO.getMcqOptionList (); // System.out.println("mcq list size::::::"+questionDTO.getMcqOptionList().size()); // mcqoptions.remove ( 0 ); // questionDTO.setMcqOptionList ( mcqoptions ); // System.out.println("mcq list size::::::"+questionsessDTO.getMcqOptionList().size()); if (answerTypeId == ApplicationConstants.MULTIPLE_CHOICE_QUESTION_TYPE && mcqoptions != null && mcqoptions.size() > 0) { questionDTO.setMcqOptionList(mcqoptions); } String[][] messageArgValues = { { questionDTO.getQuestionName() } }; questionService.modify(questionDTO); WebUtils.setSuccessMessages(request, MessageKeys.MODIFY_SUCCESS_MESSAGE_KEYS, messageArgValues); log.info("modifyQuestion() : Exit"); return promptQuestionSearchSystemLevel(mapping, form, request, response); }
From source file:io.fabric8.elasticsearch.plugin.kibana.KibanaSeed.java
public void setDashboards(final OpenshiftRequestContext context, Client client, String kibanaVersion, final String projectPrefix) { LOGGER.debug("Begin setDashboards: projectPrefix '{}' for user '{}' projects '{}' kibanaIndex '{}'", projectPrefix, context.getUser(), context.getProjects(), context.getKibanaIndex()); // We want to seed the Kibana user index initially // since the logic from Kibana has changed to create before this plugin // starts.../* ww w . j a v a 2 s.com*/ boolean changed = initialSeedKibanaIndex(context, client); // GET .../.kibana/index-pattern/_search?pretty=true&fields= // compare results to projects; handle any deltas (create, delete?) Set<String> indexPatterns = getProjectNamesFromIndexes(context, client, projectPrefix); LOGGER.debug("Found '{}' Index patterns for user", indexPatterns.size()); Set<String> projects = new HashSet<>(context.getProjects()); List<String> filteredProjects = new ArrayList<String>(filterProjectsWithIndices(projectPrefix, projects)); LOGGER.debug("projects for '{}' that have existing indexes: '{}'", context.getUser(), filteredProjects); addAliasToAllProjects(context, filteredProjects); Collections.sort(filteredProjects); // If none have been set yet if (indexPatterns.isEmpty()) { create(context.getKibanaIndex(), filteredProjects, true, client, kibanaVersion, projectPrefix, indexPatterns); changed = true; } else { List<String> common = new ArrayList<String>(indexPatterns); common.retainAll(filteredProjects); filteredProjects.removeAll(common); indexPatterns.removeAll(common); // if we aren't a cluster-admin, make sure we're deleting the // ADMIN_ALIAS_NAME if (!context.isOperationsUser()) { LOGGER.debug("user is not a cluster admin, ensure they don't keep/have the admin alias pattern"); indexPatterns.add(ADMIN_ALIAS_NAME); } // check if we're going to be adding or removing any projects if (!filteredProjects.isEmpty() || !indexPatterns.isEmpty()) { changed = true; } // for any to create (remaining in projects) call createIndices, createSearchmapping?, create dashboard create(context.getKibanaIndex(), filteredProjects, false, client, kibanaVersion, projectPrefix, indexPatterns); // cull any that are in ES but not in OS (remaining in indexPatterns) remove(context.getKibanaIndex(), indexPatterns, client, projectPrefix); common.addAll(filteredProjects); Collections.sort(common); // Set default index to first index in common if we removed the default String defaultIndex = getDefaultIndex(context, client, kibanaVersion, projectPrefix); LOGGER.debug("Checking if index patterns '{}' contain default index '{}'", indexPatterns, defaultIndex); if (indexPatterns.contains(defaultIndex) || StringUtils.isEmpty(defaultIndex)) { LOGGER.debug("'{}' does contain '{}' and common size is {}", indexPatterns, defaultIndex, common.size()); if (!common.isEmpty()) { setDefaultIndex(context.getKibanaIndex(), common.get(0), client, kibanaVersion, projectPrefix); } } } if (changed) { refreshKibanaUser(context.getKibanaIndex(), client); } }
From source file:configuration.Util.java
public static List<String> merge2ListsWithoutDup(List<String> list1, List<String> list2) { list1.removeAll(list2); list1.addAll(list2);//from w ww . j a va 2s . c o m return list1; }
From source file:com.espertech.esper.regression.resultset.TestOrderBySimple.java
private void assertOnlyProperties(List<String> requiredProperties) { EventBean[] events = testListener.getLastNewData(); if (events == null || events.length == 0) { return;/*from www .ja v a2 s .c om*/ } EventType type = events[0].getEventType(); List<String> actualProperties = new ArrayList<String>(Arrays.asList(type.getPropertyNames())); log.debug(".assertOnlyProperties actualProperties==" + actualProperties); assertTrue(actualProperties.containsAll(requiredProperties)); actualProperties.removeAll(requiredProperties); assertTrue(actualProperties.isEmpty()); }
From source file:com.smash.revolance.ui.model.page.api.PageBean.java
private void filterElementsIncludedInEachOthers(List<ElementBean> elements) { if (elements.size() > 2) { List<ElementBean> filteredElements = new ArrayList<ElementBean>(); ElementBean bigElement;//from w ww.j a va 2s . com while ((bigElement = getBiggestArea(elements)) != null) { elements.remove(bigElement); List<ElementBean> included = new ArrayList<ElementBean>(); for (ElementBean anElement : elements) { if (anElement.isIncluded(bigElement)) { included.add(anElement); } } elements.removeAll(included); filteredElements.add(bigElement); } elements.clear(); elements.addAll(filteredElements); } }
From source file:com.pinterest.teletraan.worker.ClusterReplacer.java
/** * Step 4. COMPLETING state should clean up hosts launched in INIT state * If found failed deploy asg hosts, use non-asg host to replace it. * No more launch activity in this state * If previous state failed/timeout/abort, should come to this state to do final clean up *///from w w w . ja va 2 s . c o m private void processCompletingState(ClusterUpgradeEventBean eventBean) throws Exception { String clusterName = eventBean.getCluster_name(); if (StringUtils.isEmpty(eventBean.getHost_ids())) { LOG.info("Successfully completed COMPLETING state, move to COMPLETED state"); ClusterUpgradeEventBean updateBean = new ClusterUpgradeEventBean(); // Do not set status, leave it updateBean.setState(ClusterUpgradeEventState.COMPLETED); transitionState(eventBean.getId(), updateBean); updateClusterState(clusterName); return; } List<String> nonAsgHosts = Arrays.asList(eventBean.getHost_ids().split(",")); List<String> activeNonAsgHosts = hostInfoDAO.getRunningInstances(new ArrayList<>(nonAsgHosts)); if (activeNonAsgHosts.size() != activeNonAsgHosts.size()) { updateHostsInClusterEvent(eventBean.getId(), activeNonAsgHosts); } Collection<String> failedHosts = hostDAO.getFailedHostIdsByGroup(clusterName); List<String> failedDeployNonAsgHosts = new ArrayList<>(); List<String> failedDeployAsgHosts = new ArrayList<>(); for (String failedHost : failedHosts) { if (activeNonAsgHosts.contains(failedHost)) { failedDeployNonAsgHosts.add(failedHost); } else { failedDeployAsgHosts.add(failedHost); } } if (!failedDeployNonAsgHosts.isEmpty()) { activeNonAsgHosts.removeAll(failedDeployNonAsgHosts); clusterManager.terminateHosts(clusterName, failedDeployAsgHosts, true); LOG.info(String.format("Successfully terminated %d failed deploy non-asg hosts for cluster %s: %s", failedDeployNonAsgHosts.size(), clusterName, failedDeployAsgHosts.toString())); } if (!failedDeployAsgHosts.isEmpty() && !activeNonAsgHosts.isEmpty()) { int num = Math.min(failedDeployAsgHosts.size(), activeNonAsgHosts.size()); List<String> hostsToAttach = new ArrayList<>(activeNonAsgHosts.subList(0, num)); autoScalingManager.addInstancesToAutoScalingGroup(hostsToAttach, clusterName); activeNonAsgHosts.removeAll(hostsToAttach); LOG.info(String.format("Successfully attached %d hosts to cluster %s: %s", num, clusterName, hostsToAttach.toString())); List<String> hostsToTerminate = new ArrayList<>(failedDeployAsgHosts.subList(0, num)); clusterManager.terminateHosts(clusterName, hostsToTerminate, false); LOG.info(String.format("Successfully terminated %d failed deploy asg hosts in cluster %s: %s", num, clusterName, hostsToTerminate.toString())); } if (!activeNonAsgHosts.isEmpty()) { clusterManager.terminateHosts(clusterName, activeNonAsgHosts, true); LOG.info(String.format("Successfully terminated %d non asg hosts for cluster %s: %s", activeNonAsgHosts.size(), clusterName, activeNonAsgHosts.toString())); } LOG.info("Successfully completed COMPLETING state, move to COMPLETED state"); ClusterUpgradeEventBean updateBean = new ClusterUpgradeEventBean(); updateBean.setHost_ids(""); // Do not set status, leave it updateBean.setState(ClusterUpgradeEventState.COMPLETED); updateBean.setLast_worked_on(System.currentTimeMillis()); transitionState(eventBean.getId(), updateBean); updateClusterState(clusterName); }
From source file:com.google.appinventor.components.runtime.GameClient.java
private void processInstanceLists(JSONObject instanceLists) { try {//from w w w . j a va2 s. c om joinedInstances = JsonUtil.getStringListFromJsonArray(instanceLists.getJSONArray(JOINED_LIST_KEY)); publicInstances = JsonUtil.getStringListFromJsonArray(instanceLists.getJSONArray(PUBLIC_LIST_KEY)); List<String> receivedInstancesInvited = JsonUtil .getStringListFromJsonArray(instanceLists.getJSONArray(INVITED_LIST_KEY)); if (!receivedInstancesInvited.equals(InvitedInstances())) { List<String> oldList = invitedInstances; invitedInstances = receivedInstancesInvited; List<String> newInvites = new ArrayList<String>(receivedInstancesInvited); newInvites.removeAll(oldList); for (final String instanceInvited : newInvites) { Invited(instanceInvited); } } } catch (JSONException e) { Log.w(LOG_TAG, e); Info("Instance lists failed to parse."); } }