use of com.baidu.hugegraph.entity.load.FileMapping in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method updateEdgeMapping.
@PutMapping("{id}/edge-mappings/{emid}")
public FileMapping updateEdgeMapping(@PathVariable("connId") int connId, @PathVariable("id") int id, @PathVariable("emid") String emId, @RequestBody EdgeMapping newEntity) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
this.checkEdgeMappingValid(connId, newEntity, mapping);
EdgeMapping edgeMapping = mapping.getEdgeMapping(emId);
Ex.check(edgeMapping != null, "load.file-mapping.edge-mapping.not-exist.id", emId);
newEntity.setId(emId);
Set<EdgeMapping> edgeMappings = mapping.getEdgeMappings();
edgeMappings.remove(edgeMapping);
edgeMappings.add(newEntity);
this.service.update(mapping);
return mapping;
}
use of com.baidu.hugegraph.entity.load.FileMapping in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method deleteVertexMapping.
@DeleteMapping("{id}/vertex-mappings/{vmid}")
public FileMapping deleteVertexMapping(@PathVariable("id") int id, @PathVariable("vmid") String vmid) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
VertexMapping vertexMapping = mapping.getVertexMapping(vmid);
boolean removed = mapping.getVertexMappings().remove(vertexMapping);
if (!removed) {
throw new ExternalException("load.file-mapping.vertex-mapping.not-exist.id", vmid);
}
this.service.update(mapping);
return mapping;
}
use of com.baidu.hugegraph.entity.load.FileMapping in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method deleteEdgeMapping.
@DeleteMapping("{id}/edge-mappings/{emid}")
public FileMapping deleteEdgeMapping(@PathVariable("id") int id, @PathVariable("emid") String emid) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
EdgeMapping edgeMapping = mapping.getEdgeMapping(emid);
boolean removed = mapping.getEdgeMappings().remove(edgeMapping);
if (!removed) {
throw new ExternalException("load.file-mapping.edge-mapping.not-exist.id", emid);
}
this.service.update(mapping);
return mapping;
}
use of com.baidu.hugegraph.entity.load.FileMapping in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method delete.
@DeleteMapping("{id}")
public void delete(@PathVariable("id") int id) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
this.service.deleteDiskFile(mapping);
this.service.remove(id);
}
use of com.baidu.hugegraph.entity.load.FileMapping in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method updateVertexMapping.
@PutMapping("{id}/vertex-mappings/{vmid}")
public FileMapping updateVertexMapping(@PathVariable("connId") int connId, @PathVariable("id") int id, @PathVariable("vmid") String vmId, @RequestBody VertexMapping newEntity) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
this.checkVertexMappingValid(connId, newEntity, mapping);
VertexMapping vertexMapping = mapping.getVertexMapping(vmId);
Ex.check(vertexMapping != null, "load.file-mapping.vertex-mapping.not-exist.id", vmId);
newEntity.setId(vmId);
Set<VertexMapping> vertexMappings = mapping.getVertexMappings();
vertexMappings.remove(vertexMapping);
vertexMappings.add(newEntity);
this.service.update(mapping);
return mapping;
}
Aggregations