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:it.cnr.icar.eric.server.query.ReferenceResolverImpl.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private void internalGetReferencedObjects(ServerRequestContext serverContext, RegistryObjectType ro, int depth,
        Map<Object, Object> idMap, Collection<RegistryObjectType> refObjs) throws RegistryException {
    log.trace("start: internalGetReferencedObjects");
    try {// ww  w  .  j  ava2  s . c  o  m
        if ((ro != null) && (!refObjs.contains(ro))) {
            if (log.isDebugEnabled()) {
                log.debug("get references for this ro: " + ro.getId() + " " + ro.getObjectType());
            }
            refObjs.add(ro);
            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.RegistryObjectType",
                    idMap, "ObjectType", refObjs);

            processRefAttribute(serverContext, ro,
                    "org.oasis.ebxml.registry.bindings.rim.ClassificationNodeType", idMap, "Parent", refObjs);

            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ClassificationType",
                    idMap, "ClassificationNode", refObjs);
            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ClassificationType",
                    idMap, "ClassificationScheme", refObjs);
            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ClassificationType",
                    idMap, "ClassifiedObject", refObjs);

            processRefAttribute(serverContext, ro,
                    "org.oasis.ebxml.registry.bindings.rim.ExternalIdentifierType", idMap,
                    "IdentificationScheme", refObjs);
            processRefAttribute(serverContext, ro,
                    "org.oasis.ebxml.registry.bindings.rim.ExternalIdentifierType", idMap, "RegistryObject",
                    refObjs);

            //FederationType fed = (FederationType)ro;
            //TODO: Fix so it adds only Strings not ObjectRefType
            //refInfos.addAll(fed.getMembers().getObjectRef());

            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AssociationType1",
                    idMap, "AssociationType", refObjs);
            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AssociationType1",
                    idMap, "SourceObject", refObjs);
            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AssociationType1",
                    idMap, "TargetObject", refObjs);

            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AuditableEventType",
                    idMap, "User", refObjs);
            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.AuditableEventType",
                    idMap, "RequestId", refObjs);

            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.OrganizationType",
                    idMap, "Parent", refObjs);

            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.RegistryType", idMap,
                    "Operator", refObjs);

            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ServiceBindingType",
                    idMap, "Service", refObjs);
            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.ServiceBindingType",
                    idMap, "TargetBinding", refObjs);

            processRefAttribute(serverContext, ro,
                    "org.oasis.ebxml.registry.bindings.rim.SpecificationLinkType", idMap, "ServiceBinding",
                    refObjs);
            processRefAttribute(serverContext, ro,
                    "org.oasis.ebxml.registry.bindings.rim.SpecificationLinkType", idMap, "SpecificationObject",
                    refObjs);

            processRefAttribute(serverContext, ro, "org.oasis.ebxml.registry.bindings.rim.SubscriptionType",
                    idMap, "Selector", refObjs);

            if (depth != 0) {
                depth--;
                // Now process composed objects
                Set<RegistryObjectType> composedObjects = BindingUtility.getInstance()
                        .getComposedRegistryObjects(ro, 1);
                Collection<?> composedNoDups = checkForDuplicates(refObjs, composedObjects);
                // Now process associated objects
                Collection<?> associatedObjects = getAssociatedObjects(serverContext, ro, depth, idMap,
                        refObjs);
                Collection assocNoDups = checkForDuplicates(refObjs, associatedObjects);
                Collection relatedObjects = new ArrayList();
                relatedObjects.addAll(composedNoDups);
                relatedObjects.addAll(assocNoDups);
                Iterator iter = relatedObjects.iterator();
                while (iter.hasNext()) {
                    Object obj = iter.next();
                    if (obj instanceof RegistryObjectType) {
                        RegistryObjectType regObj = (RegistryObjectType) obj;
                        internalGetReferencedObjects(serverContext, regObj, depth, idMap, refObjs);
                    }
                }
            }
        }
    } catch (RegistryException re) {
        throw re;
    } catch (Throwable t) {
        throw new RegistryException(t);
    }
    log.trace("end: internalGetReferencedObjects");
}

From source file:org.zkoss.zk.grails.composer.GrailsComposer.java

public JQuery $d(String arg) {
    Desktop desktop = root.getDesktop();
    Collection<Component> results = new HashSet<Component>();
    for (Page p : desktop.getPages()) {
        for (Component root : p.getRoots()) {
            results.addAll(Selectors.find(root, arg));
        }//from   w  w  w  . j a va  2 s . c  o  m
    }
    return new JQuery(new ArrayList<Component>(results));
}

From source file:com.gst.portfolio.charge.serialization.ChargeDefinitionCommandFromApiJsonDeserializer.java

