Skip to content

Commit 407a70a

Browse files
author
Mark
committed
Merge remote-tracking branch 'origin/4.1'
2 parents f63d9b7 + 0f9bb49 commit 407a70a

33 files changed

+1628
-127
lines changed

ChangeLog

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
v4.1.6 (2017-01-18)
2+
---------------------------
3+
* added serializer support for enclosing types
4+
5+
v4.1.5 (2017-01-12)
6+
---------------------------
7+
* fixed VPack String serialization (UTF-8 encoding)
8+
* fixed VPack parsing of fields of type Object
9+
* fixed VPack serializing of array with null values (issue #88)
10+
* added configuration for custom annotations within VPack de-/serialization
11+
* added support of transient modifier within VPack de-/serialization
12+
13+
v4.1.4 (2016-12-19)
14+
---------------------------
15+
* added VPack serializer/de-serializer for java.util.UUID
16+
* fixed VPack parsing (issue #65, #80, #82)
17+
18+
v4.1.3 (2016-11-22)
19+
---------------------------
20+
* fixed error while serializing long values with VPackBuilder
21+
* added bulk import API
22+
23+
v4.1.2 (2016-11-10)
24+
---------------------------
25+
* fixed GraphEntity for ArangoDatabase.getGraphs() (field name is null)
26+
* added VelocyPack UTC_DATE parsing to Json String (ISO 8601)
27+
* added configuration methods for VPackParser in ArangoDB.Builder
28+
* added VPackJsonSerializer for VPackParser
29+
130
v4.1.1 (2016-11-09)
231
---------------------------
332
* changed json parsing of VelocyPack types not known in json

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.arangodb</groupId>
66
<artifactId>arangodb-java-driver</artifactId>
7-
<version>4.1.2-SNAPSHOT</version>
7+
<version>4.1.7-SNAPSHOT</version>
88
<inceptionYear>2016</inceptionYear>
99
<packaging>jar</packaging>
1010

src/main/java/com/arangodb/ArangoCollection.java

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@
3030
import com.arangodb.entity.CollectionRevisionEntity;
3131
import com.arangodb.entity.DocumentCreateEntity;
3232
import com.arangodb.entity.DocumentDeleteEntity;
33+
import com.arangodb.entity.DocumentImportEntity;
3334
import com.arangodb.entity.DocumentUpdateEntity;
3435
import com.arangodb.entity.IndexEntity;
3536
import com.arangodb.entity.MultiDocumentEntity;
36-
import com.arangodb.internal.InternalArangoCollection;
3737
import com.arangodb.internal.ArangoExecutorSync;
38+
import com.arangodb.internal.InternalArangoCollection;
3839
import com.arangodb.internal.velocystream.ConnectionSync;
3940
import com.arangodb.model.CollectionPropertiesOptions;
4041
import com.arangodb.model.DocumentCreateOptions;
4142
import com.arangodb.model.DocumentDeleteOptions;
4243
import com.arangodb.model.DocumentExistsOptions;
44+
import com.arangodb.model.DocumentImportOptions;
4345
import com.arangodb.model.DocumentReadOptions;
4446
import com.arangodb.model.DocumentReplaceOptions;
4547
import com.arangodb.model.DocumentUpdateOptions;
@@ -135,6 +137,61 @@ public <T> MultiDocumentEntity<DocumentCreateEntity<T>> insertDocuments(
135137
insertDocumentsResponseDeserializer(values, params));
136138
}
137139

140+
/**
141+
* Imports documents
142+
*
143+
* @param values
144+
* a list of Objects that will be stored as documents
145+
* @return information about the import
146+
* @throws ArangoDBException
147+
*/
148+
public DocumentImportEntity importDocuments(final Collection<?> values) throws ArangoDBException {
149+
return importDocuments(values, new DocumentImportOptions());
150+
}
151+
152+
/**
153+
* Imports documents
154+
*
155+
* @param values
156+
* a list of Objects that will be stored as documents
157+
* @param options
158+
* Additional options, can be null
159+
* @return information about the import
160+
* @throws ArangoDBException
161+
*/
162+
public DocumentImportEntity importDocuments(final Collection<?> values, final DocumentImportOptions options)
163+
throws ArangoDBException {
164+
return executor.execute(importDocumentsRequest(values, options), DocumentImportEntity.class);
165+
}
166+
167+
/**
168+
* Imports documents
169+
*
170+
* @param values
171+
* JSON-encoded array of objects that will be stored as documents
172+
* @return information about the import
173+
* @throws ArangoDBException
174+
*/
175+
public DocumentImportEntity importDocuments(final String values) throws ArangoDBException {
176+
return executor.execute(importDocumentsRequest(values, new DocumentImportOptions()),
177+
DocumentImportEntity.class);
178+
}
179+
180+
/**
181+
* Imports documents
182+
*
183+
* @param values
184+
* JSON-encoded array of objects that will be stored as documents
185+
* @param options
186+
* Additional options, can be null
187+
* @return information about the import
188+
* @throws ArangoDBException
189+
*/
190+
public DocumentImportEntity importDocuments(final String values, final DocumentImportOptions options)
191+
throws ArangoDBException {
192+
return executor.execute(importDocumentsRequest(values, options), DocumentImportEntity.class);
193+
}
194+
138195
/**
139196
* Reads a single document
140197
*

src/main/java/com/arangodb/ArangoDB.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.io.IOException;
2424
import java.io.InputStream;
25+
import java.lang.annotation.Annotation;
2526
import java.util.Collection;
2627
import java.util.Properties;
2728

@@ -46,10 +47,15 @@
4647
import com.arangodb.model.UserCreateOptions;
4748
import com.arangodb.model.UserUpdateOptions;
4849
import com.arangodb.velocypack.VPack;
50+
import com.arangodb.velocypack.VPackAnnotationFieldFilter;
51+
import com.arangodb.velocypack.VPackAnnotationFieldNaming;
4952
import com.arangodb.velocypack.VPackDeserializer;
5053
import com.arangodb.velocypack.VPackInstanceCreator;
54+
import com.arangodb.velocypack.VPackJsonDeserializer;
55+
import com.arangodb.velocypack.VPackJsonSerializer;
5156
import com.arangodb.velocypack.VPackParser;
5257
import com.arangodb.velocypack.VPackSerializer;
58+
import com.arangodb.velocypack.ValueType;
5359
import com.arangodb.velocypack.exception.VPackException;
5460
import com.arangodb.velocystream.Request;
5561
import com.arangodb.velocystream.Response;
@@ -169,6 +175,20 @@ public <T> Builder registerSerializer(final Class<T> clazz, final VPackSerialize
169175
return this;
170176
}
171177

178+
/**
179+
* Register a special serializer for a member class which can only be identified by its enclosing class.
180+
*
181+
* @param clazz
182+
* type of the enclosing class
183+
* @param serializer
184+
* serializer to register
185+
* @return builder
186+
*/
187+
public <T> Builder registerEnclosingSerializer(final Class<T> clazz, final VPackSerializer<T> serializer) {
188+
vpackBuilder.registerEnclosingSerializer(clazz, serializer);
189+
return this;
190+
}
191+
172192
public <T> Builder registerDeserializer(final Class<T> clazz, final VPackDeserializer<T> deserializer) {
173193
vpackBuilder.registerDeserializer(clazz, deserializer);
174194
return this;
@@ -179,6 +199,46 @@ public <T> Builder registerInstanceCreator(final Class<T> clazz, final VPackInst
179199
return this;
180200
}
181201

202+
public Builder registerJsonDeserializer(final ValueType type, final VPackJsonDeserializer deserializer) {
203+
vpackParser.registerDeserializer(type, deserializer);
204+
return this;
205+
}
206+
207+
public Builder registerJsonDeserializer(
208+
final String attribute,
209+
final ValueType type,
210+
final VPackJsonDeserializer deserializer) {
211+
vpackParser.registerDeserializer(attribute, type, deserializer);
212+
return this;
213+
}
214+
215+
public <T> Builder registerJsonSerializer(final Class<T> clazz, final VPackJsonSerializer<T> serializer) {
216+
vpackParser.registerSerializer(clazz, serializer);
217+
return this;
218+
}
219+
220+
public <T> Builder registerJsonSerializer(
221+
final String attribute,
222+
final Class<T> clazz,
223+
final VPackJsonSerializer<T> serializer) {
224+
vpackParser.registerSerializer(attribute, clazz, serializer);
225+
return this;
226+
}
227+
228+
public <A extends Annotation> Builder annotationFieldFilter(
229+
final Class<A> type,
230+
final VPackAnnotationFieldFilter<A> fieldFilter) {
231+
vpackBuilder.annotationFieldFilter(type, fieldFilter);
232+
return this;
233+
}
234+
235+
public <A extends Annotation> Builder annotationFieldNaming(
236+
final Class<A> type,
237+
final VPackAnnotationFieldNaming<A> fieldNaming) {
238+
vpackBuilder.annotationFieldNaming(type, fieldNaming);
239+
return this;
240+
}
241+
182242
public ArangoDB build() {
183243
return new ArangoDB(
184244
new CommunicationSync.Builder().host(host).port(port).timeout(timeout).user(user).password(password)
@@ -457,4 +517,5 @@ public LogLevelEntity getLogLevel() throws ArangoDBException {
457517
public LogLevelEntity setLogLevel(final LogLevelEntity entity) throws ArangoDBException {
458518
return executor.execute(setLogLevelRequest(entity), LogLevelEntity.class);
459519
}
520+
460521
}

src/main/java/com/arangodb/entity/BaseEdgeDocument.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public BaseEdgeDocument(final String from, final String to) {
4747
this.to = to;
4848
}
4949

50+
public BaseEdgeDocument(final String key, final String from, final String to) {
51+
super(key);
52+
this.from = from;
53+
this.to = to;
54+
}
55+
5056
public BaseEdgeDocument(final Map<String, Object> properties) {
5157
super(properties);
5258
final Object tmpFrom = properties.remove(DocumentField.Type.FROM.getSerializeName());
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.entity;
22+
23+
import java.util.ArrayList;
24+
import java.util.Collection;
25+
26+
/**
27+
* @author Mark - mark at arangodb.com
28+
*
29+
*/
30+
public class DocumentImportEntity {
31+
32+
private Integer created;
33+
private Integer errors;
34+
private Integer empty;
35+
private Integer updated;
36+
private Integer ignored;
37+
private Collection<String> details;
38+
39+
public DocumentImportEntity() {
40+
super();
41+
details = new ArrayList<String>();
42+
}
43+
44+
/**
45+
* @return number of documents imported.
46+
*/
47+
public Integer getCreated() {
48+
return created;
49+
}
50+
51+
public void setCreated(final Integer created) {
52+
this.created = created;
53+
}
54+
55+
/**
56+
* @return number of documents that were not imported due to an error.
57+
*/
58+
public Integer getErrors() {
59+
return errors;
60+
}
61+
62+
public void setErrors(final Integer errors) {
63+
this.errors = errors;
64+
}
65+
66+
/**
67+
* @return number of empty lines found in the input (will only contain a value greater zero for types documents or
68+
* auto).
69+
*/
70+
public Integer getEmpty() {
71+
return empty;
72+
}
73+
74+
public void setEmpty(final Integer empty) {
75+
this.empty = empty;
76+
}
77+
78+
/**
79+
* @return number of updated/replaced documents (in case onDuplicate was set to either update or replace).
80+
*/
81+
public Integer getUpdated() {
82+
return updated;
83+
}
84+
85+
public void setUpdated(final Integer updated) {
86+
this.updated = updated;
87+
}
88+
89+
/**
90+
* @return number of failed but ignored insert operations (in case onDuplicate was set to ignore).
91+
*/
92+
public Integer getIgnored() {
93+
return ignored;
94+
}
95+
96+
public void setIgnored(final Integer ignored) {
97+
this.ignored = ignored;
98+
}
99+
100+
/**
101+
* @return if query parameter details is set to true, the result contain details with more detailed information
102+
* about which documents could not be inserted.
103+
*/
104+
public Collection<String> getDetails() {
105+
return details;
106+
}
107+
108+
public void setDetails(final Collection<String> details) {
109+
this.details = details;
110+
}
111+
112+
}

src/main/java/com/arangodb/entity/GraphEntity.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@
3030
public class GraphEntity {
3131

3232
private String name;
33+
/**
34+
* Special case where <code>_key</code> is used instead of <code>name</code>.
35+
*/
36+
private String _key;
3337
private Collection<EdgeDefinition> edgeDefinitions;
3438
private Collection<String> orphanCollections;
3539
private Boolean isSmart;
3640
private Integer numberOfShards;
3741
private String smartGraphAttribute;
3842

3943
public String getName() {
40-
return name;
44+
return name != null ? name : _key;
4145
}
4246

4347
public Collection<EdgeDefinition> getEdgeDefinitions() {

src/main/java/com/arangodb/internal/ArangoDBConstants.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class ArangoDBConstants {
5858
public static final String PATH_API_ADMIN_LOG = "/_admin/log";
5959
public static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level";
6060
public static final String PATH_API_ADMIN_ROUTING_RELOAD = "/_admin/routing/reload";
61+
public static final String PATH_API_IMPORT = "/_api/import";
6162

6263
public static final String ENCRYPTION_PLAIN = "plain";
6364

@@ -101,4 +102,12 @@ public class ArangoDBConstants {
101102
public static final String VERTEX = "vertex";
102103
public static final String EDGE = "edge";
103104
public static final String ERROR = "error";
105+
public static final String FROM_PREFIX = "fromPrefix";
106+
public static final String TO_PREFIX = "toPrefix";
107+
public static final String OVERWRITE = "overwrite";
108+
public static final String ON_DUPLICATE = "onDuplicate";
109+
public static final String COMPLETE = "complete";
110+
public static final String DETAILS = "details";
111+
public static final String TYPE = "type";
112+
104113
}

0 commit comments

Comments
 (0)