Skip to content

Commit 0f6ec39

Browse files
author
a-brandt
committed
added importDocumentsByHeaderValuesRaw
1 parent 7e04b3d commit 0f6ec39

File tree

3 files changed

+90
-18
lines changed

3 files changed

+90
-18
lines changed

src/main/java/com/arangodb/ArangoDriver.java

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
import com.arangodb.util.GraphQueryUtil;
8383
import com.arangodb.util.GraphVerticesOptions;
8484
import com.arangodb.util.ImportOptions;
85+
import com.arangodb.util.ImportOptionsJson;
8586
import com.arangodb.util.ImportOptionsRaw;
8687
import com.arangodb.util.MapBuilder;
8788
import com.arangodb.util.ShortestPathOptions;
@@ -2977,7 +2978,7 @@ public List<UserEntity> getUsers() throws ArangoException {
29772978
*/
29782979
public ImportResultEntity importDocuments(final String collection, final Collection<?> values)
29792980
throws ArangoException {
2980-
return importDriver.importDocuments(getDefaultDatabase(), collection, values, new ImportOptions());
2981+
return importDriver.importDocuments(getDefaultDatabase(), collection, values, new ImportOptionsJson());
29812982
}
29822983

29832984
/**
@@ -2987,16 +2988,16 @@ public ImportResultEntity importDocuments(final String collection, final Collect
29872988
* the collection as a string
29882989
* @param values
29892990
* a list of Objects that will be stored as documents
2990-
* @param importOptions
2991+
* @param importOptionsJson
29912992
* options for importing documents
29922993
* @return ImportResultEntity
29932994
* @throws ArangoException
29942995
*/
29952996
public ImportResultEntity importDocuments(
29962997
final String collection,
29972998
final Collection<?> values,
2998-
final ImportOptions importOptions) throws ArangoException {
2999-
return importDriver.importDocuments(getDefaultDatabase(), collection, values, importOptions);
2999+
final ImportOptionsJson importOptionsJson) throws ArangoException {
3000+
return importDriver.importDocuments(getDefaultDatabase(), collection, values, importOptionsJson);
30003001
}
30013002

30023003
/**
@@ -3019,7 +3020,7 @@ public ImportResultEntity importDocumentsRaw(
30193020
}
30203021

30213022
/**
3022-
* Creates documents in the collection.
3023+
* Creates documents in a collection.
30233024
*
30243025
* @param collection
30253026
* the collection as a string
@@ -3031,7 +3032,49 @@ public ImportResultEntity importDocumentsRaw(
30313032
public ImportResultEntity importDocumentsByHeaderValues(
30323033
final String collection,
30333034
final Collection<? extends Collection<?>> headerValues) throws ArangoException {
3034-
return importDriver.importDocumentsByHeaderValues(getDefaultDatabase(), collection, headerValues);
3035+
return importDriver.importDocumentsByHeaderValues(getDefaultDatabase(), collection, headerValues,
3036+
new ImportOptions());
3037+
}
3038+
3039+
/**
3040+
* Creates documents in a collection.
3041+
*
3042+
* @param collection
3043+
* the collection as a string
3044+
* @param headerValues
3045+
* a list of lists that will be stored as documents
3046+
* @param importOptions
3047+
* options for importing documents
3048+
* @return ImportResultEntity
3049+
* @throws ArangoException
3050+
*/
3051+
public ImportResultEntity importDocumentsByHeaderValues(
3052+
final String collection,
3053+
final Collection<? extends Collection<?>> headerValues,
3054+
ImportOptions importOptions) throws ArangoException {
3055+
return importDriver.importDocumentsByHeaderValues(getDefaultDatabase(), collection, headerValues,
3056+
importOptions);
3057+
}
3058+
3059+
/**
3060+
* Creates documents in a collection.
3061+
*
3062+
* @param collection
3063+
* the collection as a string
3064+
* @param headerValues
3065+
* raw JSON data that contains a list of lists that will be
3066+
* stored as documents
3067+
* @param importOptions
3068+
* options for importing documents
3069+
* @return ImportResultEntity
3070+
* @throws ArangoException
3071+
*/
3072+
public ImportResultEntity importDocumentsByHeaderValuesRaw(
3073+
final String collection,
3074+
String headerValues,
3075+
ImportOptions importOptions) throws ArangoException {
3076+
return importDriver.importDocumentsByHeaderValuesRaw(getDefaultDatabase(), collection, headerValues,
3077+
importOptions);
30353078
}
30363079

30373080
/**

src/main/java/com/arangodb/InternalImportDriver.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.arangodb.entity.ImportResultEntity;
66
import com.arangodb.impl.BaseDriverInterface;
77
import com.arangodb.util.ImportOptions;
8+
import com.arangodb.util.ImportOptionsJson;
89
import com.arangodb.util.ImportOptionsRaw;
910

1011
/**
@@ -16,7 +17,7 @@ ImportResultEntity importDocuments(
1617
String database,
1718
String collection,
1819
Collection<?> values,
19-
ImportOptions importOptions) throws ArangoException;
20+
ImportOptionsJson importOptionsJson) throws ArangoException;
2021

2122
ImportResultEntity importDocumentsRaw(
2223
String database,
@@ -27,6 +28,12 @@ ImportResultEntity importDocumentsRaw(
2728
ImportResultEntity importDocumentsByHeaderValues(
2829
String database,
2930
String collection,
30-
Collection<? extends Collection<?>> headerValues) throws ArangoException;
31+
Collection<? extends Collection<?>> headerValues,
32+
ImportOptions importOptions) throws ArangoException;
3133

34+
ImportResultEntity importDocumentsByHeaderValuesRaw(
35+
String database,
36+
String collection,
37+
String headerValues,
38+
ImportOptions importOptions) throws ArangoException;
3239
}

src/main/java/com/arangodb/impl/InternalImportDriverImpl.java

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import com.arangodb.http.HttpManager;
2727
import com.arangodb.http.HttpResponseEntity;
2828
import com.arangodb.util.ImportOptions;
29+
import com.arangodb.util.ImportOptionsJson;
2930
import com.arangodb.util.ImportOptionsRaw;
30-
import com.arangodb.util.MapBuilder;
3131

3232
/**
3333
* @author tamtam180 - kirscheless at gmail.com
@@ -46,9 +46,9 @@ public ImportResultEntity importDocuments(
4646
String database,
4747
String collection,
4848
Collection<?> values,
49-
ImportOptions importOptions) throws ArangoException {
49+
ImportOptionsJson importOptionsJson) throws ArangoException {
5050

51-
Map<String, Object> map = importOptions.toMap();
51+
Map<String, Object> map = importOptionsJson.toMap();
5252
map.put("type", "list");
5353

5454
return importDocumentsInternal(database, collection, EntityFactory.toJsonString(values), map);
@@ -64,7 +64,28 @@ public ImportResultEntity importDocumentsRaw(
6464
return importDocumentsInternal(database, collection, values, importOptionsRaw.toMap());
6565
}
6666

67-
public ImportResultEntity importDocumentsInternal(
67+
@Override
68+
public ImportResultEntity importDocumentsByHeaderValues(
69+
String database,
70+
String collection,
71+
Collection<? extends Collection<?>> headerValues,
72+
ImportOptions importOptions) throws ArangoException {
73+
74+
return importDocumentsByHeaderValuesInternal(database, collection,
75+
EntityFactory.toImportHeaderValues(headerValues), importOptions);
76+
}
77+
78+
@Override
79+
public ImportResultEntity importDocumentsByHeaderValuesRaw(
80+
String database,
81+
String collection,
82+
String headerValues,
83+
ImportOptions importOptions) throws ArangoException {
84+
85+
return importDocumentsByHeaderValuesInternal(database, collection, headerValues, importOptions);
86+
}
87+
88+
private ImportResultEntity importDocumentsInternal(
6889
String database,
6990
String collection,
7091
String values,
@@ -75,17 +96,18 @@ public ImportResultEntity importDocumentsInternal(
7596
HttpResponseEntity res = httpManager.doPost(createEndpointUrl(database, "/_api/import"), importOptions, values);
7697

7798
return createEntity(res, ImportResultEntity.class);
78-
7999
}
80100

81-
@Override
82-
public ImportResultEntity importDocumentsByHeaderValues(
101+
private ImportResultEntity importDocumentsByHeaderValuesInternal(
83102
String database,
84103
String collection,
85-
Collection<? extends Collection<?>> headerValues) throws ArangoException {
104+
String headerValues,
105+
ImportOptions importOptions) throws ArangoException {
106+
107+
Map<String, Object> map = importOptions.toMap();
108+
map.put(COLLECTION, collection);
86109

87-
HttpResponseEntity res = httpManager.doPost(createEndpointUrl(database, "/_api/import"),
88-
new MapBuilder().put(COLLECTION, collection).get(), EntityFactory.toImportHeaderValues(headerValues));
110+
HttpResponseEntity res = httpManager.doPost(createEndpointUrl(database, "/_api/import"), map, headerValues);
89111

90112
return createEntity(res, ImportResultEntity.class);
91113

0 commit comments

Comments
 (0)