Examples of ChainedFilter


Examples of org.apache.lucene.queries.ChainedFilter

        return (Q)this;
    }

    private Filter getFilter() {
        if (_filter == null && !filters.isEmpty()) {
            _filter = new ChainedFilter(filters.toArray(new Filter[filters.size()]));
        }
        return _filter;
    }
View Full Code Here

Examples of org.apache.lucene.queries.ChainedFilter

            return rangeFilter;
        }
        else
        {
            Filter[] filters = new Filter[]{filter, rangeFilter};
            return new ChainedFilter(filters, ChainedFilter.AND);
        }
    }
View Full Code Here

Examples of org.apache.lucene.search.ChainedFilter

        return (Q)this;
    }

    private Filter getFilter() {
        if (_filter == null && !filters.isEmpty()) {
            _filter = new ChainedFilter(filters.toArray(new Filter[filters.size()]));
        }
        return _filter;
    }
View Full Code Here

Examples of org.apache.lucene.search.ChainedFilter

    // Chain the Query (as filter) with our distance filter
    if (distanceFilter != null) {
      distanceFilter.reset();
    }
    QueryWrapperFilter qf = new QueryWrapperFilter(query);
    return new ChainedFilter(new Filter[] {qf, filter},
                             ChainedFilter.AND);
  }
View Full Code Here

