Java Code Examples for org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery

The following examples show how to use org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery. These examples are extracted from open source projects. 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
@Override
@SuppressWarnings("unchecked")
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
		NamedQueries namedQueries) {

	QueryMethod queryMethod = new QueryMethod(method, metadata, factory);

	Constructor<? extends KeyValuePartTreeQuery> constructor = (Constructor<? extends KeyValuePartTreeQuery>) ClassUtils
			.getConstructorIfAvailable(this.repositoryQueryType, QueryMethod.class,
					QueryMethodEvaluationContextProvider.class, KeyValueOperations.class, Class.class);

	Assert.state(constructor != null,
			String.format(
					"Constructor %s(QueryMethod, EvaluationContextProvider, KeyValueOperations, Class) not available!",
					ClassUtils.getShortName(this.repositoryQueryType)));

	return BeanUtils.instantiateClass(constructor, queryMethod, evaluationContextProvider, this.keyValueOperations,
			this.queryCreator);
}
 
Example 2
/**
 * Detects the query creator type to be used for the factory to set. Will lookup a {@link QueryCreatorType} annotation
 * on the {@code @Enable}-annotation or use {@link SpelQueryCreator} if not found.
 *
 * @param config
 * @return
 */
private static Class<?> getQueryType(AnnotationRepositoryConfigurationSource config) {

	AnnotationMetadata metadata = config.getEnableAnnotationMetadata();

	Map<String, Object> queryCreatorAnnotationAttributes = metadata
			.getAnnotationAttributes(QueryCreatorType.class.getName());

	if (queryCreatorAnnotationAttributes == null) {
		return KeyValuePartTreeQuery.class;
	}

	AnnotationAttributes queryCreatorAttributes = new AnnotationAttributes(queryCreatorAnnotationAttributes);
	return queryCreatorAttributes.getClass("repositoryQueryType");
}
 
Example 3
@Test // DATAKV-123
@SuppressWarnings("unchecked")
public void createsRepositoryFactory() {

	Class<? extends AbstractQueryCreator<?, ?>> creatorType = (Class<? extends AbstractQueryCreator<?, ?>>) mock(
			AbstractQueryCreator.class).getClass();
	Class<? extends RepositoryQuery> queryType = mock(KeyValuePartTreeQuery.class).getClass();

	factoryBean.setQueryCreator(creatorType);
	factoryBean.setKeyValueOperations(mock(KeyValueOperations.class));
	factoryBean.setQueryType(queryType);

	assertThat(factoryBean.createRepositoryFactory()).isNotNull();
}
 
Example 4
Source Project: spring-vault   Source File: VaultRepositoryFactory.java    License: Apache License 2.0 4 votes vote down vote up
public VaultRepositoryFactory(KeyValueOperations keyValueOperations,
		Class<? extends AbstractQueryCreator<?, ?>> queryCreator) {
	this(keyValueOperations, queryCreator, KeyValuePartTreeQuery.class);
}
 
Example 5
/**
 * Creates a new {@link KeyValueRepositoryFactory} for the given {@link KeyValueOperations} and
 * {@link AbstractQueryCreator}-type.
 *
 * @param keyValueOperations must not be {@literal null}.
 * @param queryCreator must not be {@literal null}.
 */
public KeyValueRepositoryFactory(KeyValueOperations keyValueOperations,
		Class<? extends AbstractQueryCreator<?, ?>> queryCreator) {

	this(keyValueOperations, queryCreator, KeyValuePartTreeQuery.class);
}