Search in sources :

Example 46 with VertexLabel

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);
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) VertexLabel(com.baidu.hugegraph.schema.VertexLabel) Path(jakarta.ws.rs.Path) RolesAllowed(jakarta.annotation.security.RolesAllowed) Consumes(jakarta.ws.rs.Consumes) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) PUT(jakarta.ws.rs.PUT)

Example 47 with 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);
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) VertexLabel(com.baidu.hugegraph.schema.VertexLabel) RolesAllowed(jakarta.annotation.security.RolesAllowed) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(jakarta.ws.rs.GET)

Example 48 with VertexLabel

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);
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) VertexLabel(com.baidu.hugegraph.schema.VertexLabel) Path(jakarta.ws.rs.Path) RolesAllowed(jakarta.annotation.security.RolesAllowed) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(jakarta.ws.rs.GET)

Example 49 with 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);
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel)

Example 50 with VertexLabel

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;
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel)

Aggregations

VertexLabel (com.baidu.hugegraph.schema.VertexLabel)86 Test (org.junit.Test)35 SchemaManager (com.baidu.hugegraph.schema.SchemaManager)27 Id (com.baidu.hugegraph.backend.id.Id)23 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)20 HugeGraph (com.baidu.hugegraph.HugeGraph)19 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)19 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)12 EdgeLabel (com.baidu.hugegraph.schema.EdgeLabel)12 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)11 FakeObjects (com.baidu.hugegraph.unit.FakeObjects)7 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)6 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)5 Timed (com.codahale.metrics.annotation.Timed)5 RolesAllowed (jakarta.annotation.security.RolesAllowed)5 Produces (jakarta.ws.rs.Produces)5 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)4 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)4 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)4 Date (java.util.Date)4