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:cn.vlabs.umt.ui.rest.RestUserServiceV7Impl.java

@RestMethod("search")
public List<UMTUser> search(String keyword, int offset, int count, String orderBy, boolean isAscendent) {
    if (keyword == null || keyword.equals("")) {
        return new ArrayList<UMTUser>();
    }/* ww  w  .j a  va2  s  . c  o m*/
    keyword = keyword.replaceAll("%", "");
    if (count <= 0) {
        count = Integer.MAX_VALUE;
    }

    if (offset <= 0) {
        offset = 0;
    }
    UserField field = UserField.cstnetId;
    if (UMTUser.FIELD_CSTNET_ID.equals(orderBy)) {
        field = UserField.cstnetId;
    }
    if (UMTUser.FIELD_TRUE_NAME.equals(orderBy)) {
        field = UserField.trueName;
    }
    Collection<User> users = new ArrayList<User>();
    users.addAll(coreMailclient.searchByKeyword(keyword, "all", SearchField.CSTNET_ID, offset, count));
    users.addAll(coreMailclient.searchByKeyword(keyword, "all", SearchField.DOMAIN, offset, count));
    users.addAll(coreMailclient.searchByKeyword(keyword, "all", SearchField.TRUE_NAME, offset, count));
    Collection<User> umtUsers = service.search(keyword, offset, count, field, isAscendent);
    if (umtUsers != null) {
        users.addAll(umtUsers);
    }
    ArrayList<UMTUser> rusers = new ArrayList<UMTUser>();
    Set<String> repeat = new HashSet<String>();
    if (users != null && !users.isEmpty()) {
        for (User user : users) {
            if (repeat.contains(user.getCstnetId())) {
                continue;
            }
            repeat.add(user.getCstnetId());
            rusers.add(toUMTUser(user));
        }
    }
    return rusers;
}

From source file:grails.plugin.springsecurity.web.access.intercept.AbstractFilterInvocationDefinition.java

public Collection<ConfigAttribute> getAllConfigAttributes() {
    try {/*from   ww w. j a v a  2  s . c  o m*/
        initialize();
    } catch (Exception e) {
        GrailsUtil.deepSanitize(e);
        log.error(e.getMessage(), e);
    }

    Collection<ConfigAttribute> all = new LinkedHashSet<ConfigAttribute>();
    for (InterceptedUrl iu : compiled) {
        all.addAll(iu.getConfigAttributes());
    }
    return Collections.unmodifiableCollection(all);
}

From source file:de.nava.informa.search.ChannelIndexer.java

/**
 * Index all news items contained in the given channels.
 *
 * @param createNewIndex - wether a new index should be generated or
 *                       an existant one should be taken into account
 * @param channels       - a collection of ChannelIF objects
 *//*from   w w w .j  av  a 2 s  .c  o  m*/
public void indexChannels(boolean createNewIndex, Collection channels) throws java.io.IOException {

    Collection<ItemIF> items = new ArrayList<ItemIF>();
    for (Object channel1 : channels) {
        ChannelIF channel = (ChannelIF) channel1;
        if (LOG.isDebugEnabled()) {
            LOG.debug("Searching channel " + channel + " for items.");
        }
        items.addAll(channel.getItems());
    }
    if (!items.isEmpty()) {
        indexItems(createNewIndex, items);
    } else if (LOG.isDebugEnabled()) {
        LOG.debug("No items found for indexing.");
    }
}

From source file:modalLogic.tableau.World.java

/**
 * Update clashes for an incoming literal.
 *
 * @param literal the literal//from  w w w.  j  av a  2  s  . co m
 * @param literals the other literals
 */
private void addClashes(LabelledFormula<P> literal, MultiMap<P, LabelledFormula<P>> literals,
        MultiMap<Constant, LabelledFormula<P>> constants) {
    Collection<LabelledFormula<P>> clashing = literals.get(literal.getFormula().getProposition());
    if (clashing == null) {
        clashing = new ArrayList<LabelledFormula<P>>();
    }
    clashing.addAll(constants.values());

    if (!clashing.isEmpty()) {
        for (LabelledFormula<P> c : clashing) {
            clashes.add(literal, c);
        }
    }
}

From source file:com.reprezen.swagedit.core.assist.JsonProposalProvider.java

protected Collection<ProposalDescriptor> createComplextTypeProposals(ComplexTypeDefinition type,
        AbstractNode node, String prefix) {
    final Collection<ProposalDescriptor> proposals = new LinkedHashSet<>();

    for (TypeDefinition definition : type.getComplexTypes()) {
        proposals.addAll(getProposals(definition, node, prefix));
    }//from   w  ww .j ava 2  s. c o m

    return proposals;
}

From source file:knowledgeMiner.mapping.textToCyc.TextToCyc_FunctionParser.java

/**
 * Create possile functions by splitting text at a given index and treating
 * one side as the function, and the other as the argument.
 *
 * @param textIndex/* w  w w  . j  av  a 2s .  c om*/
 *            The split point.
 * @param prefixText
 *            If the text should be prefix or suffix.
 * @param split
 *            The split text.
 * @param isaFunction
 *            The query for isa ?X Function
 * @param wmi
 *            The WMI access.
 * @param ontology
 *            The ontology access.
 * @return All possible function-arguments found in the text.
 */
