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:com.zimbra.cs.util.SpamExtract.java

private static void extract(String authToken, Account account, Server server, String query, File outdir,
        boolean delete, boolean raw) throws ServiceException, HttpException, SoapFaultException, IOException {
    String soapURL = getSoapURL(server, false);

    URL restURL = getServerURL(server, false);
    HttpClient hc = new HttpClient(); // CLI only, don't need conn mgr
    HttpState state = new HttpState();
    GetMethod gm = new GetMethod();
    gm.setFollowRedirects(true);// ww  w. ja  va2  s.c o m
    Cookie authCookie = new Cookie(restURL.getHost(), ZimbraCookie.COOKIE_ZM_AUTH_TOKEN, authToken, "/", -1,
            false);
    state.addCookie(authCookie);
    hc.setState(state);
    hc.getHostConfiguration().setHost(restURL.getHost(), restURL.getPort(),
            Protocol.getProtocol(restURL.getProtocol()));
    gm.getParams().setSoTimeout(60000);

    if (verbose) {
        LOG.info("Mailbox requests to: " + restURL);
    }

    SoapHttpTransport transport = new SoapHttpTransport(soapURL);
    transport.setRetryCount(1);
    transport.setTimeout(0);
    transport.setAuthToken(authToken);

    int totalProcessed = 0;
    boolean haveMore = true;
    int offset = 0;
    while (haveMore) {
        Element searchReq = new Element.XMLElement(MailConstants.SEARCH_REQUEST);
        searchReq.addElement(MailConstants.A_QUERY).setText(query);
        searchReq.addAttribute(MailConstants.A_SEARCH_TYPES, MailItem.Type.MESSAGE.toString());
        searchReq.addAttribute(MailConstants.A_QUERY_OFFSET, offset);
        searchReq.addAttribute(MailConstants.A_LIMIT, BATCH_SIZE);

        try {
            if (LOG.isDebugEnabled()) {
                LOG.debug(searchReq.prettyPrint());
            }
            Element searchResp = transport.invoke(searchReq, false, true, account.getId());
            if (LOG.isDebugEnabled()) {
                LOG.debug(searchResp.prettyPrint());
            }

            StringBuilder deleteList = new StringBuilder();

            List<String> ids = new ArrayList<String>();
            for (Iterator<Element> iter = searchResp.elementIterator(MailConstants.E_MSG); iter.hasNext();) {
                offset++;
                Element e = iter.next();
                String mid = e.getAttribute(MailConstants.A_ID);
                if (mid == null) {
                    LOG.warn("null message id SOAP response");
                    continue;
                }

                LOG.debug("adding id %s", mid);
                ids.add(mid);
                if (ids.size() >= BATCH_SIZE || !iter.hasNext()) {
                    StringBuilder path = new StringBuilder("/service/user/" + account.getName()
                            + "/?fmt=tgz&list=" + StringUtils.join(ids, ","));
                    LOG.debug("sending request for path %s", path.toString());
                    List<String> extractedIds = extractMessages(hc, gm, path.toString(), outdir, raw);
                    if (ids.size() > extractedIds.size()) {
                        ids.removeAll(extractedIds);
                        LOG.warn("failed to extract %s", ids);
                    }
                    for (String id : extractedIds) {
                        deleteList.append(id).append(',');
                    }

                    ids.clear();
                }
                totalProcessed++;
            }

            haveMore = false;
            String more = searchResp.getAttribute(MailConstants.A_QUERY_MORE);
            if (more != null && more.length() > 0) {
                try {
                    int m = Integer.parseInt(more);
                    if (m > 0) {
                        haveMore = true;
                        try {
                            Thread.sleep(SLEEP_TIME);
                        } catch (InterruptedException e) {
                        }
                    }
                } catch (NumberFormatException nfe) {
                    LOG.warn("more flag from server not a number: " + more, nfe);
                }
            }

            if (delete && deleteList.length() > 0) {
                deleteList.deleteCharAt(deleteList.length() - 1); // -1 removes trailing comma
                Element msgActionReq = new Element.XMLElement(MailConstants.MSG_ACTION_REQUEST);
                Element action = msgActionReq.addElement(MailConstants.E_ACTION);
                action.addAttribute(MailConstants.A_ID, deleteList.toString());
                action.addAttribute(MailConstants.A_OPERATION, ItemAction.OP_HARD_DELETE);

                if (LOG.isDebugEnabled()) {
                    LOG.debug(msgActionReq.prettyPrint());
                }
                Element msgActionResp = transport.invoke(msgActionReq, false, true, account.getId());
                if (LOG.isDebugEnabled()) {
                    LOG.debug(msgActionResp.prettyPrint());
                }
                offset = 0; //put offset back to 0 so we always get top N messages even after delete
            }
        } finally {
            gm.releaseConnection();
        }

    }
    LOG.info("Total messages processed: " + totalProcessed);
}

