use of com.baidu.hugegraph.entity.query.GremlinCollection in project incubator-hugegraph-toolchain by apache.
the class GremlinCollectionController method update.
@PutMapping("{id}")
public GremlinCollection update(@PathVariable("id") int id, @RequestBody GremlinCollection newEntity) {
this.checkIdSameAsBody(id, newEntity);
this.checkParamsValid(newEntity, false);
GremlinCollection oldEntity = this.service.get(id);
if (oldEntity == null) {
throw new ExternalException("gremlin-collection.not-exist.id", id);
}
GremlinCollection entity = this.mergeEntity(oldEntity, newEntity);
this.checkEntityUnique(entity, false);
this.service.update(entity);
return entity;
}
use of com.baidu.hugegraph.entity.query.GremlinCollection in project incubator-hugegraph-toolchain by apache.
the class GremlinCollectionController method delete.
@DeleteMapping("{id}")
public GremlinCollection delete(@PathVariable("id") int id) {
GremlinCollection oldEntity = this.service.get(id);
if (oldEntity == null) {
throw new ExternalException("gremlin-collection.not-exist.id", id);
}
this.service.remove(id);
return oldEntity;
}
use of com.baidu.hugegraph.entity.query.GremlinCollection in project incubator-hugegraph-toolchain by apache.
the class GremlinCollectionController method checkEntityUnique.
private void checkEntityUnique(GremlinCollection newEntity, boolean creating) {
int connId = newEntity.getConnId();
String name = newEntity.getName();
// NOTE: Full table scan may slow, it's better to use index
GremlinCollection oldEntity = this.service.getByName(connId, name);
if (creating) {
Ex.check(oldEntity == null, "gremlin-collection.exist.name", name);
} else {
Ex.check(oldEntity != null, () -> oldEntity.getId().equals(newEntity.getId()), "gremlin-collection.exist.name", name);
}
}
Aggregations