public void validateForUpdate(final String json) {
    if (StringUtils.isBlank(json)) {
        throw new InvalidJsonException();
    }//w  ww.j a v  a 2  s .  com

    final Type typeOfMap = new TypeToken<Map<String, Object>>() {
    }.getType();
    this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);

    final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
    final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
            .resource("charge");

    final JsonElement element = this.fromApiJsonHelper.parse(json);

    if (this.fromApiJsonHelper.parameterExists("name", element)) {
        final String name = this.fromApiJsonHelper.extractStringNamed("name", element);
        baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100);
    }

    if (this.fromApiJsonHelper.parameterExists("currencyCode", element)) {
        final String currencyCode = this.fromApiJsonHelper.extractStringNamed("currencyCode", element);
        baseDataValidator.reset().parameter("currencyCode").value(currencyCode).notBlank()
                .notExceedingLengthOf(3);
    }

    if (this.fromApiJsonHelper.parameterExists("amount", element)) {
        final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("amount",
                element.getAsJsonObject());
        baseDataValidator.reset().parameter("amount").value(amount).notNull().positiveAmount();
    }

    if (this.fromApiJsonHelper.parameterExists("minCap", element)) {
        final BigDecimal minCap = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("minCap",
                element.getAsJsonObject());
        baseDataValidator.reset().parameter("minCap").value(minCap).notNull().positiveAmount();
    }

    if (this.fromApiJsonHelper.parameterExists("maxCap", element)) {
        final BigDecimal maxCap = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("maxCap",
                element.getAsJsonObject());
        baseDataValidator.reset().parameter("maxCap").value(maxCap).notNull().positiveAmount();
    }

    if (this.fromApiJsonHelper.parameterExists("chargeAppliesTo", element)) {
        final Integer chargeAppliesTo = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargeAppliesTo",
                element);
        baseDataValidator.reset().parameter("chargeAppliesTo").value(chargeAppliesTo).notNull()
                .isOneOfTheseValues(ChargeAppliesTo.validValues());
    }

    if (this.fromApiJsonHelper.parameterExists("chargeTimeType", element)) {

        final Integer chargeTimeType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargeTimeType",
                element);

        final Collection<Object> validLoanValues = Arrays.asList(ChargeTimeType.validLoanValues());
        final Collection<Object> validSavingsValues = Arrays.asList(ChargeTimeType.validSavingsValues());
        final Collection<Object> validClientValues = Arrays.asList(ChargeTimeType.validClientValues());
        final Collection<Object> validShareValues = Arrays.asList(ChargeTimeType.validShareValues());
        final Collection<Object> allValidValues = new ArrayList<>(validLoanValues);
        allValidValues.addAll(validSavingsValues);
        allValidValues.addAll(validClientValues);
        allValidValues.addAll(validShareValues);
        baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType).notNull()
                .isOneOfTheseValues(allValidValues.toArray(new Object[allValidValues.size()]));
    }

    if (this.fromApiJsonHelper.parameterExists("feeOnMonthDay", element)) {
        final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed("feeOnMonthDay", element);
        baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay).notNull();
    }

    if (this.fromApiJsonHelper.parameterExists("feeInterval", element)) {
        final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed("feeInterval", element,
                Locale.getDefault());
        baseDataValidator.reset().parameter("feeInterval").value(feeInterval).integerGreaterThanZero();
    }

    if (this.fromApiJsonHelper.parameterExists("chargeCalculationType", element)) {
        final Integer chargeCalculationType = this.fromApiJsonHelper
                .extractIntegerNamed("chargeCalculationType", element, Locale.getDefault());
        baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType).notNull()
                .inMinMaxRange(1, 5);
    }

    if (this.fromApiJsonHelper.parameterExists("chargePaymentMode", element)) {
        final Integer chargePaymentMode = this.fromApiJsonHelper.extractIntegerNamed("chargePaymentMode",
                element, Locale.getDefault());
        baseDataValidator.reset().parameter("chargePaymentMode").value(chargePaymentMode).notNull()
                .inMinMaxRange(0, 1);
    }

    if (this.fromApiJsonHelper.parameterExists("penalty", element)) {
        final Boolean penalty = this.fromApiJsonHelper.extractBooleanNamed("penalty", element);
        baseDataValidator.reset().parameter("penalty").value(penalty).notNull();
    }

    if (this.fromApiJsonHelper.parameterExists("active", element)) {
        final Boolean active = this.fromApiJsonHelper.extractBooleanNamed("active", element);
        baseDataValidator.reset().parameter("active").value(active).notNull();
    }
    if (this.fromApiJsonHelper.parameterExists("minCap", element)) {
        final BigDecimal minCap = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("minCap",
                element.getAsJsonObject());
        baseDataValidator.reset().parameter("minCap").value(minCap).notNull().positiveAmount();
    }
    if (this.fromApiJsonHelper.parameterExists("maxCap", element)) {
        final BigDecimal maxCap = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("maxCap",
                element.getAsJsonObject());
        baseDataValidator.reset().parameter("maxCap").value(maxCap).notNull().positiveAmount();
    }
    if (this.fromApiJsonHelper.parameterExists("feeFrequency", element)) {
        final Integer feeFrequency = this.fromApiJsonHelper.extractIntegerNamed("feeFrequency", element,
                Locale.getDefault());
        baseDataValidator.reset().parameter("feeFrequency").value(feeFrequency).inMinMaxRange(0, 3);
    }

    if (this.fromApiJsonHelper.parameterExists(ChargesApiConstants.glAccountIdParamName, element)) {
        final Long glAccountId = this.fromApiJsonHelper
                .extractLongNamed(ChargesApiConstants.glAccountIdParamName, element);
        baseDataValidator.reset().parameter(ChargesApiConstants.glAccountIdParamName).value(glAccountId)
                .notNull().longGreaterThanZero();
    }

    if (this.fromApiJsonHelper.parameterExists(ChargesApiConstants.taxGroupIdParamName, element)) {
        final Long taxGroupId = this.fromApiJsonHelper.extractLongNamed(ChargesApiConstants.taxGroupIdParamName,
                element);
        baseDataValidator.reset().parameter(ChargesApiConstants.taxGroupIdParamName).value(taxGroupId).notNull()
                .longGreaterThanZero();
    }

    throwExceptionIfValidationWarningsExist(dataValidationErrors);
}

