Package org.hibernate.search.engine

Examples of org.hibernate.search.engine.DocumentBuilderIndexedEntity


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

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


   */
  @SuppressWarnings( "unchecked" )
  public void testAddWorkGetReplacedByDeleteWork() throws Exception {
    FullTextSession fullTextSession = org.hibernate.search.Search.getFullTextSession( openSession() );
    SearchFactoryImpl searchFactory = ( SearchFactoryImpl ) fullTextSession.getSearchFactory();
    DocumentBuilderIndexedEntity builder = searchFactory.getDocumentBuilderIndexedEntity( SpecialPerson.class );

    // create test entity
    SpecialPerson person = new SpecialPerson();
    person.setName( "Joe Smith" );

    EmailAddress emailAddress = new EmailAddress();
    emailAddress.setAddress( "foo@foobar.com" );
    emailAddress.setDefaultAddress(true);

    person.addEmailAddress( emailAddress );

    List<LuceneWork> queue = new ArrayList<LuceneWork>();

    builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.ADD, queue, searchFactory );

    assertEquals("There should only be one job in the queue", 1, queue.size());
    assertTrue("Wrong job type", queue.get(0) instanceof AddLuceneWork );

    builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.DELETE, queue, searchFactory );

    assertEquals("There should only be one job in the queue", 1, queue.size());
    assertTrue("Wrong job type. Add job should have been replaced by delete.", queue.get(0) instanceof DeleteLuceneWork );

    fullTextSession.close();
View Full Code Here

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

      for ( Class clazz : involvedClasses ) {
        DocumentBuilderIndexedEntity builder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( builder == null ) {
          throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        populateDirectories( targetedDirectories, builder );
      }
      this.classesAndSubclasses = involvedClasses;
View Full Code Here

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

      for ( Class clazz : involvedClasses ) {
        DocumentBuilderIndexedEntity builder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( builder == null ) {
          throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        populateDirectories( targetedDirectories, builder );
      }
      this.classesAndSubclasses = involvedClasses;
View Full Code Here

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

      for ( Class clazz : involvedClasses ) {
        DocumentBuilderIndexedEntity builder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( builder == null ) {
          throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy()
            .getDirectoryProvidersForAllShards();
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        populateDirectories( directories, directoryProviders );
      }
      this.classesAndSubclasses = involvedClasses;
View Full Code Here

  public IndexInteractionType getIndexInteractionType() {
    return IndexInteractionType.NEEDS_INDEXWRITER;
  }

  public void performWork(LuceneWork work, IndexWriter writer) {
    @SuppressWarnings("unchecked")
    DocumentBuilderIndexedEntity documentBuilder = workspace.getDocumentBuilder( work.getEntityClass() );
    Map<String, String> fieldToAnalyzerMap = ( ( AddLuceneWork ) work ).getFieldToAnalyzerMap();
    ScopedAnalyzer analyzer = ( ScopedAnalyzer ) documentBuilder.getAnalyzer();
    analyzer = updateAnalyzerMappings( analyzer, fieldToAnalyzerMap, workspace );
    Similarity similarity = documentBuilder.getSimilarity();
    if ( log.isTraceEnabled() ) {
      log.trace(
          "add to Lucene index: {}#{}:{}",
          new Object[] { work.getEntityClass(), work.getId(), work.getDocument() }
      );
View Full Code Here

   */
  @SuppressWarnings( "unchecked" )
  public void testAddWorkGetReplacedByDeleteWork() throws Exception {
    FullTextSession fullTextSession = org.hibernate.search.Search.getFullTextSession( openSession() );
    SearchFactoryImpl searchFactory = ( SearchFactoryImpl ) fullTextSession.getSearchFactory();
    DocumentBuilderIndexedEntity builder = searchFactory.getDocumentBuilderIndexedEntity( SpecialPerson.class );

    // create test entity
    SpecialPerson person = new SpecialPerson();
    person.setName( "Joe Smith" );

    EmailAddress emailAddress = new EmailAddress();
    emailAddress.setAddress( "foo@foobar.com" );
    emailAddress.setDefaultAddress(true);

    person.addEmailAddress( emailAddress );

    List<LuceneWork> queue = new ArrayList<LuceneWork>();

    builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.ADD, queue, searchFactory );

    assertEquals("There should only be one job in the queue", 1, queue.size());
    assertTrue("Wrong job type", queue.get(0) instanceof AddLuceneWork );

    builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.DELETE, queue, searchFactory );

    assertEquals("There should only be one job in the queue", 1, queue.size());
    assertTrue("Wrong job type. Add job should have been replaced by delete.", queue.get(0) instanceof DeleteLuceneWork );

    fullTextSession.close();
View Full Code Here

        DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders(
            mappedXClass, cfg, this, reflectionManager
        );
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderIndexedEntity<?> documentBuilder = new DocumentBuilderIndexedEntity(
            mappedXClass, context, providers.getProviders(), providers.getSelectionStrategy(),
            reflectionManager
        );

        indexHierarchy.addIndexedClass( mappedClass );
        documentBuildersIndexedEntities.put( mappedClass, documentBuilder );
      }
      else {
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderContainedEntity<?> documentBuilder = new DocumentBuilderContainedEntity(
            mappedXClass, context, reflectionManager
        );
        //TODO enhance that, I don't like to expose EntityState
        if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
          documentBuildersContainedEntities.put( mappedClass, documentBuilder );
        }
      }
      bindFilterDefs( mappedXClass );
      //TODO should analyzer def for classes at tyher sqme level???
View Full Code Here

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

         for (Class clazz : involvedClasses) {
            DocumentBuilderIndexedEntity builder = builders.get(clazz);
            if (builder == null) {
               throw new HibernateException("Not a mapped entity (don't forget to add @Indexed): " + clazz);
            }
            if (builder.getIdKeywordName() != null) {
               idFieldNames.add(builder.getIdKeywordName());
               allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
            }
            final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy()
                  .getDirectoryProvidersForAllShards();
            searcherSimilarity = checkSimilarity(searcherSimilarity, builder);
            populateDirectories(directories, directoryProviders);
         }
         this.classesAndSubclasses = involvedClasses;
View Full Code Here

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

         for (Class clazz : involvedClasses) {
            DocumentBuilderIndexedEntity builder = builders.get(clazz);
            if (builder == null) {
               throw new HibernateException("Not a mapped entity (don't forget to add @Indexed): " + clazz);
            }
            if (builder.getIdKeywordName() != null) {
               idFieldNames.add(builder.getIdKeywordName());
               allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
            }
            final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy()
                  .getDirectoryProvidersForAllShards();
            searcherSimilarity = checkSimilarity(searcherSimilarity, builder);
            populateDirectories(directories, directoryProviders);
         }
         this.classesAndSubclasses = involvedClasses;
View Full Code Here

TOP

Related Classes of org.hibernate.search.engine.DocumentBuilderIndexedEntity

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.