Java 类org.hibernate.engine.spi.FilterDefinition 实例源码

项目:lams    文件:HbmBinder.java   
private static void parseFilterDef(Element element, Mappings mappings) {
    String name = element.attributeValue( "name" );
    LOG.debugf( "Parsing filter-def [%s]", name );
    String defaultCondition = element.getTextTrim();
    if ( StringHelper.isEmpty( defaultCondition ) ) {
        defaultCondition = element.attributeValue( "condition" );
    }
    HashMap paramMappings = new HashMap();
    Iterator params = element.elementIterator( "filter-param" );
    while ( params.hasNext() ) {
        final Element param = (Element) params.next();
        final String paramName = param.attributeValue( "name" );
        final String paramType = param.attributeValue( "type" );
        LOG.debugf( "Adding filter parameter : %s -> %s", paramName, paramType );
        final Type heuristicType = mappings.getTypeResolver().heuristicType( paramType );
        LOG.debugf( "Parameter heuristic type : %s", heuristicType );
        paramMappings.put( paramName, heuristicType );
    }
    LOG.debugf( "Parsed filter-def [%s]", name );
    FilterDefinition def = new FilterDefinition( name, defaultCondition, paramMappings );
    mappings.addFilterDefinition( def );
}
项目:lams    文件:FilterDefBinder.java   
private static void bind(MetadataImplementor metadata, AnnotationInstance filterDef) {
    String name = JandexHelper.getValue( filterDef, "name", String.class );
    Map<String, Type> prms = new HashMap<String, Type>();
    for ( AnnotationInstance prm : JandexHelper.getValue( filterDef, "parameters", AnnotationInstance[].class ) ) {
        prms.put(
                JandexHelper.getValue( prm, "name", String.class ),
                metadata.getTypeResolver().heuristicType( JandexHelper.getValue( prm, "type", String.class ) )
        );
    }
    metadata.addFilterDefinition(
            new FilterDefinition(
                    name,
                    JandexHelper.getValue( filterDef, "defaultCondition", String.class ),
                    prms
            )
    );
    LOG.debugf( "Binding filter definition: %s", name );
}
项目:lams    文件:AnnotationBinder.java   
private static void bindFilterDef(FilterDef defAnn, Mappings mappings) {
    Map<String, org.hibernate.type.Type> params = new HashMap<String, org.hibernate.type.Type>();
    for ( ParamDef param : defAnn.parameters() ) {
        params.put( param.name(), mappings.getTypeResolver().heuristicType( param.type() ) );
    }
    FilterDefinition def = new FilterDefinition( defAnn.name(), defAnn.defaultCondition(), params );
    LOG.debugf( "Binding filter definition: %s", def.getFilterName() );
    mappings.addFilterDefinition( def );
}
项目:lams    文件:HibernateMappingProcessor.java   
private void processFilterDefinitions() {
    if ( mappingRoot().getFilterDef() == null ) {
        return;
    }

    for ( JaxbHibernateMapping.JaxbFilterDef filterDefinition : mappingRoot().getFilterDef() ) {
        final String name = filterDefinition.getName();
        final Map<String,Type> parameters = new HashMap<String, Type>();
        String condition = null;
        for ( Object o : filterDefinition.getContent() ) {
            if ( o instanceof String ) {
                // represents the condition
                if ( condition != null ) {
                    // log?
                }
                condition = (String) o;
            }
            else if ( o instanceof JaxbHibernateMapping.JaxbFilterDef.JaxbFilterParam ) {
                final JaxbHibernateMapping.JaxbFilterDef.JaxbFilterParam paramElement =
                        JaxbHibernateMapping.JaxbFilterDef.JaxbFilterParam.class.cast( o );
                // todo : should really delay this resolution until later to allow typedef names
                parameters.put(
                        paramElement.getName(),
                        metadata.getTypeResolver().heuristicType( paramElement.getType() )
                );
            }
            else {
                throw new MappingException( "Unrecognized nested filter content", origin() );
            }
        }
        if ( condition == null ) {
            condition = filterDefinition.getCondition();
        }
        metadata.addFilterDefinition( new FilterDefinition( name, condition, parameters ) );
    }
}
项目:lams    文件:MetadataImpl.java   
@Override
public void addFilterDefinition(FilterDefinition def) {
    if ( def == null || def.getFilterName() == null ) {
        throw new IllegalArgumentException( "Filter definition object or name is null: "  + def );
    }
    filterDefs.put( def.getFilterName(), def );
}
项目:lams    文件:SessionFactoryImpl.java   
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
    FilterDefinition def = filters.get( filterName );
    if ( def == null ) {
        throw new HibernateException( "No such filter configured [" + filterName + "]" );
    }
    return def;
}
项目:jspresso-ce    文件:JspressoLocalSessionFactoryBean.java   
/**
 * Registers the default Jspresso Filter.
 * <p>
 * {@inheritDoc}
 */
