public async Task <IActionResult> GetDetail(long?id) { if (id == null) { return(JsonBadRequest("Data ID is required.")); } var data = await dataRepository.GetDataIncludeAllAsync(id.Value); if (data == null) { return(JsonNotFound($"Data Id {id.Value} is not found.")); } var model = new DetailsOutputModel(data); model.Tags = tagLogic.GetAllTags(data.Id).Select(t => t.Name); var parent = await preprocessHistoryRepository.GetInputDataAsync(data.Id); if (parent != null) { model.Parent = new IndexOutputModel(parent); } var children = preprocessHistoryRepository.GetPreprocessIncludePreprocessByInputDataId(data.Id); if (children != null & children.Count() > 0) { model.Children = children.Select(p => new PreprocessHistoryOutputModel(p)); } return(JsonOK(model)); }
public async Task <IActionResult> GetDetailForTenant(long?id) { if (id == null) { return(JsonBadRequest("Role ID is required.")); } var role = await roleRepository.GetRoleAsync(id.Value); if (role == null) { return(JsonNotFound($"Role Id {id.Value} is not found.")); } if (role.IsSystemRole == true || (role.TenantId != null && role.TenantId != CurrentUserInfo.SelectedTenant.Id)) { // 参照不可のロールにアクセスしようとしている LogWarning($"Role {role.Name} is not allowed to read by the current user."); return(JsonNotFound($"Role Id {id.Value} is not found.")); // エラーメッセージは404と変えない } var model = new DetailsOutputModel(role); if (model.TenantId != null) { model.TenantName = CurrentUserInfo.SelectedTenant.Name; } return(JsonOK(model)); }
public async Task <IActionResult> GetDetail(long?id, [FromServices] INodeTenantMapRepository nodeTenantMapRepository) { if (id == null) { return(JsonBadRequest("Node ID is required.")); } var node = await nodeRepository.GetByIdAsync(id.Value); if (node == null) { return(JsonNotFound($"Node Id {id.Value} is not found.")); } var model = new DetailsOutputModel(node); if (model.AccessLevel == NodeAccessLevel.Private) { //プライベートモードの時に限り、アクセス可能なテナントを探索する model.AssignedTenants = nodeRepository.GetAssignedTenants(node.Id).Select(t => new DetailsOutputModel.AssignedTenant() { Id = t.Id, Name = t.Name, DisplayName = t.DisplayName }); } return(JsonOK(model)); }
public async Task <IActionResult> GetDetail(long id) { var experiment = await experimentRepository .GetAll() .Include(x => x.Template) .Include(x => x.TemplateVersion) .Include(x => x.DataSet) .Include(x => x.DataSetVersion) .Include(x => x.TrainingHistory).ThenInclude(x => x.DataSet) .Include(x => x.ExperimentPreprocess).ThenInclude(x => x.TrainingHistory).ThenInclude(x => x.DataSet) .SingleOrDefaultAsync(x => x.Id == id); if (experiment == null) { return(JsonNotFound($"Experiment ID {id} is not found.")); } var preprocessStatus = await UpdateStatus(experiment.ExperimentPreprocess?.TrainingHistory); var trainingStatus = await UpdateStatus(experiment.TrainingHistory); var status = GetExperimentStatus(preprocessStatus, trainingStatus); var model = new DetailsOutputModel(experiment, status.ToString()); return(JsonOK(model)); }
public async Task <IActionResult> GetDetail(long?id) { 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)); }
public async Task <IActionResult> GetDetail(long?id) { if (id == null) { return(JsonBadRequest("DataSet ID is required.")); } var dataSet = await dataSetRepository.GetDataSetIncludeDataSetEntryAsync(id.Value); if (dataSet == null) { return(JsonNotFound($"DataSet Id {id.Value} is not found.")); } var model = new DetailsOutputModel(dataSet); if (dataSet.DataSetEntries != null) { //エントリの作成開始 var entities = new Dictionary <string, List <ApiModels.DataApiModels.IndexOutputModel> >(); var flatEntries = new List <ApiModels.DataApiModels.IndexOutputModel>(); //空のデータ種別も表示したい&順番を統一したいので、先に初期化しておく foreach (var dataType in dataTypeRepository.GetAllWithOrderby(d => d.SortOrder, true)) { entities.Add(dataType.Name, new List <ApiModels.DataApiModels.IndexOutputModel>()); } //エントリを一つずつ突っ込んでいく。件数次第では遅いかも。 foreach (var entry in dataSet.DataSetEntries) { var dataFile = new ApiModels.DataApiModels.IndexOutputModel(entry.Data); if (dataSet.IsFlat) { flatEntries.Add(dataFile); } else { string key = entry.DataType.Name; entities[key].Add(dataFile); } } //各種別内のデータについて、データIDの降順に並び替える foreach (var dataType in dataTypeRepository.GetAllWithOrderby(d => d.SortOrder, true)) { entities[dataType.Name].Sort((x, y) => y.Id.CompareTo(x.Id)); } flatEntries.Sort((x, y) => y.Id.CompareTo(x.Id)); model.Entries = entities; model.FlatEntries = flatEntries; } model.IsLocked = dataSet.IsLocked; return(JsonOK(model)); }
public async Task <IActionResult> GetDetail(long?id) { if (id == null) { return(JsonBadRequest("Training ID is required.")); } var history = await trainingHistoryRepository.GetIncludeAllAsync(id.Value); if (history == null) { return(JsonNotFound($"Training ID {id.Value} is not found.")); } var model = new DetailsOutputModel(history); model.Tags = tagLogic.GetAllTrainingHistoryTag(history.Id).Select(t => t.Name); var status = history.GetStatus(); model.StatusType = status.StatusType; if (status.Exist()) { //コンテナがまだ存在している場合、情報を更新する var details = await clusterManagementLogic.GetContainerDetailsInfoAsync(history.Key, CurrentUserInfo.SelectedTenant.Name, false); model.Status = details.Status.Name; model.StatusType = details.Status.StatusType; //ステータスを更新 history.Status = details.Status.Key; unitOfWork.Commit(); model.ConditionNote = details.ConditionNote; if (details.Status.IsRunning()) { // 開放ポート未指定時には行わない if (model.Ports != null && model.Ports.Count > 0) { var endpointInfo = await clusterManagementLogic.GetContainerEndpointInfoAsync(history.Key, CurrentUserInfo.SelectedTenant.Name, false); foreach (var endpoint in endpointInfo.EndPoints ?? new List <EndPointInfo>()) { //ノードポート番号を返す model.NodePorts.Add(new KeyValuePair <string, string>(endpoint.Key, endpoint.Port.ToString())); } } } } //Gitの表示用URLを作る model.GitModel.Url = gitLogic.GetTreeUiUrl(history.ModelGitId, history.ModelRepository, history.ModelRepositoryOwner, history.ModelCommitId); return(JsonOK(model)); }
public async Task <IActionResult> GetDetail(long?id) { if (id == null) { return(JsonBadRequest("Notebook ID is required.")); } var notebookHistory = await notebookHistoryRepository.GetIncludeAllAsync(id.Value); if (notebookHistory == null) { return(JsonNotFound($"Notebook ID {id.Value} is not found.")); } var model = new DetailsOutputModel(notebookHistory); var status = notebookHistory.GetStatus(); model.StatusType = status.StatusType; if (status.Exist()) { //コンテナがまだ存在している場合、情報を更新する var details = await clusterManagementLogic.GetContainerEndpointInfoAsync(notebookHistory.Key, CurrentUserInfo.SelectedTenant.Name, false); model.Status = details.Status.Name; model.StatusType = details.Status.StatusType; //ステータスを更新 notebookHistory.Status = details.Status.Key; if (notebookHistory.StartedAt == null) { notebookHistory.StartedAt = details.StartedAt; notebookHistory.Node = details.Node; //設計上ノードが切り替わることはない } unitOfWork.Commit(); model.ConditionNote = details.ConditionNote; //コンテナが正常動作している場合、notebookのエンドポイントを取得 if (details.Status.IsRunning()) { model.NotebookNodePort = GetNotebookNodePort(details.EndPoints); model.NotebookToken = await GetNotebookTokenAsync(notebookHistory.Id); } } if (notebookHistory.ModelGitId != null) { //Gitの表示用URLを作る model.GitModel.Url = gitLogic.GetTreeUiUrl(notebookHistory.ModelGitId.Value, notebookHistory.ModelRepository, notebookHistory.ModelRepositoryOwner, notebookHistory.ModelCommitId); } return(JsonOK(model)); }
public async Task <IActionResult> GetDetail(long?id) { if (id == null) { return(JsonBadRequest("Training ID is required.")); } var history = await trainingHistoryRepository.GetIncludeAllAsync(id.Value); if (history == null) { return(JsonNotFound($"Training ID {id.Value} is not found.")); } var model = new DetailsOutputModel(history); var status = history.GetStatus(); model.StatusType = status.StatusType; if (status.Exist()) { //コンテナがまだ存在している場合、情報を更新する var details = await clusterManagementLogic.GetContainerEndpointInfoAsync(history.Key, CurrentUserInfo.SelectedTenant.Name, false); model.Status = details.Status.Name; model.StatusType = details.Status.StatusType; //ステータスを更新 history.Status = details.Status.Key; if (history.StartedAt == null) { history.StartedAt = details.StartedAt; history.Node = details.Node; //設計上ノードが切り替わることはない } unitOfWork.Commit(); model.ConditionNote = details.ConditionNote; if (details.Status.IsRunning()) { //コンテナが正常に動いているので、エンドポイントを表示する model.Endpoints = details.EndPoints; } } //Gitの表示用URLを作る model.GitModel.Url = gitLogic.GetTreeUiUrl(history.ModelGitId, history.ModelRepository, history.ModelRepositoryOwner, history.ModelCommitId); return(JsonOK(model)); }
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)); }
public IActionResult GetDetails(long?id) { if (id == null) { return(JsonBadRequest("Tenant ID is required.")); } Tenant tenant = tenantRepository.Get(id.Value); if (tenant == null) { return(JsonNotFound($"Tenant Id {id.Value} is not found.")); } var model = new DetailsOutputModel(tenant); return(JsonOK(model)); }
public async Task <IActionResult> GetDetails(long?id) { if (id == null) { return(JsonBadRequest("Registry ID is required.")); } Registry registry = await registryRepository.GetByIdAsync(id.Value); if (registry == null) { return(JsonNotFound($"Registry Id {id.Value} is not found.")); } var model = new DetailsOutputModel(registry); return(JsonOK(model)); }
public IActionResult GetDetails(long?id) { if (id == null) { return(JsonBadRequest("Storage ID is required.")); } Storage storage = tenantRepository.GetStorage(id.Value); if (storage == null) { return(JsonNotFound($"Storage Id {id.Value} is not found.")); } var model = new DetailsOutputModel(storage); return(JsonOK(model)); }
public async Task <IActionResult> GetDetails(long?id) { if (id == null) { return(JsonBadRequest("Git ID is required.")); } Git git = await gitRepository.GetByIdAsync(id.Value); if (git == null) { return(JsonNotFound($"Git Id {id.Value} is not found.")); } var model = new DetailsOutputModel(git); return(JsonOK(model)); }
public async Task<IActionResult> GetDetailForAdmin(long? id, [FromServices] ITenantRepository tenantRepository) { if (id == null) { return JsonBadRequest("Role ID is required."); } var role = await roleRepository.GetRoleAsync(id.Value); if (role == null) { return JsonNotFound($"Node Id {id.Value} is not found."); } var model = new DetailsOutputModel(role); if (model.TenantId != null) { model.TenantName = tenantRepository.Get(model.TenantId.Value).Name; } return JsonOK(model); }