Skip to content

Commit 80ff376

Browse files
schauderodrotbohm
authored andcommitted
DATAMONGO-1721 - Fixed package dependencies.
Added a Degraph based tests to identify package cycles and violations in layering. Moved Collation to the core.query package, fixing dependency cycles. Moved IndexOperations and IndexOperationsProvider to the core.index package. fixing dependency cycles. Moved GeoJsonConfiguration to config package. Replaced the original version of these interfaces/classes with a deprecated version extending the new one, in order to not break the existing API. Removed all references to Part.Type, except for those to maintain the existing API. API using Part.Type is marked as deprecated. It violates the layering, because nothing but "config" should access "repository". Tests added to MongoRegexCreator in order to facilitate the removal of Part.Type dependencies. Using the moved/new ExampleMatcherAccessor. Related Tickets: DATACMNS-1097. Original pull request: #470.
1 parent d19ea88 commit 80ff376

File tree

49 files changed

+501
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+501
-123
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ src/ant/.ant-targets-upload-dist.xml
1515
atlassian-ide-plugin.xml
1616
/.gradle/
1717
/.idea/
18+
*.graphml

spring-data-mongodb/pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@
232232
<scope>test</scope>
233233
</dependency>
234234

235+
<dependency>
236+
<groupId>de.schauderhaft.degraph</groupId>
237+
<artifactId>degraph-check</artifactId>
238+
<version>0.1.4</version>
239+
<scope>test</scope>
240+
</dependency>
241+
235242
<!-- Kotlin extension -->
236243
<dependency>
237244
<groupId>org.jetbrains.kotlin</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2015-2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.mongodb.config;
17+
18+
import org.springframework.context.annotation.Bean;
19+
import org.springframework.data.mongodb.core.geo.GeoJsonModule;
20+
import org.springframework.data.web.config.SpringDataJacksonModules;
21+
22+
/**
23+
* Configuration class to expose {@link GeoJsonModule} as a Spring bean.
24+
*
25+
* @author Oliver Gierke
26+
* @author Jens Schauder
27+
*/
28+
public class GeoJsonConfiguration implements SpringDataJacksonModules {
29+
30+
@Bean
31+
public GeoJsonModule geoJsonModule() {
32+
return new GeoJsonModule();
33+
}
34+
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.Optional;
1919

20+
import org.springframework.data.mongodb.core.query.Collation;
2021
import org.springframework.util.Assert;
2122

2223
/**

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultBulkOperations.java

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.data.mongodb.core.convert.QueryMapper;
3232
import org.springframework.data.mongodb.core.convert.UpdateMapper;
3333
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
34+
import org.springframework.data.mongodb.core.query.Collation;
3435
import org.springframework.data.mongodb.core.query.Query;
3536
import org.springframework.data.mongodb.core.query.Update;
3637
import org.springframework.data.util.Pair;

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.data.mongodb.MongoDbFactory;
2828
import org.springframework.data.mongodb.core.index.IndexDefinition;
2929
import org.springframework.data.mongodb.core.index.IndexInfo;
30+
import org.springframework.data.mongodb.core.index.IndexOperations;
3031
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
3132
import org.springframework.util.Assert;
3233

@@ -89,7 +90,7 @@ public DefaultIndexOperations(MongoDbFactory mongoDbFactory, String collectionNa
8990

9091
/*
9192
* (non-Javadoc)
92-
* @see org.springframework.data.mongodb.core.IndexOperations#ensureIndex(org.springframework.data.mongodb.core.index.IndexDefinition)
93+
* @see org.springframework.data.mongodb.core.index.IndexOperations#ensureIndex(org.springframework.data.mongodb.core.index.IndexDefinition)
9394
*/
9495
public String ensureIndex(final IndexDefinition indexDefinition) {
9596

@@ -136,7 +137,7 @@ private MongoPersistentEntity<?> lookupPersistentEntity(Class<?> entityType, Str
136137

137138
/*
138139
* (non-Javadoc)
139-
* @see org.springframework.data.mongodb.core.IndexOperations#dropIndex(java.lang.String)
140+
* @see org.springframework.data.mongodb.core.index.IndexOperations#dropIndex(java.lang.String)
140141
*/
141142
public void dropIndex(final String name) {
142143

@@ -149,15 +150,15 @@ public void dropIndex(final String name) {
149150

150151
/*
151152
* (non-Javadoc)
152-
* @see org.springframework.data.mongodb.core.IndexOperations#dropAllIndexes()
153+
* @see org.springframework.data.mongodb.core.index.IndexOperations#dropAllIndexes()
153154
*/
154155
public void dropAllIndexes() {
155156
dropIndex("*");
156157
}
157158

158159
/*
159160
* (non-Javadoc)
160-
* @see org.springframework.data.mongodb.core.IndexOperations#getIndexInfo()
161+
* @see org.springframework.data.mongodb.core.index.IndexOperations#getIndexInfo()
161162
*/
162163
public List<IndexInfo> getIndexInfo() {
163164

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperationsProvider.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import org.springframework.data.mongodb.MongoDbFactory;
1919
import org.springframework.data.mongodb.core.convert.QueryMapper;
20+
import org.springframework.data.mongodb.core.index.IndexOperations;
21+
import org.springframework.data.mongodb.core.index.IndexOperationsProvider;
2022

2123
/**
2224
* {@link IndexOperationsProvider} to obtain {@link IndexOperations} from a given {@link MongoDbFactory}. TODO: Review
@@ -38,7 +40,7 @@ class DefaultIndexOperationsProvider implements IndexOperationsProvider {
3840
}
3941

4042
/* (non-Javadoc)
41-
* @see org.springframework.data.mongodb.core.IndexOperationsProvider#reactiveIndexOps(java.lang.String)
43+
* @see org.springframework.data.mongodb.core.index.IndexOperationsProvider#reactiveIndexOps(java.lang.String)
4244
*/
4345
@Override
4446
public IndexOperations indexOps(String collectionName) {

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultReactiveIndexOperations.java

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.bson.Document;
1919
import org.springframework.data.mongodb.core.index.IndexDefinition;
2020
import org.springframework.data.mongodb.core.index.IndexInfo;
21+
import org.springframework.data.mongodb.core.index.IndexOperations;
2122
import org.springframework.util.Assert;
2223

2324
import com.mongodb.reactivestreams.client.ListIndexesPublisher;

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/FindAndModifyOptions.java

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import java.util.Optional;
1919

20+
import org.springframework.data.mongodb.core.query.Collation;
21+
2022
/**
2123
* @author Mark Pollak
2224
* @author Oliver Gierke
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2016 the original author or authors.
2+
* Copyright 2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,19 +15,17 @@
1515
*/
1616
package org.springframework.data.mongodb.core;
1717

18-
import org.springframework.context.annotation.Bean;
1918
import org.springframework.data.mongodb.core.geo.GeoJsonModule;
20-
import org.springframework.data.web.config.SpringDataJacksonModules;
2119

2220
/**
2321
* Configuration class to expose {@link GeoJsonModule} as a Spring bean.
24-
*
22+
*
2523
* @author Oliver Gierke
24+
* @author Jens Schauder
25+
*
26+
* @deprecated Use {@link org.springframework.data.mongodb.config.GeoJsonConfiguration} instead.
2627
*/
27-
public class GeoJsonConfiguration implements SpringDataJacksonModules {
28+
@Deprecated
29+
public class GeoJsonConfiguration extends org.springframework.data.mongodb.config.GeoJsonConfiguration {
2830

29-
@Bean
30-
public GeoJsonModule geoJsonModule() {
31-
return new GeoJsonModule();
32-
}
3331
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/IndexConverters.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static Collation fromDocument(Document source) {
125125
return null;
126126
}
127127

128-
return org.springframework.data.mongodb.core.Collation.from(source).toMongoCollation();
128+
return org.springframework.data.mongodb.core.query.Collation.from(source).toMongoCollation();
129129
}
130130

131131
private static Converter<Document, IndexInfo> getDocumentIndexInfoConverter() {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2016 the original author or authors.
2+
* Copyright 2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,44 +15,17 @@
1515
*/
1616
package org.springframework.data.mongodb.core;
1717

18-
import java.util.List;
19-
20-
import org.springframework.data.mongodb.core.index.IndexDefinition;
21-
import org.springframework.data.mongodb.core.index.IndexInfo;
22-
2318
/**
2419
* Index operations on a collection.
25-
*
20+
*
2621
* @author Mark Pollack
2722
* @author Oliver Gierke
2823
* @author Christoph Strobl
24+
* @author Jens Schauder
25+
*
26+
* @deprecated Use {@link org.springframework.data.mongodb.core.index.IndexOperations} instead.
2927
*/
30-
public interface IndexOperations {
31-
32-
/**
33-
* Ensure that an index for the provided {@link IndexDefinition} exists for the collection indicated by the entity
34-
* class. If not it will be created.
35-
*
36-
* @param indexDefinition must not be {@literal null}.
37-
*/
38-
String ensureIndex(IndexDefinition indexDefinition);
39-
40-
/**
41-
* Drops an index from this collection.
42-
*
43-
* @param name name of index to drop
44-
*/
45-
void dropIndex(String name);
46-
47-
/**
48-
* Drops all indices from this collection.
49-
*/
50-
void dropAllIndexes();
28+
@Deprecated
29+
public interface IndexOperations extends org.springframework.data.mongodb.core.index.IndexOperations {
5130

52-
/**
53-
* Returns the index information on the collection.
54-
*
55-
* @return index information on the collection
56-
*/
57-
List<IndexInfo> getIndexInfo();
5831
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/IndexOperationsAdapter.java

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.springframework.data.mongodb.core.index.IndexDefinition;
2222
import org.springframework.data.mongodb.core.index.IndexInfo;
23+
import org.springframework.data.mongodb.core.index.IndexOperations;
2324
import org.springframework.util.Assert;
2425

2526
/**
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 the original author or authors.
2+
* Copyright 2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,22 +13,16 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package org.springframework.data.mongodb.core;
1817

19-
import org.springframework.data.mongodb.core.convert.QueryMapper;
20-
2118
/**
22-
* TODO: Revisit for a better pattern.
2319
* @author Mark Paluch
20+
* @author Jens Schauder
2421
* @since 2.0
22+
*
23+
* @deprecated Use {@link org.springframework.data.mongodb.core.index.IndexOperationsProvider} instead.
2524
*/
26-
public interface IndexOperationsProvider {
25+
@Deprecated
26+
public interface IndexOperationsProvider extends org.springframework.data.mongodb.core.index.IndexOperationsProvider {
2727

28-
/**
29-
* Returns the operations that can be performed on indexes
30-
*
31-
* @return index operations on the named collection
32-
*/
33-
IndexOperations indexOps(String collectionName);
3428
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
2828
import org.springframework.data.mongodb.core.aggregation.TypedAggregation;
2929
import org.springframework.data.mongodb.core.convert.MongoConverter;
30+
import org.springframework.data.mongodb.core.index.IndexOperations;
3031
import org.springframework.data.mongodb.core.mapreduce.GroupBy;
3132
import org.springframework.data.mongodb.core.mapreduce.GroupByResults;
3233
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
import org.springframework.data.mongodb.core.convert.MongoWriter;
8585
import org.springframework.data.mongodb.core.convert.QueryMapper;
8686
import org.springframework.data.mongodb.core.convert.UpdateMapper;
87+
import org.springframework.data.mongodb.core.index.IndexOperations;
88+
import org.springframework.data.mongodb.core.index.IndexOperationsProvider;
8789
import org.springframework.data.mongodb.core.index.MongoMappingEventPublisher;
8890
import org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator;
8991
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
@@ -102,6 +104,7 @@
102104
import org.springframework.data.mongodb.core.mapreduce.GroupByResults;
103105
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
104106
import org.springframework.data.mongodb.core.mapreduce.MapReduceResults;
107+
import org.springframework.data.mongodb.core.query.Collation;
105108
import org.springframework.data.mongodb.core.query.Criteria;
106109
import org.springframework.data.mongodb.core.query.Meta;
107110
import org.springframework.data.mongodb.core.query.NearQuery;
@@ -612,8 +615,8 @@ public boolean exists(Query query, Class<?> entityClass, String collectionName)
612615

613616
Document mappedQuery = queryMapper.getMappedObject(query.getQueryObject(), getPersistentEntity(entityClass));
614617

615-
return execute(collectionName, new ExistsCallback(mappedQuery,
616-
query.getCollation().map(org.springframework.data.mongodb.core.Collation::toMongoCollation).orElse(null)));
618+
return execute(collectionName,
619+
new ExistsCallback(mappedQuery, query.getCollation().map(Collation::toMongoCollation).orElse(null)));
617620
}
618621

619622
// Find methods that take a Query to express the query and that return a List of objects.

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
5757
import org.springframework.data.mongodb.MongoDbFactory;
5858
import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory;
59+
import org.springframework.data.mongodb.core.query.Collation;
5960
import org.springframework.data.mongodb.core.convert.DbRefProxyHandler;
6061
import org.springframework.data.mongodb.core.convert.DbRefResolver;
6162
import org.springframework.data.mongodb.core.convert.DbRefResolverCallback;

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOptions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.util.Optional;
1919

2020
import org.bson.Document;
21-
import org.springframework.data.mongodb.core.Collation;
21+
import org.springframework.data.mongodb.core.query.Collation;
2222
import org.springframework.util.Assert;
2323

2424
import com.mongodb.DBObject;

0 commit comments

Comments
 (0)