From source file:edu.byu.softwareDist.manager.impl.FileSetManagerImpl.java

@Override
public FileLicenseSet findAssociatedLicenseSetsByFileSetId(Integer fileSetId) {
    List<String> nonAssociated = new ArrayList<String>();
    List<String> associated = new ArrayList<String>();
    final List<LicenseSet> nonAssociatedLists = lsdao.findAll();
    for (LicenseSet ls : nonAssociatedLists) {
        nonAssociated.add(ls.getName());
    }//from  www .jav  a 2  s.  c  o  m

    final List<LicenseSet> associatedLists = lsdao.findAllByFileSetId(fileSetId);
    for (LicenseSet lsn : associatedLists) {
        associated.add(lsn.getName());
    }
    nonAssociated.removeAll(associated);
    return new FileLicenseSet(fileSetId, associated, nonAssociated);
}

From source file:gov.nih.nci.caintegrator.application.study.GenomicDataSourceConfiguration.java

/**
 * @return the unmapped samples//from   w w w .j a  v  a  2 s. c  o  m
 */
public List<Sample> getUnmappedSamples() {
    List<Sample> unmappedSamples = new ArrayList<Sample>(getSamples());
    if (CollectionUtils.isNotEmpty(getStudyConfiguration().getAllControlSamples())) {
        unmappedSamples.removeAll(getStudyConfiguration().getAllControlSamples());
    }
    unmappedSamples.removeAll(getStudyConfiguration().getSamples());
    addRefreshFlagToUnMappedSamples(unmappedSamples, getRefreshSampleNames());
    return unmappedSamples;
}

From source file:com.inkubator.hrm.web.payroll.PaySalaryComponentFormController.java

@PostConstruct
@Override/*from   w w  w.jav a 2  s  .  c o m*/
public void initialization() {
    super.initialization();
    try {
        disableTax = Boolean.TRUE;
        model = new PaySalaryComponentModel();
        isUpdate = Boolean.FALSE;
        loanId = FacesUtil.getRequestParameter("execution");
        if (StringUtils.isNotEmpty(loanId)) {
            PaySalaryComponent paySalaryComponent = paySalaryComponentService
                    .getEntityByPkWithDetail(Long.parseLong(loanId.substring(1)));
            if (loanId.substring(1) != null) {
                model = getModelFromEntity(paySalaryComponent);
                dropDownModelRef = new HashMap<>();
                //                    Long modRefId = Long.parseLong(String.valueOf(model.getModelReffernsiId()));
                try {
                    dropDownModelRef = this.paySalaryComponentService.returnComponentChange(
                            paySalaryComponent.getModelComponent().getId(), model.getModelReffernsiId());

                    if (dropDownModelRef.size() > 0) {
                        isDisableComponetModel = Boolean.FALSE;
                    } else {
                        isDisableComponetModel = Boolean.TRUE;
                    }
                } catch (Exception ex) {
                    LOGGER.info(ex, ex);
                }
                List<EmployeeType> sourceSpiRole = this.employeeTypeService.getAllData();
                List<EmployeeType> targetRole = paySalaryComponent.getEmployeeTypes();
                sourceSpiRole.removeAll(targetRole);
                //
                dualListModel = new DualListModel<>(sourceSpiRole, targetRole);
                isUpdate = Boolean.TRUE;
            }
        } else {
            List<EmployeeType> source = this.employeeTypeService.getAllData();
            dualListModel.setSource(source);
            isDisableComponetModel = Boolean.TRUE;
        }

        listDrowDown();
    } catch (Exception e) {
        LOGGER.error("Error", e);
    }
}

From source file:com.bigdata.dastor.service.StorageService.java

