Example usage for java.util Collection addAll

List of usage examples for java.util Collection addAll

Introduction

In this page you can find the example usage for java.util Collection addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this collection (optional operation).

Usage

From source file:com.epam.cme.storefront.breadcrumb.impl.ProductBreadcrumbBuilder.java

public List<Breadcrumb> getBreadcrumbs(final ProductModel productModel) throws IllegalArgumentException {
    final List<Breadcrumb> breadcrumbs = new ArrayList<Breadcrumb>();

    final Collection<CategoryModel> categoryModels = new ArrayList<CategoryModel>();
    final Breadcrumb last;

    final ProductModel baseProductModel = getBaseProduct(productModel);
    last = getProductBreadcrumb(baseProductModel);
    categoryModels.addAll(baseProductModel.getSupercategories());
    last.setLinkClass(LAST_LINK_CLASS);//from   w w w.j  a va 2  s  .c o m

    breadcrumbs.add(last);

    while (!categoryModels.isEmpty()) {
        CategoryModel toDisplay = null;
        for (final CategoryModel categoryModel : categoryModels) {
            if (!(categoryModel instanceof ClassificationClassModel)) {
                if (toDisplay == null) {
                    toDisplay = categoryModel;
                }
                if (getBrowseHistory().findEntryMatchUrlEndsWith(categoryModel.getCode()) != null) {
                    break;
                }
            }
        }
        categoryModels.clear();
        if (toDisplay != null) {
            breadcrumbs.add(getCategoryBreadcrumb(getCategoryConverter().convert(toDisplay)));
            categoryModels.addAll(toDisplay.getSupercategories());
        }
    }
    Collections.reverse(breadcrumbs);
    return breadcrumbs;
}

From source file:com.playonlinux.wine.WinePrefix.java

private Collection<File> findAllFilesByExtension(String extension, File searchPath) {
    final Collection<File> candidates = new ArrayList<>();
    final File[] filesInSearchPath = searchPath.listFiles();
    assert filesInSearchPath != null;
    for (File candidate : filesInSearchPath) {
        if (candidate.isDirectory()) {
            candidates.addAll(findAllFilesByExtension(extension, candidate));
        } else if (candidate.getName().toLowerCase().endsWith(extension.toLowerCase())
                && !checkSearchExcludedFiles(candidate.getName())) {
            candidates.add(candidate);// w w w .j  a va  2  s  .  c om
        }
    }
    return candidates;
}

From source file:com.epam.cme.core.search.solrfacetsearch.provider.impl.ProductReviewCountValueProvider.java

