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.marklogic.entityservices.TestSetup.java

private void loadExtraFiles() {
    sourceFileUris = new HashSet<String>();

    JSONDocumentManager docMgr = _client.newJSONDocumentManager();
    DocumentWriteSet writeSet = docMgr.newWriteSet();

    Collection<File> sourceFiles = getTestResources("/source-documents");

    Collection<File> testDocuments = getTestResources("/test-instances");

    Collection<File> extraDocuments = new ArrayList<File>();
    extraDocuments.addAll(testDocuments);
    extraDocuments.addAll(sourceFiles);/*w  w  w .  jav  a  2s .c  o  m*/

    for (File f : extraDocuments) {
        if (f.getName().startsWith(".")) {
            continue;
        }
        if (!(f.getName().endsWith(".json") || f.getName().endsWith(".xml"))) {
            continue;
        }

        logger.info("Loading Extra Files " + f.getName());
        writeSet.add(f.getName(), new FileHandle(f));
        sourceFileUris.add(f.getName());
    }
    docMgr.write(writeSet);
}

From source file:com.google.enterprise.connector.sharepoint.spiimpl.SharepointAuthenticationManager.java

private AuthenticationResponse authenticateAgainstActiveDirectory(final AuthenticationIdentity identity)
        throws RepositoryLoginException, RepositoryException {
    long startAuthN = System.currentTimeMillis();
    AuthenticationResponse adAuthResult = adGroupsAuthenticationManager.authenticate(identity);
    if (!adAuthResult.isValid()) {
        return adAuthResult;
    }//from  www.  j a  va 2 s .c  o  m

    long startSharePoint = System.currentTimeMillis();
    @SuppressWarnings("unchecked")
    Collection<Principal> adGroups = (Collection<Principal>) adAuthResult.getGroups();
    String strUserName = addUserNameFormatForTheSearchUser(identity.getUsername(), identity.getDomain());
    Set<Principal> spGroups = sharepointClientContext.getUserDataStoreDAO()
            .getSharePointGroupsForSearchUserAndLdapGroups(sharepointClientContext.getGoogleLocalNamespace(),
                    adGroups, strUserName);

    Collection<Principal> groups = new ArrayList<Principal>();
    groups.addAll(adGroups);
    groups.addAll(spGroups);
    LOGGER.log(Level.INFO,
            "Authentication Duration [{0}] : Total = [{1}ms] " + "SharePoint = [{2}ms] AD = [{3}ms]",
            new Object[] { strUserName, (System.currentTimeMillis() - startAuthN),
                    (System.currentTimeMillis() - startSharePoint), (startSharePoint - startAuthN) });

    return new AuthenticationResponse(adAuthResult.isValid(), adAuthResult.getData(), groups);
}

From source file:fll.web.scoreEntry.ScoreEntry.java

/**
 * Output the body for the check_restrictions method.
 * // w ww .  j  ava2s . co m
 * @param writer where to write
 * @throws IOException
 * @throws ParseException
 */
