Package org.hibernate.search.engine.spi

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


    }
    else {
      Set<Class<?>> involvedClasses = new HashSet<Class<?>>( indexedTargetedEntities.size() );
      involvedClasses.addAll( indexedTargetedEntities );
      for ( Class<?> clazz : indexedTargetedEntities ) {
        EntityIndexBinder indexBinder = builders.get( clazz );
        if ( indexBinder != null ) {
          DocumentBuilderIndexedEntity<?> builder = indexBinder.getDocumentBuilder();
          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


    Map<Class<?>, EntityIndexBinder> builders = searchFactoryImplementor.getIndexBindingForEntity();
    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 ) {
      EntityIndexBinder 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

      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

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

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

    RootEntityMetadata(Class<?> rootEntity, SearchFactoryImplementor searchFactoryImplementor) {
      this.rootEntity = rootEntity;
      EntityIndexBinder provider = searchFactoryImplementor.getIndexBindingForEntity( 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

  @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 );
    EntityIndexBinder entityIndexBinding = entityIndexBinders.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

  }

  private void index(Object entity, Session session, InstanceInitializer sessionInitializer,
      ConversionContext conversionContext) throws InterruptedException {
    Class<?> clazz = HibernateHelper.getClass( entity );
    EntityIndexBinder entityIndexBinding = entityIndexBinders.get( clazz );
    // 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.
    if ( entityIndexBinding != null ) {
      EntityIndexingInterceptor interceptor = entityIndexBinding.getEntityIndexingInterceptor();
      if ( isNotSkippable( interceptor, entity ) ) {
        Serializable id = session.getIdentifier( entity );
        AddLuceneWork addWork = createAddLuceneWork( entity, sessionInitializer, conversionContext, id, clazz,
            entityIndexBinding );
        backend.enqueueAsyncWork( addWork );
View Full Code Here

  @SuppressWarnings("unchecked")
  private void index( Object entity, Session session, InstanceInitializer sessionInitializer ) throws InterruptedException {
    Serializable id = session.getIdentifier( entity );
    Class<?> clazz = HibernateHelper.getClass( entity );
    EntityIndexBinder entityIndexBinding = entityIndexBinders.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;
    }
    DocumentBuilderIndexedEntity docBuilder = entityIndexBinding.getDocumentBuilder();
    TwoWayFieldBridge idBridge = docBuilder.getIdBridge();
    ContextualException2WayBridge contextualBridge = new ContextualException2WayBridge()
        .setClass(clazz)
        .setFieldName(docBuilder.getIdKeywordName())
        .setFieldBridge(idBridge);
View Full Code Here

    }
    return luceneDocument;
  }

  private String objectIdInString(Class<?> entityClass, Serializable id, ConversionContext conversionContext) {
    EntityIndexBinder indexBindingForEntity = searchFactory.getIndexBindingForEntity( entityClass );
    if ( indexBindingForEntity == null ) {
      throw new SearchException( "Unable to find entity type metadata while deserializing: " + entityClass );
    }
    DocumentBuilderIndexedEntity<?> documentBuilder = indexBindingForEntity.getDocumentBuilder();
    return documentBuilder.objectToString( documentBuilder.getIdKeywordName(), id, conversionContext );
  }
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

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.