use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelService method get.
public EdgeLabelEntity get(String name, int connId) {
HugeClient client = this.client(connId);
try {
EdgeLabel edgeLabel = client.schema().getEdgeLabel(name);
List<IndexLabel> indexLabels = client.schema().getIndexLabels();
return convert(edgeLabel, indexLabels);
} catch (ServerException e) {
if (e.status() == Constant.STATUS_NOT_FOUND) {
throw new ExternalException("schema.edgelabel.not-exist", e, name);
}
throw new ExternalException("schema.edgelabel.get.failed", e, name);
}
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyService method checkUsing.
/**
* Check the property key is being used, used means that there is
* any vertex label or edge label contains the property(name)
*/
public boolean checkUsing(String name, int connId) {
HugeClient client = this.client(connId);
List<VertexLabel> vertexLabels = client.schema().getVertexLabels();
for (VertexLabel vertexLabel : vertexLabels) {
if (vertexLabel.properties().contains(name)) {
return true;
}
}
List<EdgeLabel> edgeLabels = client.schema().getEdgeLabels();
for (EdgeLabel edgeLabel : edgeLabels) {
if (edgeLabel.properties().contains(name)) {
return true;
}
}
return false;
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyService method add.
public void add(PropertyKeyEntity entity, int connId) {
HugeClient client = this.client(connId);
PropertyKey propertyKey = convert(entity, client);
client.schema().addPropertyKey(propertyKey);
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyService method list.
public List<PropertyKeyEntity> list(Collection<String> names, int connId, boolean emptyAsAll) {
HugeClient client = this.client(connId);
List<PropertyKey> propertyKeys;
if (CollectionUtils.isEmpty(names)) {
if (emptyAsAll) {
propertyKeys = client.schema().getPropertyKeys();
} else {
propertyKeys = new ArrayList<>();
}
} else {
propertyKeys = client.schema().getPropertyKeys(new ArrayList<>(names));
}
List<PropertyKeyEntity> results = new ArrayList<>(propertyKeys.size());
propertyKeys.forEach(propertyKey -> {
results.add(convert(propertyKey));
});
return results;
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyService method remove.
public void remove(String name, int connId) {
HugeClient client = this.client(connId);
client.schema().removePropertyKey(name);
}
Aggregations