Search in sources :

Example 11 with FileMapping

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;
}
Also used : FileMapping(com.baidu.hugegraph.entity.load.FileMapping) EdgeMapping(com.baidu.hugegraph.entity.load.EdgeMapping) ExternalException(com.baidu.hugegraph.exception.ExternalException) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 12 with FileMapping

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;
}
Also used : FileMapping(com.baidu.hugegraph.entity.load.FileMapping) VertexMapping(com.baidu.hugegraph.entity.load.VertexMapping) ExternalException(com.baidu.hugegraph.exception.ExternalException) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 13 with FileMapping

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;
}
Also used : FileMapping(com.baidu.hugegraph.entity.load.FileMapping) EdgeMapping(com.baidu.hugegraph.entity.load.EdgeMapping) ExternalException(com.baidu.hugegraph.exception.ExternalException) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 14 with FileMapping

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);
}
Also used : FileMapping(com.baidu.hugegraph.entity.load.FileMapping) ExternalException(com.baidu.hugegraph.exception.ExternalException) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 15 with FileMapping

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;
}
Also used : FileMapping(com.baidu.hugegraph.entity.load.FileMapping) VertexMapping(com.baidu.hugegraph.entity.load.VertexMapping) ExternalException(com.baidu.hugegraph.exception.ExternalException) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Aggregations

FileMapping (com.baidu.hugegraph.entity.load.FileMapping)16 ExternalException (com.baidu.hugegraph.exception.ExternalException)11 PostMapping (org.springframework.web.bind.annotation.PostMapping)6 JobManager (com.baidu.hugegraph.entity.load.JobManager)5 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)4 LoadTask (com.baidu.hugegraph.entity.load.LoadTask)3 EdgeMapping (com.baidu.hugegraph.entity.load.EdgeMapping)2 VertexMapping (com.baidu.hugegraph.entity.load.VertexMapping)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)2 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 PutMapping (org.springframework.web.bind.annotation.PutMapping)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 GraphConnection (com.baidu.hugegraph.entity.GraphConnection)1 FileSetting (com.baidu.hugegraph.entity.load.FileSetting)1 FileUploadResult (com.baidu.hugegraph.entity.load.FileUploadResult)1 JobManagerReasonResult (com.baidu.hugegraph.entity.load.JobManagerReasonResult)1 LoadParameter (com.baidu.hugegraph.entity.load.LoadParameter)1