Example usage for org.apache.commons.collections CollectionUtils containsAny

List of usage examples for org.apache.commons.collections CollectionUtils containsAny

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils containsAny.

Prototype

public static boolean containsAny(final Collection coll1, final Collection coll2) 

Source Link

Document

Returns true iff at least one element is in both collections.

Usage

From source file:com.doculibre.constellio.services.ACLServicesImpl.java

private boolean matches(Record record, PolicyACLEntry entry, Collection<ConstellioGroup> groups,
        Collection<ConstellioUser> users) {
    boolean match = false;

    IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
    IndexField indexField = entry.getIndexField();
    String regexp = entry.getMatchRegexp();

    List<Object> fieldValues = indexFieldServices.extractFieldValues(record, indexField);
    for (Object fieldValue : fieldValues) {
        Pattern pattern = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(fieldValue.toString());
        if (matcher.find()) {
            if (groups != null || users != null) {
                if (groups != null && CollectionUtils.containsAny(entry.getGroups(), groups)) {
                    match = true;//  www .  ja  v  a 2 s  . co  m
                    break;
                } else if (users != null && CollectionUtils.containsAny(entry.getUsers(), users)) {
                    match = true;
                    break;
                }
            } else {
                match = true;
                break;
            }
        }
    }
    return match;
}

From source file:com.att.aro.core.packetanalysis.impl.PacketAnalyzerImpl.java

