public PreprocessingController( IPreprocessRepository preprocessRepository, IPreprocessHistoryRepository preprocessHistoryRepository, IGitLogic gitLogic, IStorageLogic storageLogic, IUnitOfWork unitOfWork, IHttpContextAccessor accessor) : base(accessor) { this.preprocessRepository = preprocessRepository; this.preprocessHistoryRepository = preprocessHistoryRepository; this.gitLogic = gitLogic; this.storageLogic = storageLogic; this.unitOfWork = unitOfWork; }
/// <summary> /// コンストラクタ /// </summary> public PreprocessingController( IPreprocessRepository preprocessRepository, IPreprocessHistoryRepository preprocessHistoryRepository, ITenantRepository tenantRepository, IDataRepository dataRepository, IPreprocessLogic preprocessLogic, ITagLogic tagLogic, IGitLogic gitLogic, IStorageLogic storageLogic, IClusterManagementLogic clusterManagementLogic, IUnitOfWork unitOfWork, IHttpContextAccessor accessor) : base(accessor) { this.preprocessRepository = preprocessRepository; this.preprocessHistoryRepository = preprocessHistoryRepository; this.tenantRepository = tenantRepository; this.dataRepository = dataRepository; this.preprocessLogic = preprocessLogic; this.tagLogic = tagLogic; this.gitLogic = gitLogic; this.storageLogic = storageLogic; this.clusterManagementLogic = clusterManagementLogic; this.unitOfWork = unitOfWork; }
public async Task <IActionResult> Delete(long?id, [FromServices] IPreprocessRepository preprocessRepository, [FromServices] INotebookHistoryRepository notebookHistoryRepository, [FromServices] ITrainingHistoryRepository trainingHistoryRepository, [FromServices] IInferenceHistoryRepository inferenceHistoryRepository ) { // データの入力チェック if (id == null) { return(JsonBadRequest("Invalid inputs.")); } // データの存在チェック var registry = await registryRepository.GetByIdAsync(id.Value); if (registry == null) { return(JsonNotFound($"Registry ID {id.Value} is not found.")); } // データの編集可否チェック if (registry.IsNotEditable) { return(JsonBadRequest($"Registry ID {id.Value} is not allowed to delete.")); } // このレジストリを登録しているテナントがいた場合、削除はできない var tenant = registryRepository.GetTenant(registry.Id); if (tenant != null) { return(JsonConflict($"Registry {registry.Id}:{registry.Name} is used at Tenant {tenant.Id}:{tenant.Name}.")); } // このレジストリを使った履歴がある場合、削除はできない // 前処理チェック var preprocessing = preprocessRepository.Find(p => p.ContainerRegistryId == registry.Id); if (preprocessing != null) { return(JsonConflict($"Registry {registry.Id}:{registry.Name} is used at preprocessing {preprocessing.Id} in Tenant {preprocessing.TenantId}.")); } // ノートブック履歴チェック var notebook = notebookHistoryRepository.Find(n => n.ContainerRegistryId == registry.Id); if (notebook != null) { return(JsonConflict($"Registry {registry.Id}:{registry.Name} is used at notebook {notebook.Id} in Tenant {notebook.TenantId}.")); } // 学習履歴チェック var training = trainingHistoryRepository.Find(t => t.ContainerRegistryId == registry.Id); if (training != null) { return(JsonConflict($"Registry {registry.Id}:{registry.Name} is used at training {training.Id} in Tenant {training.TenantId}.")); } // 推論履歴チェック var inference = inferenceHistoryRepository.Find(i => i.ContainerRegistryId == registry.Id); if (inference != null) { return(JsonConflict($"Registry {registry.Id}:{registry.Name} is used at inference {inference.Id} in Tenant {inference.TenantId}.")); } // クラスタ管理サービス側の登録情報は特に削除しない(残っていても問題ない) registryRepository.Delete(registry); unitOfWork.Commit(); return(JsonNoContent()); }
public async Task <IActionResult> Delete(long?id, [FromServices] IPreprocessRepository preprocessRepository, [FromServices] INotebookHistoryRepository notebookHistoryRepository, [FromServices] ITrainingHistoryRepository trainingHistoryRepository, [FromServices] IInferenceHistoryRepository inferenceHistoryRepository ) { // データの入力チェック if (id == null) { return(JsonBadRequest("Invalid inputs.")); } // データの存在チェック var git = await gitRepository.GetByIdAsync(id.Value); if (git == null) { return(JsonNotFound($"Git ID {id.Value} is not found.")); } // データの編集可否チェック if (git.IsNotEditable) { return(JsonBadRequest($"Git ID {id.Value} is not allowed to delete.")); } // このGitを登録しているテナントがいた場合、削除はできない var tenant = gitRepository.GetTenant(git.Id); if (tenant != null) { return(JsonConflict($"Git {git.Id}:{git.Name} is used at Tenant {tenant.Id}:{tenant.Name}.")); } // このGitを使った履歴がある場合、削除はできない // 前処理チェック var preprocessing = preprocessRepository.Find(p => p.RepositoryGitId == git.Id); if (preprocessing != null) { return(JsonConflict($"Git {git.Id}:{git.Name} is used at preprocessing {preprocessing.Id} in Tenant {preprocessing.TenantId}.")); } // ノートブック履歴チェック var notebook = notebookHistoryRepository.Find(n => n.ModelGitId == git.Id); if (notebook != null) { return(JsonConflict($"Git {git.Id}:{git.Name} is used at notebook {notebook.Id} in Tenant {notebook.TenantId}.")); } // 学習履歴チェック var training = trainingHistoryRepository.Find(t => t.ModelGitId == git.Id); if (training != null) { return(JsonConflict($"Git {git.Id}:{git.Name} is used at training {training.Id} in Tenant {training.TenantId}.")); } // 推論履歴チェック var inference = inferenceHistoryRepository.Find(i => i.ModelGitId == git.Id); if (inference != null) { return(JsonConflict($"Git {git.Id}:{git.Name} is used at inference {inference.Id} in Tenant {inference.TenantId}.")); } gitRepository.Delete(git); unitOfWork.Commit(); return(JsonNoContent()); }