public static void generateCheckRestrictionsBody(final Writer writer, final ServletContext application)
        throws IOException, ParseException {
    final ChallengeDescription description = ApplicationAttributes.getChallengeDescription(application);
    final Formatter formatter = new Formatter(writer);

    final PerformanceScoreCategory performanceElement = description.getPerformance();

    final Collection<String> goalsWithRestrictions = new LinkedList<String>();
    final List<Restriction> restrictions = performanceElement.getRestrictions();

    // find out which goals are involved in restrictions
    for (final Restriction restrictEle : restrictions) {
        goalsWithRestrictions.addAll(getGoalsInRestriction(restrictEle));
    }

    // output variable declaration for each goal
    for (final String goalName : goalsWithRestrictions) {
        formatter.format("  var %s = \"\";%n", getElementIDForError(goalName));
    }

    // output actual check of restriction
    for (int restrictIdx = 0; restrictIdx < restrictions.size(); ++restrictIdx) {
        final Restriction restrictEle = restrictions.get(restrictIdx);
        final double lowerBound = restrictEle.getLowerBound();
        final double upperBound = restrictEle.getUpperBound();
        final String message = restrictEle.getMessage();

        final String polyString = polyToString(restrictEle);
        final String restrictValStr = String.format("restriction_%d_value", restrictIdx);
        formatter.format("  var %s = %s;%n", restrictValStr, polyString);
        formatter.format("  if(%s > %f || %s < %f) {%n", restrictValStr, upperBound, restrictValStr,
                lowerBound);
        // append error text to each error cell if the restriction is violated
        for (final String goalName : getGoalsInRestriction(restrictEle)) {
            final String errorId = getElementIDForError(goalName);
            formatter.format("    %s = %s + \" \" + \"%s\";%n", errorId, errorId, message);
        }
        formatter.format("    error_found = true;%n");
        formatter.format("  }%n");
    }

    // output text assignment for each goal involved in a restriction
    for (final String goalName : goalsWithRestrictions) {
        final String errorId = getElementIDForError(goalName);
        formatter.format("  replaceText(\"%s\", %s);%n", errorId, errorId);
        formatter.format("  if(%s.length > 0) {%n", errorId);
        formatter.format("    var el = document.getElementById(\"%s\");%n", errorId);
        formatter.format("  }%n");
        formatter.format("  replaceText(\"%s\", %s);%n", errorId, errorId);
        formatter.format("%n");
    }
}

From source file:interactivespaces.service.web.server.internal.netty.NettyHttpRequest.java

@Override
public Set<HttpCookie> getCookies() {

    Collection<String> cookieHeader = getHeader("Cookie");
    if (cookieHeader == null) {
        return Sets.newHashSet();
    }/*from   ww  w. ja va  2  s.  co m*/
    Collection<HttpCookie> cookies = Sets.newHashSet();
    for (String cookie : cookieHeader) {
        cookies.addAll(
                Collections2.transform(new CookieDecoder().decode(cookie), new Function<Cookie, HttpCookie>() {
                    @Override
                    public HttpCookie apply(final Cookie cookie) {
                        return convertFromNettyCookie(cookie);
                    }
                }));
    }
    return Sets.newHashSet(cookies);
}

From source file:net.jakubholy.jeeutils.jsfelcheck.sourcefinder.FilesystemViewFinder.java

/** {@inheritDoc} */
public Collection<File> findViewFiles() {

    final Collection<File> allFiles = new LinkedList<File>();

    for (File searchRoot : searchRoots) {
        @SuppressWarnings("unchecked")
        Collection<File> viewFilesUnderRoot = FileUtils.listFiles(searchRoot, allowedExtensions, true);
        allFiles.addAll(viewFilesUnderRoot);
    }//from   w w w. j  a  va2  s.c  o m

    return allFiles;
}

From source file:graph.module.DepthModule.java

private Collection<Node> getMinimumParents(DAGNode node) {
    // Check for rewrite
    RewriteOfModule rewriteModule = (RewriteOfModule) dag_.getModule(RewriteOfModule.class);
    if (rewriteModule != null)
        node = rewriteModule.getRewrite(node);

    QueryModule querier = (QueryModule) dag_.getModule(QueryModule.class);

    Collection<Node> minParents = new ArrayList<>();

    // Add genls/*from   w ww  .  java  2  s. c om*/
    minParents.addAll(checkParentRelationship(node, CommonConcepts.GENLS, querier));

    // Add isa
    minParents.addAll(checkParentRelationship(node, CommonConcepts.ISA, querier));

    // Add genlPreds
    minParents.addAll(checkParentRelationship(node, CommonConcepts.GENLPREDS, querier));

    // Add genlMt
    minParents.addAll(checkParentRelationship(node, CommonConcepts.GENLMT, querier));

    // If function
    if (node instanceof OntologyFunction) {
        // Add resultIsa
        minParents.addAll(querier.functionResults((OntologyFunction) node, CommonConcepts.RESULT_ISA));

        // Add resultGenls
        minParents.addAll(querier.functionResults((OntologyFunction) node, CommonConcepts.RESULT_GENL));
    }

    minParents.remove(node);
    return CommonQuery.minGeneralFilter(minParents, dag_);
}

