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.zht.common.rabc.service.impl.RbacPermissionServiceImpl.java

@SuppressWarnings("unchecked")
@Override//  w  w  w .  ja va  2  s. com
public List<String> findAllPermsUserHaveAndInDefaultRole(String userName) {
    if (userName == null) {
        return null;
    }
    //defaultRbacRole
    String hqlFromRole = " select rp.rbacPermission.code from RbacRolePermission rp where rp.rbacRole.id in (select u.defaultRbacRole.id from RbacUser u where u.userName =:userName) ";

    //      String hqlFromRole=" select p.code from RbacPermission p join p.rbacRoles r where r.id = (select u.defaultRbacRole.id from RbacUser u where u.userName =:userName)";
    List<String> listFromRole = (List<String>) rbacPermissionDao.findJustList(hqlFromRole,
            new ParamObject(POType.H_NO_NC).addParam("userName", userName));

    String hqlFormUP = " select up.rbacPermission.code from RbacUserPermission up  where up.rbacUser.userName =:userName)";
    List<String> listFormUP = (List<String>) rbacPermissionDao.findJustList(hqlFormUP,
            new ParamObject(POType.H_NO_NC).addParam("userName", userName));

    String hql = " select upr.rbacPermission.code from RbacUserPermissionReject upr  where upr.rbacUser.userName =:userName)";
    List<String> listFromUPR = (List<String>) rbacPermissionDao.findJustList(hql,
            new ParamObject(POType.H_NO_NC).addParam("userName", userName));

    List<String> codeList = new ArrayList<String>();

    if (listFromRole != null) {
        codeList.addAll(listFromRole);
    }
    if (listFormUP != null) {
        codeList.addAll(listFormUP);
    }
    codeList = (List<String>) ZBeanUtil.removeDuplicateWithOrder(codeList);
    if (listFromUPR != null) {
        codeList.removeAll(listFromUPR);
    }
    return codeList;

}

From source file:com.infinity.controller.ElasticController.java

@RequestMapping(value = { "/elastic/exp/update/{id}" }, method = RequestMethod.POST)
public ModelAndView updateFormExp(@ModelAttribute("exp") Experiences exp, String candiatId)
        throws InterruptedException, JsonProcessingException, ExecutionException, UnsupportedEncodingException,
        IOException, ParseException {

    LOG.debug(candiatId);//from ww  w.  jav  a 2  s. co  m

    Candidat candidat = candidatService.getById(candiatId);
    candidat.setId(candiatId);
    PartialCandidat partialCandidat = new PartialCandidat();
    partialCandidat.setId(candidat.getId());
    partialCandidat.setName(candidat.getName());
    ArrayList<String> emptyTechno = new ArrayList<>();
    List<String> techno = exp.getTecnoList();
    for (String technoToRemove : exp.getTecnoList()) {
        if (technoToRemove.isEmpty()) {
            emptyTechno.add(technoToRemove);
        }
    }
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    Date start = simpleDateFormat.parse(exp.getStart());
    Date end = simpleDateFormat.parse(exp.getEnd());

    long diff = end.getTime() - start.getTime();

    float aYear = 31536000000.0f;
    float nbYear = diff / aYear;
    techno.removeAll(emptyTechno);
    exp.setDuration(nbYear);
    exp.setTecnoList(techno);
    exp.setPartialCandidat(partialCandidat);
    expService.updateById(exp);

    ModelAndView modelAndView = new ModelAndView("updateExp");
    modelAndView.addObject("exp", exp);
    return modelAndView;
}

From source file:com.hadoopvietnam.cache.memcached.MemcachedCache.java

/**
 * {@inheritDoc}/*from  www.j av  a  2s .c o  m*/
 */
