@SuppressWarnings("unchecked") @Override public DocumentCreateEntity<T> deserialize(final Response response) throws VPackException { final VPackSlice body = response.getBody(); final DocumentCreateEntity<T> doc = util().deserialize(body, DocumentCreateEntity.class); final VPackSlice newDoc = body.get(NEW); if (newDoc.isObject()) { doc.setNew((T) util(Serializer.CUSTOM).deserialize(newDoc, value.getClass())); } final VPackSlice oldDoc = body.get(OLD); if (oldDoc.isObject()) { doc.setOld((T) util(Serializer.CUSTOM).deserialize(oldDoc, value.getClass())); } if (options == null || Boolean.TRUE != options.getSilent()) { final Map<DocumentField.Type, String> values = new HashMap<DocumentField.Type, String>(); values.put(DocumentField.Type.ID, doc.getId()); values.put(DocumentField.Type.KEY, doc.getKey()); values.put(DocumentField.Type.REV, doc.getRev()); executor.documentCache().setValues(value, values); } return doc; } };
protected <T> Request insertDocumentRequest(final T value, final DocumentCreateOptions options) { final Request request = request(db.name(), RequestType.POST, PATH_API_DOCUMENT, name); final DocumentCreateOptions params = (options != null ? options : new DocumentCreateOptions()); request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync()); request.putQueryParam(RETURN_NEW, params.getReturnNew()); request.putQueryParam(RETURN_OLD, params.getReturnOld()); request.putQueryParam(SILENT, params.getSilent()); request.putQueryParam(OVERWRITE, params.getOverwrite()); request.setBody(util(Serializer.CUSTOM).serialize(value)); return request; }
protected <T> Request insertDocumentsRequest(final Collection<T> values, final DocumentCreateOptions params) { final Request request = request(db.name(), RequestType.POST, PATH_API_DOCUMENT, name); request.putQueryParam(ArangoRequestParam.WAIT_FOR_SYNC, params.getWaitForSync()); request.putQueryParam(RETURN_NEW, params.getReturnNew()); request.putQueryParam(RETURN_OLD, params.getReturnOld()); request.putQueryParam(SILENT, params.getSilent()); request.putQueryParam(OVERWRITE, params.getOverwrite()); request.setBody(util(Serializer.CUSTOM).serialize(values, new ArangoSerializer.Options().serializeNullValues(false).stringAsJson(true))); return request; }