Upgrade to Spring Data Hopper

See gh-380
This commit is contained in:
Eddú Meléndez
2016-03-19 01:26:16 +10:00
parent 46f72b42e8
commit d6cff2e6a8
14 changed files with 76 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2005-2013 the original author or authors.
* Copyright 2005-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.ldap.repository.query;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.query.QueryMethod;
import org.springframework.ldap.repository.Query;
@@ -27,6 +28,7 @@ import java.lang.reflect.Method;
* QueryMethod for Ldap Queries.
*
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
* @since 2.0
*/
public class LdapQueryMethod extends QueryMethod {
@@ -38,8 +40,8 @@ public class LdapQueryMethod extends QueryMethod {
* @param method must not be {@literal null}
* @param metadata must not be {@literal null}
*/
public LdapQueryMethod(Method method, RepositoryMetadata metadata) {
super(method, metadata);
public LdapQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
super(method, metadata, factory);
this.method = method;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2005-2013 the original author or authors.
* Copyright 2005-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.springframework.ldap.repository.support;
import com.mysema.query.apt.DefaultConfiguration;
import com.querydsl.apt.DefaultConfiguration;
import org.springframework.ldap.odm.annotations.Id;
import javax.annotation.processing.RoundEnvironment;
@@ -27,6 +27,7 @@ import java.util.Map;
/**
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
* @since 2.0
*/
class DefaultLdapAnnotationProcessorConfiguration extends DefaultConfiguration {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2005-2013 the original author or authors.
* Copyright 2005-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,10 +16,10 @@
package org.springframework.ldap.repository.support;
import com.mysema.query.annotations.QueryEntities;
import com.mysema.query.apt.AbstractQuerydslProcessor;
import com.mysema.query.apt.Configuration;
import com.mysema.query.apt.DefaultConfiguration;
import com.querydsl.apt.AbstractQuerydslProcessor;
import com.querydsl.apt.Configuration;
import com.querydsl.apt.DefaultConfiguration;
import com.querydsl.core.annotations.QueryEntities;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Transient;
@@ -34,6 +34,7 @@ import java.util.Collections;
* QueryDSL Annotation Processor to generate QueryDSL classes for entity classes annotated with {@link Entry}.
*
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
* @since 2.0
*/
@SupportedAnnotationTypes("org.springframework.ldap.odm.annotations.*")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2005-2013 the original author or authors.
* Copyright 2005-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.ldap.repository.support;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.core.EntityInformation;
import org.springframework.data.repository.core.NamedQueries;
@@ -37,6 +38,7 @@ import static org.springframework.data.querydsl.QueryDslUtils.QUERY_DSL_PRESENT;
/**
* Factory to create {@link org.springframework.ldap.repository.LdapRepository} instances.
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
* @since 2.0
*/
public class LdapRepositoryFactory extends RepositoryFactorySupport {
@@ -92,8 +94,8 @@ public class LdapRepositoryFactory extends RepositoryFactorySupport {
private final class LdapQueryLookupStrategy implements QueryLookupStrategy {
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries) {
LdapQueryMethod queryMethod = new LdapQueryMethod(method, metadata);
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory, NamedQueries namedQueries) {
LdapQueryMethod queryMethod = new LdapQueryMethod(method, metadata, factory);
Class<?> domainType = metadata.getDomainType();
if(queryMethod.hasQueryAnnotation()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2005-2013 the original author or authors.
* Copyright 2005-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,17 +16,17 @@
package org.springframework.ldap.repository.support;
import com.mysema.query.types.Constant;
import com.mysema.query.types.Expression;
import com.mysema.query.types.FactoryExpression;
import com.mysema.query.types.Operation;
import com.mysema.query.types.Operator;
import com.mysema.query.types.Ops;
import com.mysema.query.types.ParamExpression;
import com.mysema.query.types.Path;
import com.mysema.query.types.SubQueryExpression;
import com.mysema.query.types.TemplateExpression;
import com.mysema.query.types.Visitor;
import com.querydsl.core.types.Constant;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.FactoryExpression;
import com.querydsl.core.types.Operation;
import com.querydsl.core.types.Operator;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.ParamExpression;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.SubQueryExpression;
import com.querydsl.core.types.TemplateExpression;
import com.querydsl.core.types.Visitor;
import org.springframework.ldap.filter.AndFilter;
import org.springframework.ldap.filter.EqualsFilter;
import org.springframework.ldap.filter.Filter;
@@ -42,6 +42,7 @@ import org.springframework.ldap.odm.core.ObjectDirectoryMapper;
* Helper class for generating LDAP filters from QueryDSL Expressions.
*
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
* @since 2.0
*/
class LdapSerializer implements Visitor<Object, Void> {
@@ -70,7 +71,7 @@ class LdapSerializer implements Visitor<Object, Void> {
@Override
public Object visit(Operation<?> expr, Void context) {
Operator<?> operator = expr.getOperator();
Operator operator = expr.getOperator();
if (operator == Ops.EQ) {
return new EqualsFilter(attribute(expr), value(expr));
} else if (operator == Ops.AND) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2005-2013 the original author or authors.
* Copyright 2005-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,11 +16,11 @@
package org.springframework.ldap.repository.support;
import com.mysema.query.DefaultQueryMetadata;
import com.mysema.query.FilteredClause;
import com.mysema.query.support.QueryMixin;
import com.mysema.query.types.EntityPath;
import com.mysema.query.types.Predicate;
import com.querydsl.core.DefaultQueryMetadata;
import com.querydsl.core.FilteredClause;
import com.querydsl.core.support.QueryMixin;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Predicate;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.query.LdapQuery;
@@ -32,6 +32,7 @@ import static org.springframework.ldap.query.LdapQueryBuilder.query;
* Spring LDAP specific {@link FilteredClause} implementation.
*
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
* @since 2.0
*/
public class QueryDslLdapQuery<K> implements FilteredClause<QueryDslLdapQuery<K>> {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2005-2013 the original author or authors.
* Copyright 2005-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
package org.springframework.ldap.repository.support;
import com.mysema.query.types.OrderSpecifier;
import com.mysema.query.types.Predicate;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Predicate;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -32,6 +32,7 @@ import java.util.List;
* Base repository implementation for QueryDSL support.
*
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
* @since 2.0
*/
public class QueryDslLdapRepository<T> extends SimpleLdapRepository<T> implements QueryDslPredicateExecutor<T> {

View File

@@ -3,6 +3,8 @@ package org.springframework.ldap.repository.query;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.odm.core.impl.BaseUnitTestPerson;
@@ -17,6 +19,7 @@ import static org.junit.Assert.assertEquals;
/**
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
*/
@ContextConfiguration("classpath:/query-test.xml")
public class PartTreeLdapRepositoryQueryTest extends AbstractJUnit4SpringContextTests {
@@ -26,12 +29,14 @@ public class PartTreeLdapRepositoryQueryTest extends AbstractJUnit4SpringContext
private Class<?> targetClass;
private Class<?> entityClass;
private DefaultRepositoryMetadata repositoryMetadata;
private ProjectionFactory factory;
@Before
public void prepareTest() {
entityClass = UnitTestPerson.class;
targetClass = UnitTestPersonRepository.class;
repositoryMetadata = new DefaultRepositoryMetadata(targetClass);
factory = new SpelAwareProxyProjectionFactory();
}
@Test
@@ -155,7 +160,7 @@ public class PartTreeLdapRepositoryQueryTest extends AbstractJUnit4SpringContext
}
private void assertFilterAndBaseForMethod(Method targetMethod, String expectedFilter, String expectedBase, Object... expectedParams) {
LdapQueryMethod queryMethod = new LdapQueryMethod(targetMethod, repositoryMetadata);
LdapQueryMethod queryMethod = new LdapQueryMethod(targetMethod, repositoryMetadata, factory);
PartTreeLdapRepositoryQuery tested = new PartTreeLdapRepositoryQuery(queryMethod, entityClass, ldapTemplate);
LdapQuery query = tested.createQuery(expectedParams);

View File

@@ -1,16 +1,16 @@
package org.springframework.ldap.repository.support;
import com.mysema.query.types.Path;
import com.mysema.query.types.PathMetadata;
import com.mysema.query.types.path.EntityPathBase;
import com.mysema.query.types.path.ListPath;
import com.mysema.query.types.path.PathInits;
import com.mysema.query.types.path.StringPath;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.PathMetadata;
import com.querydsl.core.types.dsl.EntityPathBase;
import com.querydsl.core.types.dsl.ListPath;
import com.querydsl.core.types.dsl.PathInits;
import com.querydsl.core.types.dsl.StringPath;
import org.springframework.ldap.odm.core.impl.UnitTestPerson;
import javax.annotation.Generated;
import static com.mysema.query.types.PathMetadataFactory.forVariable;
import static com.querydsl.core.types.PathMetadataFactory.forVariable;
/**
@@ -37,7 +37,7 @@ public class QPerson extends EntityPathBase<UnitTestPerson> {
super(path.getType(), path.getMetadata());
}
public QPerson(PathMetadata<?> metadata) {
public QPerson(PathMetadata metadata) {
super(UnitTestPerson.class, metadata);
}

View File

@@ -1,6 +1,6 @@
package org.springframework.ldap.repository.support;
import com.mysema.query.types.Expression;
import com.querydsl.core.types.Expression;
import org.junit.Before;
import org.junit.Test;
import org.springframework.ldap.filter.Filter;
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertEquals;
/**
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
*/
public class QueryDslFilterGeneratorTest {