Examples of org.hibernate.search.filter.ChainedFilter

  }

  private void buildFilters() {
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    if ( filterDefinitions != null && filterDefinitions.size() > 0 ) {
      ChainedFilter chainedFilter = new ChainedFilter();
      for ( FullTextFilterImpl filterDefinition : filterDefinitions.values() ) {
        FilterDef def = searchFactoryImplementor.getFilterDefinition( filterDefinition.getName() );
        Class implClass = def.getImpl();
        Object instance;
        try {
          instance = implClass.newInstance();
        }
        catch (InstantiationException e) {
          throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
        }
        catch (IllegalAccessException e) {
          throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
        }
        for ( Map.Entry<String, Object> entry : filterDefinition.getParameters().entrySet() ) {
          def.invoke( entry.getKey(), instance, entry.getValue() );
        }
        if ( def.isCache() && def.getKeyMethod() == null && filterDefinition.getParameters().size() > 0 ) {
          throw new SearchException("Filter with parameters and no @Key method: " + filterDefinition.getName() );
        }
        FilterKey key = null;
        if ( def.isCache() ) {
          if ( def.getKeyMethod() == null ) {
            key = new FilterKey( ) {
              public int hashCode() {
                return getImpl().hashCode();
              }

              public boolean equals(Object obj) {
                if ( ! ( obj instanceof FilterKey ) ) return false;
                FilterKey that = (FilterKey) obj;
                return this.getImpl().equals( that.getImpl() );
              }
            };
          }
          else {
            try {
              key = (FilterKey) def.getKeyMethod().invoke( instance );
            }
            catch (IllegalAccessException e) {
              throw new SearchException("Unable to access @Key method: "
                  + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
            }
            catch (InvocationTargetException e) {
              throw new SearchException("Unable to access @Key method: "
                  + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
            }
            catch (ClassCastException e) {
              throw new SearchException("@Key method does not return FilterKey: "
                  + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
            }
          }
          key.setImpl( def.getImpl() );
        }

        Filter filter = def.isCache() ?
            searchFactoryImplementor.getFilterCachingStrategy().getCachedFilter( key ) :
            null;
        if (filter == null) {
          if ( def.getFactoryMethod() != null ) {
            try {
              filter = (Filter) def.getFactoryMethod().invoke( instance );
            }
            catch (IllegalAccessException e) {
              throw new SearchException("Unable to access @Factory method: "
                  + def.getImpl().getName() + "." + def.getFactoryMethod().getName() );
            }
            catch (InvocationTargetException e) {
              throw new SearchException("Unable to access @Factory method: "
                  + def.getImpl().getName() + "." + def.getFactoryMethod().getName() );
            }
            catch (ClassCastException e) {
              throw new SearchException("@Key method does not return a org.apache.lucene.search.Filter class: "
                  + def.getImpl().getName() + "." + def.getFactoryMethod().getName() );
            }
          }
          else {
            try {
              filter = (Filter) instance;
            }
            catch (ClassCastException e) {
              throw new SearchException("@Key method does not return a org.apache.lucene.search.Filter class: "
                  + def.getImpl().getName() + "." + def.getFactoryMethod().getName() );
            }
          }
          if ( def.isCache() ) searchFactoryImplementor.getFilterCachingStrategy().addCachedFilter( key, filter );
        }
        chainedFilter.addFilter( filter );
      }
      if ( filter != null ) chainedFilter.addFilter( filter );
      filter = chainedFilter;
    }
  }
View Full Code Here

Examples of org.hibernate.search.filter.ChainedFilter

  private void buildFilters() {
    if ( filterDefinitions == null || filterDefinitions.size() == 0 ) {
      return; // there is nothing to do if we don't have any filter definitions
    }

    ChainedFilter chainedFilter = new ChainedFilter();
    for ( FullTextFilterImpl fullTextFilter : filterDefinitions.values() ) {
      Filter filter = buildLuceneFilter( fullTextFilter );
      chainedFilter.addFilter( filter );
    }

    if ( filter != null ) {
      chainedFilter.addFilter( filter );
    }
    filter = chainedFilter;
  }
View Full Code Here

Examples of org.hibernate.search.filter.ChainedFilter

      }
    }
  }

  private void buildFilters() {
    ChainedFilter chainedFilter = null;
    if ( !filterDefinitions.isEmpty() ) {
      chainedFilter = new ChainedFilter();
      for ( FullTextFilterImpl fullTextFilter : filterDefinitions.values() ) {
        Filter filter = buildLuceneFilter( fullTextFilter );
        if ( filter != null ) {
          chainedFilter.addFilter( filter );
        }
      }
    }

    if ( userFilter != null ) {
      //chainedFilter is not always necessary here but the code is easier to read
      if ( chainedFilter == null ) {
        chainedFilter = new ChainedFilter();
      }
      chainedFilter.addFilter( userFilter );
    }

    if ( chainedFilter == null || chainedFilter.isEmpty() ) {
      filter = null;
    }
    else {
      filter = chainedFilter;
    }
View Full Code Here

Examples of org.hibernate.search.filter.ChainedFilter

  private void buildFilters() {
    if ( filterDefinitions == null || filterDefinitions.size() == 0 ) {
      return; // there is nothing to do if we don't have any filter definitions
    }

    ChainedFilter chainedFilter = new ChainedFilter();
    for (FullTextFilterImpl fullTextFilter : filterDefinitions.values()) {
      Filter filter = buildLuceneFilter(fullTextFilter);
      chainedFilter.addFilter( filter );
    }

    if ( filter != null ) chainedFilter.addFilter( filter );
    filter = chainedFilter;
  }
View Full Code Here

Examples of org.hibernate.search.filter.ChainedFilter

      }
    }
  }

  private void buildFilters() {
    ChainedFilter chainedFilter = null;
    if ( !filterDefinitions.isEmpty() ) {
      chainedFilter = new ChainedFilter();
      for ( FullTextFilterImpl fullTextFilter : filterDefinitions.values() ) {
        Filter filter = buildLuceneFilter( fullTextFilter );
        if ( filter != null ) {
          chainedFilter.addFilter( filter );
        }
      }
    }

    if ( userFilter != null ) {
      //chainedFilter is not always necessary here but the code is easier to read
      if ( chainedFilter == null ) {
        chainedFilter = new ChainedFilter();
      }
      chainedFilter.addFilter( userFilter );
    }

    if ( chainedFilter == null || chainedFilter.isEmpty() ) {
      filter = null;
    }
    else {
      filter = chainedFilter;
    }
View Full Code Here

Examples of org.hibernate.search.filter.ChainedFilter

      }
    }
  }

  private void buildFilters() {
    ChainedFilter chainedFilter = null;
    if ( !filterDefinitions.isEmpty() ) {
      chainedFilter = new ChainedFilter();
      for ( FullTextFilterImpl fullTextFilter : filterDefinitions.values() ) {
        Filter filter = buildLuceneFilter( fullTextFilter );
        if ( filter != null ) {
          chainedFilter.addFilter( filter );
        }
      }
    }

    if ( userFilter != null ) {
      //chainedFilter is not always necessary here but the code is easier to read
      if ( chainedFilter == null ) {
        chainedFilter = new ChainedFilter();
      }
      chainedFilter.addFilter( userFilter );
    }

    if ( chainedFilter == null || chainedFilter.isEmpty() ) {
      filter = null;
    }
    else {
      filter = chainedFilter;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.