@Override public IndexingOverride onAdd(TermConcept theEntity) { if (theEntity.getIndexStatus() == null) { return IndexingOverride.SKIP; } return IndexingOverride.APPLY_DEFAULT; }
@Override public IndexingOverride onAdd(ResourceTable entity) { if (entity.getDeleted() == null) { if (entity.getIndexStatus() != null) { return IndexingOverride.APPLY_DEFAULT; } } return IndexingOverride.SKIP; }
@Override public IndexingOverride onUpdate(ResourceTable entity) { if (entity.getIndexStatus() == null) { return IndexingOverride.SKIP; } if (entity.getDeleted() == null) { return IndexingOverride.UPDATE; } return IndexingOverride.REMOVE; }
/** * This method in automatically invoked when a new App is first persisted by core Hibernate. When the * App is active, the default Hibernate Search operation (i.e. add to the Lucene index) is used. * When the App is inactive, Lucene indexing is skipped. */ public IndexingOverride onAdd(App entity) { if(entity.isActive()) { return IndexingOverride.APPLY_DEFAULT; } return IndexingOverride.SKIP; }
/** * This method is automatically invoked when an existing App is updated by core Hibernate. If the current * state of the App is active, then this method calls for an update in the Lucene index. If the App is * now inactive, then this method calls for it to be removed from the Lucene index. */ public IndexingOverride onUpdate(App entity) { if(entity.isActive()) { return IndexingOverride.UPDATE; } else { return IndexingOverride.REMOVE; } }
@Override public IndexingOverride onDelete(SdcctEntity entity) { LOGGER.trace(buildMessage(entity, EntityIndexingEventType.DELETE)); return IndexingOverride.APPLY_DEFAULT; }
@Override public IndexingOverride onCollectionUpdate(SdcctEntity entity) { LOGGER.trace(buildMessage(entity, EntityIndexingEventType.COLLECTION_UPDATE)); return IndexingOverride.APPLY_DEFAULT; }
@Override public IndexingOverride onUpdate(SdcctEntity entity) { LOGGER.trace(buildMessage(entity, EntityIndexingEventType.UPDATE)); return IndexingOverride.APPLY_DEFAULT; }
@Override public IndexingOverride onAdd(SdcctEntity entity) { LOGGER.trace(buildMessage(entity, EntityIndexingEventType.ADD)); return IndexingOverride.APPLY_DEFAULT; }
@Override public IndexingOverride onCollectionUpdate(TermConcept theEntity) { return IndexingOverride.APPLY_DEFAULT; }
@Override public IndexingOverride onDelete(TermConcept theEntity) { return IndexingOverride.APPLY_DEFAULT; }
@Override public IndexingOverride onUpdate(TermConcept theEntity) { return onAdd(theEntity); }
@Override public IndexingOverride onDelete(ResourceTable entity) { return IndexingOverride.APPLY_DEFAULT; }
@Override public IndexingOverride onCollectionUpdate(ResourceTable entity) { return IndexingOverride.APPLY_DEFAULT; }
@SuppressWarnings("unchecked") private void index(Object entity, InstanceInitializer sessionInitializer, ConversionContext conversionContext) throws InterruptedException { Serializable id = (Serializable) this.peristenceUnitUtil.getIdentifier( entity ); if ( entityIndexBinding == null ) { // it might be possible to receive not-indexes subclasses of the currently indexed columnTypes; // being not-indexed, we skip them. // FIXME for improved performance: avoid loading them in an early phase. return; } @SuppressWarnings("rawtypes") EntityIndexingInterceptor interceptor = this.entityIndexBinding.getEntityIndexingInterceptor(); if ( interceptor != null ) { IndexingOverride onAdd = interceptor.onAdd( entity ); switch ( onAdd ) { case REMOVE: case SKIP: return; default: break; } // default: continue indexing this instance } DocumentBuilderIndexedEntity docBuilder = this.entityIndexBinding.getDocumentBuilder(); TwoWayFieldBridge idBridge = docBuilder.getIdBridge(); conversionContext.pushProperty( docBuilder.getIdKeywordName() ); String idInString = null; try { idInString = conversionContext.setClass( this.entityClass ) .twoWayConversionContext( idBridge ) .objectToString( id ); } finally { conversionContext.popProperty(); } // depending on the complexity of the object graph going to be indexed it's possible // that we hit the database several times during work construction. AddLuceneWork addWork = docBuilder.createAddWork( null, this.entityClass, entity, id, idInString, sessionInitializer, conversionContext ); this.batchBackend.enqueueAsyncWork( addWork ); }
/** * This method is automatically invoked when a new App is deleted by core Hibernate. Regardless of whether * the App is active, this method tells Hibernate Search to use the default action (i.e. remove it from * the Lucene index if present). */ public IndexingOverride onDelete(App entity) { return IndexingOverride.APPLY_DEFAULT; }
/** * This method is automatically invoked when an existing App is part of a larger collection that is being * updated by core Hibernate. This doesn't matter to the purpose of this interceptor, so this method simply * uses the regular "onUpdate() above". */ public IndexingOverride onCollectionUpdate(App entity) { return onUpdate(entity); }