Skip to content

Commit 56283fe

Browse files
committed
fix merge errors and unify parameter order with options
1 parent c4414cc commit 56283fe

File tree

6 files changed

+41
-44
lines changed

6 files changed

+41
-44
lines changed

src/main/java/com/arangodb/springframework/core/ArangoOperations.java

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ default <T> ArangoCursor<T> query(String query, Map<String, Object> bindVars, Cl
105105
*
106106
* @param query
107107
* An AQL query string
108+
* @param options
109+
* Additional options that will be passed to the query API, can be null
108110
* @param entityClass
109111
* The entity type of the result
110112
* @return cursor of the results
@@ -189,7 +191,9 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteAllById(
189191
* @return information about the documents
190192
* @throws DataAccessException
191193
*/
192-
MultiDocumentEntity<DocumentDeleteEntity<?>> deleteAllById(Iterable<?> ids, Class<?> entityClass) throws DataAccessException;
194+
default <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteAllById(Iterable<?> ids, Class<T> entityClass) throws DataAccessException {
195+
return deleteAllById(ids, new DocumentDeleteOptions(), entityClass);
196+
}
193197

194198
/**
195199
* Deletes the document with the given {@code id} from a collection.
@@ -365,12 +369,9 @@ default <T> DocumentUpdateEntity<T> replace(Object id, T value) throws DataAcces
365369
/**
366370
* Retrieves the document with the given {@code id} from a collection.
367371
*
368-
* @param id
369-
* The id or key of the document
370-
* @param entityClass
371-
* The entity class which represents the collection
372-
* @param options
373-
* Additional options, can be null
372+
* @param id The id or key of the document
373+
* @param entityClass The entity class which represents the collection
374+
* @param options Additional options, can be null
374375
* @return the document identified by the id
375376
* @throws DataAccessException
376377
*/
@@ -393,31 +394,28 @@ default <T> Optional<T> find(Object id, Class<T> entityClass) throws DataAccessE
393394
/**
394395
* Retrieves all documents from a collection.
395396
*
396-
* @param entityClass
397-
* The entity class which represents the collection
397+
* @param entityClass The entity class which represents the collection
398398
* @return the documents
399399
* @throws DataAccessException
400400
*/
401-
<T> Iterable<T> findAll(Class<T> entityClass, DocumentReadOptions options) throws DataAccessException;
401+
<T> Iterable<T> findAll(DocumentReadOptions options, Class<T> entityClass) throws DataAccessException;
402402

403403
default <T> Iterable<T> findAll(Class<T> entityClass) throws DataAccessException {
404-
return findAll(entityClass, new DocumentReadOptions());
404+
return findAll(new DocumentReadOptions(), entityClass);
405405
}
406406

407407
/**
408408
* Retrieves multiple documents with the given {@code ids} from a collection.
409409
*
410-
* @param ids
411-
* The ids or keys of the documents
412-
* @param entityClass
413-
* The entity class which represents the collection
410+
* @param ids The ids or keys of the documents
411+
* @param entityClass The entity class which represents the collection
414412
* @return the documents
415413
* @throws DataAccessException
416414
*/
417-
<T> Iterable<T> findAll(final Iterable<?> ids, final Class<T> entityClass, DocumentReadOptions options) throws DataAccessException;
415+
<T> Iterable<T> findAll(final Iterable<?> ids, DocumentReadOptions options, final Class<T> entityClass) throws DataAccessException;
418416

419417
default <T> Iterable<T> findAll(final Iterable<?> ids, final Class<T> entityClass) throws DataAccessException {
420-
return findAll(ids, entityClass, new DocumentReadOptions());
418+
return findAll(ids, new DocumentReadOptions(), entityClass);
421419
}
422420

423421
/**
@@ -512,17 +510,15 @@ default <T> Iterable<T> repsertAll(Iterable<T> values, Class<? super T> entityCl
512510
/**
513511
* Checks whether the document exists by reading a single document head
514512
*
515-
* @param id
516-
* The id or key of the document
517-
* @param entityClass
518-
* The entity type representing the collection
513+
* @param id The id or key of the document
514+
* @param entityClass The entity type representing the collection
519515
* @return true if the document exists, false if not
520516
* @throws DataAccessException
521517
*/
522-
boolean exists(Object id, Class<?> entityClass, DocumentExistsOptions options) throws DataAccessException;
518+
boolean exists(Object id, DocumentExistsOptions options, Class<?> entityClass) throws DataAccessException;
523519

524520
default boolean exists(Object id, Class<?> entityClass) throws DataAccessException {
525-
return exists(id, entityClass, new DocumentExistsOptions());
521+
return exists(id, new DocumentExistsOptions(), entityClass);
526522
}
527523

528524
/**

src/main/java/com/arangodb/springframework/core/convert/resolver/EdgeFromResolver.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434
*/
3535
public class EdgeFromResolver extends AbstractResolver implements RelationResolver<From> {
3636

37+
private final ArangoOperations template;
38+
3739
public EdgeFromResolver(final ArangoOperations template, QueryTransactionBridge transactionBridge) {
38-
super(template, transactionBridge);
40+
super(template.getConverter().getConversionService(), transactionBridge);
41+
this.template = template;
3942
}
4043

4144
@Override

src/main/java/com/arangodb/springframework/core/convert/resolver/EdgeToResolver.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434
*/
3535
public class EdgeToResolver extends AbstractResolver implements RelationResolver<To> {
3636

37+
private final ArangoOperations template;
38+
3739
public EdgeToResolver(final ArangoOperations template, QueryTransactionBridge transactionBridge) {
38-
super(template, transactionBridge);
40+
super(template.getConverter().getConversionService(), transactionBridge);
41+
this.template = template;
3942
}
4043

4144
@Override

src/main/java/com/arangodb/springframework/core/template/ArangoTemplate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,14 +498,14 @@ public <T> Optional<T> find(final Object id, final Class<T> entityClass, final D
498498
}
499499

500500
@Override
501-
public <T> Iterable<T> findAll(final Class<T> entityClass, DocumentReadOptions options) throws DataAccessException {
501+
public <T> Iterable<T> findAll(DocumentReadOptions options, final Class<T> entityClass) throws DataAccessException {
502502
final String query = "FOR entity IN @@col RETURN entity";
503503
final Map<String, Object> bindVars = Collections.singletonMap("@col", entityClass);
504504
return query(query, bindVars, asQueryOptions(options), entityClass).asListRemaining();
505505
}
506506

507507
@Override
508-
public <T> Iterable<T> findAll(final Iterable<?> ids, final Class<T> entityClass, DocumentReadOptions options)
508+
public <T> Iterable<T> findAll(final Iterable<?> ids, DocumentReadOptions options, final Class<T> entityClass)
509509
throws DataAccessException {
510510
try {
511511
final Collection<String> keys = new ArrayList<>();
@@ -696,7 +696,7 @@ private void updateDBFields(final Object value, final DocumentEntity documentEnt
696696
}
697697

698698
@Override
699-
public boolean exists(final Object id, final Class<?> entityClass, DocumentExistsOptions options) throws DataAccessException {
699+
public boolean exists(final Object id, DocumentExistsOptions options, final Class<?> entityClass) throws DataAccessException {
700700
try {
701701
boolean transactional = options != null && options.getStreamTransactionId() != null;
702702
return _collection(entityClass, transactional).documentExists(determineDocumentKeyFromId(id), options);

src/main/java/com/arangodb/springframework/repository/SimpleArangoRepository.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
import com.arangodb.springframework.core.template.ArangoTemplate;
3737
import com.arangodb.springframework.core.util.AqlUtils;
3838
import com.arangodb.springframework.repository.query.QueryTransactionBridge;
39-
import org.slf4j.Logger;
40-
import org.slf4j.LoggerFactory;
4139
import org.springframework.dao.OptimisticLockingFailureException;
4240
import org.springframework.data.domain.*;
4341
import org.springframework.data.repository.query.FluentQuery;
@@ -56,8 +54,6 @@
5654
@SuppressWarnings({ "rawtypes", "unchecked" })
5755
public class SimpleArangoRepository<T, ID> implements ArangoRepository<T, ID> {
5856

59-
private static final Logger LOGGER = LoggerFactory.getLogger(SimpleArangoRepository.class);
60-
6157
private final ArangoTemplate arangoTemplate;
6258
private final ArangoConverter converter;
6359
private final ArangoMappingContext mappingContext;
@@ -108,7 +104,7 @@ public <S extends T> S save(final S entity) {
108104
*/
109105
@Override
110106
public <S extends T> Iterable<S> saveAll(final Iterable<S> entities) {
111-
Iterable<S> saved = arangoTemplate.repsertAll(entities, domainClass, defaultQueryOptions());
107+
Iterable<S> saved = arangoTemplate.repsertAll(entities, defaultQueryOptions(), domainClass);
112108
return returnOriginalEntities ? entities : saved;
113109
}
114110

@@ -131,7 +127,7 @@ public Optional<T> findById(final ID id) {
131127
*/
132128
@Override
133129
public boolean existsById(final ID id) {
134-
return arangoTemplate.exists(id, domainClass, defaultExistsOptions());
130+
return arangoTemplate.exists(id, defaultExistsOptions(), domainClass);
135131
}
136132

137133
/**
@@ -141,7 +137,7 @@ public boolean existsById(final ID id) {
141137
*/
142138
@Override
143139
public Iterable<T> findAll() {
144-
return arangoTemplate.findAll(domainClass, defaultReadOptions());
140+
return arangoTemplate.findAll(defaultReadOptions(), domainClass);
145141
}
146142

147143
/**
@@ -153,7 +149,7 @@ public Iterable<T> findAll() {
153149
*/
154150
@Override
155151
public Iterable<T> findAllById(final Iterable<ID> ids) {
156-
return arangoTemplate.findAll(ids, domainClass, defaultReadOptions());
152+
return arangoTemplate.findAll(ids, defaultReadOptions(), domainClass);
157153
}
158154

159155
/**
@@ -175,7 +171,7 @@ public long count() {
175171
@Override
176172
public void deleteById(final ID id) {
177173
try {
178-
arangoTemplate.delete(id, domainClass, defaultDeleteOptions());
174+
arangoTemplate.delete(id, defaultDeleteOptions(), domainClass);
179175
} catch (DocumentNotFoundException unknown) {
180176
// silently ignored
181177
}
@@ -190,14 +186,14 @@ public void deleteById(final ID id) {
190186
@Override
191187
public void delete(final T entity) {
192188
Object id = persistentEntity.getIdentifierAccessor(entity).getRequiredIdentifier();
193-
DocumentDeleteOptions opts = new DocumentDeleteOptions();
189+
DocumentDeleteOptions opts = defaultDeleteOptions();
194190
persistentEntity.getRevProperty()
195191
.map(persistentEntity.getPropertyAccessor(entity)::getProperty)
196192
.map(r -> converter.convertIfNecessary(r, String.class))
197193
.ifPresent(opts::ifMatch);
198194

199195
try {
200-
arangoTemplate.delete(id, opts, domainClass, defaultDeleteOptions());
196+
arangoTemplate.delete(id, opts, domainClass);
201197
} catch (DocumentNotFoundException e) {
202198
throw new OptimisticLockingFailureException(e.getMessage(), e);
203199
}
@@ -208,7 +204,7 @@ public void delete(final T entity) {
208204
* @implNote do not add @Override annotation to keep backwards compatibility with spring-data-commons 2.4
209205
*/
210206
public void deleteAllById(Iterable<? extends ID> ids) {
211-
MultiDocumentEntity<DocumentDeleteEntity<?>> res = arangoTemplate.deleteAllById(ids, domainClass, defaultDeleteOptions());
207+
MultiDocumentEntity<DocumentDeleteEntity<T>> res = arangoTemplate.deleteAllById(ids, defaultDeleteOptions(), domainClass);
212208
for (ErrorEntity error : res.getErrors()) {
213209
// Entities that aren't found in the persistence store are silently ignored.
214210
if (error.getErrorNum() != 1202) {

src/main/java/com/arangodb/springframework/transaction/ArangoTransactionManager.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected void doBegin(Object transaction, TransactionDefinition definition) thr
114114

115115
/**
116116
* Commit the current stream transaction. The query bridge is cleared
117-
* afterwards.
117+
* afterward.
118118
*
119119
* @see ArangoDatabase#commitStreamTransaction(String)
120120
* @see QueryTransactionBridge#clearCurrentTransaction()
@@ -147,7 +147,7 @@ protected void doCommit(DefaultTransactionStatus status) throws TransactionExcep
147147

148148
/**
149149
* Roll back the current stream transaction. The query bridge is cleared
150-
* afterwards.
150+
* afterward.
151151
*
152152
* @see ArangoDatabase#abortStreamTransaction(String)
153153
* @see QueryTransactionBridge#clearCurrentTransaction()
@@ -169,7 +169,7 @@ protected void doRollback(DefaultTransactionStatus status) throws TransactionExc
169169

170170
/**
171171
* Check if the transaction object has the bound holder. For new
172-
* transactions the holder will be bound afterwards.
172+
* transactions the holder will be bound afterward.
173173
*/
174174
@Override
175175
protected boolean isExistingTransaction(Object transaction) throws TransactionException {
@@ -189,7 +189,6 @@ protected void doSetRollbackOnly(DefaultTransactionStatus status) throws Transac
189189
}
190190

191191
/**
192-
* Any transaction object is configured according to the definition upfront.
193192
* Bind the holder for the first new transaction created.
194193
*
195194
* @see ArangoTransactionHolder

0 commit comments

Comments
 (0)