From source file:com.mitre.storefront.breadcrumb.impl.ProductBreadcrumbBuilder.java

protected void addCategoryBreadCrumbs(final List<Breadcrumb> breadcrumbs, final String baseProductCode) {
    final Collection<CategoryModel> categoryModels = new ArrayList<CategoryModel>();

    final ProductModel baseProductModel = productService.getProductForCode(baseProductCode);

    categoryModels.addAll(baseProductModel.getSupercategories());
    while (!categoryModels.isEmpty()) {
        CategoryModel toDisplay = null;//from  w  ww .j  a  v  a  2 s.  c o  m
        for (final CategoryModel categoryModel : categoryModels) {
            if (!(categoryModel instanceof ClassificationClassModel)) {
                if (toDisplay == null) {
                    toDisplay = categoryModel;
                }
                if (getBrowseHistory().findUrlInHistory(categoryModel.getCode()) != null) {
                    break;
                }
            }
        }
        categoryModels.clear();
        if (toDisplay != null) {
            breadcrumbs.add(getCategoryBreadcrumb(toDisplay));
            categoryModels.addAll(toDisplay.getSupercategories());
        }
    }
}

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

protected void createBreadcrumbCategoryHierarchyPath(final String categoryCode, final boolean emptyBreadcrumbs,
        final List<Breadcrumb> breadcrumbs) {
    // Create category hierarchy path for breadcrumb
    final List<Breadcrumb> categoryBreadcrumbs = new ArrayList<>();
    final Collection<CategoryModel> categoryModels = new ArrayList<>();
    final CategoryModel lastCategoryModel = getCommerceCategoryService().getCategoryForCode(categoryCode);
    categoryModels.addAll(lastCategoryModel.getSupercategories());
    categoryBreadcrumbs.add(getCategoryBreadcrumb(lastCategoryModel, !emptyBreadcrumbs ? LAST_LINK_CLASS : ""));

    while (!categoryModels.isEmpty()) {
        final CategoryModel categoryModel = categoryModels.iterator().next();

        if (!(categoryModel instanceof ClassificationClassModel)) {
            if (categoryModel != null) {
                categoryBreadcrumbs.add(getCategoryBreadcrumb(categoryModel));
                categoryModels.clear();/*from  ww w . ja v  a 2 s. c  om*/
                categoryModels.addAll(categoryModel.getSupercategories());
            }
        } else {
            categoryModels.remove(categoryModel);
        }
    }
    Collections.reverse(categoryBreadcrumbs);
    breadcrumbs.addAll(categoryBreadcrumbs);
}