From source file:io.neba.core.logviewer.LogFiles.java

@SuppressWarnings("unchecked")
public Collection<File> resolveLogFiles() throws IOException {
    File logDir = getLogfileDirectory();
    Collection<File> logFiles = new TreeSet<>((o1, o2) -> {
        return o1.getPath().compareToIgnoreCase(o2.getPath());
    });/*from   w w w .  j  ava2 s. c om*/

    if (logDir == null) {
        // No configured log file directory exists, assume the default
        logDir = new File(this.slingHomeDirectory, "logs");
    }

    // The log directory may be removed during runtime - always check access.
    if (logDir.exists() && logDir.isDirectory()) {
        logFiles.addAll(listFiles(logDir, LOGFILE_FILTER, TrueFileFilter.INSTANCE));
    }

    for (File logFile : resolveFactoryConfiguredLogFiles()) {
        if (!logFile.getParentFile().getAbsolutePath().startsWith(logDir.getAbsolutePath())) {
            logFiles.addAll(listFiles(logFile.getParentFile(), LOGFILE_FILTER, TrueFileFilter.INSTANCE));
        }
    }
    return logFiles;
}

From source file:knowledgeMiner.mining.SentenceParserHeuristic.java

/**
 * Compose the hierarchical set of noun-adjective combinations from the NP.
 * First gets all anchors, then processes each JJ and NN combination, adding
 * them directly or as subvalues of the anchors.
 * // w  w  w  .j  a v a 2s  .c om
 * @param parse
 *            The parse to compose the strings from.
 * @param anchors
 *            The anchors to insert during composition.
 * @return A Hierarchical Weighted Set of strings representing the order of
 *         strings that should be attempted to assert.
 */
public Collection<Tree<String>> composeAdjNounsTree(Parse parse, SortedMap<String, String> anchors) {
    String text = parse.getCoveredText();
    Collection<Tree<String>> results = new ArrayList<>();

    // Add all visible anchors
    // Keep track of which text is in what anchors
    Map<String, Tree<String>> anchorMap = new HashMap<>();
    results.addAll(extractAnchors(text, anchors, anchorMap));

    // Work backwards through the children, adding nouns, then adjectives to
    // the nouns
    results.addAll(pairNounAdjs(parse, anchors, anchorMap));
    return results;
}

From source file:com.jivesoftware.licenseserver.SignedFetchInterceptor.java

