Package org.hibernate.search.engine.spi

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


    }
    else {
      Set<Class<?>> involvedClasses = new HashSet<Class<?>>( indexedTargetedEntities.size() );
      involvedClasses.addAll( indexedTargetedEntities );
      for ( Class<?> clazz : indexedTargetedEntities ) {
        EntityIndexBinding indexBinder = builders.get( clazz );
        if ( indexBinder != null ) {
          DocumentBuilderIndexedEntity<?> builder = indexBinder.getDocumentBuilder();
          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

      for ( Class clazz : involvedClasses ) {
        EntityIndexBinding 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


    Map<Class<?>, EntityIndexBinding> builders = searchFactoryImplementor.getIndexBindings();
    Set<FieldCacheCollectorFactory> allCollectors = new HashSet<FieldCacheCollectorFactory>();
    // we need all documentBuilder to agree on type, fieldName, and enabling the option:
    FieldCacheCollectorFactory anyImplementation = null;
    for ( Class<?> clazz : classesAndSubclasses ) {
      EntityIndexBinding docBuilder = builders.get( clazz );
      FieldCacheCollectorFactory fieldCacheCollectionFactory = docBuilder.getIdFieldCacheCollectionFactory();
      if ( fieldCacheCollectionFactory == null ) {
        // some implementation disable it, so we won't use it
        return null;
      }
      anyImplementation = fieldCacheCollectionFactory;
View Full Code Here

  private void assertFacetingFieldExists() {
    if ( fieldName == null ) {
      throw new IllegalArgumentException( "null is an invalid field name" );
    }

    EntityIndexBinding indexBinding = factory.getIndexBinding( entityType );
    if ( indexBinding == null ) {
      throw new SearchException(
          "Entity " + entityType.getName()
              + " is not an indexed entity. Unable to create faceting request"
      );
    }
    documentBuilder = indexBinding.getDocumentBuilder();
  }
View Full Code Here

  }

  static DocumentBuilderIndexedEntity<?> getDocumentBuilder(QueryBuildingContext queryContext) {
    final SearchFactoryImplementor factory = queryContext.getFactory();
    final Class<?> type = queryContext.getEntityType();
    EntityIndexBinding indexBinding = factory.getIndexBinding( type );
    if ( indexBinding == null ) {
      throw new AssertionFailure( "Class is not indexed: " + type );
    }
    return indexBinding.getDocumentBuilder();
  }
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) {
    EntityIndexBinding entityIndexBinding = searchFactoryImplementor.getIndexBinding( 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() {
      EntityIndexBinding indexBindingForEntity = searchFactoryImplementor.getIndexBinding(
          entityClass
      );
      return indexBindingForEntity != null ?
          (EntityIndexingInterceptor<? super T>) indexBindingForEntity.getEntityIndexingInterceptor() :
          null;
    }
View Full Code Here

   }

   @Test(dependsOnMethods="simpleIndexTest") //depends as otherwise the Person index is not initialized yet
   public void testPropertiesWhereRead() {
      SearchFactoryIntegrator searchFactory = TestQueryHelperFactory.extractSearchFactory(cache);
      EntityIndexBinding indexBindingForEntity = searchFactory.getIndexBinding(Person.class);
      IndexManager[] managers = indexBindingForEntity.getIndexManagers();
      assertEquals(1, managers.length);
      assertNotNull(managers[0]);
      assertTrue(managers[0] instanceof DirectoryBasedIndexManager);
      DirectoryBasedIndexManager dbim = (DirectoryBasedIndexManager) managers[0];
      assertTrue(dbim.getDirectoryProvider() instanceof RAMDirectoryProvider);
View Full Code Here

    public final Set<Class<?>> mappedSubclasses;
    private final Criteria criteria;

    RootEntityMetadata(Class<?> rootEntity, SearchFactoryImplementor searchFactoryImplementor) {
      this.rootEntity = rootEntity;
      EntityIndexBinding provider = searchFactoryImplementor.getIndexBinding( rootEntity );
      if ( provider == null ) {
        throw new AssertionFailure("Provider not found for class: " + rootEntity);
      }
      this.mappedSubclasses = provider.getDocumentBuilder().getMappedSubclasses();
      this.criteria = null; //default
    }
View Full Code Here

   *
   * @return the {@code DocumentBuilder} for the specified object
   */
  protected AbstractDocumentBuilder getDocumentBuilder(final Object instance) {
    Class<?> clazz = instance.getClass();
    EntityIndexBinding entityIndexBinding = searchFactoryImplementor.getIndexBinding( clazz );
    if ( entityIndexBinding != null ) {
      return entityIndexBinding.getDocumentBuilder();
    }
    else {
      return searchFactoryImplementor.getDocumentBuilderContainedEntity( clazz );
    }
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void index(Object entity, Session session, InstanceInitializer sessionInitializer, ConversionContext conversionContext)
      throws InterruptedException {
    Serializable id = session.getIdentifier( entity );
    Class<?> clazz = HibernateHelper.getClass( entity );
    EntityIndexBinding entityIndexBinding = entityIndexBindings.get( clazz );
    if ( entityIndexBinding == null ) {
      // it might be possible to receive not-indexes subclasses of the currently indexed type;
      // being not-indexed, we skip them.
      // FIXME for improved performance: avoid loading them in an early phase.
      return;
    }

    EntityIndexingInterceptor interceptor = entityIndexBinding.getEntityIndexingInterceptor();
    if ( interceptor != null ) {
      IndexingOverride onAdd = interceptor.onAdd( entity );
      switch ( onAdd ) {
        case REMOVE:
        case SKIP:
          return;
      }
      //default: continue indexing this instance
    }

    DocumentBuilderIndexedEntity docBuilder = entityIndexBinding.getDocumentBuilder();
    TwoWayFieldBridge idBridge = docBuilder.getIdBridge();
    conversionContext.pushProperty( docBuilder.getIdKeywordName() );
    String idInString = null;
    try {
      idInString = conversionContext
View Full Code Here

TOP

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

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.