Package org.hibernate.search.bridge

Examples of org.hibernate.search.bridge.FieldBridge


        Store.YES,
        Field.Index.NOT_ANALYZED_NO_NORMS,
        Field.TermVector.NO,
        idBoost
    );
    final FieldBridge contextualizedBridge = conversionContext.oneWayConversionContext( idBridge );
    conversionContext.setClass( entityType );
    conversionContext.pushProperty( idKeywordName );

    try {
      contextualizedBridge.set( idKeywordName, id, doc, luceneOptions );
    }
    finally {
      conversionContext.popProperty();
    }
View Full Code Here


    // needed for field access: I cannot work in the proxied version
    Object unproxiedInstance = unproxy( instance, objectInitializer );

    // process the class bridges
    for ( int i = 0; i < propertiesMetadata.classBridges.size(); i++ ) {
      FieldBridge fb = propertiesMetadata.classBridges.get( i );
      final String fieldName = propertiesMetadata.classNames.get( i );
      final FieldBridge oneWayConversionContext = conversionContext.oneWayConversionContext( fb );
      conversionContext.pushProperty( fieldName );
      try {
        oneWayConversionContext.set(
            fieldName, unproxiedInstance,
            doc, propertiesMetadata.getClassLuceneOptions( i )
        );
      }
      finally {
        conversionContext.popProperty();
      }
    }

    // process the indexed fields
    XMember previousMember = null;
    Object currentFieldValue = null;
    for ( int i = 0; i < propertiesMetadata.fieldNames.size(); i++ ) {
      XMember member = propertiesMetadata.fieldGetters.get( i );
      if ( previousMember != member ) {
        currentFieldValue = ReflectionHelper.getMemberValue( unproxiedInstance, member );
        previousMember = member;
        if ( member.isCollection() ) {
          if ( currentFieldValue instanceof Collection ) {
            objectInitializer.initializeCollection( (Collection) currentFieldValue );
          }
          else if ( currentFieldValue instanceof Map ) {
            objectInitializer.initializeMap( (Map) currentFieldValue );
          }
        }
      }

      final FieldBridge fieldBridge = propertiesMetadata.fieldBridges.get( i );
      final String fieldName = propertiesMetadata.fieldNames.get( i );
      final FieldBridge oneWayConversionContext = conversionContext.oneWayConversionContext( fieldBridge );
      conversionContext.pushProperty( propertiesMetadata.fieldGetterNames.get( i ) );
      try {
        oneWayConversionContext.set(
            fieldName, currentFieldValue, doc,
            propertiesMetadata.getFieldLuceneOptions( i, currentFieldValue )
        );
      }
      finally {
View Full Code Here

  private void processEmbeddedNullValue(Document doc, PropertiesMetadata propertiesMetadata, ConversionContext conversionContext, int i, XMember member) {
    final String nullMarker = propertiesMetadata.embeddedNullTokens.get( i );
    if ( nullMarker != null ) {
      String fieldName = propertiesMetadata.embeddedNullFields.get( i );
      FieldBridge fieldBridge = propertiesMetadata.embeddedNullFieldBridges.get( i );
      final FieldBridge contextualizedBridge = conversionContext.oneWayConversionContext( fieldBridge );
      conversionContext.pushProperty( fieldName );
      try {
        contextualizedBridge.set( fieldName, null, doc, NULL_EMBEDDED_MARKER_OPTIONS );
      }
      finally {
        conversionContext.popProperty();
      }
    }
View Full Code Here

    }
    if ( fieldName.equals( idKeywordName ) ) {
      return objectToString( idBridge, idKeywordName, value, conversionContext );
    }
    else {
      FieldBridge bridge = getBridge( getMetadata(), fieldName );
      if ( bridge != null ) {
        final Class<? extends FieldBridge> bridgeClass = bridge.getClass();
        if ( TwoWayFieldBridge.class.isAssignableFrom( bridgeClass ) ) {
          return objectToString( (TwoWayFieldBridge) bridge, fieldName, value, conversionContext );
        }
        else if ( StringBridge.class.isAssignableFrom( bridgeClass ) ) {
          return objectToString( (StringBridge) bridge, fieldName, value, conversionContext );
View Full Code Here

    return getBridge( getMetadata(), fieldName );
  }

  private FieldBridge getBridge(PropertiesMetadata metadata, String fieldName) {
    //process base fields
    FieldBridge fieldBridge = getBridge( metadata.fieldNames, metadata.fieldBridges, fieldName );
    if ( fieldBridge != null ) {
      return fieldBridge;
    }

    //process fields of embedded
View Full Code Here

    else if ( indexNullAs.equals( org.hibernate.search.annotations.Field.DEFAULT_NULL_TOKEN ) ) {
      indexNullAs = context.getDefaultNullToken();
    }
    nullToken = indexNullAs;

    FieldBridge bridge = BridgeFactory.guessType( fieldAnn, numericFieldAnn, member, reflectionManager );
    if ( indexNullAs != null && bridge instanceof TwoWayFieldBridge ) {
      bridge = new NullEncodingTwoWayFieldBridge( (TwoWayFieldBridge) bridge, indexNullAs );
    }
    fieldBridge = bridge;
View Full Code Here

    if ( PropertiesMetadata.Container.OBJECT == container ) {
      return new NullEncodingFieldBridge( NULL_EMBEDDED_STRING_BRIDGE, indexNullAs );
    }
    else {
      NumericField numericField = member.getAnnotation( NumericField.class );
      FieldBridge fieldBridge = BridgeFactory.guessType( null, numericField, member, reflectionManager );
      if ( fieldBridge instanceof StringBridge ) {
        fieldBridge = new NullEncodingFieldBridge( (StringBridge) fieldBridge, indexNullAs );
      }
      return fieldBridge;
    }
View Full Code Here

  }

  private PropertyMetadata providedIdMetadata(XClass clazz, ConfigContext context, ReflectionManager reflectionManager) {
    PropertyMetadata propertyMetadata = null;

    FieldBridge providedIdFieldBridge = null;
    String providedIdFieldName = null;
    ProvidedId provided = findProvidedId( clazz, reflectionManager );
    if ( provided != null ) {
      providedIdFieldBridge = BridgeFactory.extractTwoWayType( provided.bridge(), clazz, reflectionManager );
      providedIdFieldName = provided.name();
View Full Code Here

    // now add the entity id to the document
    DocumentFieldMetadata idFieldMetaData = idPropertyMetadata.getFieldMetadata( idFieldName );

    LuceneOptions luceneOptions = new LuceneOptionsImpl( idFieldMetaData );
    final FieldBridge contextualizedBridge = conversionContext.oneWayConversionContext( getIdBridge() );
    conversionContext.setClass( entityType );
    conversionContext.pushProperty( idFieldMetaData.getName() );

    try {
      contextualizedBridge.set( idFieldMetaData.getName(), id, doc, luceneOptions );
    }
    finally {
      conversionContext.popProperty();
    }
View Full Code Here

    // needed for field access: I cannot work in the proxied version
    Object unproxiedInstance = unproxy( instance, objectInitializer );

    // process the class bridges
    for ( DocumentFieldMetadata fieldMetadata : typeMetadata.getClassBridgeMetadata() ) {
      FieldBridge fieldBridge = fieldMetadata.getFieldBridge();
      final String fieldName = fieldMetadata.getName();
      final FieldBridge oneWayConversionContext = conversionContext.oneWayConversionContext( fieldBridge );
      conversionContext.pushProperty( fieldName );
      try {
        oneWayConversionContext.set(
            fieldName,
            unproxiedInstance,
            doc,
            typeMetadata.getClassLuceneOptions( fieldMetadata )
        );
      }
      finally {
        conversionContext.popProperty();
      }
    }

    // process the indexed fields
    XMember previousMember = null;
    Object currentFieldValue = null;
    for ( PropertyMetadata propertyMetadata : typeMetadata.getAllPropertyMetadata() ) {
      XMember member = propertyMetadata.getPropertyAccessor();
      if ( previousMember != member ) {
        currentFieldValue = unproxy(
            ReflectionHelper.getMemberValue( unproxiedInstance, member ),
            objectInitializer
        );
        previousMember = member;
        if ( member.isCollection() ) {
          if ( currentFieldValue instanceof Collection ) {
            objectInitializer.initializeCollection( (Collection) currentFieldValue );
          }
          else if ( currentFieldValue instanceof Map ) {
            objectInitializer.initializeMap( (Map) currentFieldValue );
          }
        }
      }

      try {
        conversionContext.pushProperty( propertyMetadata.getPropertyAccessorName() );

        for ( DocumentFieldMetadata fieldMetadata : propertyMetadata.getFieldMetadata() ) {
          final FieldBridge fieldBridge = fieldMetadata.getFieldBridge();
          final String fieldName = fieldMetadata.getName();
          final FieldBridge oneWayConversionContext = conversionContext.oneWayConversionContext( fieldBridge );

          oneWayConversionContext.set(
              fieldName,
              currentFieldValue,
              doc,
              typeMetadata.getFieldLuceneOptions( propertyMetadata, fieldMetadata, currentFieldValue )
          );
View Full Code Here

TOP

Related Classes of org.hibernate.search.bridge.FieldBridge

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.