Package org.hibernate.annotations.common.reflection

Examples of org.hibernate.annotations.common.reflection.XMember


    }
  }

  private void processContainedIn(Object instance, List<LuceneWork> queue, PropertiesMetadata metadata, SearchFactoryImplementor searchFactoryImplementor) {
    for (int i = 0; i < metadata.containedInGetters.size(); i++) {
      XMember member = metadata.containedInGetters.get( i );
      Object value = getMemberValue( instance, member );
      if ( value == null ) continue;

      if ( member.isArray() ) {
        for (Object arrayValue : (Object[]) value) {
          //highly inneficient but safe wrt the actual targeted class
          Class<?> valueClass = Hibernate.getClass( arrayValue );
          DocumentBuilder<?> builder = searchFactoryImplementor.getDocumentBuilder( valueClass );
          if ( builder == null ) continue;
          processContainedInValue( arrayValue, queue, valueClass, builder, searchFactoryImplementor );
        }
      }
      else if ( member.isCollection() ) {
        Collection collection;
        if ( Map.class.equals( member.getCollectionClass() ) ) {
          //hum
          collection = ( (Map) value ).values();
        }
        else {
          collection = (Collection) value;
View Full Code Here


      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 );
      propertiesMetadata.fieldBridges.get( i ).set(
          propertiesMetadata.fieldNames.get( i ), value, doc,
          propertiesMetadata.getFieldLuceneOptions( i ) );
    }
    for (int i = 0; i < propertiesMetadata.embeddedGetters.size(); i++) {
      XMember member = propertiesMetadata.embeddedGetters.get( i );
      Object value = getMemberValue( unproxiedInstance, member );
      //TODO handle boost at embedded level: already stored in propertiesMedatada.boost

      if ( value == null ) continue;
      PropertiesMetadata embeddedMetadata = propertiesMetadata.embeddedPropertiesMetadata.get( i );
View Full Code Here

        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 {
        conversionContext.popProperty();
      }
    }

    // allow analyzer override for the fields added by the class and field bridges
    allowAnalyzerDiscriminatorOverride(
        doc, propertiesMetadata, fieldToAnalyzerMap, processedFieldNames, unproxiedInstance
    );

    // recursively process embedded objects
    for ( int i = 0; i < propertiesMetadata.embeddedGetters.size(); i++ ) {
      XMember member = propertiesMetadata.embeddedGetters.get( i );
      conversionContext.pushProperty( propertiesMetadata.embeddedFieldNames.get( i ) );
      try {
        Object value = ReflectionHelper.getMemberValue( unproxiedInstance, member );
        //TODO handle boost at embedded level: already stored in propertiesMedatada.boost
View Full Code Here

   * @param workplan the current work plan
   * @param currentDepth the current {@link org.hibernate.search.engine.spi.DepthValidator} object used to check the graph traversal
   */
  public void appendContainedInWorkForInstance(Object instance, WorkPlan workplan, DepthValidator currentDepth) {
    for ( int i = 0; i < metadata.containedInGetters.size(); i++ ) {
      XMember member = metadata.containedInGetters.get( i );
      Object unproxiedInstance = instanceInitializer.unproxy( instance );

      DepthValidator depth = updateDepth( unproxiedInstance, member, currentDepth );
      depth.increaseDepth();
     
      if (depth.isMaxDepthReached())
        return;

      Object value = ReflectionHelper.getMemberValue( unproxiedInstance, member );

      if ( value == null ) {
        continue;
      }

      if ( member.isArray() ) {
        @SuppressWarnings("unchecked")
        T[] array = (T[]) value;
        for ( T arrayValue : array ) {
          processSingleContainedInInstance( workplan, arrayValue, depth );
        }
      }
      else if ( member.isCollection() ) {
        Collection<T> collection = null;
        try {
          collection = getActualCollection( member, value );
          collection.size(); //load it
        }
View Full Code Here

    final int fieldNbr = fields.length;
    Object[] result = new Object[fieldNbr];
    ContextualException2WayBridge contextualBridge = new ContextualException2WayBridge();
    contextualBridge.setClass( clazz );
    if ( builderIndexedEntity.getIdKeywordName() != null ) {
      final XMember member = builderIndexedEntity.getIdGetter();
      if ( member != null ) {
        contextualBridge.pushMethod( member.getName() );
      }
      populateResult(
          builderIndexedEntity.getIdKeywordName(),
          builderIndexedEntity.getIdBridge(),
          Store.YES,
View Full Code Here

          );
    }

    // process the indexed fields
    for ( int i = 0; i < propertiesMetadata.fieldNames.size(); i++ ) {
      XMember member = propertiesMetadata.fieldGetters.get( i );
      Object value = ReflectionHelper.getMemberValue( unproxiedInstance, member );

      final FieldBridge fieldBridge = propertiesMetadata.fieldBridges.get( i );
      final String fieldName = propertiesMetadata.fieldNames.get( i );
      contextualBridge
          .setFieldBridge( fieldBridge )
          .pushMethod( member.getName() )
          .setFieldName( fieldName )
          .set(
              fieldName, value, doc,
              propertiesMetadata.getFieldLuceneOptions( i, value )
          );
      contextualBridge.popMethod();
    }

    // allow analyzer override for the fields added by the class and field bridges
    allowAnalyzerDiscriminatorOverride(
        doc, propertiesMetadata, fieldToAnalyzerMap, processedFieldNames, unproxiedInstance
    );

    // recursively process embedded objects
    for ( int i = 0; i < propertiesMetadata.embeddedGetters.size(); i++ ) {
      XMember member = propertiesMetadata.embeddedGetters.get( i );
      contextualBridge.pushMethod( member.getName() );
      Object value = ReflectionHelper.getMemberValue( unproxiedInstance, member );
      //TODO handle boost at embedded level: already stored in propertiesMedatada.boost

      if ( value == null ) {
        continue;
View Full Code Here

  private String buildAnnotationDefinitionPoint(XAnnotatedElement annotatedElement) {
    if ( annotatedElement instanceof XClass ) {
      return ( (XClass) annotatedElement ).getName();
    }
    else if ( annotatedElement instanceof XMember ) {
      XMember member = (XMember) annotatedElement;
      return member.getType().getName() + '.' + member.getName();
    }
    else if ( annotatedElement instanceof XPackage ) {
      return ( (XPackage) annotatedElement ).getName();
    }
    else {
View Full Code Here

  /**
   * If we have a work instance we have to check whether the instance to be indexed is contained in any other indexed entities.
   **/
  public void appendContainedInWorkForInstance(Object instance, WorkPlan workplan) {
    for ( int i = 0; i < metadata.containedInGetters.size(); i++ ) {
      XMember member = metadata.containedInGetters.get( i );
      Object value = ReflectionHelper.getMemberValue( instance, member );

      if ( value == null ) {
        continue;
      }

      if ( member.isArray() ) {
        @SuppressWarnings("unchecked")
        T[] array = (T[]) value;
        for ( T arrayValue : array ) {
          processSingleContainedInInstance( workplan, arrayValue );
        }
      }
      else if ( member.isCollection() ) {
        Collection<T> collection = null;
        try {
          collection = getActualCollection( member, value );
          collection.size(); //load it
        }
View Full Code Here

    }
  }

  private void processContainedIn(Object instance, List<LuceneWork> queue, PropertiesMetadata metadata, SearchFactoryImplementor searchFactoryImplementor) {
    for (int i = 0; i < metadata.containedInGetters.size(); i++) {
      XMember member = metadata.containedInGetters.get( i );
      Object value = getMemberValue( instance, member );
      if ( value == null ) continue;

      if ( member.isArray() ) {
        for (Object arrayValue : (Object[]) value) {
          //highly inneficient but safe wrt the actual targeted class
          Class<?> valueClass = Hibernate.getClass( arrayValue );
          DocumentBuilder<?> builder = searchFactoryImplementor.getDocumentBuilder( valueClass );
          if ( builder == null ) continue;
          processContainedInValue( arrayValue, queue, valueClass, builder, searchFactoryImplementor );
        }
      }
      else if ( member.isCollection() ) {
        Collection collection;
        if ( Map.class.equals( member.getCollectionClass() ) ) {
          //hum
          collection = ( (Map) value ).values();
        }
        else {
          collection = (Collection) value;
View Full Code Here

      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 );
      propertiesMetadata.fieldBridges.get( i ).set(
          propertiesMetadata.fieldNames.get( i ), value, doc,
          propertiesMetadata.getFieldLuceneOptions( i ) );
    }
    for (int i = 0; i < propertiesMetadata.embeddedGetters.size(); i++) {
      XMember member = propertiesMetadata.embeddedGetters.get( i );
      Object value = getMemberValue( unproxiedInstance, member );
      //TODO handle boost at embedded level: already stored in propertiesMedatada.boost

      if ( value == null ) continue;
      PropertiesMetadata embeddedMetadata = propertiesMetadata.embeddedPropertiesMetadata.get( i );
View Full Code Here

TOP

Related Classes of org.hibernate.annotations.common.reflection.XMember

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.