Package org.hibernate.annotations.common.annotationfactory

Examples of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor


      final Collection<Map<String,Object>> numericFields = property.getNumericFields();
      List<org.hibernate.search.annotations.Field> fieldAnnotations =
          new ArrayList<org.hibernate.search.annotations.Field>( fields.size() );
      List<NumericField> numericFieldAnnotations = new ArrayList<NumericField>( numericFields.size() );
      for(Map<String, Object> numericField : numericFields) {
        AnnotationDescriptor fieldAnnotation = new AnnotationDescriptor( NumericField.class );
        for ( Map.Entry<String, Object> entry : numericField.entrySet() ) {
          fieldAnnotation.setValue( entry.getKey(), entry.getValue() );
        }
        numericFieldAnnotations.add( (NumericField) AnnotationFactory.create( fieldAnnotation ) );
      }
      for(Map<String, Object> field : fields) {
        AnnotationDescriptor fieldAnnotation = new AnnotationDescriptor( org.hibernate.search.annotations.Field.class );
        for ( Map.Entry<String, Object> entry : field.entrySet() ) {
          if ( entry.getKey().equals( "analyzer" ) ) {
            AnnotationDescriptor analyzerAnnotation = new AnnotationDescriptor( Analyzer.class );
            @SuppressWarnings("unchecked")
            Map<String, Object> analyzer = (Map<String, Object>) entry.getValue();
            for ( Map.Entry<String, Object> analyzerEntry : analyzer.entrySet() ) {
              analyzerAnnotation.setValue( analyzerEntry.getKey(), analyzerEntry.getValue() );
            }
            fieldAnnotation.setValue( "analyzer", AnnotationFactory.create( analyzerAnnotation ) );
          }
          else if ( entry.getKey().equals( "boost" ) ) {
            AnnotationDescriptor boostAnnotation = new AnnotationDescriptor( Boost.class );
            @SuppressWarnings("unchecked")
            Map<String, Object> boost = (Map<String, Object>) entry.getValue();
            for ( Map.Entry<String, Object> boostEntry : boost.entrySet() ) {
              boostAnnotation.setValue( boostEntry.getKey(), boostEntry.getValue() );
            }
            fieldAnnotation.setValue( "boost", AnnotationFactory.create( boostAnnotation ) );
          }
          else if ( entry.getKey().equals( "bridge" ) ) {
            AnnotationDescriptor bridgeAnnotation = new AnnotationDescriptor( FieldBridge.class );
            @SuppressWarnings("unchecked")
            Map<String, Object> bridge = (Map<String, Object>) entry.getValue();
            for ( Map.Entry<String, Object> bridgeEntry : bridge.entrySet() ) {
              if ( bridgeEntry.getKey().equals( "params" ) ) {
                addParamsToAnnotation( bridgeAnnotation, bridgeEntry );
              }
              else {
                bridgeAnnotation.setValue( bridgeEntry.getKey(), bridgeEntry.getValue() );
              }
            }
            fieldAnnotation.setValue( "bridge", AnnotationFactory.create( bridgeAnnotation ) );
          }
          else {
            fieldAnnotation.setValue( entry.getKey(), entry.getValue() );
          }
        }
        fieldAnnotations.add( (org.hibernate.search.annotations.Field) AnnotationFactory.create( fieldAnnotation ) );
      }
      AnnotationDescriptor fieldsAnnotation = new AnnotationDescriptor( Fields.class );
      AnnotationDescriptor numericFieldsAnnotation = new AnnotationDescriptor( NumericFields.class );

      final org.hibernate.search.annotations.Field[] fieldArray =
          new org.hibernate.search.annotations.Field[fieldAnnotations.size()];
      final org.hibernate.search.annotations.Field[] fieldAsArray = fieldAnnotations.toArray( fieldArray );

      final NumericField[] numericFieldArray = new NumericField[numericFieldAnnotations.size()];
      final NumericField[] numericFieldAsArray = numericFieldAnnotations.toArray( numericFieldArray );
      numericFieldsAnnotation.setValue( "value", numericFieldAsArray);
      annotations.put( NumericFields.class, AnnotationFactory.create( numericFieldsAnnotation ));
      fieldsAnnotation.setValue( "value", fieldAsArray );
      annotations.put( Fields.class, AnnotationFactory.create( fieldsAnnotation ) );
      createDateBridge( property );
      createCalendarBridge( property );
View Full Code Here


    }

    private void createDynamicBoost(PropertyDescriptor property) {
      if ( property.getDynamicBoost() != null ) {
        AnnotationDescriptor dynamicBoostAnn = new AnnotationDescriptor( DynamicBoost.class );
        Set<Entry<String, Object>> entrySet = property.getDynamicBoost().entrySet();
        for ( Entry<String, Object> entry : entrySet ) {
          dynamicBoostAnn.setValue( entry.getKey(), entry.getValue() );
        }
        annotations.put( DynamicBoost.class, AnnotationFactory.create( dynamicBoostAnn ) );
      }
    }
