Example usage for java.util List removeAll

List of usage examples for java.util List removeAll

Introduction

In this page you can find the example usage for java.util List removeAll.

Prototype

boolean removeAll(Collection<?> c);

Source Link

Document

Removes from this list all of its elements that are contained in the specified collection (optional operation).

Usage

From source file:net.cpollet.jixture.asserts.JixtureAssert.java

public JixtureAssert containsAtMost(List<Fixture> fixtures) {
    List<Map<String, ?>> expectedMaps = new LinkedList<Map<String, ?>>();

    for (Fixture fixture : fixtures) {
        expectedMaps.addAll(getExpectedMaps(fixture));
    }//from   w  w w  .ja v  a  2  s .c  o  m

    List<Map<String, ?>> actualMaps = getActualMaps();

    actualMaps.removeAll(expectedMaps);

    if (0 != actualMaps.size()) {
        throw new AssertionError("Unexpected but present elements " + actualMaps.toString());
    }

    return this;
}

From source file:de.sub.goobi.metadaten.RenderableMetadatum.java

/**
 * Updates the bound metadata group by the current value(s) of the
 * implementing instance./*from  w w  w.j a  va  2  s . c om*/
 */
protected void updateBinding() {
    if (binding != null) {
        List<Metadata> bound = binding.getMetadataList();
        bound.removeAll(binding.getMetadataByType(metadataType.getName()));
        bound.addAll(((RenderableGroupableMetadatum) this).toMetadata());
    }
}

From source file:edu.cornell.mannlib.vivo.utilities.rdbmigration.RdbMigrator.java

private boolean isUnexpectedModels() {
    List<String> unexpectedModels = new ArrayList<>(modelsToCopy);
    unexpectedModels.removeAll(EXPECTED_MODELS);
    if (unexpectedModels.isEmpty()) {
        return false;
    }//w w w . j a v  a2  s  .  co  m

    System.out.println(
            "VIVO requires only these models from RDB:\n   " + StringUtils.join(EXPECTED_MODELS, "\n   ")
                    + "\nYour RDB triple-store contains these additional models:\n   "
                    + StringUtils.join(unexpectedModels, "\n   "));
    return true;
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.ExamCoordinatorsForGivenUnit.java

@Override
public Object provide(Object source, Object currentValue) {
    VigilantGroupBean bean = (VigilantGroupBean) source;
    ExecutionYear currentYear = ExecutionYear.readCurrentExecutionYear();
    Unit unit = bean.getSelectedUnit();// ww w  . j  a va2  s .co m
    List<ExamCoordinator> coordinators = new ArrayList<ExamCoordinator>();
    if (unit != null) {
        coordinators.addAll(unit.getExamCoordinatorsForGivenYear(currentYear));
    }
    VigilantGroup group = bean.getSelectedVigilantGroup();
    if (group != null) {
        coordinators.removeAll(group.getExamCoordinatorsSet());
    }

    Collections.sort(coordinators, new BeanComparator("person.name"));
    return coordinators;

}

From source file:org.openmrs.web.controller.maintenance.GlobalPropertyController.java

/**
 * The onSubmit function receives the form/command object that was modified
 * by the input form and saves it to the db
 *
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 * @should save or update included properties
 * @should purge not included properties
 *//*from w  w  w  .j  av  a 2  s.  co  m*/
@SuppressWarnings("unchecked")
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    String action = request.getParameter("action");
    if (action == null) {
        action = "cancel";
    }

    if (action.equals(getMessageSourceAccessor().getMessage("general.save"))) {
        HttpSession httpSession = request.getSession();

        if (Context.isAuthenticated()) {
            AdministrationService as = Context.getAdministrationService();

            // fetch the backing object
            // and save it to a hashmap for easy retrieval of
            // already-used-GPs
            List<GlobalProperty> formBackingObject = (List<GlobalProperty>) obj;
            Map<String, GlobalProperty> formBackingObjectMap = new HashMap<String, GlobalProperty>();
            for (GlobalProperty prop : formBackingObject) {
                formBackingObjectMap.put(prop.getProperty(), prop);
            }

            // the list we'll save to the database
            List<GlobalProperty> globalPropList = new ArrayList<GlobalProperty>();

            String[] keys = request.getParameterValues(PROP_NAME);
            String[] values = request.getParameterValues(PROP_VAL_NAME);
            String[] descriptions = request.getParameterValues(PROP_DESC_NAME);

            for (int x = 0; x < keys.length; x++) {
                String key = keys[x];
                String val = values[x];
                String desc = descriptions[x];

                // try to get an already-used global property for this key
                GlobalProperty tmpGlobalProperty = formBackingObjectMap.get(key);

                // if it exists, use that object...just update it
                if (tmpGlobalProperty != null) {
                    tmpGlobalProperty.setPropertyValue(val);
                    tmpGlobalProperty.setDescription(desc);
                    globalPropList.add(tmpGlobalProperty);
                } else {
                    // if it doesn't exist, create a new global property
                    globalPropList.add(new GlobalProperty(key, val, desc));
                }
            }

            try {
                // delete all properties not in this new list
                List<GlobalProperty> purgeGlobalPropList = new ArrayList<GlobalProperty>(
                        as.getAllGlobalProperties());
                purgeGlobalPropList.removeAll(globalPropList);
                as.purgeGlobalProperties(purgeGlobalPropList);

                as.saveGlobalProperties(globalPropList);
                httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "GlobalProperty.saved");

                // refresh log level from global property(ies)
                OpenmrsUtil.applyLogLevels();

                OpenmrsUtil.setupLogAppenders();
            } catch (Exception e) {
                log.error("Error saving properties", e);
                httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "GlobalProperty.not.saved");
                httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, e.getMessage());
            }

            return new ModelAndView(new RedirectView(getSuccessView()));

        }
    }

    return showForm(request, response, errors);

}

