Java Code Examples for org.springframework.data.repository.query.QueryLookupStrategy.Key

The following examples show how to use org.springframework.data.repository.query.QueryLookupStrategy.Key. 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
/**
 * Creates a {@link QueryLookupStrategy} for the given {@link EbeanServer} and {@link Key}.
 *
 * @param ebeanServer               must not be {@literal null}.
 * @param key                       may be {@literal null}.
 * @param evaluationContextProvider must not be {@literal null}.
 * @return
 */
public static QueryLookupStrategy create(EbeanServer ebeanServer, Key key,
                                         QueryMethodEvaluationContextProvider evaluationContextProvider) {

    Assert.notNull(ebeanServer, "EbeanServer must not be null!");
    Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");

    switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
        case CREATE:
            return new CreateQueryLookupStrategy(ebeanServer);
        case USE_DECLARED_QUERY:
            return new DeclaredQueryLookupStrategy(ebeanServer, evaluationContextProvider);
        case CREATE_IF_NOT_FOUND:
            return new CreateIfNotFoundQueryLookupStrategy(ebeanServer, new CreateQueryLookupStrategy(ebeanServer),
                    new DeclaredQueryLookupStrategy(ebeanServer, evaluationContextProvider));
        default:
            throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
    }
}
 
Example 2
public static QueryLookupStrategy create(SqlSessionTemplate sqlSessionTemplate,
		Key key, QueryMethodEvaluationContextProvider evaluationContextProvider) {

	Assert.notNull(sqlSessionTemplate, "SqlSessionTemplate must not be null!");
	Assert.notNull(evaluationContextProvider,
			"EvaluationContextProvider must not be null!");

	switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
	case CREATE:
		return new CreateQueryLookupStrategy(sqlSessionTemplate);
	case USE_DECLARED_QUERY:
		return new DeclaredQueryLookupStrategy(sqlSessionTemplate,
				evaluationContextProvider);
	case CREATE_IF_NOT_FOUND:
		return new CreateIfNotFoundQueryLookupStrategy(sqlSessionTemplate,
				new CreateQueryLookupStrategy(sqlSessionTemplate),
				new DeclaredQueryLookupStrategy(sqlSessionTemplate,
						evaluationContextProvider));
	default:
		throw new IllegalArgumentException(
				String.format("Unsupported query lookup strategy %s!", key));
	}
}
 
Example 3
/**
 * @param key
 * @param evaluationContextProvider
 * @param keyValueOperations
 * @param queryCreator
 * @since 1.1
 */
public KeyValueQueryLookupStrategy(@Nullable Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider, KeyValueOperations keyValueOperations,
		Class<? extends AbstractQueryCreator<?, ?>> queryCreator,
		Class<? extends RepositoryQuery> repositoryQueryType) {

	Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");
	Assert.notNull(keyValueOperations, "KeyValueOperations must not be null!");
	Assert.notNull(queryCreator, "Query creator type must not be null!");
	Assert.notNull(repositoryQueryType, "RepositoryQueryType type must not be null!");

	this.evaluationContextProvider = evaluationContextProvider;
	this.keyValueOperations = keyValueOperations;
	this.queryCreator = queryCreator;
	this.repositoryQueryType = repositoryQueryType;
}
 
Example 4
/**
 * Creates a {@link QueryLookupStrategy} for the given
 * {@link DynamoDBMapper} and {@link Key}.
 *
 * @param dynamoDBOperations
 * @param key
 * @return
 */
public static QueryLookupStrategy create(DynamoDBOperations dynamoDBOperations, Key key) {

	if (key == null) {
		return new CreateQueryLookupStrategy(dynamoDBOperations);
	}

	switch (key) {
	case CREATE:
		return new CreateQueryLookupStrategy(dynamoDBOperations);
	case USE_DECLARED_QUERY:
		throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
	case CREATE_IF_NOT_FOUND:
		return new CreateIfNotFoundQueryLookupStrategy(dynamoDBOperations);
	default:
		throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
	}
}
 
Example 5
Source Project: sdn-rx   Source File: ReactiveNeo4jRepositoryFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(Key key,
	QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional
		.of(new ReactiveNeo4jQueryLookupStrategy(neo4jOperations, mappingContext, evaluationContextProvider));
}
 
Example 6
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional.of(new DatastoreQueryLookupStrategy(this.datastoreMappingContext,
			this.datastoreOperations,
			delegateContextProvider(evaluationContextProvider)));
}
 
Example 7
Source Project: spring-cloud-gcp   Source File: SpannerRepositoryFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional.of(new SpannerQueryLookupStrategy(this.spannerMappingContext,
			this.spannerTemplate,
			delegateContextProvider(evaluationContextProvider), EXPRESSION_PARSER));
}
 
Example 8
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional.of(MybatisQueryLookupStrategy.create(sqlSessionTemplate, key,
			evaluationContextProvider));
}
 
Example 9
Source Project: sdn-rx   Source File: Neo4jRepositoryFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional.of(new Neo4jQueryLookupStrategy(neo4jOperations, mappingContext, evaluationContextProvider));
}
 
Example 10
Source Project: dubbox   Source File: SolrRepositoryFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key) {
	return new SolrQueryLookupStrategy();
}
 
Example 11
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key,
    EvaluationContextProvider evaluationContextProvider) {
  return new AclQueryLookupStrategy(key, evaluationContextProvider);
}
 
Example 12
public AclQueryLookupStrategy(Key key, EvaluationContextProvider evaluationContextProvider) {
  this.key = key;
  this.evaluationContextProvider = evaluationContextProvider;
}
 
Example 13
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {
	return Optional.of(new KeyValueQueryLookupStrategy(key, evaluationContextProvider, this.keyValueOperations,
			this.queryCreator, this.repositoryQueryType));
}
 
Example 14
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key) {
	return DynamoDBQueryLookupStrategy.create(dynamoDBOperations, key);
}