View Full Code Here

    }

    private void createContainedIn(PropertyDescriptor property) {
      if ( property.getContainedIn() != null ) {
        Map<String, Object> containedIn = property.getContainedIn();
        AnnotationDescriptor containedInAnn = new AnnotationDescriptor( ContainedIn.class );
        Set<Entry<String, Object>> entrySet = containedIn.entrySet();
        for ( Entry<String, Object> entry : entrySet ) {
          containedInAnn.setValue( entry.getKey(), entry.getValue() );
        }
        annotations.put( ContainedIn.class, AnnotationFactory.create( containedInAnn ) );
      }
    }
View Full Code Here

    }

    private void createIndexEmbedded(PropertyDescriptor property) {
      Map<String, Object> indexEmbedded = property.getIndexEmbedded();
      if ( indexEmbedded != null ) {
        AnnotationDescriptor indexEmbeddedAnn = new AnnotationDescriptor( IndexedEmbedded.class );
        Set<Entry<String, Object>> entrySet = indexEmbedded.entrySet();
        for ( Entry<String, Object> entry : entrySet ) {
          indexEmbeddedAnn.setValue( entry.getKey(), entry.getValue() );
        }
        annotations.put( IndexedEmbedded.class, AnnotationFactory.create( indexEmbeddedAnn ) );
      }
    }
View Full Code Here

      }
    }

    private void createIndexed(EntityDescriptor entity) {
      Class<? extends Annotation> annotationType = Indexed.class;
      AnnotationDescriptor annotation = new AnnotationDescriptor( annotationType );
      if ( entity.getIndexed() != null ) {
        for ( Map.Entry<String, Object> entry : entity.getIndexed().entrySet() ) {
          annotation.setValue( entry.getKey(), entry.getValue() );
        }
        annotations.put( annotationType, AnnotationFactory.create( annotation ) );
      }

      if ( entity.getSimilarity() != null ) {
        annotation = new AnnotationDescriptor( Similarity.class );
        for ( Map.Entry<String, Object> entry : entity.getSimilarity().entrySet() ) {
          annotation.setValue( entry.getKey(), entry.getValue() );
        }
        annotations.put( Similarity.class, AnnotationFactory.create( annotation ) );
      }

      if ( entity.getBoost() != null ) {
        annotation = new AnnotationDescriptor( Boost.class );
        for ( Map.Entry<String, Object> entry : entity.getBoost().entrySet() ) {
          annotation.setValue( entry.getKey(), entry.getValue() );
        }
        annotations.put( Boost.class, AnnotationFactory.create( annotation ) );
      }

      if ( entity.getAnalyzerDiscriminator() != null ) {
        annotation = new AnnotationDescriptor( AnalyzerDiscriminator.class );
        for ( Map.Entry<String, Object> entry : entity.getAnalyzerDiscriminator().entrySet() ) {
          annotation.setValue( entry.getKey(), entry.getValue() );
        }
        annotations.put( AnalyzerDiscriminator.class, AnnotationFactory.create( annotation ) );
      }
      if ( entity.getFullTextFilterDefs().size() > 0 ) {
        AnnotationDescriptor fullTextFilterDefsAnnotation = new AnnotationDescriptor( FullTextFilterDefs.class );
        FullTextFilterDef[] fullTextFilterDefArray = createFullTextFilterDefArray( entity.getFullTextFilterDefs() );
        fullTextFilterDefsAnnotation.setValue( "value", fullTextFilterDefArray );
        annotations.put( FullTextFilterDefs.class, AnnotationFactory.create( fullTextFilterDefsAnnotation ) );
      }
      if ( entity.getProvidedId() != null ) {
        createProvidedId( entity );
      }

      if ( entity.getClassBridgeDefs().size() > 0 ) {
        AnnotationDescriptor classBridgesAnn = new AnnotationDescriptor( ClassBridges.class );
        ClassBridge[] classBridesDefArray = createClassBridgesDefArray( entity.getClassBridgeDefs() );
        classBridgesAnn.setValue( "value", classBridesDefArray );
        annotations.put( ClassBridges.class, AnnotationFactory.create( classBridgesAnn ) );
      }

      if ( entity.getDynamicBoost() != null ) {
        AnnotationDescriptor dynamicBoostAnn = new AnnotationDescriptor( DynamicBoost.class );
        Set<Entry<String, Object>> entrySet = entity.getDynamicBoost().entrySet();
        for ( Entry<String, Object> entry : entrySet ) {
          dynamicBoostAnn.setValue( entry.getKey(), entry.getValue() );
        }
        annotations.put( DynamicBoost.class, AnnotationFactory.create( dynamicBoostAnn ) );
      }

    }