@Override
protected SessionFactory buildSessionFactory(LocalSessionFactoryBuilder sfb) {
  Map<String, Type> filterParameters = new HashMap<>();
  filterParameters.put(
      HibernateBackendController.JSPRESSO_SESSION_GLOBALS_LOGIN, sfb
          .getTypeResolver().heuristicType("string"));
  filterParameters.put(
      HibernateBackendController.JSPRESSO_SESSION_GLOBALS_LANGUAGE, sfb
          .getTypeResolver().heuristicType("string"));
  sfb.addFilterDefinition(new FilterDefinition(
      HibernateBackendController.JSPRESSO_SESSION_GLOBALS, null,
      filterParameters));
  return super.buildSessionFactory(sfb);
}
项目:openeos    文件:FilterConfigurator.java   
private void addFilterDefinitions(FilterProvider provider, ConfigurationProvider configurationProvider) {
    Configuration conf = configurationProvider.getConfiguration();
    conf.buildMappings();
    Map<?, ?> filterDefinitions = conf.getFilterDefinitions();
    TypeResolver resolver = conf.getTypeResolver();
    for (BasicFilterDefinition filterDef : provider.getFilterDefinitions()) {
        Map<String, Type> paramMapConverted = new HashMap<String, Type>();
        for (Entry<String, String> paramEntry : filterDef.getParameterTypeMap().entrySet()) {
            Type type = resolver.heuristicType(paramEntry.getValue());
            paramMapConverted.put(paramEntry.getKey(), type);
        }
        FilterDefinition definition = new FilterDefinition(filterDef.getName(), filterDef.getDefaultCondition(),
                paramMapConverted);
        LOG.debug("Registering new filter definition with name '{}'", definition.getFilterName());
        if (filterDefinitions.containsKey(definition.getFilterName())) {
            LOG.warn("The configuration already has filter definition with name '{}',  overwriting.",
                    definition.getFilterName());
        }
        conf.addFilterDefinition(definition);
        filterProviderMap.put(definition.getFilterName(), provider);
        Iterator<PersistentClass> classIterator = conf.getClassMappings();
        while (classIterator.hasNext()) {
            PersistentClass persistentClass = classIterator.next();
            provider.addFilterToClassIfNecesary(persistentClass, filterDef);
        }
    }
    configurationProvider.invalidate();
}
项目:hibernate-dynamic-dialects    文件:SessionFactoryImpl.java   
public FilterDefinition getFilterDefinition(String filterName)
        throws HibernateException {
    FilterDefinition def = filters.get(filterName);
    if (def == null) {
        throw new HibernateException("No such filter configured ["
                + filterName + "]");
    }
    return def;
}
项目:lemon    文件:SessionFactoryWrapper.java   
public FilterDefinition getFilterDefinition(String filterName)
        throws HibernateException {
    return sessionFactoryImplementor.getFilterDefinition(filterName);
}
项目:lams    文件:Configuration.java   
protected void reset() {
        metadataSourceQueue = new MetadataSourceQueue();
        createReflectionManager();

        classes = new HashMap<String,PersistentClass>();
        imports = new HashMap<String,String>();
        collections = new HashMap<String,Collection>();
        tables = new TreeMap<String,Table>();

        namedQueries = new HashMap<String,NamedQueryDefinition>();
        namedSqlQueries = new HashMap<String,NamedSQLQueryDefinition>();
        sqlResultSetMappings = new HashMap<String, ResultSetMappingDefinition>();
        namedEntityGraphMap = new HashMap<String, NamedEntityGraphDefinition>();
        namedProcedureCallMap = new HashMap<String, NamedProcedureCallDefinition>(  );
        typeDefs = new HashMap<String,TypeDef>();
        filterDefinitions = new HashMap<String, FilterDefinition>();
        fetchProfiles = new HashMap<String, FetchProfile>();
        auxiliaryDatabaseObjects = new ArrayList<AuxiliaryDatabaseObject>();

        tableNameBinding = new HashMap();
        columnNameBindingPerTable = new HashMap();

        secondPasses = new ArrayList<SecondPass>();
        propertyReferences = new ArrayList<Mappings.PropertyReference>();
        extendsQueue = new HashMap<ExtendsQueueEntry, String>();

        xmlHelper = new XMLHelper();
        interceptor = EmptyInterceptor.INSTANCE;
        properties = Environment.getProperties();
        entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;

        sqlFunctions = new HashMap<String, SQLFunction>();

        entityTuplizerFactory = new EntityTuplizerFactory();
//      componentTuplizerFactory = new ComponentTuplizerFactory();

        identifierGeneratorFactory = new DefaultIdentifierGeneratorFactory();

        mappedSuperClasses = new HashMap<Class<?>, MappedSuperclass>();

        metadataSourcePrecedence = Collections.emptyList();

        namedGenerators = new HashMap<String, IdGenerator>();
        joins = new HashMap<String, Map<String, Join>>();
        classTypes = new HashMap<String, AnnotatedClassType>();
        generatorTables = new HashMap<String, Properties>();
        defaultNamedQueryNames = new HashSet<String>();
        defaultNamedNativeQueryNames = new HashSet<String>();
        defaultSqlResultSetMappingNames = new HashSet<String>();
        defaultNamedProcedure =  new HashSet<String>(  );
        defaultNamedGenerators = new HashSet<String>();
        uniqueConstraintHoldersByTable = new HashMap<Table, List<UniqueConstraintHolder>>();
        jpaIndexHoldersByTable = new HashMap<Table,List<JPAIndexHolder>>(  );
        mappedByResolver = new HashMap<String, String>();
        propertyRefResolver = new HashMap<String, String>();
        caches = new ArrayList<CacheHolder>();
        namingStrategyDelegator = LegacyNamingStrategyDelegator.DEFAULT_INSTANCE;
        setEntityResolver( new EJB3DTDEntityResolver() );
        anyMetaDefs = new HashMap<String, AnyMetaDef>();
        propertiesAnnotatedWithMapsId = new HashMap<XClass, Map<String, PropertyData>>();
        propertiesAnnotatedWithIdAndToOne = new HashMap<XClass, Map<String, PropertyData>>();
        specjProprietarySyntaxEnabled = System.getProperty( "hibernate.enable_specj_proprietary_syntax" ) != null;
    }