public void removeFromLists(final List<String> inKeys, final List<Long> inValues) {
    Map<String, ArrayList<Long>> results = multiGetList(inKeys);
    for (final String key : results.keySet()) {
        if (log.isTraceEnabled()) {
            log.trace("Removing from list '" + key + "', values: " + inValues);
        }

        CASMutation<Object> mutation = new CASMutation<Object>() {
            // This is only invoked when a list already exists.
            public Object getNewValue(final Object current) {
                Object toReturn = current;
                List<Long> list;
                try {
                    list = getListFromBytes(current);
                    if (list != null) {
                        list.removeAll(inValues);
                    }

                    // always convert back to byte[] to return to memcached
                    toReturn = getBytesFromList(list);
                } catch (IOException e) {
                    // we had a problem serializing from cache ... log an error
                    // and continue assuming the app will reload from database for the next reader
                    log.error("Unable to retrieve key " + key + " from memcached.  Not able to delete "
                            + inValues + " from list.");
                }
                return toReturn;
            }
        };

        SerializingTranscoder transcoder = new SerializingTranscoder();
        CASMutator<Object> mutator = new CASMutator<Object>(client, transcoder);

        // This returns whatever value was successfully stored within the cache,
        // either the initial list or a mutated existing one
        try {
            byte[] initialValue = null;
            mutator.cas(key, initialValue, MAX_EXPIRATION_TIME, mutation);
        } catch (Exception e) {
            log.error("Nothing to delete from memcached for key - " + key, e);
        }

    }
}

From source file:com.inkubator.hrm.web.recruitment.RecruitmentRequestApprovalFormController.java

private RecruitHireApplyModel convertJsonToModel(String jsonData) throws Exception {

    RecruitHireApplyModel model = null;//from  ww w.ja v  a  2  s .  c o m
    Gson gson = JsonUtil.getHibernateEntityGsonBuilder().create();

    JsonParser parser = new JsonParser();
    JsonObject jsonObject = (JsonObject) parser.parse(jsonData);
    RecruitHireApply recruitHireApply = gson.fromJson(jsonObject, RecruitHireApply.class);
    model = getModelFromEntity(recruitHireApply);

    JsonArray arrayDetailRecruitmentRequest = jsonObject.getAsJsonArray("listDetailRecruitHireApply");
    List<OrgTypeOfSpecList> listTypeOfSpec = new ArrayList<>();

    if (null != arrayDetailRecruitmentRequest) {
        for (int i = 0; i < arrayDetailRecruitmentRequest.size(); i++) {
            RecruitHireApplyDetail detail = gson.fromJson(arrayDetailRecruitmentRequest.get(i),
                    RecruitHireApplyDetail.class);
            listTypeOfSpec.add(detail.getOrgTypeOfSpecList());
        }
    }

    //Group list by OrgTypeOfSpec.name
    Group<OrgTypeOfSpecList> groupOrgTypeOfSpecList = Lambda.group(listTypeOfSpec,
            Lambda.by(Lambda.on(OrgTypeOfSpecList.class).getOrgTypeOfSpec().getId()));

    //iterate each group list element
    for (String key : groupOrgTypeOfSpecList.keySet()) {

        List<OrgTypeOfSpecList> listGroupedOrgTypeOfSpecList = groupOrgTypeOfSpecList.find(key);
        OrgTypeOfSpec orgTypeOfSpec = orgTypeOfSpecService.getEntiyByPK(Long.parseLong(key));
        int index = name.indexOf(orgTypeOfSpec.getName());

        if (index != -1) {

            mapTypeList.put(orgTypeOfSpec.getName(), listGroupedOrgTypeOfSpecList);
            List<OrgTypeOfSpecList> listSource = dataForRenders.get(index).getSource();
            List<OrgTypeOfSpecList> listSourceToRemove = Lambda.select(listSource,
                    Lambda.having(Lambda.on(OrgTypeOfSpecList.class).getCode(),
                            Matchers.isIn(Lambda.extract(listGroupedOrgTypeOfSpecList,
                                    Lambda.on(OrgTypeOfSpecList.class).getCode()))));
            listSource.removeAll(listSourceToRemove);

            dataForRenders.get(index).setTarget(listGroupedOrgTypeOfSpecList);
            dataForRenders.get(index).setSource(listSource);
        }
    }

    return model;
}

