Skip to content

Commit f589bf3

Browse files
committed
#80 handle missing options
1 parent 79a682c commit f589bf3

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public ArangoDBVersion getVersion() throws DataAccessException {
363363
public <T> ArangoCursor<T> query(final String query, final Map<String, Object> bindVars,
364364
final AqlQueryOptions options, final Class<T> entityClass) throws DataAccessException {
365365
try {
366-
ArangoCursor<T> cursor = db().query(query, entityClass, bindVars == null ? null : prepareBindVars(bindVars, false), options);
366+
ArangoCursor<T> cursor = db().query(query, entityClass, bindVars == null ? null : prepareBindVars(bindVars, options != null && options.getStreamTransactionId() != null), options);
367367
return new ArangoExtCursor<>(cursor, entityClass, eventPublisher);
368368
} catch (final ArangoDBException e) {
369369
throw translateException(e);
@@ -393,7 +393,7 @@ public <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteAll(
393393

394394
MultiDocumentEntity<DocumentDeleteEntity<T>> result;
395395
try {
396-
result = _collection(entityClass, options.getStreamTransactionId() != null).deleteDocuments(toList(values), options, entityClass);
396+
result = _collection(entityClass, options != null && options.getStreamTransactionId() != null).deleteDocuments(toList(values), options, entityClass);
397397
} catch (final ArangoDBException e) {
398398
throw translateException(e);
399399
}
@@ -425,7 +425,7 @@ public <T> DocumentDeleteEntity<T> delete(final Object id, final DocumentDeleteO
425425

426426
DocumentDeleteEntity<T> result;
427427
try {
428-
result = _collection(entityClass, id, options.getStreamTransactionId() != null).deleteDocument(determineDocumentKeyFromId(id), options, entityClass);
428+
result = _collection(entityClass, id, options != null && options.getStreamTransactionId() != null).deleteDocument(determineDocumentKeyFromId(id), options, entityClass);
429429
} catch (final ArangoDBException e) {
430430
throw translateException(e);
431431
}
@@ -445,7 +445,7 @@ public <T> MultiDocumentEntity<DocumentUpdateEntity<T>> updateAll(
445445

446446
MultiDocumentEntity<DocumentUpdateEntity<T>> result;
447447
try {
448-
result = _collection(entityClass, options.getStreamTransactionId() != null).updateDocuments(toList(values), options, entityClass);
448+
result = _collection(entityClass, options != null && options.getStreamTransactionId() != null).updateDocuments(toList(values), options, entityClass);
449449
} catch (final ArangoDBException e) {
450450
throw translateException(e);
451451
}
@@ -463,7 +463,7 @@ public <T> DocumentUpdateEntity<T> update(final Object id, final T value, final
463463

464464
DocumentUpdateEntity<T> result;
465465
try {
466-
result = _collection(value.getClass(), id, options.getStreamTransactionId() != null).updateDocument(determineDocumentKeyFromId(id), value, options);
466+
result = _collection(value.getClass(), id, options != null && options.getStreamTransactionId() != null).updateDocument(determineDocumentKeyFromId(id), value, options);
467467
} catch (final ArangoDBException e) {
468468
throw translateException(e);
469469
}
@@ -484,7 +484,7 @@ public <T> MultiDocumentEntity<DocumentUpdateEntity<T>> replaceAll(
484484

485485
MultiDocumentEntity<DocumentUpdateEntity<T>> result;
486486
try {
487-
result = _collection(entityClass, options.getStreamTransactionId() != null).replaceDocuments(toList(values), options, entityClass);
487+
result = _collection(entityClass, options != null && options.getStreamTransactionId() != null).replaceDocuments(toList(values), options, entityClass);
488488
} catch (final ArangoDBException e) {
489489
throw translateException(e);
490490
}
@@ -501,7 +501,7 @@ public <T> DocumentUpdateEntity<T> replace(final Object id, final T value, final
501501

502502
DocumentUpdateEntity<T> result;
503503
try {
504-
result = _collection(value.getClass(), id, false).replaceDocument(determineDocumentKeyFromId(id), value, options);
504+
result = _collection(value.getClass(), id, options != null && options.getStreamTransactionId() != null).replaceDocument(determineDocumentKeyFromId(id), value, options);
505505
} catch (final ArangoDBException e) {
506506
throw translateException(e);
507507
}
@@ -515,7 +515,7 @@ public <T> DocumentUpdateEntity<T> replace(final Object id, final T value, final
515515
public <T> Optional<T> find(final Object id, final Class<T> entityClass, final DocumentReadOptions options)
516516
throws DataAccessException {
517517
try {
518-
T res = _collection(entityClass, id, options.getStreamTransactionId() != null).getDocument(determineDocumentKeyFromId(id), entityClass, options);
518+
T res = _collection(entityClass, id, options != null && options.getStreamTransactionId() != null).getDocument(determineDocumentKeyFromId(id), entityClass, options);
519519
if (res != null) {
520520
potentiallyEmitEvent(new AfterLoadEvent<>(res));
521521
}
@@ -538,7 +538,7 @@ public <T> Iterable<T> findAll(final Iterable<?> ids, final Class<T> entityClass
538538
try {
539539
final Collection<String> keys = new ArrayList<>();
540540
ids.forEach(id -> keys.add(determineDocumentKeyFromId(id)));
541-
Collection<T> docs = _collection(entityClass, options.getStreamTransactionId() != null).getDocuments(keys, entityClass).getDocuments();
541+
Collection<T> docs = _collection(entityClass, options != null && options.getStreamTransactionId() != null).getDocuments(keys, entityClass).getDocuments();
542542
for (T doc : docs) {
543543
if (doc != null) {
544544
potentiallyEmitEvent(new AfterLoadEvent<>(doc));
@@ -558,7 +558,7 @@ public <T> MultiDocumentEntity<DocumentCreateEntity<T>> insertAll(
558558

559559
MultiDocumentEntity<DocumentCreateEntity<T>> result;
560560
try {
561-
result = _collection(entityClass, options.getStreamTransactionId() != null).insertDocuments(toList(values), options, entityClass);
561+
result = _collection(entityClass, options != null && options.getStreamTransactionId() != null).insertDocuments(toList(values), options, entityClass);
562562
} catch (final ArangoDBException e) {
563563
throw translateException(e);
564564
}
@@ -574,7 +574,7 @@ public <T> DocumentCreateEntity<T> insert(final T value, final DocumentCreateOpt
574574

575575
DocumentCreateEntity<T> result;
576576
try {
577-
result = _collection(value.getClass(), options.getStreamTransactionId() != null).insertDocument(value, options);
577+
result = _collection(value.getClass(), options != null && options.getStreamTransactionId() != null).insertDocument(value, options);
578578
} catch (final ArangoDBException e) {
579579
throw translateException(e);
580580
}
@@ -587,7 +587,7 @@ public <T> DocumentCreateEntity<T> insert(final T value, final DocumentCreateOpt
587587
@Override
588588
public <T> T repsert(final T value, AqlQueryOptions options) throws DataAccessException {
589589
@SuppressWarnings("unchecked") final Class<T> clazz = (Class<T>) value.getClass();
590-
final String collectionName = _collection(clazz, options.getStreamTransactionId() != null).name();
590+
final String collectionName = _collection(clazz, options != null && options.getStreamTransactionId() != null).name();
591591

592592
potentiallyEmitEvent(new BeforeSaveEvent<>(value));
593593

@@ -619,7 +619,7 @@ public <T> Iterable<T> repsertAll(final Iterable<T> values, final Class<? super
619619
return Collections.emptyList();
620620
}
621621

622-
final String collectionName = _collection(entityClass, options.getStreamTransactionId() != null).name();
622+
final String collectionName = _collection(entityClass, options != null && options.getStreamTransactionId() != null).name();
623623
potentiallyEmitBeforeSaveEvent(values);
624624

625625
Map<String, Object> bindVars = new HashMap<>();
@@ -720,7 +720,7 @@ private void updateDBFields(final Object value, final DocumentEntity documentEnt
720720
@Override
721721
public boolean exists(final Object id, final Class<?> entityClass, DocumentExistsOptions options) throws DataAccessException {
722722
try {
723-
return _collection(entityClass, options.getStreamTransactionId() != null).documentExists(determineDocumentKeyFromId(id), options);
723+
return _collection(entityClass, options != null && options.getStreamTransactionId() != null).documentExists(determineDocumentKeyFromId(id), options);
724724
} catch (final ArangoDBException e) {
725725
throw translateException(e);
726726
}
@@ -840,7 +840,7 @@ private <T> List<T> toList(Iterable<T> it) {
840840
return l;
841841
}
842842

843-
private AqlQueryOptions asQueryOptions(DocumentReadOptions source) {
843+
private static AqlQueryOptions asQueryOptions(DocumentReadOptions source) {
844844
return new AqlQueryOptions().streamTransactionId(source.getStreamTransactionId()).allowDirtyRead(source.getAllowDirtyRead());
845845
}
846846
}

0 commit comments

Comments
 (0)