Search in sources :

Example 16 with Predicate

use of org.apache.commons.collections.Predicate in project pinot by linkedin.

the class PinotHelixResourceManager method getAllRealtimeTables.

public List<String> getAllRealtimeTables() {
    List<String> ret = _helixAdmin.getResourcesInCluster(_helixClusterName);
    CollectionUtils.filter(ret, new Predicate() {

        @Override
        public boolean evaluate(Object object) {
            if (object == null) {
                return false;
            }
            if (object.toString().endsWith("_" + ServerType.REALTIME.toString())) {
                return true;
            }
            return false;
        }
    });
    return ret;
}
Also used : Predicate(org.apache.commons.collections.Predicate)

Example 17 with Predicate

use of org.apache.commons.collections.Predicate in project RESTdoclet by IG-Group.

the class MethodBuilder method initRestParams.

/**
    * Initialises the REST-parameters of this method.
    * 
    * @param method method to initialise
    * @param methodDoc the method's Java documentation object.
    * @param baseUri the controller base uri
    */
private void initRestParams(Method method, final MethodDoc methodDoc, final String baseUri) {
    LOG.debug(method.getName());
    ArrayList<RestParameter> restParams = new ArrayList<RestParameter>();
    for (NameValuePair pair : new RequestMappingParamsParser(elementValue(methodDoc, RequestMapping.class, "params")).parse()) {
        final Predicate predicate = new ParameterNamePredicate(pair.getName());
        if (!CollectionUtils.exists(method.getRequestParams(), predicate)) {
            LOG.debug(pair.getName() + " - " + pair.getValue());
            restParams.add(new RestParameter(pair));
        }
    }
    AnnotationValue urlAnnotation = elementValue(methodDoc, RequestMapping.class, "value");
    if (urlAnnotation != null) {
        Boolean deprecatedMatch = false;
        String[] methodUris = parseValueAnnotation(urlAnnotation);
        String[] deprecatedURIs = DocTypeUtils.getDeprecatedURIs(methodDoc);
        for (final String uri : methodUris) {
            LOG.debug("uri:" + baseUri + uri);
            boolean deprecated = false;
            if (deprecatedURIs != null) {
                for (final String deprecatedUri : deprecatedURIs) {
                    LOG.debug("deprecated:" + deprecatedUri);
                    if (StringUtils.equals(deprecatedUri, uri)) {
                        LOG.debug("=DEPRECATED");
                        deprecated = true;
                        deprecatedMatch = true;
                        break;
                    }
                }
            }
            method.getUris().add(new Uri(baseUri + uri, deprecated));
        }
        if (deprecatedURIs != null && !deprecatedMatch) {
            LOG.warn("Deprecated URI tag on method " + methodDoc.name() + " does not match any service URIs.");
        }
    }
    method.setRestParams(restParams);
}
Also used : NameValuePair(com.iggroup.oss.restdoclet.doclet.util.NameValuePair) ArrayList(java.util.ArrayList) RequestMappingParamsParser(com.iggroup.oss.restdoclet.doclet.util.RequestMappingParamsParser) Uri(com.iggroup.oss.restdoclet.doclet.type.Uri) Predicate(org.apache.commons.collections.Predicate) ParameterNamePredicate(com.iggroup.oss.restdoclet.doclet.util.ParameterNamePredicate) RestParameter(com.iggroup.oss.restdoclet.doclet.type.RestParameter) AnnotationValue(com.sun.javadoc.AnnotationValue) ParameterNamePredicate(com.iggroup.oss.restdoclet.doclet.util.ParameterNamePredicate)

Example 18 with Predicate

use of org.apache.commons.collections.Predicate in project head by mifos.

the class BranchReportClientSummaryHelperIntegrationTest method assertClientSummary.

