use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelApiTest method testDelete.
@Test
public void testDelete() {
EdgeLabel edgeLabel = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").singleTime().properties("date", "city").build();
edgeLabelAPI.create(edgeLabel);
long taskId = edgeLabelAPI.delete("created");
waitUntilTaskCompleted(taskId);
Utils.assertResponseError(404, () -> {
edgeLabelAPI.get("created");
});
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelApiTest method testCreateWithUndefinedVertexLabel.
@Test
public void testCreateWithUndefinedVertexLabel() {
EdgeLabel edgeLabel = schema().edgeLabel("created").sourceLabel("programmer").targetLabel("software").singleTime().properties("date", "city").build();
Utils.assertResponseError(400, () -> {
edgeLabelAPI.create(edgeLabel);
});
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project hugegraph-computer by hugegraph.
the class FileEdgeFetcher method buildElement.
@Override
protected List<Edge> buildElement(Line line, ElementBuilder<Edge> builder) {
List<Edge> edges = super.buildElement(line, builder);
for (Edge edge : edges) {
// generate edgeId
EdgeLabel edgeLabel = (EdgeLabel) builder.schemaLabel();
String edgeId = IdUtil.assignEdgeId(edge, edgeLabel);
edge.id(edgeId);
}
return edges;
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelService method convert.
private static EdgeLabel convert(EdgeLabelUpdateEntity entity, HugeClient client) {
if (entity == null) {
return null;
}
Set<String> properties = new HashSet<>();
if (entity.getAppendProperties() != null) {
entity.getAppendProperties().forEach(p -> {
properties.add(p.getName());
});
}
EdgeLabel.Builder builder;
builder = client.schema().edgeLabel(entity.getName()).properties(toStringArray(properties)).nullableKeys(toStringArray(properties));
EdgeLabel edgeLabel = builder.build();
Map<String, Object> userdata = edgeLabel.userdata();
EdgeLabelStyle style = entity.getStyle();
if (style != null) {
userdata.put(USER_KEY_STYLE, JsonUtil.toJson(style));
}
return edgeLabel;
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel 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);
}
}
Aggregations