From source file:edu.cmu.tetrad.sem.GeneralizedSemEstimator.java

public GeneralizedSemIm estimate2(GeneralizedSemPm pm, DataSet data) {

    GeneralizedSemIm estIm = new GeneralizedSemIm(pm);
    MyContext context = new MyContext();

    List<Node> nodes = pm.getGraph().getNodes();
    nodes.removeAll(pm.getErrorNodes());

    List<String> parameters = new ArrayList<>(pm.getParameters());

    LikelihoodFittingFunction5 likelihoodFittingFunction = new LikelihoodFittingFunction5(pm, parameters, nodes,
            data, context);//from  w w w.j a v a  2s.c  om

    double[] values = new double[parameters.size()];

    for (int j = 0; j < parameters.size(); j++) {
        Expression expression = pm.getParameterEstimationInitializationExpression(parameters.get(j));
        RealDistribution dist = expression.getRealDistribution(context);
        if (dist != null) {
            double lb = dist.getSupportLowerBound();
            double up = dist.getSupportUpperBound();
            values[j] = expression.evaluate(context);
            if (values[j] < lb)
                values[j] = lb;
            if (values[j] > up)
                values[j] = up;
        } else {
            values[j] = expression.evaluate(context);
        }
    }

    double[] point = optimize(likelihoodFittingFunction, values, 1);

    for (int j = 0; j < parameters.size(); j++) {
        estIm.setParameterValue(parameters.get(j), point[j]);
    }

    //        MultiGeneralAndersonDarlingTest test = new MultiGeneralAndersonDarlingTest(allResiduals, allDistributions);
    //        System.out.println("Multi AD A^2 = " + test.getASquared());
    //        System.out.println("Multi AD A^2-Star = " + test.getASquaredStar());
    //        System.out.println("Multi AD p = " + test.getP());

    return estIm;
}

From source file:com.isoftstone.crawl.template.crawlstate.CrawlState.java

/**
 * ??.//from   w  ww . j a v a 2 s .  c  o m
 *
 * @param pageModel
 * @return
 */
