use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeLabelCoreTest method testAddEdgeLabelWithoutProperty.
@Test
public void testAddEdgeLabelWithoutProperty() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
schema.vertexLabel("book").properties("id", "name").primaryKeys("id").create();
EdgeLabel look = schema.edgeLabel("look").singleTime().link("person", "book").create();
Assert.assertNotNull(look);
Assert.assertEquals("look", look.name());
assertVLEqual("person", look.sourceLabel());
assertVLEqual("book", look.targetLabel());
Assert.assertEquals(0, look.properties().size());
Assert.assertEquals(0, look.sortKeys().size());
Assert.assertEquals(Frequency.SINGLE, look.frequency());
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeLabelCoreTest method testAddEdgeLabelWithNullableKeys.
@Test
public void testAddEdgeLabelWithNullableKeys() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
schema.vertexLabel("book").properties("id", "name").primaryKeys("id").create();
EdgeLabel look = schema.edgeLabel("look").properties("time", "weight").nullableKeys("weight").link("person", "book").create();
Assert.assertNotNull(look);
Assert.assertEquals("look", look.name());
assertVLEqual("person", look.sourceLabel());
assertVLEqual("book", look.targetLabel());
Assert.assertEquals(2, look.properties().size());
assertContainsPk(look.properties(), "time", "weight");
Assert.assertEquals(1, look.nullableKeys().size());
assertContainsPk(look.nullableKeys(), "weight");
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeLabelCoreTest method testAddEdgeLabel.
@Test
public void testAddEdgeLabel() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
schema.vertexLabel("book").properties("id", "name").primaryKeys("id").create();
EdgeLabel look = schema.edgeLabel("look").multiTimes().properties("time").link("person", "book").sortKeys("time").create();
Assert.assertNotNull(look);
Assert.assertEquals("look", look.name());
assertVLEqual("person", look.sourceLabel());
assertVLEqual("book", look.targetLabel());
Assert.assertEquals(1, look.properties().size());
assertContainsPk(look.properties(), "time");
Assert.assertEquals(1, look.sortKeys().size());
assertContainsPk(look.sortKeys(), "time");
Assert.assertEquals(Frequency.MULTIPLE, look.frequency());
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeLabelCoreTest method testAddEdgeLabelWithoutFrequency.
@Test
public void testAddEdgeLabelWithoutFrequency() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
schema.vertexLabel("book").properties("id", "name").primaryKeys("id").create();
EdgeLabel look = schema.edgeLabel("look").properties("time").link("person", "book").create();
Assert.assertNotNull(look);
Assert.assertEquals("look", look.name());
assertVLEqual("person", look.sourceLabel());
assertVLEqual("book", look.targetLabel());
Assert.assertEquals(1, look.properties().size());
assertContainsPk(look.properties(), "time");
Assert.assertEquals(0, look.sortKeys().size());
Assert.assertEquals(Frequency.SINGLE, look.frequency());
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeLabelAPI method list.
@GET
@Timed
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=edge_label_read" })
public String list(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("names") List<String> names) {
boolean listAll = CollectionUtils.isEmpty(names);
if (listAll) {
LOG.debug("Graph [{}] list edge labels", graph);
} else {
LOG.debug("Graph [{}] get edge labels by names {}", graph, names);
}
HugeGraph g = graph(manager, graph);
List<EdgeLabel> labels;
if (listAll) {
labels = g.schema().getEdgeLabels();
} else {
labels = new ArrayList<>(names.size());
for (String name : names) {
labels.add(g.schema().getEdgeLabel(name));
}
}
return manager.serializer(g).writeEdgeLabels(labels);
}
Aggregations