private void assertClientSummary(BranchReportBO branchReport) throws PersistenceException {
    Assert.assertNotNull(branchReport.getBranchReportId());
    Set<BranchReportClientSummaryBO> branchReportClientSummaries = branchReport.getClientSummaries();
    Assert.assertNotNull(branchReportClientSummaries);
    Assert.assertEquals(12, branchReportClientSummaries.size());
    Predicate predicate = new BranchReportClientSummaryBatchBOExtractor().matchAllPredicates(branchReportClientSummaries);
    Assert.assertNull(predicate + " not found in summaries", predicate);
}
Also used : BranchReportClientSummaryBO(org.mifos.reports.branchreport.BranchReportClientSummaryBO) BranchReportClientSummaryBatchBOExtractor(org.mifos.reports.branchreport.helper.BranchReportClientSummaryBatchBOExtractor) Predicate(org.apache.commons.collections.Predicate)

Example 19 with Predicate

use of org.apache.commons.collections.Predicate in project OpenAM by OpenRock.

the class SessionService method getValidInternalSessions.

/**
     * Get all valid Internal Sessions.
     */
private List<InternalSession> getValidInternalSessions() {
    synchronized (cache) {
        List<InternalSession> sessions = new ArrayList<InternalSession>(cache.getAllSessions());
        org.apache.commons.collections.CollectionUtils.filter(sessions, new Predicate() {

            @Override
            public boolean evaluate(Object o) {
                // Apache Commons is old.
                InternalSession s = (InternalSession) o;
                if (s.getState() != VALID) {
                    return false;
                }
                if (s.isAppSession() && !serviceConfig.isReturnAppSessionEnabled()) {
                    return false;
                }
                return true;
            }
        });
        return sessions;
    }
}
Also used : ArrayList(java.util.ArrayList) Predicate(org.apache.commons.collections.Predicate)

Example 20 with Predicate

use of org.apache.commons.collections.Predicate in project incubator-atlas by apache.

the class AtlasTypeDefGraphStore method searchTypesDef.

@Override
public AtlasTypesDef searchTypesDef(SearchFilter searchFilter) throws AtlasBaseException {
    final AtlasTypesDef typesDef = new AtlasTypesDef();
    Predicate searchPredicates = FilterUtil.getPredicateFromSearchFilter(searchFilter);
    for (AtlasEnumType enumType : typeRegistry.getAllEnumTypes()) {
        if (searchPredicates.evaluate(enumType)) {
            typesDef.getEnumDefs().add(enumType.getEnumDef());
        }
    }
    for (AtlasStructType structType : typeRegistry.getAllStructTypes()) {
        if (searchPredicates.evaluate(structType)) {
            typesDef.getStructDefs().add(structType.getStructDef());
        }
    }
    for (AtlasClassificationType classificationType : typeRegistry.getAllClassificationTypes()) {
        if (searchPredicates.evaluate(classificationType)) {
            typesDef.getClassificationDefs().add(classificationType.getClassificationDef());
        }
    }
    for (AtlasEntityType entityType : typeRegistry.getAllEntityTypes()) {
        if (searchPredicates.evaluate(entityType)) {
            typesDef.getEntityDefs().add(entityType.getEntityDef());
        }
    }
    return typesDef;
}
Also used : AtlasEnumType(org.apache.atlas.type.AtlasEnumType) AtlasStructType(org.apache.atlas.type.AtlasStructType) AtlasClassificationType(org.apache.atlas.type.AtlasClassificationType) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Predicate(org.apache.commons.collections.Predicate)

Aggregations

Predicate (org.apache.commons.collections.Predicate)24 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)3 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 EnvironmentVariable (com.thoughtworks.go.domain.EnvironmentVariable)2 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)2 GoCipher (com.thoughtworks.go.security.GoCipher)2 PipelineScheduleOptions (com.thoughtworks.go.server.domain.PipelineScheduleOptions)2 MaterialUpdateSuccessfulMessage (com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Resource (org.apache.sling.api.resource.Resource)2 MultiInstanceofPredicate (org.jumpmind.db.util.MultiInstanceofPredicate)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 RestParameter (com.iggroup.oss.restdoclet.doclet.type.RestParameter)1 Uri (com.iggroup.oss.restdoclet.doclet.type.Uri)1 NameValuePair (com.iggroup.oss.restdoclet.doclet.util.NameValuePair)1