public String deleteCrawlerSeed(PageModel pageModel) {
    CrawlToolResource serviceHelper = new CrawlToolResource();
    ParseResult parseResult = serviceHelper.getParseResult(pageModel);
    String templateUrl = pageModel.getBasicInfoViewModel().getUrl();

    ArrayList<String> templateUrlList = new ArrayList<String>();
    templateUrlList.add(templateUrl);

    String pageSort = pageModel.getTemplateIncreaseViewModel().getPageSort();
    ArrayList<String> seedsTemp = TemplateFactory.getPaginationOutlink(parseResult);
    ArrayList<String> seeds = new ArrayList<String>();
    seeds.add(templateUrl);
    String incrementPageCountStr = pageModel.getTemplateIncreaseViewModel().getPageCounts();
    int incrementPageCount = Integer.valueOf(incrementPageCountStr);
    if (incrementPageCount > 0) {
        incrementPageCount = incrementPageCount - 1;
    }
    if ("??".equals(pageSort)) {
        for (int i = 0; i < incrementPageCount && i < seedsTemp.size(); i++) {
            seeds.add(seedsTemp.get(i));
        }
    } else {
        for (int i = seedsTemp.size() - 1; i >= 0 && incrementPageCount > 0; i--, incrementPageCount--) {
            seeds.add(seedsTemp.get(i));
        }
    }

    String domain = pageModel.getScheduleDispatchViewModel().getDomain();
    String period = pageModel.getTemplateIncreaseViewModel().getPeriod();
    String sequence = pageModel.getScheduleDispatchViewModel().getSequence();

    String folderName = domain + "_" + "1" + period + "_" + sequence;
    String incrementFolderName = domain + "_" + "1" + period + "_" + WebtoolConstants.INCREMENT_FILENAME_SIGN
            + "_" + sequence;

    //-- 1.1 ???.
    serviceHelper.deleteSeeds(folderName, templateUrlList);
    //-- 1.2 ???.
    serviceHelper.deleteSeeds(incrementFolderName, seeds);
    //-- 1.3 redis????.
    List<String> beforeSeedList = serviceHelper.getSeedListResult(templateUrl,
            Constants.SEEDLIST_REDIS_DEBINDEX);
    beforeSeedList.removeAll(seeds);
    serviceHelper.setSeedListResult(beforeSeedList, templateUrl, Constants.SEEDLIST_REDIS_DEBINDEX);

    // --2.?redis.
    // --2.1 ???redis.
    String normalRedisKey = folderName + WebtoolConstants.DISPATCH_REIDIS_POSTFIX_NORMAL;
    DispatchVo normalDispatchVo = RedisOperator.getDispatchResult(normalRedisKey,
            Constants.DISPATCH_REDIS_DBINDEX);
    if (normalDispatchVo == null) {
        LOG.info("??" + normalRedisKey);
        return "??";
    }
    List<Seed> normalSeedList = normalDispatchVo.getSeed();
    if (normalSeedList == null) {
        LOG.info("????" + normalRedisKey);
        return "????";
    }
    Seed normalSeed = new Seed(templateUrl, "false", WebtoolConstants.DISPATCH_STATIS_START);
    //--?????.
    normalSeedList.remove(normalSeed);
    if (normalSeedList.isEmpty()) {
        // -- ???key.
        RedisOperator.delFromDispatchDB(normalRedisKey);
    } else {
        normalDispatchVo.setSeed(normalSeedList);
        RedisOperator.setDispatchResult(normalDispatchVo, normalRedisKey, Constants.DISPATCH_REDIS_DBINDEX);
    }

    //-- 2.2 ???redis.
    String incrementRedisKey = folderName + WebtoolConstants.DISPATCH_REIDIS_POSTFIX_INCREMENT;

    DispatchVo dispatchVo = RedisOperator.getDispatchResult(incrementRedisKey,
            Constants.DISPATCH_REDIS_DBINDEX);
    if (dispatchVo == null) {
        LOG.info("??." + incrementRedisKey);
        return "??";
    }
    List<Seed> seedList = dispatchVo.getSeed();
    if (seedList == null) {
        LOG.info("????" + normalRedisKey);
        return "????";
    }
    for (Iterator<String> it = seeds.iterator(); it.hasNext();) {
        String seedStr = it.next();
        Seed seed = new Seed(seedStr, "false");
        seedList.remove(seed);
    }

    if (seedList.isEmpty()) {
        // -- ???key.
        RedisOperator.delFromDispatchDB(incrementRedisKey);
    } else {
        dispatchVo.setSeed(seedList);
        RedisOperator.setDispatchResult(dispatchVo, incrementRedisKey, Constants.DISPATCH_REDIS_DBINDEX);
    }
    return SUCCESS;
}

From source file:voldemort.ServerTestUtils.java

/***
 * //from  w  w w  .  j a  va  2s . co m
 * 
 * NOTE: This relies on the current behavior of the AsyncOperationService to
 * remove an operation if an explicit isComplete() is invoked. If/When that
 * is changed, this method will always block upto timeoutMs & return
 * 
 * @param server
 * @param asyncOperationPattern substring to match with the operation
 *        description
 * @param timeoutMs
 * @return
 */
