Java Code Examples for org.hibernate.impl.FilterImpl#getParameter()

The following examples show how to use org.hibernate.impl.FilterImpl#getParameter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 2
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 3
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 4
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 5
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 6
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 7
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 8
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 9
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 10
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}
 
Example 11
Source File: JoinProcessor.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void processDynamicFilterParameters(
		final String sqlFragment,
		final ParameterContainer container,
		final HqlSqlWalker walker) {
	if ( walker.getEnabledFilters().isEmpty()
			&& ( ! hasDynamicFilterParam( sqlFragment ) )
			&& ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
		return;
	}

	Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
	String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
			.append( dialect.openQuote() )
			.append( dialect.closeQuote() )
			.toString();
	StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
	StringBuffer result = new StringBuffer();

	while ( tokens.hasMoreTokens() ) {
		final String token = tokens.nextToken();
		if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
			final String filterParameterName = token.substring( 1 );
			final String[] parts = LoadQueryInfluencers.parseFilterParameterName( filterParameterName );
			final FilterImpl filter = ( FilterImpl ) walker.getEnabledFilters().get( parts[0] );
			final Object value = filter.getParameter( parts[1] );
			final Type type = filter.getFilterDefinition().getParameterType( parts[1] );
			final String typeBindFragment = StringHelper.join(
					",",
					ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() ) )
			);
			final String bindFragment = ( value != null && Collection.class.isInstance( value ) )
					? StringHelper.join( ",", ArrayHelper.fillArray( typeBindFragment, ( ( Collection ) value ).size() ) )
					: typeBindFragment;
			result.append( bindFragment );
			container.addEmbeddedParameter( new DynamicFilterParameterSpecification( parts[0], parts[1], type ) );
		}
		else {
			result.append( token );
		}
	}

	container.setText( result.toString() );
}