Java 类org.hibernate.search.bridge.FieldBridge 实例源码

项目:infinispan-avro    文件:ValueWrapperFieldBridge.java   
public static FieldBridge retrieveFieldBridge(String fieldName, Schema schema) {
   List<String> path = new ArrayList<>();
   path.add(schema.getName());
   for(String p : fieldName.split(Support.DELIMITER_REGEX))
      path.add(p);
   return retrieveFieldBridge(
         schema.getType(),
         schema,
         path.toArray(new String[]{}));
}
项目:hawkular-alerts    文件:TagsBridge.java   
@Override
public FieldBridge getElementBridge() {
    return bridge;
}
项目:Hibernate-Search-GenericJPA    文件:IndexUpdater.java   
@Override
public void delete(
        Class<?> entityClass,
        List<Class<?>> inIndexOf,
        Object id,
        EntityProvider entityProvider,
        Transaction tx) {
    for ( Class<?> indexClass : inIndexOf ) {
        RehashedTypeMetadata metadata = IndexUpdater.this.metadataForIndexRoot.get( indexClass );
        List<String> fields = metadata.getIdFieldNamesForType().get( entityClass );
        for ( String field : fields ) {
            DocumentFieldMetadata metaDataForIdField = metadata.getDocumentFieldMetadataForIdFieldName().get(
                    field
            );
            SingularTermDeletionQuery.Type idType = metadata.getSingularTermDeletionQueryTypeForIdFieldName()
                    .get( entityClass );
            Object idValueForDeletion;
            if ( idType == SingularTermDeletionQuery.Type.STRING ) {
                FieldBridge fb = metaDataForIdField.getFieldBridge();
                if ( !(fb instanceof StringBridge) ) {
                    throw new IllegalArgumentException( "no TwoWayStringBridge found for field: " + field );
                }
                idValueForDeletion = ((StringBridge) fb).objectToString( id );
            }
            else {
                idValueForDeletion = id;
            }
            if ( indexClass.equals( entityClass ) ) {
                this.searchIntegrator.getWorker().performWork(
                        new Work(
                                entityClass,
                                (Serializable) id,
                                WorkType.DELETE
                        ), tx
                );
            }
            else {
                HSQuery hsQuery = this.searchIntegrator
                        .createHSQuery()
                        .targetedEntities( Collections.singletonList( indexClass ) )
                        .luceneQuery(
                                this.searchIntegrator.buildQueryBuilder()
                                        .forEntity( indexClass )
                                        .get()
                                        .keyword()
                                        .onField( field )
                                        .matching( idValueForDeletion )
                                        .createQuery()
                        );
                int count = hsQuery.queryResultSize();
                int processed = 0;
                // this was just contained somewhere
                // so we have to update the containing entity
                while ( processed < count ) {
                    for ( EntityInfo entityInfo : hsQuery.firstResult( processed ).projection(
                            ProjectionConstants.ID
                    ).maxResults( HSQUERY_BATCH )
                            .queryEntityInfos() ) {
                        Serializable originalId = (Serializable) entityInfo.getProjection()[0];
                        Object original = entityProvider.get( indexClass, originalId );
                        if ( original != null ) {
                            this.update( original, tx );
                        }
                        else {
                            // original is not available in the
                            // database, but it will be deleted by its
                            // own delete event
                            // TODO: log this?
                        }
                    }
                    processed += HSQUERY_BATCH;
                }
            }
        }
    }
}