コード例 #1
0
        public async Task <IActionResult> GetDetailTemplateVersion(long id, long versionId)
        {
            var templateVersion = await templateVersionRepository
                                  .GetAll()
                                  .Include(x => x.PreprocessContainerRegistry)
                                  .Include(x => x.TrainingContainerRegistry)
                                  .Include(x => x.EvaluationContainerRegistry)
                                  .SingleOrDefaultAsync(x => x.Id == versionId && x.TemplateId == id);

            if (templateVersion == null)
            {
                return(JsonNotFound($"TemplateVersion (Id {id} VersionId {versionId}) is not found."));
            }

            var model = new VersionDetailsOutputModel(templateVersion);

            // Gitの表示用URLを作る
            if (templateVersion.PreprocessRepositoryGitId != null)
            {
                model.PreprocessGitModel.Url = gitLogic.GetTreeUiUrl(templateVersion.PreprocessRepositoryGitId.Value, templateVersion.PreprocessRepositoryName, templateVersion.PreprocessRepositoryOwner, templateVersion.PreprocessRepositoryCommitId);
            }
            model.TrainingGitModel.Url = gitLogic.GetTreeUiUrl(templateVersion.TrainingRepositoryGitId, templateVersion.TrainingRepositoryName, templateVersion.TrainingRepositoryOwner, templateVersion.TrainingRepositoryCommitId);
            if (templateVersion.EvaluationRepositoryGitId != null)
            {
                model.EvaluationGitModel.Url = gitLogic.GetTreeUiUrl(templateVersion.EvaluationRepositoryGitId.Value, templateVersion.EvaluationRepositoryName, templateVersion.EvaluationRepositoryOwner, templateVersion.EvaluationRepositoryCommitId);
            }

            return(JsonOK(model));
        }
コード例 #2
0
        public async Task <IActionResult> GetDataSetVersion(long id, long versionId)
        {
            var dataSetVersion = await aquariumDataSetVersionRepository
                                 .GetAll()
                                 .Include(x => x.DataSet)
                                 .ThenInclude(d => d.DataSetEntries)
                                 .ThenInclude(d => d.Data)
                                 .SingleOrDefaultAsync(x => x.Id == versionId && x.AquariumDataSetId == id);

            if (dataSetVersion == null)
            {
                return(JsonNotFound($"DataSetVersion (AquariumDataSetId {id} and VersionId {versionId}) is not found."));
            }

            var result  = new VersionDetailsOutputModel(dataSetVersion);
            var dataSet = dataSetVersion.DataSet;

            if (dataSet.DataSetEntries != null)
            {
                result.Entries     = new Dictionary <string, List <ApiModels.DataApiModels.IndexOutputModel> >();
                result.FlatEntries = new List <ApiModels.DataApiModels.IndexOutputModel>();

                foreach (var dataType in dataTypeRepository.GetAllWithOrderby(d => d.SortOrder, true))
                {
                    result.Entries.Add(dataType.Name, new List <ApiModels.DataApiModels.IndexOutputModel>());
                }

                if (dataSet.IsFlat)
                {
                    result.FlatEntries = dataSet.DataSetEntries
                                         .OrderByDescending(x => x.Data.Id)
                                         .Select(x => new ApiModels.DataApiModels.IndexOutputModel(x.Data));
                }
                else
                {
                    foreach (var x in dataSet.DataSetEntries.OrderByDescending(x => x.Data.Id))
                    {
                        result.Entries[x.DataType.Name].Add(new ApiModels.DataApiModels.IndexOutputModel(x.Data));
                    }
                }
            }
            result.Memo = dataSet.Memo;
            return(JsonOK(result));
        }