Package org.hibernate.search.bridge

Examples of org.hibernate.search.bridge.FieldBridge


        if ( idKeywordName != null && explicitDocumentId ) {
          throw new AssertionFailure( "Two document id assigned: "
              + idKeywordName + " and " + attributeName );
        }
        idKeywordName = prefix + attributeName;
        FieldBridge fieldBridge = BridgeFactory.guessType( null, member, reflectionManager );
        if ( fieldBridge instanceof TwoWayFieldBridge ) {
          idBridge = (TwoWayFieldBridge) fieldBridge;
        }
        else {
          throw new SearchException(
View Full Code Here


  private void buildDocumentFields(Object instance, Document doc, PropertiesMetadata propertiesMetadata) {
    if ( instance == null ) return;
    //needed for field access: I cannot work in the proxied version
    Object unproxiedInstance = unproxy( instance );
    for (int i = 0; i < propertiesMetadata.classBridges.size(); i++) {
      FieldBridge fb = propertiesMetadata.classBridges.get( i );
      fb.set( propertiesMetadata.classNames.get( i ), unproxiedInstance,
          doc, propertiesMetadata.getClassLuceneOptions( i ) );
    }
    for (int i = 0; i < propertiesMetadata.fieldNames.size(); i++) {
      XMember member = propertiesMetadata.fieldGetters.get( i );
      Object value = getMemberValue( unproxiedInstance, member );
View Full Code Here

        if ( idAnnotation instanceof DocumentId ) {
          explicitDocumentId = true;
        }
        idKeywordName = prefix + attributeName;

        FieldBridge fieldBridge = BridgeFactory.guessType( null, numericFieldAnn, member, reflectionManager );
        if ( fieldBridge instanceof TwoWayFieldBridge ) {
          idBridge = (TwoWayFieldBridge) fieldBridge;
        }
        else {
          throw new SearchException(
View Full Code Here

        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 = 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 );
          }
        }
      }

      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

    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

    propertiesMetadata.classNames.add( fieldName );
    propertiesMetadata.classStores.add( ann.store() );
    Field.Index index = AnnotationProcessingHelper.getIndex( Index.YES, Analyze.NO, Norms.NO );
    propertiesMetadata.classIndexes.add( index );
    propertiesMetadata.classTermVectors.add( AnnotationProcessingHelper.getTermVector( TermVector.NO ) );
    final FieldBridge spatialBridge;
    if ( reflectionManager.toXClass( Coordinates.class ).isAssignableFrom( clazz ) ) {
      spatialBridge = BridgeFactory.buildSpatialBridge( ann, clazz, null, null );
    }
    else {
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.