From source file:net.mindengine.oculus.frontend.web.controllers.report.ReportLinkToIssueController.java

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Session session = Session.create(request);
    verifyPermissions(request);/*from  ww w  . java2s  .co m*/
    String redirect = getMandatoryStringParameter(request, "redirect");
    Long issueId = getMandatoryLongParameter(request, "reportLinkIssue");
    Long projectId = getMandatoryLongParameter(request, "projectId");
    String reasonPattern = getMandatoryStringParameter(request, "linkIssueReasonPattern");

    /*
     * Obtaining collected test runs from session data
     */
    List<TestRunSearchData> collectedTestRuns = session.getCollectedTestRuns();
    if (collectedTestRuns == null || collectedTestRuns.size() == 0)
        throw new InvalidRequest("You have to collect test runs first");

    IssueCollation issueCollation = new IssueCollation();
    issueCollation.setIssueId(issueId);
    issueCollation.setReasonPattern(reasonPattern);

    /*
     * Collecting a set of tests into the issue collation.
     * 
     * Using a map instead of list because we have to collect only unique
     * tests. So to prevent a test duplication we will check for each test
     * in a map before adding it. As we have 2 ways of linking tests to
     * issue: by testId and by test name we will store them in two map
     * variables
     */
    Map<Long, IssueCollationTest> testsMap = new HashMap<Long, IssueCollationTest>();
    Map<String, IssueCollationTest> testNamesMap = new HashMap<String, IssueCollationTest>();

    for (TestRunSearchData testRun : collectedTestRuns) {
        if (testRun.getTestId() != null && testRun.getTestId() > 0) {
            IssueCollationTest test = new IssueCollationTest();
            test.setTestId(testRun.getTestId());
            if (!testsMap.containsKey(test.getTestId())) {
                testsMap.put(test.getTestId(), test);
            }
        } else {
            /*
             * This means that a test run wasn't bound to any existent test.
             * Here it will check that there is no
             */
            IssueCollationTest test = new IssueCollationTest();
            test.setTestId(0L);
            test.setTestName(testRun.getTestRunName());
            if (!testNamesMap.containsKey(test.getTestName())) {
                testNamesMap.put(test.getTestName(), test);
            }
        }
    }
    Collection<IssueCollationTest> collatedTests = new LinkedList<IssueCollationTest>();
    collatedTests.addAll(testsMap.values());
    collatedTests.addAll(testNamesMap.values());
    issueCollation.setTests(collatedTests);

    /*
     * Collecting a set of conditions To be able to do this we will need to
     * fetch the project trm suite parameters before.
     */
    issueCollation.setConditions(new LinkedList<IssueCollationCondition>());
    List<TrmProperty> suiteParameters = trmDAO.getProperties(projectId, TrmProperty._TYPE_SUITE_PARAMETER);
    if (suiteParameters.size() > 0) {
        for (TrmProperty suiteParameter : suiteParameters) {
            // suiteParameter.getId();
            Long spId = suiteParameter.getId();
            boolean used = false;
            String strUsed = request.getParameter("linkIssueSuiteParameterUse" + spId);
            if (strUsed != null && strUsed.toLowerCase().equals("on")) {
                used = true;
            }

            if (used) {
                String value = request.getParameter("linkIssueSuiteParameterValue" + spId);
                if (value == null)
                    value = "off";
                if (!value.isEmpty()) {
                    IssueCollationCondition condition = new IssueCollationCondition();
                    condition.setTrmPropertyId(spId);
                    condition.setValue(value);
                    issueCollation.getConditions().add(condition);
                }
            }
        }
    }

    issueDAO.linkTestRunsToIssue(collectedTestRuns, issueId);
    issueDAO.linkTestsToIssue(issueCollation);

    if (!redirect.isEmpty())
        return new ModelAndView("redirect:" + redirect);
    return new ModelAndView("redirect:../display/home");
}

From source file:com.cloudseal.spring.client.userdetails.CloudsealUserAttributes.java

private Map<String, Collection<XMLObject>> getAttributes(SAMLCredential credential) {
    Collection<Attribute> credentialAttributes = credential.getAttributes();
    Map<String, Collection<XMLObject>> attributes = new HashMap<String, Collection<XMLObject>>(
            credentialAttributes.size());
    for (Attribute attribute : credentialAttributes) {
        String name = attribute.getName();
        Collection<XMLObject> newValue = new ArrayList<XMLObject>(attribute.getAttributeValues());
        Collection<XMLObject> oldValue = attributes.get(name);
        if (oldValue != null) {
            oldValue.addAll(newValue);
        } else {//from   w w  w . j  a  va2  s  .  co m
            attributes.put(name, newValue);
        }
    }
    return attributes;
}