protected Collection<OntologyConcept> createPossibleFunction(int textIndex, boolean prefixText, String[] split,
        Object[] isaFunction, WMISocket wmi, OntologySocket ontology) {
    // Process the function text
    String possibleFunction = null;
    if (prefixText)
        possibleFunction = StringUtils.join(split, ' ', 0, textIndex + 1) + " " + FUNCTION_STRING;
    else
        possibleFunction = FUNCTION_STRING + " " + StringUtils.join(split, ' ', textIndex, split.length);
    Collection<OntologyConcept> functionConcepts = ontology.findFilteredConceptByName(possibleFunction, false,
            true, true, isaFunction);

    // Also check "'s" pattern
    possibleFunction = possibleFunction.replaceAll(FUNCTION_STRING, FUNCTION_STRING + "'s");
    functionConcepts
            .addAll(ontology.findFilteredConceptByName(possibleFunction, false, true, true, isaFunction));

    // Process the remaining text
    String remText = null;
    if (prefixText)
        remText = StringUtils.join(split, ' ', textIndex + 1, split.length);
    else
        remText = StringUtils.join(split, ' ', 0, textIndex);
    // TODO Recursive infinite loop
    HierarchicalWeightedSet<OntologyConcept> functionTarget = mapper_.mapTextToCyc(remText, true, false, false,
            false, wmi, ontology);
    return resolveFunctionCombination(functionConcepts, functionTarget, ontology);
}

From source file:com.fatminds.vaadin.cmis.CmisDatalistContainer.java

@Override
public Collection<String> getContainerPropertyIds() {
    Collection<String> ret = new Vector<String>();
    ret.addAll(super.getContainerPropertyIds());
    ret.add((String) propertyId);
    return ret;/*  w w  w  . j  a v a2  s .co m*/
}

From source file:com.surevine.alfresco.esl.impl.webscript.visibility.SharedVisibilityReport.java

@Override
public void execute(WebScriptRequest request, WebScriptResponse response) throws IOException {
    final String currentUserName = _authenticationService.getCurrentUserName();

    if (_logger.isDebugEnabled()) {
        _logger.debug("Gettng visibility report for " + currentUserName);
    }/*from  w ww .ja v  a  2  s. c o  m*/
    Set<Presence> usersInAnyGroup = new TreeSet<Presence>(new OnlineFirstComparator());
    Map<String, Collection<Presence>> report = new HashMap<String, Collection<Presence>>();
    Iterator<String> groupNames = _visibilityUtil
            .getGroupsForCurrentUser(_caveatConfigService, _constraintName, _displayName).iterator();
    if (_logger.isDebugEnabled()) {
        _logger.debug("Groups retrieved for " + currentUserName);
    }
    boolean userHasGroups = false;
    while (groupNames.hasNext()) {
        userHasGroups = true;
        String groupName = groupNames.next();
        if (_logger.isDebugEnabled()) {
            _logger.debug("  Adding " + groupName + " to shared visibility report");
        }
        Collection<Presence> usersWithAccessToThisGroup = new TreeSet<Presence>(new OnlineFirstComparator());
        usersWithAccessToThisGroup
                .addAll(_visibilityUtil.whoHasAccessToGroup(_caveatConfigService, _constraintName, groupName));
        usersInAnyGroup.addAll(usersWithAccessToThisGroup);
        report.put(groupName, stripUsersFromPresence(currentUserName, usersWithAccessToThisGroup));
    }
    if (userHasGroups) {
        report.put("Any of my Groups", stripUsersFromPresence(currentUserName, usersInAnyGroup));
    } else {
        if (_logger.isDebugEnabled()) {
            _logger.debug("  User does not have any groups");
        }
        Iterator<String> usersWithNoGroups = getUsersWithNoGroups().iterator();
        Set<Presence> usersInNoGroupsWithPresence = new TreeSet<Presence>(new OnlineFirstComparator());
        if (_logger.isDebugEnabled()) {
            _logger.debug("  Adding " + getUsersWithNoGroups() + " users with no groups to report");
        }
        while (usersWithNoGroups.hasNext()) {
            String userName = usersWithNoGroups.next();
            if (_logger.isDebugEnabled()) {
                _logger.debug("    Adding " + userName + " as a user with no groups");
            }
            usersInNoGroupsWithPresence.add(_presenceService.getUserPresence(userName, false));
        }
        report.put("Users with no security groups",
                stripUsersFromPresence(currentUserName, usersInNoGroupsWithPresence));
    }

    JSONObject json = new JSONObject(report);

    Cache cache = new Cache();
    cache.setNeverCache(false);
    cache.setIsPublic(false);
    cache.setMaxAge(900L);
    cache.setMustRevalidate(false);
    cache.setETag("100");

    response.setCache(cache);

    response.setStatus(200);
    response.setContentType("application/json");
    response.getWriter().write(json.toString());
    response.getWriter().flush();
}

From source file:org.jtheque.movies.services.impl.MoviesService.java

@Override
public Set<Movie> getMovies(Category category, boolean includeSubCategory) {
    Collection<Category> categories = new HashSet<Category>(10);

    categories.add(category);/*w ww.j ava2s .c  o  m*/

    if (includeSubCategory) {
        categories.addAll(categoriesService.getSubCategories(category));
    }

    Set<Movie> movies = new HashSet<Movie>(getMovies());

    CollectionUtils.filter(movies, new CategoriesFilter(categories));

    return movies;
}

From source file:croche.maven.plugin.dbupgrade.CreateUpgradeScriptMojo.java

/**
 * Gets the comma separated list of effective include patterns.
 * @return The comma separated list of effective include patterns, never <code>null</code>.
 *//*w w  w.ja  va2  s.  c  o  m*/
@SuppressWarnings({ "rawtypes", "unchecked" })
String getIncludesCSV() {
    Collection patterns = new LinkedHashSet();
    if (this.includes != null) {
        patterns.addAll(Arrays.asList(this.includes));
    }
    if (patterns.isEmpty()) {
        patterns.add("**/*");
    }
    return StringUtils.join(patterns.iterator(), ",");
}