|
185 | 185 | * @author Michael Krog |
186 | 186 | * @author Jakub Zurawa |
187 | 187 | */ |
188 | | -public class MongoTemplate |
189 | | - implements MongoOperations, ApplicationContextAware, IndexOperationsProvider, SearchIndexOperationsProvider, ReadPreferenceAware { |
| 188 | +public class MongoTemplate implements MongoOperations, ApplicationContextAware, IndexOperationsProvider, |
| 189 | + SearchIndexOperationsProvider, ReadPreferenceAware { |
190 | 190 |
|
191 | 191 | private static final Log LOGGER = LogFactory.getLog(MongoTemplate.class); |
192 | 192 | private static final WriteResultChecking DEFAULT_WRITE_RESULT_CHECKING = WriteResultChecking.NONE; |
@@ -771,6 +771,21 @@ public IndexOperations indexOps(Class<?> entityClass) { |
771 | 771 | return indexOps(getCollectionName(entityClass), entityClass); |
772 | 772 | } |
773 | 773 |
|
| 774 | + @Override |
| 775 | + public SearchIndexOperations searchIndexOps(String collectionName) { |
| 776 | + return searchIndexOps(null, collectionName); |
| 777 | + } |
| 778 | + |
| 779 | + @Override |
| 780 | + public SearchIndexOperations searchIndexOps(Class<?> type) { |
| 781 | + return new DefaultSearchIndexOperations(this, type); |
| 782 | + } |
| 783 | + |
| 784 | + @Override |
| 785 | + public SearchIndexOperations searchIndexOps(@Nullable Class<?> type, String collectionName) { |
| 786 | + return new DefaultSearchIndexOperations(this, collectionName, type); |
| 787 | + } |
| 788 | + |
774 | 789 | @Override |
775 | 790 | public BulkOperations bulkOps(BulkMode mode, String collectionName) { |
776 | 791 | return bulkOps(mode, null, collectionName); |
@@ -1316,7 +1331,7 @@ private WriteConcern potentiallyForceAcknowledgedWrite(@Nullable WriteConcern wc |
1316 | 1331 |
|
1317 | 1332 | if (ObjectUtils.nullSafeEquals(WriteResultChecking.EXCEPTION, writeResultChecking)) { |
1318 | 1333 | if (wc == null || wc.getWObject() == null |
1319 | | - || (wc.getWObject()instanceof Number concern && concern.intValue() < 1)) { |
| 1334 | + || (wc.getWObject() instanceof Number concern && concern.intValue() < 1)) { |
1320 | 1335 | return WriteConcern.ACKNOWLEDGED; |
1321 | 1336 | } |
1322 | 1337 | } |
@@ -1968,7 +1983,8 @@ public <T> List<T> mapReduce(Query query, Class<?> domainType, String inputColle |
1968 | 1983 | } |
1969 | 1984 |
|
1970 | 1985 | if (mapReduceOptions.getOutputSharded().isPresent()) { |
1971 | | - MongoCompatibilityAdapter.mapReduceIterableAdapter(mapReduce).sharded(mapReduceOptions.getOutputSharded().get()); |
| 1986 | + MongoCompatibilityAdapter.mapReduceIterableAdapter(mapReduce) |
| 1987 | + .sharded(mapReduceOptions.getOutputSharded().get()); |
1972 | 1988 | } |
1973 | 1989 |
|
1974 | 1990 | if (StringUtils.hasText(mapReduceOptions.getOutputCollection()) && !mapReduceOptions.usesInlineOutput()) { |
@@ -2067,7 +2083,7 @@ public <T> List<T> findAllAndRemove(Query query, Class<T> entityClass, String co |
2067 | 2083 | } |
2068 | 2084 |
|
2069 | 2085 | @Override |
2070 | | - public <T> UpdateResult replace(Query query, T replacement, ReplaceOptions options, String collectionName){ |
| 2086 | + public <T> UpdateResult replace(Query query, T replacement, ReplaceOptions options, String collectionName) { |
2071 | 2087 |
|
2072 | 2088 | Assert.notNull(replacement, "Replacement must not be null"); |
2073 | 2089 | return replace(query, (Class<T>) ClassUtils.getUserClass(replacement), replacement, options, collectionName); |
@@ -2743,8 +2759,7 @@ protected <T> T doFindAndModify(CollectionPreparer collectionPreparer, String co |
2743 | 2759 | LOGGER.debug(String.format( |
2744 | 2760 | "findAndModify using query: %s fields: %s sort: %s for class: %s and update: %s in collection: %s", |
2745 | 2761 | serializeToJsonSafely(mappedQuery), fields, serializeToJsonSafely(sort), entityClass, |
2746 | | - serializeToJsonSafely(mappedUpdate), |
2747 | | - collectionName)); |
| 2762 | + serializeToJsonSafely(mappedUpdate), collectionName)); |
2748 | 2763 | } |
2749 | 2764 |
|
2750 | 2765 | return executeFindOneInternal( |
@@ -3013,21 +3028,6 @@ static RuntimeException potentiallyConvertRuntimeException(RuntimeException ex, |
3013 | 3028 | return resolved == null ? ex : resolved; |
3014 | 3029 | } |
3015 | 3030 |
|
3016 | | - @Override |
3017 | | - public SearchIndexOperations searchIndexOps(String collectionName) { |
3018 | | - return searchIndexOps(null, collectionName); |
3019 | | - } |
3020 | | - |
3021 | | - @Override |
3022 | | - public SearchIndexOperations searchIndexOps(Class<?> type) { |
3023 | | - return new DefaultSearchIndexOperations(this, type); |
3024 | | - } |
3025 | | - |
3026 | | - @Override |
3027 | | - public SearchIndexOperations searchIndexOps(Class<?> type, String collectionName) { |
3028 | | - return new DefaultSearchIndexOperations(this, collectionName, type); |
3029 | | - } |
3030 | | - |
3031 | 3031 | // Callback implementations |
3032 | 3032 |
|
3033 | 3033 | /** |
|
0 commit comments