use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelAPI method update.
@PUT
@Timed
@Path("{name}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=vertex_label_write" })
public String update(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("name") String name, @QueryParam("action") String action, JsonVertexLabel jsonVertexLabel) {
LOG.debug("Graph [{}] {} vertex label: {}", graph, action, jsonVertexLabel);
checkUpdatingBody(jsonVertexLabel);
E.checkArgument(name.equals(jsonVertexLabel.name), "The name in url(%s) and body(%s) are different", name, jsonVertexLabel.name);
// Parse action parameter
boolean append = checkAndParseAction(action);
HugeGraph g = graph(manager, graph);
VertexLabel.Builder builder = jsonVertexLabel.convert2Builder(g);
VertexLabel vertexLabel = append ? builder.append() : builder.eliminate();
return manager.serializer(g).writeVertexLabel(vertexLabel);
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelAPI method list.
@GET
@Timed
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=vertex_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 vertex labels", graph);
} else {
LOG.debug("Graph [{}] get vertex labels by names {}", graph, names);
}
HugeGraph g = graph(manager, graph);
List<VertexLabel> labels;
if (listAll) {
labels = g.schema().getVertexLabels();
} else {
labels = new ArrayList<>(names.size());
for (String name : names) {
labels.add(g.schema().getVertexLabel(name));
}
}
return manager.serializer(g).writeVertexLabels(labels);
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelAPI method get.
@GET
@Timed
@Path("{name}")
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=vertex_label_read" })
public String get(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("name") String name) {
LOG.debug("Graph [{}] get vertex label by name '{}'", graph, name);
HugeGraph g = graph(manager, graph);
VertexLabel vertexLabel = g.schema().getVertexLabel(name);
return manager.serializer(g).writeVertexLabel(vertexLabel);
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class HugeGraphAuthProxy method removeVertexLabel.
@Override
public Id removeVertexLabel(Id id) {
VertexLabel label = this.hugegraph.vertexLabel(id);
verifySchemaPermission(HugePermission.DELETE, label);
return this.hugegraph.removeVertexLabel(id);
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class StandardHugeGraph method vertexLabel.
@Override
public VertexLabel vertexLabel(Id id) {
VertexLabel vl = this.schemaTransaction().getVertexLabel(id);
E.checkArgument(vl != null, "Undefined vertex label with id: '%s'", id);
return vl;
}
Aggregations