@Override
public Collection<FieldValue> getFieldValues(final IndexConfig indexConfig,
        final IndexedProperty indexedProperty, final Object model) throws FieldValueProviderException {
    if (model instanceof ProductModel) {
        final ProductModel product = (ProductModel) model;

        final Collection<FieldValue> fieldValues = new ArrayList<FieldValue>();

        if (indexedProperty.isLocalized()) {
            final Collection<LanguageModel> languages = indexConfig.getLanguages();
            for (final LanguageModel language : languages) {
                fieldValues.addAll(createFieldValue(product, language, indexedProperty));
            }// ww  w.  j a  v  a2s. c om
        } else {
            fieldValues.addAll(createFieldValue(product, null, indexedProperty));
        }
        return fieldValues;
    } else {
        throw new FieldValueProviderException("Cannot evaluate rating of non-product item");
    }
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.breadcrumb.impl.ProductBreadcrumbBuilder.java

/**
 * Returns a list of breadcrumbs for the given product.
 *
 * @param productCode//w  w  w .  jav  a2  s  . co m
 * @return breadcrumbs for the given product
 */
public List<Breadcrumb> getBreadcrumbs(final String productCode) {
    final ProductModel productModel = getProductService().getProductForCode(productCode);
    final List<Breadcrumb> breadcrumbs = new ArrayList<>();

    final Collection<CategoryModel> categoryModels = new ArrayList<>();
    final Breadcrumb last;

    final ProductModel baseProductModel = getBaseProduct(productModel);
    last = getProductBreadcrumb(baseProductModel);
    categoryModels.addAll(baseProductModel.getSupercategories());
    last.setLinkClass(LAST_LINK_CLASS);

    breadcrumbs.add(last);

    while (!categoryModels.isEmpty()) {
        CategoryModel toDisplay = null;
        toDisplay = processCategoryModels(categoryModels, toDisplay);
        categoryModels.clear();
        if (toDisplay != null) {
            breadcrumbs.add(getCategoryBreadcrumb(toDisplay));
            categoryModels.addAll(toDisplay.getSupercategories());
        }
    }
    Collections.reverse(breadcrumbs);
    return breadcrumbs;
}

From source file:com.reprezen.swagedit.assist.SwaggerProposalProvider.java

protected Collection<Proposal> createComplextTypeProposals(ComplexTypeDefinition type, AbstractNode node,
        String prefix) {/*from  ww w. jav  a  2  s  . c o  m*/
    final Collection<Proposal> proposals = new LinkedHashSet<>();

    for (TypeDefinition definition : type.getComplexTypes()) {
        proposals.addAll(getProposals(definition, node, prefix));
    }

    return proposals;
}

From source file:it.cnr.icar.eric.client.ui.thin.UserPreferencesBean.java

/** Returns a Collection of all locales as SelectItems. */
public Collection<SelectItem> getAllLocalesSelectItems() {
    if (allLocalesSelectItems == null) {
        TreeMap<String, SelectItem> selectItemsMap = new TreeMap<String, SelectItem>();
        Locale loc[] = Locale.getAvailableLocales();
        for (int i = 0; i < loc.length; i++) {
            String name = loc[i].getDisplayName(loc[i]);
            SelectItem item = new SelectItem(loc[i].toString(), name);
            selectItemsMap.put(name.toLowerCase(), item);
        }/*w  w  w. j  a  v a2 s. c om*/
        Collection<SelectItem> all = new ArrayList<SelectItem>();
        all.addAll(selectItemsMap.values());
        allLocalesSelectItems = all;
    }
    return allLocalesSelectItems;
}

From source file:net.ontopia.topicmaps.query.parser.OrClause.java

@Override
public Collection getAllVariables() {
    Collection vars = new HashSet();

    for (int ix = 0; ix < alternatives.size(); ix++) {
        List subclauses = (List) alternatives.get(ix);

        for (int i = 0; i < subclauses.size(); i++) {
            AbstractClause clause = (AbstractClause) subclauses.get(i);
            vars.addAll(clause.getAllVariables());
        }//from  w ww  .j  av  a 2 s  . co  m
    }

    return vars;
}

From source file:es.ucm.fdi.dalgs.course.service.CourseService.java

@PreAuthorize("hasRole('ROLE_USER')")
@PostFilter("hasPermission(filterObject, 'READ') or hasPermission(filterObject, 'ADMINISTRATION')")
public ResultClass<Course> getCoursesByAcademicTerm(Long id_academic, Boolean showAll) {
    ResultClass<Course> result = new ResultClass<>();

    Collection<Course> courses = new ArrayList<Course>();
    courses.addAll(repositoryCourse.getCoursesByAcademicTerm(id_academic, showAll));
    result.addAll(courses);/* w  ww.j a v  a2  s .  c  om*/
    return result;
}

From source file:gr.abiss.calipso.plugins.state.CopyItemInfoToAssetPlugin.java

@Override
public Serializable executePostStateChange(CalipsoService calipsoService, History history) {

    // get the item the history belongs to
    Item item = history.getParent();//ww w  .  j  a v  a 2s  .  c om
    logger.info("Creating iteminfo asset for item " + item.getUniqueRefId());
    List<Asset> itemAssets = calipsoService.findAllAssetsByItem(item);
    if (CollectionUtils.isNotEmpty(itemAssets)) {
        List<Asset> redundantAssets = new LinkedList<Asset>();
        for (Asset asset : itemAssets) {
            //            if(asset.getAssetType().getId() == 1 && this.asset == null){
            //               this.assetType = asset.getAssetType();
            //               this.asset = asset;
            //            }
            //            else 
            if (asset.getAssetType().getId() == 1 /* && this.asset != null */) {
                // mark redundant asset for removal
                redundantAssets.add(asset);
            }
        }
        // remove redundant assets
        item.getAssets().removeAll(redundantAssets);

        calipsoService.updateItem(item, history.getLoggedBy(), false);
        Collection<Serializable> tRemove = new HashSet<Serializable>();
        tRemove.addAll(redundantAssets);
        calipsoService.remove(tRemove);
    }

    // if new
    if (asset == null) {
        asset = new Asset();
        asset.setAssetType(assetType);
        asset.setCreatedBy(history.getLoggedBy());
        // date added in the inventory
        this.asset.setSupportStartDate(new Date());
        this.asset.setDateCreated(this.asset.getSupportStartDate());
        this.asset.setDateUpdated(this.asset.getDateCreated());
    }

    // add to asset and history
    item.addAsset(asset);
    // copy information from item
    initFromHistoryItem(calipsoService, item, asset, assetType);
    // save the asset 
    calipsoService.storeAsset(asset);
    // update html and plain text comment
    String htmlSuffix = ItemUtils.fmt("item_view.automatically.created.asset",
            new Object[] { assetType.getName(), asset.getInventoryCode() }, calipsoService.getMessageSource(),
            new Locale(history.getLoggedBy().getLocale()));
    history.setHtmlComment(history.getHtmlComment() + htmlSuffix);
    history.setComment(history.getComment() + XmlUtils.stripTags(htmlSuffix));
    calipsoService.updateItem(item, history.getLoggedBy(), false);

    logger.info("Created item info asset " + asset.getInventoryCode() + " for item " + item.getUniqueRefId());
    //calipsoService.updateHistory(history);
    return asset;
}

From source file:oauth.signpost.signature.SignatureBaseString.java

/**
 * Collects HTTP GET query string parameters as per OAuth Core 1.0 spec
 * section 9.1.1/*from  w  w  w  .j  ava  2  s .c o m*/
 * 
 * @param request
 *            The HTTP request
 * @return the URL without the query parameters, if there were any
 */
private String collectQueryParameters(Collection<Parameter> parameters) {

    String url = request.getRequestLine().getUri();
    int q = url.indexOf('?');
    if (q >= 0) {
        // Combine the URL query string with the other parameters:
        parameters.addAll(OAuth.decodeForm(url.substring(q + 1)));
        url = url.substring(0, q);
    }

    return url;
}