use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class GraphService method updateVertex.
public Vertex updateVertex(int connId, VertexEntity entity) {
HugeClient client = this.client(connId);
GraphManager graph = client.graph();
Vertex vertex = this.buildVertex(connId, entity);
// TODO: client should add updateVertex() method
return graph.addVertex(vertex);
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class GraphService method fillProperties.
private void fillProperties(int connId, SchemaLabelEntity schema, GraphElement element, Map<String, Object> properties) {
HugeClient client = this.client(connId);
for (Map.Entry<String, Object> entry : properties.entrySet()) {
String key = entry.getKey();
Object rawValue = entry.getValue();
// Skip nullable property
if (schema.getNullableProps().contains(key)) {
if (rawValue instanceof String && StringUtils.isEmpty((String) rawValue)) {
continue;
}
}
PropertyKeyEntity pkEntity = this.pkService.get(key, connId);
PropertyKey propertyKey = PropertyKeyService.convert(pkEntity, client);
assert propertyKey != null;
Object value;
try {
// DataTypeUtil.convert in loader need param InputSource
FileSource source = new FileSource();
ListFormat listFormat = new ListFormat("", "", ",");
source.listFormat(listFormat);
value = DataTypeUtil.convert(rawValue, propertyKey, source);
} catch (IllegalArgumentException e) {
throw new ExternalException("graph.property.convert.failed", e, key, rawValue);
}
element.property(key, value);
}
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class GraphService method updateEdge.
public Edge updateEdge(int connId, EdgeEntity entity) {
HugeClient client = this.client(connId);
GraphManager graph = client.graph();
EdgeHolder edgeHolder = this.buildEdge(connId, entity);
// TODO: client should add updateEdge()
return graph.addEdge(edgeHolder.edge);
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class GraphService method addEdge.
public GraphView addEdge(int connId, EdgeEntity entity) {
HugeClient client = this.client(connId);
GraphManager graph = client.graph();
EdgeHolder edgeHolder = this.buildEdge(connId, entity);
Edge edge = graph.addEdge(edgeHolder.edge);
Vertex source = edgeHolder.source;
Vertex target = edgeHolder.target;
return GraphView.builder().vertices(ImmutableSet.of(source, target)).edges(ImmutableSet.of(edge)).build();
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelService method list.
public List<EdgeLabelEntity> list(Collection<String> names, int connId, boolean emptyAsAll) {
HugeClient client = this.client(connId);
List<EdgeLabel> edgeLabels;
if (CollectionUtils.isEmpty(names)) {
if (emptyAsAll) {
edgeLabels = client.schema().getEdgeLabels();
} else {
edgeLabels = new ArrayList<>();
}
} else {
edgeLabels = client.schema().getEdgeLabels(new ArrayList<>(names));
}
List<IndexLabel> indexLabels = client.schema().getIndexLabels();
List<EdgeLabelEntity> results = new ArrayList<>(edgeLabels.size());
edgeLabels.forEach(edgeLabel -> {
results.add(convert(edgeLabel, indexLabels));
});
return results;
}
Aggregations