From source file:io.cloudslang.lang.compiler.validator.CompileValidatorImpl.java

private List<String> getInputsNotWired(List<String> mandatoryInputNames, List<String> stepInputNames) {
    List<String> inputsNotWired = new ArrayList<>(mandatoryInputNames);
    inputsNotWired.removeAll(stepInputNames);
    return inputsNotWired;
}

From source file:mondrian.olap.IdBatchResolverTest.java

private void assertContains(String msg, Collection<String> strings, Collection<String> list) {
    if (!strings.containsAll(list)) {
        List<String> copy = new ArrayList<String>(list);
        copy.removeAll(strings);
        fail(String.format("%s\nMissing: %s", msg, Arrays.toString(copy.toArray())));
    }/*from  w  w  w .ja v a 2 s.co  m*/
}

From source file:br.com.anteros.social.facebook.AnterosFacebookSession.java

private List<String> getNotGrantedReadPermissions() {
    Set<String> grantedPermissions = getAcceptedPermissions();
    List<String> readPermissions = new ArrayList<>(configuration.getReadPermissions());
    readPermissions.removeAll(grantedPermissions);
    return readPermissions;
}

From source file:com.celements.web.plugin.cmd.DocFormCommand.java

String collapse(String[] value) {
    List<String> valueList = new ArrayList<String>(Arrays.asList(value));
    valueList.removeAll(Arrays.asList((String) null));
    valueList.removeAll(Arrays.asList(""));
    return StringUtils.join(valueList.toArray(), "|");
}

From source file:br.com.hslife.orcamento.task.AgendamentoTask.java

@Scheduled(fixedDelay = 3600000)
@SuppressWarnings("deprecation")
public void executarTarefa() {
    try {/*from www.j a  v a  2  s. c om*/

        CriterioAgendamento criterioAgendamento = new CriterioAgendamento();
        criterioAgendamento.setTipo(TipoAgendamento.PREVISAO);

        List<Agenda> agendamentos = getService().buscarPorCriterioAgendamento(criterioAgendamento);
        List<LancamentoConta> lancamentosAtualizados = new ArrayList<>();
        LancamentoConta lancamento;
        Date dataLancamento;

        for (Agenda agenda : agendamentos) {
            Date dataAgenda = new Date(agenda.getInicio().getYear() + 1900, agenda.getInicio().getMonth(),
                    agenda.getInicio().getDate(), 0, 0, 0);
            switch (agenda.getEntity()) {
            case "LancamentoConta":
                lancamento = getLancamentoContaService().buscarPorID(agenda.getIdEntity());
                if (lancamento != null) {
                    dataLancamento = new Date(lancamento.getDataPagamento().getYear() + 1900,
                            lancamento.getDataPagamento().getMonth(), lancamento.getDataPagamento().getDate(),
                            0, 0, 0);
                    if (lancamento.getStatusLancamentoConta().equals(StatusLancamentoConta.AGENDADO)
                            && dataLancamento.equals(dataAgenda)) {
                        lancamentosAtualizados.add(lancamento);
                    } else {
                        getService().excluir(agenda);
                    }
                } else {
                    getService().excluir(agenda);
                }
                break;
            default:
                break;
            }
        }

        CriterioBuscaLancamentoConta criterioBusca = new CriterioBuscaLancamentoConta();
        criterioBusca.setStatusLancamentoConta(new StatusLancamentoConta[] { StatusLancamentoConta.AGENDADO });
        criterioBusca.setDataInicio(new Date());

        List<LancamentoConta> lancamentos = getLancamentoContaService().buscarPorCriterioBusca(criterioBusca);
        lancamentos.removeAll(lancamentosAtualizados);

        for (LancamentoConta l : lancamentos) {
            Agenda agenda = new Agenda();
            agenda.setDescricao(l.getDescricao());
            agenda.setInicio(l.getDataPagamento());
            agenda.setFim(l.getDataPagamento());
            agenda.setDiaInteiro(true);
            agenda.setEmitirAlerta(true);
            agenda.setTipoAgendamento(TipoAgendamento.PREVISAO);
            agenda.setNotas(l.getObservacao());
            agenda.setUsuario(l.getConta().getUsuario());
            agenda.setIdEntity(l.getId());
            agenda.setEntity(l.getClass().getSimpleName());

            getService().cadastrar(agenda);
        }

    } catch (Exception e) {
        logger.catching(e);
        e.printStackTrace();
    }
}