Skip to content

Commit a7a36ad

Browse files
committed
#80 refactor resolvers: prepare read and query options
1 parent 18fbb3a commit a7a36ad

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ private Class<?> enhancedTypeFor(final Class<?> type) {
102102
return enhancer.createClass();
103103
}
104104

105+
protected DocumentReadOptions defaultReadOptions() {
106+
DocumentReadOptions options = new DocumentReadOptions();
107+
return options;
108+
}
109+
110+
protected AqlQueryOptions defaultQueryOptions() {
111+
AqlQueryOptions options = new AqlQueryOptions();
112+
return options;
113+
}
114+
105115
static class ProxyInterceptor<A extends Annotation> implements Serializable,
106116
org.springframework.cglib.proxy.MethodInterceptor, org.aopalliance.intercept.MethodInterceptor {
107117

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.springframework.data.util.TypeInformation;
2424

2525
import com.arangodb.ArangoCursor;
26-
import com.arangodb.model.AqlQueryOptions;
2726
import com.arangodb.springframework.annotation.From;
2827
import com.arangodb.springframework.core.ArangoOperations;
2928
import com.arangodb.util.MapBuilder;
@@ -63,8 +62,8 @@ private Object _resolveMultiple(final String id, final TypeInformation<?> type)
6362

6463
private ArangoCursor<?> _resolve(final String id, final Class<?> type, final boolean limit) {
6564
final String query = String.format("FOR e IN @@edge FILTER e._from == @id %s RETURN e", limit ? "LIMIT 1" : "");
66-
return template.query(query, new MapBuilder().put("@edge", type).put("id", id).get(), new AqlQueryOptions(),
67-
type);
65+
return template.query(query, new MapBuilder().put("@edge", type).put("id", id).get(),
66+
defaultQueryOptions(), type);
6867
}
6968

7069
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.springframework.data.util.TypeInformation;
2424

2525
import com.arangodb.ArangoCursor;
26-
import com.arangodb.model.AqlQueryOptions;
2726
import com.arangodb.springframework.annotation.To;
2827
import com.arangodb.springframework.core.ArangoOperations;
2928
import com.arangodb.util.MapBuilder;
@@ -62,8 +61,8 @@ private Object _resolveMultiple(final String id, final TypeInformation<?> type)
6261

6362
private ArangoCursor<?> _resolve(final String id, final Class<?> type, final boolean limit) {
6463
final String query = String.format("FOR e IN @@edge FILTER e._to == @id RETURN e", limit ? "LIMIT 1" : "");
65-
return template.query(query, new MapBuilder().put("@edge", type).put("id", id).get(), new AqlQueryOptions(),
66-
type);
64+
return template.query(query, new MapBuilder().put("@edge", type).put("id", id).get(),
65+
defaultQueryOptions(), type);
6766
}
6867

6968
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Object resolveOne(final String id, final TypeInformation<?> type, Collect
4343
}
4444

4545
private Object _resolveOne(final String id, final TypeInformation<?> type) {
46-
return template.find(id, type.getType()).get();
46+
return template.find(id, type.getType(), defaultReadOptions()).get();
4747
}
4848

4949
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Object resolveOne(final String id, final TypeInformation<?> type, Collect
4343
}
4444

4545
private Object _resolveOne(final String id, final TypeInformation<?> type) {
46-
return template.find(id, type.getType()).get();
46+
return template.find(id, type.getType(), defaultReadOptions()).get();
4747
}
4848

4949
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Object resolveMultiple(final Collection<String> ids, final TypeInformatio
5555

5656
@Override
5757
public Object resolve(final String id, final TypeInformation<?> type, final Ref annotation) {
58-
return template.find(id, type.getType()).get();
58+
return template.find(id, type.getType(), defaultReadOptions()).get();
5959
}
6060

6161
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private ArangoCursor<?> _resolve(
100100
edges, //
101101
limit ? "LIMIT 1" : "");
102102

103-
return template.query(query, bindVars.get(), type);
103+
return template.query(query, bindVars.get(), defaultQueryOptions(), type);
104104
}
105105

106106
}

0 commit comments

Comments
 (0)