项目:lams    文件:Configuration.java   
public void addFilterDefinition(FilterDefinition definition) {
    filterDefinitions.put( definition.getFilterName(), definition );
}
项目:lams    文件:Configuration.java   
public FilterDefinition getFilterDefinition(String name) {
    return filterDefinitions.get( name );
}
项目:lams    文件:Configuration.java   
public void addFilterDefinition(FilterDefinition definition) {
    filterDefinitions.put( definition.getFilterName(), definition );
}
项目:lams    文件:EntityBinding.java   
public Iterable<FilterDefinition> getFilterDefinitions() {
    return filterDefinitions;
}
项目:lams    文件:EntityBinding.java   
public void addFilterDefinition(FilterDefinition filterDefinition) {
    filterDefinitions.add( filterDefinition );
}
项目:lams    文件:MetadataImpl.java   
public Iterable<FilterDefinition> getFilterDefinitions() {
    return filterDefs.values();
}
项目:lams    文件:FilterImpl.java   
public FilterDefinition getFilterDefinition() {
    return definition;
}
项目:gorm-hibernate5    文件:GrailsDomainBinder.java   
/**
 * Binds a root class (one with no super classes) to the runtime meta model
 * based on the supplied Grails domain class
 *
 * @param entity The Grails domain class
 * @param mappings    The Hibernate Mappings object
 * @param sessionFactoryBeanName  the session factory bean name
 */