public static void calculatePendingRanges(AbstractReplicationStrategy strategy, String table) {
    TokenMetadata tm = StorageService.instance.getTokenMetadata();
    Multimap<Range, InetAddress> pendingRanges = HashMultimap.create();
    Map<Token, InetAddress> bootstrapTokens = tm.getBootstrapTokens();
    Set<InetAddress> leavingEndPoints = tm.getLeavingEndPoints();

    if (bootstrapTokens.isEmpty() && leavingEndPoints.isEmpty()) {
        if (logger_.isDebugEnabled())
            logger_.debug("No bootstrapping or leaving nodes -> empty pending ranges for " + table);
        tm.setPendingRanges(table, pendingRanges);
        return;/*from   w  w  w  .j a  v  a  2s.c  om*/
    }

    Multimap<InetAddress, Range> addressRanges = strategy.getAddressRanges(table);

    // Copy of metadata reflecting the situation after all leave operations are finished.
    TokenMetadata allLeftMetadata = tm.cloneAfterAllLeft();

    // get all ranges that will be affected by leaving nodes
    Set<Range> affectedRanges = new HashSet<Range>();
    for (InetAddress endPoint : leavingEndPoints)
        affectedRanges.addAll(addressRanges.get(endPoint));

    // for each of those ranges, find what new nodes will be responsible for the range when
    // all leaving nodes are gone.
    for (Range range : affectedRanges) {
        List<InetAddress> currentEndPoints = strategy.getNaturalEndpoints(range.right, tm, table);
        List<InetAddress> newEndPoints = strategy.getNaturalEndpoints(range.right, allLeftMetadata, table);
        newEndPoints.removeAll(currentEndPoints);
        pendingRanges.putAll(range, newEndPoints);
    }

    // At this stage pendingRanges has been updated according to leave operations. We can
    // now finish the calculation by checking bootstrapping nodes.

    // For each of the bootstrapping nodes, simply add and remove them one by one to
    // allLeftMetadata and check in between what their ranges would be.
    for (Map.Entry<Token, InetAddress> entry : bootstrapTokens.entrySet()) {
        InetAddress endPoint = entry.getValue();

        allLeftMetadata.updateNormalToken(entry.getKey(), endPoint);
        for (Range range : strategy.getAddressRanges(allLeftMetadata, table).get(endPoint))
            pendingRanges.put(range, endPoint);
        allLeftMetadata.removeEndpoint(endPoint);
    }

    tm.setPendingRanges(table, pendingRanges);

    if (logger_.isDebugEnabled())
        logger_.debug("Pending ranges:\n" + (pendingRanges.isEmpty() ? "<empty>" : tm.printPendingRanges()));
}

From source file:org.openmrs.module.ipd.web.controller.PatientAdmittedController.java

