public async Task <IActionResult> Delete(long?id, [FromServices] IPreprocessHistoryRepository preprocessHistoryRepository) { //データの入力チェック if (id == null) { return(JsonBadRequest("Invalid inputs.")); } //データの存在チェック var preprocessing = await preprocessRepository.GetByIdAsync(id.Value); if (preprocessing == null) { return(JsonNotFound($"Preprocessing ID {id.Value} is not found.")); } var history = preprocessHistoryRepository.Find(p => p.PreprocessId == id.Value); if (history != null) { //過去に前処理を実行済みなので、削除できない return(JsonConflict($"Preprocessing ID {id.Value} is already executed. History ID = {history.Id} ")); } preprocessRepository.Delete(preprocessing); unitOfWork.Commit(); return(JsonNoContent()); }
public async Task <IActionResult> GetDetail(long?id, [FromServices] IPreprocessHistoryRepository preprocessHistoryRepository) { if (id == null) { return(JsonBadRequest("Preprocessing ID is required.")); } var preprocessing = await preprocessRepository.GetIncludeAllAsync(id.Value); if (preprocessing == null) { return(JsonNotFound($"Preprocessing Id {id.Value} is not found.")); } var model = new DetailsOutputModel(preprocessing) { IsLocked = await preprocessHistoryRepository.ExistsAsync(p => p.PreprocessId == id.Value) }; //Gitの表示用URLを作る if (preprocessing.RepositoryGitId != null) { model.GitModel.Url = gitLogic.GetTreeUiUrl(preprocessing.RepositoryGitId.Value, preprocessing.RepositoryName, preprocessing.RepositoryOwner, preprocessing.RepositoryCommitId); } return(JsonOK(model)); }
/// <summary> /// コンストラクタ /// </summary> public PreprocessLogic( IPreprocessHistoryRepository preprocessHistoryRepository, IDataLogic dataLogic, IClusterManagementLogic clusterManagementLogic, IUnitOfWork unitOfWork, ICommonDiLogic commonDiLogic) : base(commonDiLogic) { this.preprocessHistoryRepository = preprocessHistoryRepository; this.dataLogic = dataLogic; this.clusterManagementLogic = clusterManagementLogic; this.unitOfWork = unitOfWork; }
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; }
public DataController( IDataRepository dataRepository, IPreprocessHistoryRepository preprocessHistoryRepository, IDataLogic dataLogic, ITagLogic tagLogic, IStorageLogic storageLogic, IUnitOfWork unitOfWork, IHttpContextAccessor accessor) : base(accessor) { this.dataRepository = dataRepository; this.preprocessHistoryRepository = preprocessHistoryRepository; this.dataLogic = dataLogic; this.tagLogic = tagLogic; this.storageLogic = storageLogic; this.unitOfWork = unitOfWork; }
public async Task <IActionResult> DeleteHistory([FromRoute] long id, [FromRoute] long?dataId, [FromServices] IPreprocessHistoryRepository preprocessHistoryRepository, [FromServices] IPreprocessLogic preprocessLogic) { if (dataId == null) { return(JsonBadRequest("Data ID is requried.")); } //データの存在チェック var preprocessHistory = await preprocessHistoryRepository.GetPreprocessIncludeDataAndPreprocessAsync(id, dataId.Value); if (preprocessHistory == null) { return(JsonNotFound($"Preprocessing History about Preprocess {id} to Data {dataId} is not found.")); } //出力データを削除できるか、確認 var lockedOutput = preprocessHistoryRepository.GetLockedOutput(preprocessHistory.Id); if (lockedOutput != null) { return(JsonConflict($"Preprocessing History about Preprocess {id} to Data {dataId} can NOT delete. The output data {lockedOutput.Id} is locked.")); } //前処理履歴の削除 bool result = await preprocessLogic.DeleteAsync(preprocessHistory, false); if (result) { return(JsonNoContent()); } else { return(JsonError(HttpStatusCode.ServiceUnavailable, $"Failed to delete Preprocessing History about Preprocess {id} to Data {dataId}. Please contact your server administrator.")); } }
/// <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> EditDetails(long?id, [FromBody] CreateInputModel model, [FromServices] IPreprocessHistoryRepository preprocessHistoryRepository) { //データの入力チェック if (!ModelState.IsValid || !id.HasValue) { return(JsonBadRequest("Invalid inputs.")); } if (model.GitModel != null && model.GitModel.IsValid() == false) { return(JsonBadRequest($"The input about Git is not valid.")); } //データの存在チェック var preprocessing = await preprocessRepository.GetIncludeAllAsync(id.Value); if (preprocessing == null) { return(JsonNotFound($"Preprocessing ID {id.Value} is not found.")); } var history = preprocessHistoryRepository.Find(p => p.PreprocessId == id.Value); if (history != null) { //過去に前処理を実行済みなので、編集できない return(JsonConflict($"Preprocessing ID {id.Value} is already executed. History ID = {history.Id} ")); } var errorResult = await SetPreprocessDetailsAsync(preprocessing, model); if (errorResult != null) { return(errorResult); } unitOfWork.Commit(); var result = new DetailsOutputModel(preprocessing); //Gitの表示用URLを作る if (preprocessing.RepositoryGitId != null) { result.GitModel.Url = gitLogic.GetTreeUiUrl(preprocessing.RepositoryGitId.Value, preprocessing.RepositoryName, preprocessing.RepositoryOwner, preprocessing.RepositoryCommitId); } return(JsonOK(result)); }