use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeAPI method update.
@PUT
@Timed(name = "single-update")
@Path("{id}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=edge_write" })
public String update(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") String id, @QueryParam("action") String action, JsonEdge jsonEdge) {
LOG.debug("Graph [{}] update edge: {}", graph, jsonEdge);
checkUpdatingBody(jsonEdge);
if (jsonEdge.id != null) {
E.checkArgument(id.equals(jsonEdge.id), "The ids are different between url and " + "request body ('%s' != '%s')", id, jsonEdge.id);
}
// Parse action param
boolean append = checkAndParseAction(action);
HugeGraph g = graph(manager, graph);
HugeEdge edge = (HugeEdge) g.edge(id);
EdgeLabel edgeLabel = edge.schemaLabel();
for (String key : jsonEdge.properties.keySet()) {
PropertyKey pkey = g.propertyKey(key);
E.checkArgument(edgeLabel.properties().contains(pkey.id()), "Can't update property for edge '%s' because " + "there is no property key '%s' in its edge label", id, key);
}
commit(g, () -> updateProperties(edge, jsonEdge, append));
return manager.serializer(g).writeEdge(edge);
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeLabelAPI method create.
@POST
@Timed
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=edge_label_write" })
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonEdgeLabel jsonEdgeLabel) {
LOG.debug("Graph [{}] create edge label: {}", graph, jsonEdgeLabel);
checkCreatingBody(jsonEdgeLabel);
HugeGraph g = graph(manager, graph);
EdgeLabel.Builder builder = jsonEdgeLabel.convert2Builder(g);
EdgeLabel edgeLabel = builder.create();
return manager.serializer(g).writeEdgeLabel(edgeLabel);
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class HugeGraphAuthProxy method removeEdgeLabel.
@Override
public Id removeEdgeLabel(Id id) {
EdgeLabel label = this.hugegraph.edgeLabel(id);
verifySchemaPermission(HugePermission.DELETE, label);
return this.hugegraph.removeEdgeLabel(id);
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class StandardHugeGraph method edgeLabel.
@Override
public EdgeLabel edgeLabel(Id id) {
EdgeLabel el = this.schemaTransaction().getEdgeLabel(id);
E.checkArgument(el != null, "Undefined edge label with id: '%s'", id);
return el;
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class StandardHugeGraph method removeEdge.
@Override
public void removeEdge(String label, Object id) {
if (label != null) {
EdgeLabel el = this.edgeLabel(label);
if (!el.existsIndexLabel()) {
// Improve perf by removeEdge(id)
Id idValue = HugeEdge.getIdValue(id, false);
HugeEdge edge = new HugeEdge(this, idValue, el);
this.removeEdge(edge);
return;
}
}
this.edge(id).remove();
}
Aggregations