public static boolean waitForAsyncOperationOnServer(VoldemortServer server, String asyncOperationPattern,
        long timeoutMs) {
    long endTimeMs = System.currentTimeMillis() + timeoutMs;
    AsyncOperationService service = server.getAsyncRunner();
    List<Integer> matchingOperationIds = null;
    // wait till the atleast one matching operation shows up
    while (System.currentTimeMillis() < endTimeMs) {
        matchingOperationIds = service.getMatchingAsyncOperationList(asyncOperationPattern, true);
        if (matchingOperationIds.size() > 0) {
            break;
        }
    }
    // now wait for those operations to complete
    while (System.currentTimeMillis() < endTimeMs) {
        List<Integer> completedOps = new ArrayList<Integer>(matchingOperationIds.size());
        for (Integer op : matchingOperationIds) {
            if (service.isComplete(op)) {
                completedOps.add(op);
            }
        }
        matchingOperationIds.removeAll(completedOps);
        if (matchingOperationIds.size() == 0) {
            return false;
        }
    }
    return false;
}

From source file:com.epam.ta.reportportal.core.item.history.TestItemsHistoryService.java

@Override
public void validateItems(List<TestItem> itemsForHistory, List<String> ids, String projectName) {
    // check all items loaded
    BusinessRule.expect(itemsForHistory, Preconditions.NOT_EMPTY_COLLECTION)
            .verify(UNABLE_LOAD_TEST_ITEM_HISTORY, "Unable to find history for items '" + ids + "'.");

    Set<String> projectIds = launchRepository
            .find(itemsForHistory.stream().map(TestItem::getLaunchRef).collect(toList())).stream()
            .map(Launch::getProjectRef).collect(toSet());

    BusinessRule//from   w ww  .  j  a v a 2s  . c om
            .expect((projectIds.size() == 1) && (projectIds.contains(projectName)), Predicates.equalTo(TRUE))
            .verify(UNABLE_LOAD_TEST_ITEM_HISTORY, "Unable to find history for items '" + ids + "'.");

    ids.removeAll(itemsForHistory.stream().map(TestItem::getId).collect(toList()));

    BusinessRule.expect(ids.isEmpty(), Predicates.equalTo(TRUE)).verify(UNABLE_LOAD_TEST_ITEM_HISTORY,
            "Unable to find history for items '" + ids + "'.");

    // check all items is siblings
    checkItemsIsSiblings(itemsForHistory);
}

From source file:com.flexive.war.beans.admin.main.WorkflowBean.java

/**
 * Return a list of all workflow step definitions that can be added to the current workflow
 * (i.e. all defined steps minus the steps already used in the workflow).
 *
 * @return a list of all workflow step definitions that can be added to the current workflow
 *///from  ww w.  j  a v a 2  s .c o m
@SuppressWarnings("unchecked")
public List<SelectItem> getStepsForAdding() {
    final List<StepDefinition> stepDefinitions = new ArrayList<StepDefinition>(
            CacheAdmin.getFilteredEnvironment().getStepDefinitions());
    List<StepEdit> steps = currentWorkflow.steps;
    stepDefinitions.removeAll(FxSharedUtils.getUsedStepDefinitions(
            steps != null ? steps : currentWorkflow.workflow.getSteps(), stepDefinitions));
    return FxJsfUtils.asSelectListWithLabel(stepDefinitions);
}

From source file:com.alibaba.jstorm.schedule.default_assign.WorkerScheduler.java

private void checkUserDefineWorkers(DefaultTopologyAssignContext context, List<WorkerAssignment> workers,
        Map<Integer, String> taskToComponent) {
    Set<ResourceWorkerSlot> unstoppedWorkers = context.getUnstoppedWorkers();
    List<WorkerAssignment> re = new ArrayList<WorkerAssignment>();
    for (WorkerAssignment worker : workers) {
        for (ResourceWorkerSlot unstopped : unstoppedWorkers) {
            if (unstopped.compareToUserDefineWorker(worker, taskToComponent))
                re.add(worker);//w w  w .  j a v  a2 s.c o  m
        }
    }
    workers.removeAll(re);

}