Search in sources :

Example 26 with NotFoundException

use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.

the class EdgeLabelBuilder method eliminate.

@Override
public EdgeLabel eliminate() {
    EdgeLabel edgeLabel = this.edgeLabelOrNull(this.name);
    if (edgeLabel == null) {
        throw new NotFoundException("Can't update edge label '%s' " + "since it doesn't exist", this.name);
    }
    // Only allowed to eliminate user data
    this.checkStableVars();
    this.checkProperties(Action.ELIMINATE);
    this.checkNullableKeys(Action.ELIMINATE);
    Userdata.check(this.userdata, Action.ELIMINATE);
    edgeLabel.removeUserdata(this.userdata);
    this.graph().addEdgeLabel(edgeLabel);
    return edgeLabel;
}
Also used : EdgeLabel(com.baidu.hugegraph.schema.EdgeLabel) NotFoundException(com.baidu.hugegraph.exception.NotFoundException)

Example 27 with NotFoundException

use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.

the class PropertyKeyBuilder method append.

@Override
public PropertyKey append() {
    PropertyKey propertyKey = this.propertyKeyOrNull(this.name);
    if (propertyKey == null) {
        throw new NotFoundException("Can't update property key '%s' " + "since it doesn't exist", this.name);
    }
    this.checkStableVars();
    Userdata.check(this.userdata, Action.APPEND);
    propertyKey.userdata(this.userdata);
    this.graph().addPropertyKey(propertyKey);
    return propertyKey;
}
Also used : NotFoundException(com.baidu.hugegraph.exception.NotFoundException) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 28 with NotFoundException

use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.

the class VertexLabelBuilder method append.

@Override
public VertexLabel append() {
    VertexLabel vertexLabel = this.vertexLabelOrNull(this.name);
    if (vertexLabel == null) {
        throw new NotFoundException("Can't update vertex label '%s' " + "since it doesn't exist", this.name);
    }
    this.checkStableVars();
    this.checkProperties(Action.APPEND);
    this.checkNullableKeys(Action.APPEND);
    Userdata.check(this.userdata, Action.APPEND);
    for (String key : this.properties) {
        PropertyKey propertyKey = this.graph().propertyKey(key);
        vertexLabel.property(propertyKey.id());
    }
    for (String key : this.nullableKeys) {
        PropertyKey propertyKey = this.graph().propertyKey(key);
        vertexLabel.nullableKey(propertyKey.id());
    }
    vertexLabel.userdata(this.userdata);
    this.graph().addVertexLabel(vertexLabel);
    return vertexLabel;
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel) NotFoundException(com.baidu.hugegraph.exception.NotFoundException) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 29 with NotFoundException

use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.

the class VertexLabelBuilder method eliminate.

@Override
public VertexLabel eliminate() {
    VertexLabel vertexLabel = this.vertexLabelOrNull(this.name);
    if (vertexLabel == null) {
        throw new NotFoundException("Can't update vertex label '%s' " + "since it doesn't exist", this.name);
    }
    // Only allowed to eliminate user data
    this.checkStableVars();
    this.checkProperties(Action.ELIMINATE);
    this.checkNullableKeys(Action.ELIMINATE);
    Userdata.check(this.userdata, Action.ELIMINATE);
    vertexLabel.removeUserdata(this.userdata);
    this.graph().addVertexLabel(vertexLabel);
    return vertexLabel;
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel) NotFoundException(com.baidu.hugegraph.exception.NotFoundException)

Example 30 with NotFoundException

use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.

the class MysqlTable method queryId2Select.

protected List<StringBuilder> queryId2Select(Query query, StringBuilder select) {
    // Query by id(s)
    if (query.idsSize() == 0) {
        return ImmutableList.of(select);
    }
    List<HugeKeys> nameParts = this.idColumnName();
    List<List<Object>> ids = new ArrayList<>(query.idsSize());
    for (Id id : query.ids()) {
        List<Object> idParts = this.idColumnValue(id);
        if (nameParts.size() != idParts.size()) {
            throw new NotFoundException("Unsupported ID format: '%s' (should contain %s)", id, nameParts);
        }
        ids.add(idParts);
    }
    // Query only by partition-key
    if (nameParts.size() == 1) {
        List<Object> values = new ArrayList<>(ids.size());
        for (List<Object> objects : ids) {
            assert objects.size() == 1;
            values.add(objects.get(0));
        }
        WhereBuilder where = this.newWhereBuilder();
        where.in(formatKey(nameParts.get(0)), values);
        select.append(where.build());
        return ImmutableList.of(select);
    }
    /*
         * Query by partition-key + clustering-key
         * NOTE: Error if multi-column IN clause include partition key:
         * error: multi-column relations can only be applied to clustering
         * columns when using: select.where(QueryBuilder.in(names, idList));
         * So we use multi-query instead of IN
         */
    List<StringBuilder> selections = new ArrayList<>(ids.size());
    for (List<Object> objects : ids) {
        assert nameParts.size() == objects.size();
        StringBuilder idSelection = new StringBuilder(select);
        /*
             * NOTE: concat with AND relation, like:
             * "pk = id and ck1 = v1 and ck2 = v2"
             */
        WhereBuilder where = this.newWhereBuilder();
        where.and(formatKeys(nameParts), objects);
        idSelection.append(where.build());
        selections.add(idSelection);
    }
    return selections;
}
Also used : ArrayList(java.util.ArrayList) NotFoundException(com.baidu.hugegraph.exception.NotFoundException) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) Id(com.baidu.hugegraph.backend.id.Id) HugeKeys(com.baidu.hugegraph.type.define.HugeKeys)

Aggregations

NotFoundException (com.baidu.hugegraph.exception.NotFoundException)30 HugeGraph (com.baidu.hugegraph.HugeGraph)15 Timed (com.codahale.metrics.annotation.Timed)15 Path (jakarta.ws.rs.Path)15 Consumes (jakarta.ws.rs.Consumes)14 DELETE (jakarta.ws.rs.DELETE)8 Produces (jakarta.ws.rs.Produces)7 PUT (jakarta.ws.rs.PUT)6 Id (com.baidu.hugegraph.backend.id.Id)5 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)4 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)3 HugeProject (com.baidu.hugegraph.auth.HugeProject)2 EdgeLabel (com.baidu.hugegraph.schema.EdgeLabel)2 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)2 SchemaLabel (com.baidu.hugegraph.schema.SchemaLabel)2 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)2 HugeKeys (com.baidu.hugegraph.type.define.HugeKeys)2 ImmutableList (com.google.common.collect.ImmutableList)2 RolesAllowed (jakarta.annotation.security.RolesAllowed)2 ArrayList (java.util.ArrayList)2