use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class VertexLabelService method getLinkEdgeLabels.
public List<String> getLinkEdgeLabels(String name, int connId) {
HugeClient client = this.client(connId);
List<EdgeLabel> edgeLabels = client.schema().getEdgeLabels();
List<String> results = new ArrayList<>();
for (EdgeLabel edgeLabel : edgeLabels) {
if (edgeLabel.linkedVertexLabel(name)) {
results.add(edgeLabel.name());
}
}
return results;
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class AsyncTaskService method list.
public IPage<Task> list(int connId, int pageNo, int pageSize, String content, String type, String status) {
HugeClient client = this.getClient(connId);
if (status.isEmpty()) {
status = null;
}
List<Task> tasks = client.task().list(status);
List<Task> result = new ArrayList<>();
for (Task task : tasks) {
if (!type.isEmpty() && !type.equals(task.type())) {
continue;
}
if (!content.isEmpty()) {
String taskId = String.valueOf(task.id());
if (!content.equals(taskId) && !task.name().contains(content)) {
continue;
}
}
result.add(task);
}
result.sort(Comparator.comparing(Task::createTime).reversed());
return PageUtil.page(result, pageNo, pageSize);
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class AsyncTaskService method remove.
public void remove(int connId, int id) {
HugeClient client = this.getClient(connId);
client.task().delete(id);
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class GroovyExecutor method execute.
public void execute(String groovyScript, HugeClient client) {
CompilerConfiguration config = new CompilerConfiguration();
config.setScriptBaseClass(DelegatingScript.class.getName());
ImportCustomizer importCustomizer = new ImportCustomizer();
importCustomizer.addImports(HugeClient.class.getName());
importCustomizer.addImports(SchemaManager.class.getName());
config.addCompilationCustomizers(importCustomizer);
GroovyShell shell = new GroovyShell(getClass().getClassLoader(), this.binding, config);
// Groovy invoke java through the delegating script.
DelegatingScript script = (DelegatingScript) shell.parse(groovyScript);
script.setDelegate(client);
script.run();
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class VertexLabelService method update.
public void update(VertexLabelUpdateEntity entity, int connId) {
HugeClient client = this.client(connId);
VertexLabel vertexLabel = convert(entity, client);
// All existed indexlabels
List<IndexLabel> existedIndexLabels = client.schema().getIndexLabels();
List<String> existedIndexLabelNames = collectNames(existedIndexLabels);
List<String> addedIndexLabelNames = entity.getAppendPropertyIndexNames();
List<IndexLabel> addedIndexLabels = convertIndexLabels(entity.getAppendPropertyIndexes(), client, true, entity.getName());
List<String> removedIndexLabelNames = entity.getRemovePropertyIndexes();
if (addedIndexLabelNames != null) {
for (String name : addedIndexLabelNames) {
if (existedIndexLabelNames.contains(name)) {
throw new ExternalException("schema.vertexlabel.update.append-index-existed", entity.getName(), name);
}
}
}
if (removedIndexLabelNames != null) {
for (String name : removedIndexLabelNames) {
if (!existedIndexLabelNames.contains(name)) {
throw new ExternalException("schema.vertexlabel.update.remove-index-unexisted", entity.getName(), name);
}
}
}
try {
// NOTE: property can append but doesn't support eliminate now
client.schema().appendVertexLabel(vertexLabel);
} catch (Exception e) {
throw new ExternalException("schema.vertexlabel.update.failed", e, entity.getName());
}
this.piService.addBatch(addedIndexLabels, client);
this.piService.removeBatch(removedIndexLabelNames, client);
}
Aggregations