public void bindRoot(HibernatePersistentEntity entity, InFlightMetadataCollector mappings, String sessionFactoryBeanName) {
    if (mappings.getEntityBinding(entity.getName()) != null) {
        LOG.info("[GrailsDomainBinder] Class [" + entity.getName() + "] is already mapped, skipping.. ");
        return;
    }

    RootClass root = new RootClass(this.metadataBuildingContext);
    root.setAbstract(entity.isAbstract());
    final MappingContext mappingContext = entity.getMappingContext();



    final java.util.Collection<PersistentEntity> children = mappingContext.getDirectChildEntities(entity);
    if (children.isEmpty()) {
        root.setPolymorphic(false);
    }
    bindClass(entity, root, mappings);

    Mapping m = getMapping(entity);

    bindRootPersistentClassCommonValues(entity, root, mappings, sessionFactoryBeanName);

    if (!children.isEmpty()) {
        boolean tablePerSubclass = m != null && !m.getTablePerHierarchy();
        if (!tablePerSubclass) {
            // if the root class has children create a discriminator property
            bindDiscriminatorProperty(root.getTable(), root, mappings);
        }
        // bind the sub classes
        bindSubClasses(entity, root, mappings, sessionFactoryBeanName);
    }

    if(entity.isMultiTenant()) {
        TenantId tenantId = entity.getTenantId();
        if(tenantId != null) {
            String filterCondition = getMultiTenantFilterCondition(sessionFactoryBeanName, entity);
            root.addFilter(GormProperties.TENANT_IDENTITY,filterCondition, true, Collections.<String, String>emptyMap(), Collections.<String, String>emptyMap());
            mappings.addFilterDefinition(new FilterDefinition(
                    GormProperties.TENANT_IDENTITY,
                    filterCondition,
                    Collections.singletonMap(GormProperties.TENANT_IDENTITY, root.getProperty(tenantId.getName()).getType())
            ));
        }

    }
    mappings.addEntityBinding(root);
}
项目:ignite    文件:CacheHibernateStoreFactorySelfTest.java   
/** {@inheritDoc} */
@Override public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
    return null;
}
项目:ignite    文件:CacheHibernateStoreFactorySelfTest.java   
/** {@inheritDoc} */
@Override public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
    return null;
}
项目:hyberbin-osgi    文件:DynamicSessionFactory.java   
public FilterDefinition getFilterDefinition(String filterName)
        throws HibernateException {
    return getHibernateSessionFactory().getFilterDefinition(filterName);
}
项目:lams    文件:Mappings.java   
/**
 * Retrieves a filter definition by name.
 *
 * @param name The name of the filter definition to retrieve.
 * @return The filter definition, or null.
 */
public FilterDefinition getFilterDefinition(String name);
项目:lams    文件:Mappings.java   
/**
 * Adds a filter definition to this repository.
 *
 * @param definition The filter definition to add.
 */
public void addFilterDefinition(FilterDefinition definition);
项目:lams    文件:Filter.java   
/**
 * Get the filter definition containing additional information about the
 * filter (such as default-condition and expected parameter names/types).
 *
 * @return The filter definition
 */
public FilterDefinition getFilterDefinition();
项目:lams    文件:FilterImpl.java   
/**
 * Constructs a new FilterImpl.
 *
 * @param configuration The filter's global configuration.
 */
public FilterImpl(FilterDefinition configuration) {
    this.definition = configuration;
    filterName = definition.getFilterName();
}
项目:lams    文件:SessionFactory.java   
/**
 * Obtain the definition of a filter by name.
 *
 * @param filterName The name of the filter for which to obtain the definition.
 * @return The filter definition.
 * @throws HibernateException If no filter defined with the given name.
 */
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException;
项目:lams    文件:Metadata.java   
public Iterable<FilterDefinition> getFilterDefinitions();
项目:lams    文件:MetadataImplementor.java   
public void addFilterDefinition(FilterDefinition filterDefinition);