Package org.hibernate.search.backend.spi

Examples of org.hibernate.search.backend.spi.Work


        operation = IndexingOverride.APPLY_DEFAULT;
        break;
      default:
        throw new AssertionFailure( "Unknown work type: " + work.getType() );
    }
    Work result = work;
    Class<?> entityClass = work.getEntityClass();
    switch ( operation ) {
      case APPLY_DEFAULT:
        break;
      case SKIP:
        result = null;
        log.forceSkipIndexOperationViaInterception( entityClass, work.getType() );
        break;
      case UPDATE:
        result = new Work( work.getEntity(), work.getId(), WorkType.UPDATE );
        log.forceUpdateOnIndexOperationViaInterception( entityClass, work.getType() );
        break;
      case REMOVE:
        //This works because other Work constructors are never used from WorkType ADD, UPDATE, REMOVE, COLLECTION
        //TODO should we force isIdentifierRollback to false if the operation is not a delete?
        result = new Work( work.getEntity(), work.getId(), WorkType.DELETE, work.isIdentifierWasRolledBack() );
        log.forceRemoveOnIndexOperationViaInterception( entityClass, work.getType() );
        break;
      default:
        throw new AssertionFailure( "Unknown action type: " + operation );
    }
View Full Code Here


              case SKIP:
                log.forceSkipIndexOperationViaInterception( entityClass, WorkType.UPDATE );
                break;
              case REMOVE:
                log.forceRemoveOnIndexOperationViaInterception( entityClass, WorkType.UPDATE );
                Work work = new Work(value, extractedId, WorkType.DELETE);
                entityWork = new PerEntityWork( work );
                entityById.put( extractedId, entityWork );
                break;
              default:
                throw new AssertionFailure( "Unknown action type: " + operation );
View Full Code Here

    person.addEmailAddress( emailAddress );

    WorkQueue plannerEngine = new WorkQueue( searchFactory );

    plannerEngine.add( new Work( person, 1, WorkType.ADD ) );

    plannerEngine.prepareWorkPlan();
    List<LuceneWork> sealedQueue = plannerEngine.getSealedQueue();

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

    plannerEngine.add( new Work( person, 1, WorkType.DELETE ) );
    plannerEngine.prepareWorkPlan();
    sealedQueue = plannerEngine.getSealedQueue();

    assertEquals( "Jobs should have countered each other", 0, sealedQueue.size() );
View Full Code Here

    dvd1.title = dvdTitle;
    storeObject( dvd1, id );
  }

  private void storeObject(Object entity, Serializable id) {
    Work work = new Work( entity, id, WorkType.UPDATE, false );
    TransactionContextForTest tc = new TransactionContextForTest();
    slaveNode.getSearchFactory().getWorker().performWork( work, tc );
    tc.end();
  }
View Full Code Here

  private static void writeABook(Integer id, String bookTitle, Worker worker) {
    Book book = new Book();
    book.id = id;
    book.title = bookTitle;
    Work work = new Work( book, book.id, WorkType.ADD, false );
    TransactionContextForTest tc = new TransactionContextForTest();
    worker.performWork( work, tc );
    tc.end();
  }
View Full Code Here

  }

  private static void deleteABook(Integer id, Worker worker) {
    Book book = new Book();
    book.id = id;
    Work work = new Work( book, id, WorkType.DELETE, false );
    TransactionContextForTest tc = new TransactionContextForTest();
    worker.performWork( work, tc );
    tc.end();
  }
View Full Code Here

  private void writeABook(long id, String bookTitle) {
    Book book = new Book();
    book.id = id;
    book.title = bookTitle;
    Work work = new Work( book, book.id, WorkType.ADD, false );
    TransactionContextForTest tc = new TransactionContextForTest();
    sfHolder.getSearchFactory().getWorker().performWork( work, tc );
    tc.end();
  }
View Full Code Here

  }

  private void writeData(SearchFactoryHolder sfHolder, int numberEntities) {
    for ( int i = 0; i < numberEntities; i++ ) {
      Quote quote = new Quote( 1, i * 10 );
      Work work = new Work( quote, quote.id, WorkType.ADD, false );
      TransactionContextForTest tc = new TransactionContextForTest();
      sfHolder.getSearchFactory().getWorker().performWork( work, tc );
      tc.end();
    }
  }
View Full Code Here

    { // Store guest "Thorin Oakenshield" in the index
      Guest lastDwarf = new Guest();
      lastDwarf.id = 13l;
      lastDwarf.name = "Thorin Oakenshield";

      Work work = new Work( lastDwarf, lastDwarf.id, WorkType.ADD, false );
      TransactionContextForTest tc = new TransactionContextForTest();
      searchFactory.getWorker().performWork( work, tc );
      tc.end();
    }

    QueryBuilder guestQueryBuilder = searchFactory.buildQueryBuilder()
        .forEntity( Guest.class )
        .get();

    Query queryAllGuests = guestQueryBuilder.all().createQuery();

    List<EntityInfo> queryEntityInfos = searchFactory.createHSQuery()
      .luceneQuery( queryAllGuests )
      .targetedEntities( Arrays.asList( new Class<?>[]{ Guest.class } ) )
      .queryEntityInfos();

    Assert.assertEquals( 1, queryEntityInfos.size() );
    Assert.assertEquals( 13L, queryEntityInfos.get( 0 ).getId() );

    RecordingFilter filter = new RecordingFilter( "name" );
    List<EntityInfo> filteredQueryEntityInfos = searchFactory.createHSQuery()
        .luceneQuery( queryAllGuests )
        .targetedEntities( Arrays.asList( new Class<?>[]{ Guest.class } ) )
        .filter( filter )
        .queryEntityInfos();

    checkFilterInspectedAllSegments( filter );
    expectedTermsForFilter( filter, "thorin", "oakenshield" );
    Assert.assertEquals( 1, filteredQueryEntityInfos.size() );
    Assert.assertEquals( 13L, filteredQueryEntityInfos.get( 0 ).getId() );

    { // Store guest "Balin"
      Guest balin = new Guest();
      balin.id = 7l;
      balin.name = "Balin";

      Work work = new Work( balin, balin.id, WorkType.ADD, false );
      TransactionContextForTest tc = new TransactionContextForTest();
      searchFactory.getWorker().performWork( work, tc );
      tc.end();
    }
View Full Code Here

      Book book = new Book();
      book.title = "Less is nice";
      book.text = "When using Infinispan Query, users have to always remember to add @ProvidedId on their classes" +
          " or a nasty exception will remind them. Can't we just assume it's always annotated?";
      String isbn = "some entity-external id";
      Work work = new Work( book, isbn, WorkType.ADD, false );
      TransactionContextForTest tc = new TransactionContextForTest();
      sf.getWorker().performWork( work, tc );
      tc.end();

      QueryBuilder queryBuilder = sf.buildQueryBuilder()
View Full Code Here

TOP

Related Classes of org.hibernate.search.backend.spi.Work

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.