Package org.hibernate.search.engine.spi

Examples of org.hibernate.search.engine.spi.EntityIndexBinder


    this.transactionContext = new InstanceTransactionContext();
    transactionContext.beginTransaction();
  }

  public <T> T get(Class<T> entityType, Serializable id) {
    final EntityIndexBinder entityIndexBinding = searchFactory.getIndexBindingForEntity( entityType );
    if ( entityIndexBinding == null ) {
      String msg = "Entity to retrueve is not an @Indexed entity: " + entityType.getClass().getName();
      throw new IllegalArgumentException( msg );
    }
    if (id == null) {
      throw new IllegalArgumentException( "Identifier cannot be null" );
    }
    DocumentBuilderIndexedEntity<?> docBuilder = entityIndexBinding.getDocumentBuilder();
    Query luceneQuery = new TermQuery( docBuilder.getTerm( id ) );
    FullTextQuery searchQuery = createFullTextQuery( luceneQuery, entityType );
    List<?> results = searchQuery.list();
    if (results.size() > 1) {
      //TODO find correct exception
View Full Code Here


    }

    Class<?> clazz = getClass( entity );
    //TODO cache that at the FTSession level
    //not strictly necessary but a small optimization
    final EntityIndexBinder entityIndexBinding = searchFactory.getIndexBindingForEntity( clazz );
    if ( entityIndexBinding == null ) {
      String msg = "Entity to index is not an @Indexed entity: " + entity.getClass().getName();
      throw new IllegalArgumentException( msg );
    }
    Serializable id = entityIndexBinding.getDocumentBuilder().getId( entity );
    Work<T> work = new Work<T>( entity, id, WorkType.INDEX );
    searchFactory.getWorker().performWork( work, transactionContext );

    //TODO
    //need to add elements in a queue kept at the Session level
View Full Code Here

   * @param entityClass the entity type for which to retrieve the document builder
   *
   * @return the DocumentBuilder for this type
   */
  private static <T> AbstractDocumentBuilder<T> getEntityBuilder(SearchFactoryImplementor searchFactoryImplementor, Class<?> entityClass) {
    EntityIndexBinder entityIndexBinding = searchFactoryImplementor.getIndexBindingForEntity( entityClass );
    if ( entityIndexBinding == null ) {
      DocumentBuilderContainedEntity entityBuilder = searchFactoryImplementor.getDocumentBuilderContainedEntity(
          entityClass
      );
      if ( entityBuilder == null ) {
        // should never happen but better be safe than sorry
        throw new SearchException(
            "Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: " + entityClass
        );
      }
      else {
        return entityBuilder;
      }
    }
    else {
      return (AbstractDocumentBuilder<T>) entityIndexBinding.getDocumentBuilder();
    }
  }
View Full Code Here

        }
      }
    }

    private EntityIndexingInterceptor<? super T> getEntityInterceptor() {
      EntityIndexBinder indexBindingForEntity = searchFactoryImplementor.getIndexBindingForEntity(
          entityClass
      );
      return indexBindingForEntity!=null ?
          (EntityIndexingInterceptor<? super T> ) indexBindingForEntity.getEntityIndexingInterceptor() :
          null;
    }
View Full Code Here

    }
    return -1;
  }

  private static DocumentBuilderIndexedEntity<?> getDocumentBuilder(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz) {
    EntityIndexBinder entityIndexBinding = searchFactoryImplementor.getIndexBindingForEntity(
        clazz
    );
    if ( entityIndexBinding == null ) {
      throw new SearchException( "No Lucene configuration set up for: " + clazz );
    }
    return entityIndexBinding.getDocumentBuilder();
  }
View Full Code Here

          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

      for ( Class clazz : involvedClasses ) {
        EntityIndexBinder indexBinder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( indexBinder == null ) {
          throw new SearchException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        DocumentBuilderIndexedEntity<?> builder = indexBinder.getDocumentBuilder();
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        useFieldCacheOnClassTypes = useFieldCacheOnClassTypes || builder.getFieldCacheOption()
            .contains( FieldCacheType.CLASS );
        populateIndexManagers( targetedIndexes, indexBinder.getSelectionStrategy() );
      }
      this.classesAndSubclasses = involvedClasses;
    }
    this.idFieldNames = idFieldNames;
View Full Code Here

      throw log.needAtLeastOneIndexedEntityType();
    }

    HashMap<String, IndexManager> indexManagers = new HashMap<String, IndexManager>();
    for ( Class<?> type : entities ) {
      EntityIndexBinder entityIndexBinding = searchFactory.getSafeIndexBindingForEntity( type );
      IndexManager[] indexManagersForAllShards = entityIndexBinding.getSelectionStrategy()
          .getIndexManagersForAllShards();
      for ( IndexManager im : indexManagersForAllShards ) {
        indexManagers.put( im.getIndexName(), im );
      }
    }
View Full Code Here

      im.optimize();
    }
  }

  public void optimize(Class entityType) {
    EntityIndexBinder entityIndexBinding = getSafeIndexBindingForEntity( entityType );
    for ( IndexManager im: entityIndexBinding.getIndexManagers() ) {
      im.optimize();
    }
  }
View Full Code Here

   * @param entityClass the entity type for which to retrieve the document builder
   *
   * @return the DocumentBuilder for this type
   */
  private static <T> AbstractDocumentBuilder<T> getEntityBuilder(SearchFactoryImplementor searchFactoryImplementor, Class<?> entityClass) {
    EntityIndexBinder entityIndexBinding = searchFactoryImplementor.getIndexBindingForEntity( entityClass );
    if ( entityIndexBinding == null ) {
      DocumentBuilderContainedEntity entityBuilder = searchFactoryImplementor.getDocumentBuilderContainedEntity(
          entityClass
      );
      if ( entityBuilder == null ) {
        // should never happen but better be safe than sorry
        throw new SearchException(
            "Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: " + entityClass
        );
      }
      else {
        return entityBuilder;
      }
    }
    else {
      return entityIndexBinding.getDocumentBuilder();
    }
  }
View Full Code Here

    }
    return analyzer;
  }

  public Analyzer getAnalyzer(Class<?> clazz) {
    EntityIndexBinder entityIndexBinding = getSafeIndexBindingForEntity( clazz );
    DocumentBuilderIndexedEntity<?> builder = entityIndexBinding.getDocumentBuilder();
    return builder.getAnalyzer();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.engine.spi.EntityIndexBinder

Copyright © 2018 www.massapicom. 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.