protected OAuthMessage sign(String method, String uri, String postBody, Collection<OAuth.Parameter> params,
        String opensocialParams, Map<String, String> context) throws OAuthException {
    if (uri == null)
        return null;

    UriBuilder target = UriBuilder.parse(uri);
    String query = target.getQuery();
    target.setQuery(null);/* www  . j  av a 2 s . c  o m*/
    params.addAll(OAuth.decodeForm(query));
    if (opensocialParams != null)
        params.addAll(OAuth.decodeForm(opensocialParams));

    OAuthUtil.SignatureType signatureType = OAuthUtil.SignatureType.URL_ONLY;
    if (postBody != null)
        signatureType = OAuthUtil.SignatureType.URL_AND_FORM_PARAMS;

    switch (signatureType) {
    case URL_ONLY:
        LOG.info("url_only");
        break;
    case URL_AND_FORM_PARAMS:
        try {
            params.addAll(OAuth.decodeForm(postBody));
        } catch (IllegalArgumentException e) {
            // Occurs if OAuth.decodeForm finds an invalid URL to decode.
            throw new OAuthException("Could not decode body", e);
        }
        break;
    case URL_AND_BODY_HASH:
        try {
            byte[] body = IOUtils.toByteArray(postBody);
            byte[] hash = DigestUtils.sha(body);
            String b64 = new String(Base64.encodeBase64(hash), Charsets.UTF_8.name());
            params.add(new OAuth.Parameter(OAuthConstants.OAUTH_BODY_HASH, b64));
        } catch (IOException e) {
            throw new OAuthException("Error taking body hash", e);
        }
        break;
    default:
        LOG.info("default");
        break;
    }

    // authParams are parameters prefixed with 'xoauth' 'oauth' or 'opensocial',
    // trusted parameters have ability to override these parameters.
    List<OAuth.Parameter> authParams = Lists.newArrayList();
    params.addAll(authParams);

    OAuthMessage message;
    try {
        String consumerKey = context.get("applicationConsumerKey");
        String consumerSecret = context.get("applicationConsumerSecret");

        if (consumerKey == null || consumerSecret == null) {
            throw new Exception(
                    "Consumer key/secret not available, this Jive installation hasn't been properly registered with apps market");
        }
        OAuthAccessor accessor = new OAuthAccessor(new OAuthConsumer(null, consumerKey, consumerSecret, null));

        int index = uri.indexOf("?");
        if (index != -1) {
            uri = uri.substring(0, index);
        }
        message = accessor.newRequestMessage(method == null ? "GET" : method, uri, params);
    } catch (Exception e) {
        throw new OAuthException(e);
    }

    return message;
}

From source file:it.doqui.index.ecmengine.business.personalization.multirepository.index.lucene.RepositoryAwareLuceneCategoryServiceImpl.java

public Collection<ChildAssociationRef> getRootCategories(StoreRef storeRef, QName aspectName) {
    Collection<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
    Set<NodeRef> nodeRefs = getClassificationNodes(storeRef, aspectName);
    for (NodeRef nodeRef : nodeRefs) {
        assocs.addAll(getChildren(nodeRef, Mode.SUB_CATEGORIES, Depth.IMMEDIATE));
    }//from  ww w . ja v a 2 s .c  o  m
    return assocs;
}

From source file:it.doqui.index.ecmengine.business.personalization.multirepository.index.lucene.RepositoryAwareLuceneCategoryServiceImpl.java

public Collection<ChildAssociationRef> getCategories(StoreRef storeRef, QName aspectQName, Depth depth) {
    Collection<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
    Set<NodeRef> nodeRefs = getClassificationNodes(storeRef, aspectQName);
    for (NodeRef nodeRef : nodeRefs) {
        assocs.addAll(getChildren(nodeRef, Mode.SUB_CATEGORIES, depth));
    }/*from  w w  w  . j a va  2  s .com*/
    return assocs;
}

From source file:admin.service.SimpleJobService.java

@Override
public Collection<String> listJobs(int start, int count) {
    Collection<String> jobNames = new LinkedHashSet<String>(jobLocator.getJobNames());
    if (start + count > jobNames.size()) {
        jobNames.addAll(jobInstanceDao.getJobNames());
    }/*from w  w  w .j a  v a2 s.c o m*/
    if (start >= jobNames.size()) {
        start = jobNames.size();
    }
    if (start + count >= jobNames.size()) {
        count = jobNames.size() - start;
    }
    return new ArrayList<String>(jobNames).subList(start, start + count);
}

From source file:net.sf.jabref.gui.fieldeditors.FileListEditor.java

public void autoSetLinks() {
    auto.setEnabled(false);/*  w  ww.  ja  v  a  2s . c o m*/

    Collection<BibEntry> entries = new ArrayList<>();
    entries.addAll(frame.getCurrentBasePanel().getSelectedEntries());

    // filesystem lookup
    JDialog dialog = new JDialog(frame, true);
    JabRefExecutorService.INSTANCE
            .execute(AutoSetLinks.autoSetLinks(entries, null, null, tableModel, databaseContext, e -> {
                auto.setEnabled(true);

                if (e.getID() > 0) {
                    entryEditor.updateField(this);
                    adjustColumnWidth();
                    frame.output(Localization.lang("Finished automatically setting external links."));
                } else {
                    frame.output(Localization.lang("Finished automatically setting external links.") + " "
                            + Localization.lang("No files found."));

                    // auto download file as no file found before
                    frame.getCurrentBasePanel().runCommand(Actions.DOWNLOAD_FULL_TEXT);
                }
                // reset
                auto.setEnabled(true);
            }, dialog));
}