diff --git a/src/Serval/src/Serval.DataFiles/Consumers/GetCorpusConsumer.cs b/src/Serval/src/Serval.DataFiles/Consumers/GetCorpusConsumer.cs index d5ed424b..712f155c 100644 --- a/src/Serval/src/Serval.DataFiles/Consumers/GetCorpusConsumer.cs +++ b/src/Serval/src/Serval.DataFiles/Consumers/GetCorpusConsumer.cs @@ -28,8 +28,8 @@ await context.RespondAsync( Files = corpus .Files.Select(f => new CorpusFileResult { - TextId = f.TextId!, - File = Map(corpusDataFilesDict[f.FileRef]!) + TextId = f.TextId ?? corpusDataFilesDict[f.FileRef].Name, + File = Map(corpusDataFilesDict[f.FileRef]) }) .ToList() } diff --git a/src/Serval/src/Serval.DataFiles/Services/CorpusService.cs b/src/Serval/src/Serval.DataFiles/Services/CorpusService.cs index b453ec60..35dbad08 100644 --- a/src/Serval/src/Serval.DataFiles/Services/CorpusService.cs +++ b/src/Serval/src/Serval.DataFiles/Services/CorpusService.cs @@ -46,8 +46,8 @@ await _mediator.Publish( Files = corpus .Files.Select(f => new CorpusFileResult { - TextId = f.TextId!, - File = Map(corpusDataFilesDict[f.FileRef]!) + TextId = f.TextId ?? corpusDataFilesDict[f.FileRef].Name, + File = Map(corpusDataFilesDict[f.FileRef]) }) .ToList() }, diff --git a/src/Serval/src/Serval.Shared/Services/EntityServiceBase.cs b/src/Serval/src/Serval.Shared/Services/EntityServiceBase.cs index b46aa87f..a8626bff 100644 --- a/src/Serval/src/Serval.Shared/Services/EntityServiceBase.cs +++ b/src/Serval/src/Serval.Shared/Services/EntityServiceBase.cs @@ -13,6 +13,15 @@ public virtual async Task GetAsync(string id, CancellationToken cancellationT return entity; } + public virtual async Task> GetAllAsync( + IEnumerable ids, + CancellationToken cancellationToken = default + ) + { + HashSet idSet = ids.ToHashSet(); + return await Entities.GetAllAsync(e => idSet.Contains(e.Id), cancellationToken); + } + public virtual async Task CreateAsync(T entity, CancellationToken cancellationToken = default) { await Entities.InsertAsync(entity, cancellationToken); diff --git a/src/Serval/src/Serval.Shared/Services/OwnedEntityServiceBase.cs b/src/Serval/src/Serval.Shared/Services/OwnedEntityServiceBase.cs index 8760a937..2ddcd521 100644 --- a/src/Serval/src/Serval.Shared/Services/OwnedEntityServiceBase.cs +++ b/src/Serval/src/Serval.Shared/Services/OwnedEntityServiceBase.cs @@ -7,13 +7,4 @@ public virtual async Task> GetAllAsync(string owner, Cancellation { return await Entities.GetAllAsync(e => e.Owner == owner, cancellationToken); } - - public virtual async Task> GetAllAsync( - IEnumerable ids, - CancellationToken cancellationToken = default - ) - { - HashSet idSet = ids.ToHashSet(); - return await Entities.GetAllAsync(e => idSet.Contains(e.Id), cancellationToken); - } } diff --git a/src/Serval/src/Serval.Translation/Consumers/CorpusUpdatedConsumer.cs b/src/Serval/src/Serval.Translation/Consumers/CorpusUpdatedConsumer.cs index 366e8099..b096d30b 100644 --- a/src/Serval/src/Serval.Translation/Consumers/CorpusUpdatedConsumer.cs +++ b/src/Serval/src/Serval.Translation/Consumers/CorpusUpdatedConsumer.cs @@ -18,7 +18,7 @@ private static CorpusFile Map(CorpusFileResult corpusFile) return new CorpusFile { Id = corpusFile.File.DataFileId, - TextId = corpusFile.TextId, + TextId = corpusFile.TextId ?? corpusFile.File.Name, Filename = corpusFile.File.Filename, Format = corpusFile.File.Format, }; diff --git a/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs b/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs index 1fa13d74..47358472 100644 --- a/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs +++ b/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs @@ -1294,7 +1294,7 @@ CancellationToken cancellationToken Id = f.File.DataFileId, Filename = f.File.Filename, Format = f.File.Format, - TextId = f.TextId + TextId = f.TextId ?? f.File.Name }) .ToList(), }