@RequestMapping(value = "/module/ipd/discharge.htm", method = RequestMethod.GET)
public String dischargeView(@RequestParam(value = "id", required = false) Integer admittedId,
        @ModelAttribute("ipdCommand") IpdFinalResultCommand command, Model model) {

    IpdService ipdService = (IpdService) Context.getService(IpdService.class);
    IpdPatientAdmitted admitted = ipdService.getIpdPatientAdmitted(admittedId);

    Patient patient = admitted.getPatient();
    model.addAttribute("patientId", patient.getId());

    PersonAddress add = patient.getPersonAddress();
    String address = " " + add.getAddress1() + " " + add.getCountyDistrict() + " " + add.getCityVillage();
    model.addAttribute("address", address);

    PersonAttribute relationNameattr = patient.getAttribute("Father/Husband Name");
    //ghanshyam 10/07/2012 New Requirement #312 [IPD] Add fields in the Discharge screen and print out
    PersonAttribute relationTypeattr = patient.getAttribute("Relative Name Type");
    model.addAttribute("relationName", relationNameattr.getValue());
    //ghanshyam 30/07/2012 this code modified under feedback of 'New Requirement #312
    if (relationTypeattr != null) {
        model.addAttribute("relationType", relationTypeattr.getValue());
    } else {//w w  w .j  av a  2s. co m
        model.addAttribute("relationType", "Relative Name");
    }
    model.addAttribute("dateTime", new Date().toString());

    Concept outComeList = Context.getConceptService()
            .getConceptByName(HospitalCoreConstants.CONCEPT_ADMISSION_OUTCOME);

    model.addAttribute("listOutCome", outComeList.getAnswers());

    model.addAttribute("admitted", admitted);

    //change CHUYEN

    //
    ConceptService conceptService = Context.getConceptService();
    AdministrationService administrationService = Context.getAdministrationService();
    String gpDiagnosis = administrationService
            .getGlobalProperty(PatientDashboardConstants.PROPERTY_PROVISIONAL_DIAGNOSIS);
    String gpProcedure = administrationService
            .getGlobalProperty(PatientDashboardConstants.PROPERTY_POST_FOR_PROCEDURE);
    List<Obs> obsList = new ArrayList<Obs>(admitted.getPatientAdmissionLog().getIpdEncounter().getAllObs());
    Concept conDiagnosis = conceptService.getConcept(gpDiagnosis);

    Concept conProcedure = conceptService.getConcept(gpProcedure);

    List<Concept> selectedDiagnosisList = new ArrayList<Concept>();
    List<Concept> selectedProcedureList = new ArrayList<Concept>();
    if (CollectionUtils.isNotEmpty(obsList)) {
        for (Obs obs : obsList) {
            if (obs.getConcept().getConceptId().equals(conDiagnosis.getConceptId())) {
                selectedDiagnosisList.add(obs.getValueCoded());
            }
            if (obs.getConcept().getConceptId().equals(conProcedure.getConceptId())) {
                selectedProcedureList.add(obs.getValueCoded());
            }
        }
    }

    //
    PatientDashboardService dashboardService = Context.getService(PatientDashboardService.class);
    List<Concept> diagnosis = dashboardService.listByDepartmentByWard(admitted.getAdmittedWard().getId(),
            DepartmentConcept.TYPES[0]);
    if (CollectionUtils.isNotEmpty(diagnosis) && CollectionUtils.isNotEmpty(selectedDiagnosisList)) {
        diagnosis.removeAll(selectedDiagnosisList);
    }
    if (CollectionUtils.isNotEmpty(diagnosis)) {
        Collections.sort(diagnosis, new ConceptComparator());
    }
    model.addAttribute("listDiagnosis", diagnosis);
    List<Concept> procedures = dashboardService.listByDepartmentByWard(admitted.getAdmittedWard().getId(),
            DepartmentConcept.TYPES[1]);
    if (CollectionUtils.isNotEmpty(procedures) && CollectionUtils.isNotEmpty(selectedProcedureList)) {
        procedures.removeAll(selectedProcedureList);
    }
    if (CollectionUtils.isNotEmpty(procedures)) {
        Collections.sort(procedures, new ConceptComparator());
    }
    model.addAttribute("listProcedures", procedures);
    //

    /*      
    PatientDashboardService dashboardService = Context.getService(PatientDashboardService.class);
    List<Concept> diagnosis = dashboardService.searchDiagnosis(null);
    if(CollectionUtils.isNotEmpty(diagnosis) && CollectionUtils.isNotEmpty(selectedDiagnosisList)){
       diagnosis.removeAll(selectedDiagnosisList);
    }
    Collections.sort(diagnosis, new ConceptComparator());
    model.addAttribute("listDiagnosis", diagnosis);
    List<Concept> procedures = dashboardService.searchProcedure(null);
    if(CollectionUtils.isNotEmpty(procedures) && CollectionUtils.isNotEmpty(selectedProcedureList)){
       procedures.removeAll(selectedProcedureList);
    }
    Collections.sort(procedures, new ConceptComparator());
    model.addAttribute("listProcedures", procedures);*/
    Collections.sort(selectedDiagnosisList, new ConceptComparator());
    Collections.sort(selectedProcedureList, new ConceptComparator());
    //Patient category
    model.addAttribute("patCategory", PatientUtils.getPatientCategory(patient));
    model.addAttribute("sDiagnosisList", selectedDiagnosisList);
    model.addAttribute("sProcedureList", selectedProcedureList);

    return "module/ipd/dischargeForm";
}

From source file:com.baidu.rigel.biplatform.tesseract.datasource.DynamicSqlDataSource.java

/**
 * ?DataSourcekey???KEY ?KEY//from w  ww. ja  va  2 s  .  com
 * 
 * @return ?DataSourcekey
 * @throw IllegalArgumentException ??
 */
private String getDataSourceKey() {
    if (MapUtils.isEmpty(dataSources)) {
        throw new IllegalArgumentException("can not get datasource by empty datasources!");
    }
    List<String> allKeys = Lists.newArrayList(dataSources.keySet());
    LOGGER.debug("get " + allKeys.size() + " size avaliable datasources");
    if (!failedMap.isEmpty()) {
        Set<String> failedKeys = failedMap.keySet();
        LOGGER.warn("found failed datasource keys :" + failedKeys);
        allKeys.removeAll(failedKeys);
        accessValidDataSourceKeys.removeAll(failedKeys);
    }
    if (allKeys.size() > 0) {
        allKeys.removeAll(accessValidDataSourceKeys);
        if (allKeys.size() > 0) {
            LOGGER.debug("after filter access valid datasource," + allKeys);
            return allKeys.get(0);
        } else {
            LOGGER.debug("return first time access datasource key:" + accessValidDataSourceKeys);
            return (String) accessValidDataSourceKeys.toArray()[0];
        }
    }
    throw new IllegalArgumentException("can not get datasource key because all datasource is failed!");
}

