use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class StandardTaskScheduler method findTask.
public <V> HugeTask<V> findTask(Id id) {
HugeTask<V> result = this.call(() -> {
Iterator<Vertex> vertices = this.tx().queryVertices(id);
Vertex vertex = QueryResults.one(vertices);
if (vertex == null) {
return null;
}
return HugeTask.fromVertex(vertex);
});
if (result == null) {
throw new NotFoundException("Can't find task with id '%s'", id);
}
return result;
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class PropertyKeyBuilder method eliminate.
@Override
public PropertyKey eliminate() {
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.ELIMINATE);
propertyKey.removeUserdata(this.userdata);
this.graph().addPropertyKey(propertyKey);
return propertyKey;
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class EdgeLabelBuilder method append.
@Override
public EdgeLabel append() {
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);
}
// These methods will check params and fill to member variables
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);
edgeLabel.property(propertyKey.id());
}
for (String key : this.nullableKeys) {
PropertyKey propertyKey = this.graph().propertyKey(key);
edgeLabel.nullableKey(propertyKey.id());
}
edgeLabel.userdata(this.userdata);
this.graph().addEdgeLabel(edgeLabel);
return edgeLabel;
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class CassandraTable method queryId2Select.
protected List<Select> queryId2Select(Query query, Select 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> idList = new ArrayList<>(ids.size());
for (List<Object> id : ids) {
assert id.size() == 1;
idList.add(id.get(0));
}
return this.ids2IdSelects(select, nameParts.get(0), idList);
}
/*
* 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<Select> selects = new ArrayList<>(ids.size());
for (List<Object> id : ids) {
assert nameParts.size() == id.size();
Select idSelect = cloneSelect(select, this.table());
/*
* NOTE: concat with AND relation, like:
* "pk = id and ck1 = v1 and ck2 = v2"
*/
for (int i = 0, n = nameParts.size(); i < n; i++) {
idSelect.where(formatEQ(nameParts.get(i), id.get(i)));
}
selects.add(idSelect);
}
return selects;
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class GroupAPI method delete.
@DELETE
@Timed
@Path("{id}")
@Consumes(APPLICATION_JSON)
public void delete(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") String id) {
LOG.debug("Graph [{}] delete group: {}", graph, id);
// just check if the graph exists
@SuppressWarnings("unused") HugeGraph g = graph(manager, graph);
try {
manager.authManager().deleteGroup(IdGenerator.of(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid group id: " + id);
}
}
Aggregations