From d6cff2e6a8b06b79f1ce9a395ecc154df4e548c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Sat, 19 Mar 2016 01:26:16 +1000 Subject: [PATCH] Upgrade to Spring Data Hopper See gh-380 --- core/build.gradle | 2 +- .../repository/query/LdapQueryMethod.java | 8 +++--- ...tLdapAnnotationProcessorConfiguration.java | 5 ++-- .../support/LdapAnnotationProcessor.java | 11 ++++---- .../support/LdapRepositoryFactory.java | 8 +++--- .../repository/support/LdapSerializer.java | 27 ++++++++++--------- .../repository/support/QueryDslLdapQuery.java | 13 ++++----- .../support/QueryDslLdapRepository.java | 7 ++--- .../PartTreeLdapRepositoryQueryTest.java | 7 ++++- .../ldap/repository/support/QPerson.java | 16 +++++------ .../support/QueryDslFilterGeneratorTest.java | 3 ++- gradle/java.gradle | 6 ++--- test/integration-tests-spring25/build.gradle | 8 ++++-- test/integration-tests/build.gradle | 8 ++++-- 14 files changed, 76 insertions(+), 53 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index 82f33df7..2ffaddfe 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -18,7 +18,7 @@ dependencies { "org.springframework:spring-context:$springVersion", "org.springframework:spring-jdbc:$springVersion", "org.springframework:spring-orm:$springVersion", - "com.mysema.querydsl:querydsl-apt:$queryDslVersion", + "com.querydsl:querydsl-apt:$queryDslVersion", "commons-pool:commons-pool:$commonsPoolVersion", "org.apache.commons:commons-pool2:$commonsPool2Version" diff --git a/core/src/main/java/org/springframework/ldap/repository/query/LdapQueryMethod.java b/core/src/main/java/org/springframework/ldap/repository/query/LdapQueryMethod.java index b444f3f3..368b47ab 100644 --- a/core/src/main/java/org/springframework/ldap/repository/query/LdapQueryMethod.java +++ b/core/src/main/java/org/springframework/ldap/repository/query/LdapQueryMethod.java @@ -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; } diff --git a/core/src/main/java/org/springframework/ldap/repository/support/DefaultLdapAnnotationProcessorConfiguration.java b/core/src/main/java/org/springframework/ldap/repository/support/DefaultLdapAnnotationProcessorConfiguration.java index e0df7926..5d026cb1 100644 --- a/core/src/main/java/org/springframework/ldap/repository/support/DefaultLdapAnnotationProcessorConfiguration.java +++ b/core/src/main/java/org/springframework/ldap/repository/support/DefaultLdapAnnotationProcessorConfiguration.java @@ -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 { diff --git a/core/src/main/java/org/springframework/ldap/repository/support/LdapAnnotationProcessor.java b/core/src/main/java/org/springframework/ldap/repository/support/LdapAnnotationProcessor.java index 49925ad3..c4da05db 100644 --- a/core/src/main/java/org/springframework/ldap/repository/support/LdapAnnotationProcessor.java +++ b/core/src/main/java/org/springframework/ldap/repository/support/LdapAnnotationProcessor.java @@ -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.*") diff --git a/core/src/main/java/org/springframework/ldap/repository/support/LdapRepositoryFactory.java b/core/src/main/java/org/springframework/ldap/repository/support/LdapRepositoryFactory.java index 74011b8f..84afc196 100644 --- a/core/src/main/java/org/springframework/ldap/repository/support/LdapRepositoryFactory.java +++ b/core/src/main/java/org/springframework/ldap/repository/support/LdapRepositoryFactory.java @@ -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()) { diff --git a/core/src/main/java/org/springframework/ldap/repository/support/LdapSerializer.java b/core/src/main/java/org/springframework/ldap/repository/support/LdapSerializer.java index 9e2e3fdd..f4b82bd7 100644 --- a/core/src/main/java/org/springframework/ldap/repository/support/LdapSerializer.java +++ b/core/src/main/java/org/springframework/ldap/repository/support/LdapSerializer.java @@ -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 { @@ -70,7 +71,7 @@ class LdapSerializer implements Visitor { @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) { diff --git a/core/src/main/java/org/springframework/ldap/repository/support/QueryDslLdapQuery.java b/core/src/main/java/org/springframework/ldap/repository/support/QueryDslLdapQuery.java index 6926b942..e9092f48 100644 --- a/core/src/main/java/org/springframework/ldap/repository/support/QueryDslLdapQuery.java +++ b/core/src/main/java/org/springframework/ldap/repository/support/QueryDslLdapQuery.java @@ -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 implements FilteredClause> { diff --git a/core/src/main/java/org/springframework/ldap/repository/support/QueryDslLdapRepository.java b/core/src/main/java/org/springframework/ldap/repository/support/QueryDslLdapRepository.java index f19e6fb5..56914e1c 100644 --- a/core/src/main/java/org/springframework/ldap/repository/support/QueryDslLdapRepository.java +++ b/core/src/main/java/org/springframework/ldap/repository/support/QueryDslLdapRepository.java @@ -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 extends SimpleLdapRepository implements QueryDslPredicateExecutor { diff --git a/core/src/test/java/org/springframework/ldap/repository/query/PartTreeLdapRepositoryQueryTest.java b/core/src/test/java/org/springframework/ldap/repository/query/PartTreeLdapRepositoryQueryTest.java index eb2aacef..2901a270 100644 --- a/core/src/test/java/org/springframework/ldap/repository/query/PartTreeLdapRepositoryQueryTest.java +++ b/core/src/test/java/org/springframework/ldap/repository/query/PartTreeLdapRepositoryQueryTest.java @@ -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); diff --git a/core/src/test/java/org/springframework/ldap/repository/support/QPerson.java b/core/src/test/java/org/springframework/ldap/repository/support/QPerson.java index a33de2c8..b7c24f93 100644 --- a/core/src/test/java/org/springframework/ldap/repository/support/QPerson.java +++ b/core/src/test/java/org/springframework/ldap/repository/support/QPerson.java @@ -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 { super(path.getType(), path.getMetadata()); } - public QPerson(PathMetadata metadata) { + public QPerson(PathMetadata metadata) { super(UnitTestPerson.class, metadata); } diff --git a/core/src/test/java/org/springframework/ldap/repository/support/QueryDslFilterGeneratorTest.java b/core/src/test/java/org/springframework/ldap/repository/support/QueryDslFilterGeneratorTest.java index 6c26fbd6..daa72bac 100644 --- a/core/src/test/java/org/springframework/ldap/repository/support/QueryDslFilterGeneratorTest.java +++ b/core/src/test/java/org/springframework/ldap/repository/support/QueryDslFilterGeneratorTest.java @@ -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 { diff --git a/gradle/java.gradle b/gradle/java.gradle index f7c15e7a..d1ad28c6 100644 --- a/gradle/java.gradle +++ b/gradle/java.gradle @@ -5,8 +5,8 @@ sourceCompatibility = '1.6' targetCompatibility = '1.6' ext.apacheDsVersion = '1.5.5' -ext.springVersion = '3.2.13.RELEASE' -ext.springDataVersion = '1.11.0.RELEASE' +ext.springVersion = '4.2.5.RELEASE' +ext.springDataVersion = '1.12.0.RC1' ext.springDataSpring3Version = '1.10.2.RELEASE' ext.springBatchVersion = '2.0.4.RELEASE' ext.junitVersion = '4.11' @@ -17,7 +17,7 @@ ext.commonsLoggingVersion = '1.2' ext.gsbaseVersion = '2.0.1' ext.log4jVersion = '1.2.17' ext.mockitoVersion = '1.10.19' -ext.queryDslVersion = '3.6.3' +ext.queryDslVersion = '4.0.9' ext.slf4jVersion = '1.7.12' ext.powerMockVersion = '1.6.2' ext.commonsPool2Version = '2.4.2' diff --git a/test/integration-tests-spring25/build.gradle b/test/integration-tests-spring25/build.gradle index c4aec54f..6660140a 100644 --- a/test/integration-tests-spring25/build.gradle +++ b/test/integration-tests-spring25/build.gradle @@ -19,8 +19,12 @@ dependencies { exclude group: "junit", module:"junit" } - testCompile "org.springframework.data:spring-data-commons:$springDataVersion", - "org.springframework:spring-test:$spring25Version", + testCompile ("org.springframework.data:spring-data-commons:$springDataVersion") { + exclude group: "org.springframework", module:"spring-core" + exclude group: "org.springframework", module:"spring-beans" + } + + testCompile "org.springframework:spring-test:$spring25Version", "org.springframework:spring-context:$spring25Version", "org.springframework:spring-core:$spring25Version", "org.springframework:spring-tx:$spring25Version", diff --git a/test/integration-tests/build.gradle b/test/integration-tests/build.gradle index a39cfb3a..d98f39a0 100644 --- a/test/integration-tests/build.gradle +++ b/test/integration-tests/build.gradle @@ -28,8 +28,12 @@ dependencies { compile project(":spring-ldap-test"), project(":spring-ldap-core-tiger") - compile "com.mysema.querydsl:querydsl-apt:$queryDslVersion", - "org.springframework.data:spring-data-commons:$springDataSpring3Version" + compile "com.querydsl:querydsl-apt:$queryDslVersion", + + compile("org.springframework.data:spring-data-commons:$springDataVersion") { + exclude group: "org.springframework", module: "spring-beans" + exclude group: "org.springframework", module: "spring-core" + } compile("org.springframework.security:spring-security-core:$springSecurityVersion") { exclude group: "org.springframework", module: "spring-expression"