From source file:org.openmrs.module.orderextension.web.controller.OrderExtensionOrderController.java

/**
 * Shows the page to list order sets//from w  ww . ja v a  2  s  . c om
 */
@RequestMapping(value = "/module/orderextension/orderList")
public void listOrders(ModelMap model, @RequestParam(value = "patientId", required = true) Integer patientId) {
    Patient patient = Context.getPatientService().getPatient(patientId);

    model.addAttribute("patient", patient);

    List<DrugRegimen> regimens = Context.getService(OrderExtensionService.class).getOrderGroups(patient,
            DrugRegimen.class);
    model.addAttribute("regimens", regimens);

    List<DrugOrder> drugOrders = Context.getOrderService().getDrugOrdersByPatient(patient);
    for (DrugRegimen r : regimens) {
        drugOrders.removeAll(r.getMembers());
    }
    model.addAttribute("drugOrders", drugOrders);

    model.addAttribute("orderSets", Context.getService(OrderExtensionService.class).getNamedOrderSets(false));
}

From source file:com.msopentech.odatajclient.testservice.AbstractServices.java

@DELETE
@Path("/{entitySetName}({entityId})/$links/{linkName}({linkId})")
public Response deleteLink(@HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
        @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
        @PathParam("entitySetName") String entitySetName, @PathParam("entityId") String entityId,
        @PathParam("linkName") String linkName, @PathParam("linkId") String linkId,
        @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
    try {/*  w  w  w. j  a  v  a 2s. c o m*/
        final Accept acceptType;
        if (StringUtils.isNotBlank(format)) {
            acceptType = Accept.valueOf(format.toUpperCase());
        } else {
            acceptType = Accept.parse(accept, getVersion());
        }

        if (acceptType == Accept.ATOM) {
            throw new UnsupportedMediaTypeException("Unsupported media type");
        }

        final AbstractUtilities utils = getUtilities(acceptType);

        final Map.Entry<String, List<String>> currents = JSONUtilities.extractLinkURIs(
                utils.readLinks(entitySetName, entityId, linkName, Accept.JSON_FULLMETA).getLinks());

        final Map.Entry<String, List<String>> toBeRemoved = JSONUtilities.extractLinkURIs(
                utils.readLinks(entitySetName, entityId, linkName + "(" + linkId + ")", Accept.JSON_FULLMETA)
                        .getLinks());

        final List<String> remains = currents.getValue();
        remains.removeAll(toBeRemoved.getValue());

        utils.putLinksInMemory(Commons.getEntityBasePath(entitySetName, entityId), entitySetName, linkName,
                remains);

        return xml.createResponse(null, null, null, Response.Status.NO_CONTENT);
    } catch (Exception e) {
        return xml.createFaultResponse(accept, e);
    }
}

From source file:org.tjm.setting.controller.VisibilityController.java

/**
 * ?/*  w  w  w  .java 2 s .  c  o m*/
 */
public void checkOutCheckInFile() {
    // FileIdentityFactory ??  Map 
    FileIdentityFactory.getInstance().refresh();
    // ? Map (????)
    Map<FileIdentity, String> identityMap = FileIdentityFactory.getInstance().getIdentityMap();
    Set<FileIdentity> keys = identityMap.keySet();
    // ? List
    List<FileIdentity> realFileIdentityList = new ArrayList<FileIdentity>();
    // ??
    for (FileIdentity fi : keys) {
        realFileIdentityList.add(fi);
    }
    // ? List
    List<FileIdentity> clone_realFileIdentityList = new ArrayList<FileIdentity>(realFileIdentityList);
    // DB List
    List<FileIdentity> dbFileIdentityList = fileIdentityDao.selectAll();
    //  ?  ?
    realFileIdentityList.removeAll(dbFileIdentityList);
    for (FileIdentity add_fileIdentity : realFileIdentityList) {
        logger.warn(
                " : " + add_fileIdentity.getFilepath() + "?...");
        fileIdentityDao.save(add_fileIdentity);
        logger.warn(" : " + add_fileIdentity.getFilepath() + " ?...");
    }

    //    ??
    dbFileIdentityList.removeAll(clone_realFileIdentityList);

    for (FileIdentity delete_fileIdentity : dbFileIdentityList) {

        logger.warn(" : " + delete_fileIdentity.getFilepath()
                + "?...");
        fileIdentityDao.remove(delete_fileIdentity.getId());
        logger.warn(" : " + delete_fileIdentity.getFilepath() + " ?...");
    }
}