[REMOVE] PipelineService and related request/response classes; refId parameter added to MinioAttachment search functionality

main
bjkim 9 months ago
parent 559303abe0
commit f3865f74ea

@ -59,9 +59,10 @@ public class MinioAttachmentController {
description = "첨부파일 구분자. 예: WORKFLOW_STEP, DATASET, TRAINING_SCRIPT",
example = "WORKFLOW_STEP"
)
@RequestParam(value = "refType", required = false) String refType
) {
Page<MinioAttachmentEntity> page = minioAttachmentService.search(request, refType);
@RequestParam(value = "refType", required = false) String refType,
@RequestParam(value = "refId", required = false, defaultValue = "0") Integer refId
) {
Page<MinioAttachmentEntity> page = minioAttachmentService.search(request, refType, refId);
return ResponseEntity.ok(page);
}
@ -107,73 +108,6 @@ public class MinioAttachmentController {
}
}
@Operation(summary = "파일 업로드 및 Kubeflow 업로드",
description = "MinIO와 DB에 저장하고 Kubeflow REST API에도 업로드합니다. Kubeflow API 경로는 요청 시 지정 가능")
@PostMapping(value = "/upload-and-kubeflow", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<Map<String, Object>> uploadFileAndKubeflow(
@Parameter(description = "업로드할 파일") @RequestPart("file") MultipartFile file,
@RequestPart(value = "path", required = false) String path,
@RequestParam(value = "refId", required = false) Long refId,
@RequestParam(value = "refType", required = false, defaultValue = "TRAINING_SCRIPT") String refType,
@RequestParam(value = "title", required = false) String title,
@RequestParam(value = "description", required = false) String description,
@RequestParam(value = "version", required = false, defaultValue = "1") Integer version,
@RequestParam(value = "regUserId") String regUserId,
@RequestParam(value = "projectId") Long projectId,
@RequestParam(value = "kubeflowApi") String kubeflowApi
) {
Map<String, Object> response = new HashMap<>();
try {
MinioAttachmentEntity saved = minioAttachmentService.uploadFile(
file, path, refId, refType, title, description, version, regUserId, projectId
);
String minioUrl = minioAttachmentService.getFileUrl(saved.getStoragePath());
response.put("attachment", saved);
response.put("minioUrl", minioUrl);
RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
body.add("uploadfile", new MultipartInputStreamFileResource(file.getInputStream(), file.getOriginalFilename()));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
String fullUrl = kubeflowBaseUrl + kubeflowApi;
ResponseEntity<String> kubeflowResponse = restTemplate.postForEntity(fullUrl, requestEntity, String.class);
response.put("kubeflowResponse", kubeflowResponse.getBody());
return ResponseEntity.ok(response);
} catch (Exception e) {
log.error("파일 업로드 실패", e);
response.put("error", e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
}
}
// 파일 업로드용 InputStreamResource
private static class MultipartInputStreamFileResource extends InputStreamResource {
private final String filename;
public MultipartInputStreamFileResource(InputStream inputStream, String filename) {
super(inputStream);
this.filename = filename;
}
@Override
public String getFilename() {
return this.filename;
}
@Override
public long contentLength() {
return -1;
}
}
@Operation(summary = "파일 업데이트", description = "파일을 새 버전으로 업로드합니다. 기존 파일은 그대로 보존되고, 버전은 +1 증가합니다.")
@PutMapping(value = "/{id}/update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<Map<String, Object>> updateFile(

@ -1,9 +0,0 @@
//package kr.re.etri.autoflow.payload.request;
//
//import lombok.Data;
//
//@Data
//public class V2Beta1CreatePipelineAndVersionRequest {
// private V2Beta1Pipeline pipeline;
// private V2Beta1PipelineVersion pipeline_version;
//}

@ -1,12 +0,0 @@
//package kr.re.etri.autoflow.payload.request;
//
//import lombok.Data;
//
//@Data
//public class V2Beta1Pipeline {
// private String pipeline_id;
// private String display_name;
// private String name;
// private String description;
// private String namespace;
//}

@ -1,14 +0,0 @@
//package kr.re.etri.autoflow.payload.request;
//
//import lombok.Data;
//
//@Data
//public class V2Beta1PipelineVersion {
// private String pipeline_id;
// private String pipeline_version_id;
// private String display_name;
// private String name;
// private String description;
// private String package_url;
// private String code_source_url;
//}

@ -59,7 +59,6 @@ public class DataGroupService {
endDate
);
if (request.getProjectId() != null) {
spec = spec.and((root, query, cb) ->
cb.equal(root.get("projectId"), request.getProjectId())

@ -110,7 +110,7 @@ public class MinioAttachmentService {
/**
* +
*/
public Page<MinioAttachmentEntity> search(ProjectBaseSearchRequest request, String refType) {
public Page<MinioAttachmentEntity> search(ProjectBaseSearchRequest request, String refType, Integer refId) {
int pageIndex = request.getPage() > 0 ? request.getPage() - 1 : 0;
Pageable pageable = PageRequest.of(
@ -125,6 +125,7 @@ public class MinioAttachmentService {
Specification<MinioAttachmentEntity> spec =
minioAttachmentSpecification.searchByConditions(
refType,
refId,
request.getSearchType(),
request.getKeyword(),
startDate,

@ -1,49 +0,0 @@
//package kr.re.etri.autoflow.service;
//
//import kr.re.etri.autoflow.payload.request.V2Beta1CreatePipelineAndVersionRequest;
//import kr.re.etri.autoflow.payload.request.V2Beta1Pipeline;
//import lombok.RequiredArgsConstructor;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.http.*;
//import org.springframework.stereotype.Service;
//import org.springframework.web.client.RestTemplate;
//
//@Service
//@RequiredArgsConstructor
//public class PipelineService {
//
// private final RestTemplate restTemplate;
//
// @Value("${kubeflow.api.url}")
// private String kubeflowApiUrl;
//
// public V2Beta1Pipeline createPipeline(V2Beta1Pipeline pipeline) {
// HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.APPLICATION_JSON);
//
// HttpEntity<V2Beta1Pipeline> request = new HttpEntity<>(pipeline, headers);
//
// ResponseEntity<V2Beta1Pipeline> response = restTemplate.exchange(
// kubeflowApiUrl + "/apis/v2beta1/pipelines",
// HttpMethod.POST,
// request,
// V2Beta1Pipeline.class
// );
// return response.getBody();
// }
//
// public V2Beta1Pipeline createPipelineAndVersion(V2Beta1CreatePipelineAndVersionRequest requestPayload) {
// HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.APPLICATION_JSON);
//
// HttpEntity<V2Beta1CreatePipelineAndVersionRequest> request = new HttpEntity<>(requestPayload, headers);
//
// ResponseEntity<V2Beta1Pipeline> response = restTemplate.exchange(
// kubeflowApiUrl + "/apis/v2beta1/pipelines/create",
// HttpMethod.POST,
// request,
// V2Beta1Pipeline.class
// );
// return response.getBody();
// }
//}

@ -43,6 +43,7 @@ public class MinioAttachmentSpecification {
public Specification<MinioAttachmentEntity> searchByConditions(
String refType,
Integer refId,
String searchType,
String keyword,
LocalDate startDate,
@ -56,6 +57,11 @@ public class MinioAttachmentSpecification {
predicate = cb.and(predicate, cb.equal(root.get("refType"), refType));
}
// refId 조건 추가
if (refId != null ) {
predicate = cb.and(predicate, cb.equal(root.get("refId"), refId));
}
// keyword 검색
if (keyword != null && !keyword.isEmpty()) {
if (searchType == null || searchType.isEmpty()

Loading…
Cancel
Save