use of com.baidu.hugegraph.structure.schema.EdgeLabel 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.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelService method checkUsing.
public boolean checkUsing(String name, int connId) {
HugeClient client = this.client(connId);
List<EdgeLabel> edgeLabels = client.schema().getEdgeLabels();
for (EdgeLabel edgeLabel : edgeLabels) {
if (edgeLabel.linkedVertexLabel(name)) {
return true;
}
}
return false;
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelTest method testAddEdgeLabelWithUserData.
@Test
public void testAddEdgeLabelWithUserData() {
SchemaManager schema = schema();
EdgeLabel father = schema.edgeLabel("father").link("person", "person").properties("weight").userdata("multiplicity", "one-to-many").create();
Assert.assertEquals(2, father.userdata().size());
Assert.assertEquals("one-to-many", father.userdata().get("multiplicity"));
String time = (String) father.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
EdgeLabel write = schema.edgeLabel("write").link("person", "book").properties("date", "weight").userdata("multiplicity", "one-to-many").userdata("multiplicity", "many-to-many").create();
// The same key user data will be overwritten
Assert.assertEquals(2, write.userdata().size());
Assert.assertEquals("many-to-many", write.userdata().get("multiplicity"));
time = (String) write.userdata().get("~create_time");
createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelTest method testRemoveEdgeLabelSync.
@Test
public void testRemoveEdgeLabelSync() {
SchemaManager schema = schema();
EdgeLabel write = schema.edgeLabel("write").link("person", "book").properties("date", "weight").userdata("multiplicity", "one-to-many").userdata("icon", "picture2").create();
Assert.assertNotNull(write);
// Remove edge label sync
schema.removeEdgeLabel("write");
write = schema.edgeLabel("write").link("person", "book").properties("date", "weight").userdata("multiplicity", "one-to-many").userdata("icon", "picture2").create();
Assert.assertNotNull(write);
// Remove edge label sync with timeout
schema.removeEdgeLabel("write", 10);
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelTest method testLinkedVertexLabel.
@Test
public void testLinkedVertexLabel() {
SchemaManager schema = schema();
EdgeLabel father = schema.edgeLabel("father").link("person", "person").properties("weight").userdata("multiplicity", "one-to-many").create();
EdgeLabel write = schema.edgeLabel("write").link("person", "book").properties("date", "weight").userdata("multiplicity", "one-to-many").userdata("multiplicity", "many-to-many").create();
Assert.assertTrue(father.linkedVertexLabel("person"));
Assert.assertFalse(father.linkedVertexLabel("book"));
Assert.assertTrue(write.linkedVertexLabel("person"));
Assert.assertTrue(write.linkedVertexLabel("book"));
}
Aggregations