protected PacketAnalyzerResult finalResult(AbstractTraceResult result, Profile profile, AnalysisFilter filter) {
    PacketAnalyzerResult data = new PacketAnalyzerResult();
    List<PacketInfo> filteredPackets; // List of packets included in analysis (application filtered)
    Profile aProfile = profile;/*from  www.  ja  v  a  2 s .  co  m*/
    if (aProfile == null) {
        aProfile = profilefactory.createLTEdefault();//if the user doesn't load any profile.....
        aProfile.setName("AT&T LTE");
    }

    // for the situation, filter out all noo-ip pacekts and caused the allpackets is empty, need to refactor
    if (result != null && result.getAllpackets() != null && result.getAllpackets().size() == 0) {
        data.setTraceresult(result);
        return data;
    }

    TimeRange timeRange = null;

    filteredPackets = new ArrayList<PacketInfo>();
    if (filter == null) {
        if (result != null) {
            filteredPackets = result.getAllpackets();
        }
    } else {// do the filter
        timeRange = filter.getTimeRange();
        if (result != null) {
            filteredPackets = filterPackets(filter, result.getAllpackets());
        }
    }

    // Set the Abstract Trace Data with the filtered packets - All packets are not necessary.
    // Fix for Sev 2 Issue correcting the throughput graph - DE187846
    // Fix for Sev 2 Time Range Analysis Issue - DE187848
    if (result != null) {
        result.setAllpackets(filteredPackets);
    }

    List<Session> sessionlist = sessionmanager.assembleSession(filteredPackets);
    List<PacketInfo> filteredPacketsNoDNSUDP = new ArrayList<PacketInfo>();
    for (Session session : sessionlist) {
        for (PacketInfo packet : session.getPackets()) {
            filteredPacketsNoDNSUDP.add(packet);
        }
    }
    int totaltemp = 0;
    for (Session byteCountSession : sessionlist) {
        totaltemp += byteCountSession.getBytesTransferred();
    }
    Statistic stat = this.getStatistic(filteredPacketsNoDNSUDP);
    if (result != null && stat.getAppName() != null && stat.getAppName().size() == 1
            && stat.getAppName().contains("Unknown")) {
        stat.setAppName(new HashSet<String>(result.getAppInfos()));
    }

    stat.setTotalByte(totaltemp);//to make sure match the same number with 4.1.1.
    //stat is used to get some info for RrcStateMachine etc

    if (result != null) {
        logger.debug("Starting pre processing in PAI");
        AbstractRrcStateMachine statemachine = statemachinefactory.create(filteredPackets, aProfile,
                stat.getPacketDuration(), result.getTraceDuration(), stat.getTotalByte(), timeRange);

        EnergyModel energymodel = energymodelfactory.create(aProfile, statemachine.getTotalRRCEnergy(),
                result.getGpsInfos(), result.getCameraInfos(), result.getBluetoothInfos(),
                result.getScreenStateInfos());

        BurstCollectionAnalysisData burstcollectiondata = burstcollectionanalyzer.analyze(filteredPackets,
                aProfile, stat.getPacketSizeToCountMap(), statemachine.getStaterangelist(),
                result.getUserEvents(), result.getCpuActivityList().getCpuActivities(), sessionlist);
        data.clearBPResults();
        try {
            List<BestPracticeType> imgVidBP = BestPracticeType.getByCategory(BestPracticeType.Category.VIDEO);
            imgVidBP.add(BestPracticeType.IMAGE_MDATA);
            imgVidBP.add(BestPracticeType.IMAGE_CMPRS);
            imgVidBP.add(BestPracticeType.IMAGE_FORMAT);
            imgVidBP.add(BestPracticeType.IMAGE_COMPARE);
            if (CollectionUtils.containsAny(SettingsUtil.retrieveBestPractices(), imgVidBP)) {
                videoUsageAnalyzer.clearData();
                data.setVideoUsage(videoUsageAnalyzer.analyze(result, sessionlist));
            } else {
                data.setVideoUsage(videoUsageAnalyzer.clearData());
            }
        } catch (Exception ex) {
            logger.error("Error in Video usage analysis :" + ex.getLocalizedMessage(), ex);
        }

        data.setBurstcollectionAnalysisData(burstcollectiondata);
        data.setEnergyModel(energymodel);
        data.setSessionlist(sessionlist);
        data.setStatemachine(statemachine);
        data.setStatistic(stat);
        data.setTraceresult(result);
        data.setProfile(aProfile);
        data.setFilter(filter);
        data.setDeviceKeywords(result.getDeviceKeywordInfos());
    }
    return data;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.administrativeOffice.lists.StudentListByDegreeDA.java

static private boolean hasStudentStatuteType(final SearchStudentsByDegreeParametersBean searchBean,
        final Registration registration) {
    return CollectionUtils.containsAny(searchBean.getStudentStatuteTypes(), registration.getStudent()
            .getStatutesTypesValidOnAnyExecutionSemesterFor(searchBean.getExecutionYear()));
}

From source file:ddf.catalog.impl.operations.CreateOperations.java

private boolean isMetacardBlacklisted(Metacard metacard, List<String> fanoutBlacklist) {
    Set<String> tags = new HashSet<>(metacard.getTags());

    if (tags.isEmpty()) {
        tags.add(Metacard.DEFAULT_TAG);/*from  w  w w .  ja v  a 2  s.  c o  m*/
    }

    return CollectionUtils.containsAny(tags, fanoutBlacklist);
}

From source file:gov.nih.nci.caarray.application.project.ProjectManagementServiceBean.java

private void checkArrayDesignManufacturer(Project project) throws InconsistentProjectStateException {
    final Set<ArrayDesign> designs = project.getExperiment().getArrayDesigns();
    for (final ArrayDesign ad : designs) {
        if ((project.getExperiment().getManufacturer() != null
                && project.getExperiment().getManufacturer() != ad.getProvider())
                || (!project.getExperiment().getAssayTypes().isEmpty() && !CollectionUtils
                        .containsAny(ad.getAssayTypes(), project.getExperiment().getAssayTypes()))) {
            throw new InconsistentProjectStateException(Reason.ARRAY_DESIGNS_DONT_MATCH_MANUF_OR_TYPE,
                    new Object[] {});
        }/*from w  w w .j a  va 2s .  c o  m*/

    }
}

From source file:com.streamsets.datacollector.restapi.PreviewResource.java

private void checkDynamicPreviewPermissions(DynamicPreviewRequestJson dynamicPreviewRequest) {
    switch (dynamicPreviewRequest.getType()) {
    case CLASSIFICATION_CATALOG:
        if (!CollectionUtils.containsAny(currentUser.getRoles(),
                DYNAMIC_PREVIEW_ALLOWED_ROLES_CLASSIFICATION)) {
            throw new ForbiddenException(Collections.singletonMap("message",
                    String.format(
                            "User did not have any roles that would allow performing %s type dynamic preview",
                            DynamicPreviewType.CLASSIFICATION_CATALOG.name())));
        }/*  w w w.j  a v a 2 s . c  o  m*/
        break;
    case PROTECTION_POLICY:
        // permissions on specific policies will be checked on DPM side
        break;
    }
}

From source file:edu.scripps.fl.pubchem.promiscuity.PCPromiscuityFactory.java

private PromiscuityCount<Long> getSummaryCountPerCompound(Set<Long> allSummaries,
        Map<Long, List<Long>> summaryToAIDsMap, List<Long> allAssayTotal, List<Long> allAssayActive,
        Map<Long, List<Protein>> aidProteinMap, Map<Long, List<Protein>> summaryProteinMap) {
    List<Long> summaryTotal = new ArrayList<Long>();
    List<Long> summaryActive = new ArrayList<Long>();
    for (Entry<Long, List<Long>> entry : summaryToAIDsMap.entrySet()) {
        List<Long> xrefAIDs = entry.getValue();
        if (CollectionUtils.containsAny(xrefAIDs, allAssayTotal)) {
            summaryTotal.add(entry.getKey());
            checkIfActiveSummary(xrefAIDs, allAssayActive, entry.getKey(), summaryActive, aidProteinMap,
                    summaryProteinMap);/*from   www. j a  va  2 s .c om*/
        }
    }
    PromiscuityCount<Long> summaryCount = new PromiscuityCount<Long>(allProjectsName, summaryActive,
            summaryTotal);
    return summaryCount;
}

From source file:eu.eexcess.domaindetection.wordnet.WordnetDomainsDetector.java

/**
 * Returns the set of common domains give the domain tree
 * @param domains //  www  . j av a  2s  .  c  o  m
 * @return
 */
@SuppressWarnings("unused")
private Set<String> getCommonDomains(Map<String, DomainAssignment> domains) {

    Set<String> commonDomains = null;
    for (String domain : domains.keySet()) {
        if (commonDomains != null && commonDomains.contains(domain)) {
            // ok, within the selected branch
        } else if (commonDomains == null) {
            // make this the new selected branch
            Map<String, Double> parentsToWeight = domainToParentDomainToWeight.get(domain);
            if (parentsToWeight != null) {
                commonDomains = new HashSet<String>(parentsToWeight.keySet());
            } else {
                commonDomains = new HashSet<String>();
            }
            commonDomains.add(domain);
        } else {
            // if there are any common domains
            Map<String, Double> parentsToWeight = domainToParentDomainToWeight.get(domain);
            Set<String> currentDomains;
            if (parentsToWeight != null) {
                currentDomains = new HashSet<String>(parentsToWeight.keySet());
            } else {
                currentDomains = new HashSet<String>();
            }
            currentDomains.add(domain);

            if (CollectionUtils.containsAny(commonDomains, currentDomains)) {
                for (Iterator<String> iterator = commonDomains.iterator(); iterator.hasNext();) {
                    String commonDomain = iterator.next();
                    if (!currentDomains.contains(commonDomain)) {
                        iterator.remove();
                    }
                }
            }

            // no commons domains, so we have to give up
            if (commonDomains.isEmpty()) {
                break;
            }
        }
    }
    return commonDomains;
}

From source file:mitm.common.security.crl.PKIXRevocationChecker.java

private boolean hasMatchingName(DistributionPointName dpn1, DistributionPointName dpn2, X500Principal issuer)
        throws IOException {
    if (dpn1 == null && dpn2 == null) {
        return true;
    }/*  w w w .ja va 2  s.c  o  m*/

    if (dpn1 == null || dpn2 == null) {
        return false;
    }

    GeneralName[] generalNames1 = null;
    GeneralName[] generalNames2 = null;

    X500Name name1 = null;
    X500Name name2 = null;

    if (dpn1.getType() == DistributionPointName.NAME_RELATIVE_TO_CRL_ISSUER) {
        name1 = getFullName(issuer, dpn1);
    } else {
        generalNames1 = GeneralNames.getInstance(dpn1.getName()).getNames();
    }

    if (dpn2.getType() == DistributionPointName.NAME_RELATIVE_TO_CRL_ISSUER) {
        name2 = getFullName(issuer, dpn2);
    } else {
        generalNames2 = GeneralNames.getInstance(dpn2.getName()).getNames();
    }

    if (generalNames1 != null && generalNames2 != null) {
        return CollectionUtils.containsAny(Arrays.asList(generalNames1), Arrays.asList(generalNames2));
    }

    if (name1 != null && name2 != null) {
        return name1.equals(name2);
    }

    return name1 != null ? hasMatchingName(name1, generalNames2) : hasMatchingName(name2, generalNames1);
}

From source file:ddf.catalog.impl.operations.DeleteOperations.java

private boolean isMetacardBlacklisted(Metacard metacard, List<String> fanoutTagBlacklist) {
    Set<String> tags = new HashSet<>(metacard.getTags());

    // defaulting to resource tag if the metacard doesn't contain any tags
    if (tags.isEmpty()) {
        tags.add(Metacard.DEFAULT_TAG);//from w  w  w. ja va  2  s . c  om
    }

    return CollectionUtils.containsAny(tags, fanoutTagBlacklist);
}