Search in sources :

Example 1 with NotAllCreatedException

use of com.baidu.hugegraph.exception.NotAllCreatedException in project incubator-hugegraph-toolchain by apache.

the class EdgeAPI method create.

public List<String> create(List<Edge> edges, boolean checkVertex) {
    MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<>();
    headers.putSingle("Content-Encoding", BATCH_ENCODING);
    Map<String, Object> params = ImmutableMap.of("check_vertex", checkVertex);
    RestResult result = this.client.post(this.batchPath(), edges, headers, params);
    List<String> ids = result.readList(String.class);
    if (edges.size() != ids.size()) {
        throw new NotAllCreatedException("Not all edges are successfully created, " + "expect '%s', the actual is '%s'", ids, edges.size(), ids.size());
    }
    return ids;
}
Also used : MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) RestResult(com.baidu.hugegraph.rest.RestResult) NotAllCreatedException(com.baidu.hugegraph.exception.NotAllCreatedException)

Example 2 with NotAllCreatedException

use of com.baidu.hugegraph.exception.NotAllCreatedException in project incubator-hugegraph-toolchain by apache.

the class VertexAPI method create.

public List<Object> create(List<Vertex> vertices) {
    MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<>();
    headers.putSingle("Content-Encoding", BATCH_ENCODING);
    RestResult result = this.client.post(this.batchPath(), vertices, headers);
    List<Object> ids = result.readList(Object.class);
    if (vertices.size() != ids.size()) {
        throw new NotAllCreatedException("Not all vertices are successfully created, " + "expect '%s', the actual is '%s'", ids, vertices.size(), ids.size());
    }
    return ids;
}
Also used : MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) RestResult(com.baidu.hugegraph.rest.RestResult) NotAllCreatedException(com.baidu.hugegraph.exception.NotAllCreatedException)

Aggregations

NotAllCreatedException (com.baidu.hugegraph.exception.NotAllCreatedException)2 RestResult (com.baidu.hugegraph.rest.RestResult)2 MultivaluedHashMap (jakarta.ws.rs.core.MultivaluedHashMap)2