View Full Code Here

      return classBridgeDefArray;
    }


    private ClassBridge createClassBridge(Map<String, Object> classBridgeDef) {
      AnnotationDescriptor annotation = new AnnotationDescriptor( ClassBridge.class );
      Set<Entry<String, Object>> entrySet = classBridgeDef.entrySet();
      for ( Entry<String, Object> entry : entrySet ) {
        if ( entry.getKey().equals( "params" ) ) {
          addParamsToAnnotation( annotation, entry );
        }
        else {
          annotation.setValue( entry.getKey(), entry.getValue() );
        }
      }
      return AnnotationFactory.create( annotation );
    }
View Full Code Here

      }
      return AnnotationFactory.create( annotation );
    }

    private void createProvidedId(EntityDescriptor entity) {
      AnnotationDescriptor annotation = new AnnotationDescriptor( ProvidedId.class );
      Set<Entry<String, Object>> entrySet = entity.getProvidedId().entrySet();
      for ( Entry<String, Object> entry : entrySet ) {
        if ( entry.getKey().equals( "bridge" ) ) {
          AnnotationDescriptor bridgeAnnotation = new AnnotationDescriptor( FieldBridge.class );
          @SuppressWarnings("unchecked")
          Map<String, Object> bridge = (Map<String, Object>) entry.getValue();
          for ( Map.Entry<String, Object> bridgeEntry : bridge.entrySet() ) {
            if ( bridgeEntry.getKey().equals( "params" ) ) {
              addParamsToAnnotation( bridgeAnnotation, bridgeEntry );
            }
            else {
              bridgeAnnotation.setValue( bridgeEntry.getKey(), bridgeEntry.getValue() );
            }
          }
          annotation.setValue( "bridge", AnnotationFactory.create( bridgeAnnotation ) );
        }
        else {
View Full Code Here

  private void processEventAnnotations(List<Annotation> annotationList, XMLContext.Default defaults) {
    boolean eventElement = false;
    for ( Element element : elementsForProperty ) {
      String elementName = element.getName();
      if ( "pre-persist".equals( elementName ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( PrePersist.class );
        annotationList.add( AnnotationFactory.create( ad ) );
        eventElement = true;
      }
      else if ( "pre-remove".equals( elementName ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( PreRemove.class );
        annotationList.add( AnnotationFactory.create( ad ) );
        eventElement = true;
      }
      else if ( "pre-update".equals( elementName ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( PreUpdate.class );
        annotationList.add( AnnotationFactory.create( ad ) );
        eventElement = true;
      }
      else if ( "post-persist".equals( elementName ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( PostPersist.class );
        annotationList.add( AnnotationFactory.create( ad ) );
        eventElement = true;
      }
      else if ( "post-remove".equals( elementName ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( PostRemove.class );
        annotationList.add( AnnotationFactory.create( ad ) );
        eventElement = true;
      }
      else if ( "post-update".equals( elementName ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( PostUpdate.class );
        annotationList.add( AnnotationFactory.create( ad ) );
        eventElement = true;
      }
      else if ( "post-load".equals( elementName ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( PostLoad.class );
        annotationList.add( AnnotationFactory.create( ad ) );
        eventElement = true;
      }
    }
    if ( !eventElement && defaults.canUseJavaAnnotations() ) {
View Full Code Here

          throw new AnnotationException(
              "Unable to find " + element.getPath() + ".class: " + className, e
          );
        }
      }
      AnnotationDescriptor ad = new AnnotationDescriptor( EntityListeners.class );
      ad.setValue( "value", entityListenerClasses.toArray( new Class[entityListenerClasses.size()] ) );
      return AnnotationFactory.create( ad );
    }
    else if ( defaults.canUseJavaAnnotations() ) {
      return getJavaAnnotation( EntityListeners.class );
    }
View Full Code Here

        );
    final Class<JoinTable> annotationType = JoinTable.class;
    if ( defaultToJoinTable
        && ( StringHelper.isNotEmpty( defaults.getCatalog() )
        || StringHelper.isNotEmpty( defaults.getSchema() ) ) ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( annotationType );
      if ( defaults.canUseJavaAnnotations() ) {
        JoinTable table = getJavaAnnotation( annotationType );
        if ( table != null ) {
          ad.setValue( "name", table.name() );
          ad.setValue( "schema", table.schema() );
          ad.setValue( "catalog", table.catalog() );
          ad.setValue( "uniqueConstraints", table.uniqueConstraints() );
          ad.setValue( "joinColumns", table.joinColumns() );
          ad.setValue( "inverseJoinColumns", table.inverseJoinColumns() );
        }
      }
      if ( StringHelper.isEmpty( (String) ad.valueOf( "schema" ) )
          && StringHelper.isNotEmpty( defaults.getSchema() ) ) {
        ad.setValue( "schema", defaults.getSchema() );
      }
      if ( StringHelper.isEmpty( (String) ad.valueOf( "catalog" ) )
          && StringHelper.isNotEmpty( defaults.getCatalog() ) ) {
        ad.setValue( "catalog", defaults.getCatalog() );
      }
      return AnnotationFactory.create( ad );
    }
    else if ( defaults.canUseJavaAnnotations() ) {
      return getJavaAnnotation( annotationType );
View Full Code Here

TOP

Related Classes of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor

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.