=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===
This commit is contained in:
@@ -22,6 +22,7 @@ namespace adas_core.Infrastructure.Repositories;
|
||||
/// Repository implementation for managing DisplayConfig entities in MongoDB.
|
||||
/// Provides CRUD operations and specialized queries for display configurations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ca069f4 -->
|
||||
public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayConfigRepository
|
||||
{
|
||||
private readonly ApiSettings _apiSettings;
|
||||
@@ -35,6 +36,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="apiSettings">API settings containing collection names configuration.</param>
|
||||
/// <param name="logger">Logger for repository operations.</param>
|
||||
/// <param name="unitRepository">Repository for unit-related operations.</param>
|
||||
/// <!-- aidoc:v1 sig=a0aa8ef body=0dfcbb0 -->
|
||||
public DisplayConfigRepository(
|
||||
IMongoDatabase database,
|
||||
ApiSettings apiSettings,
|
||||
@@ -50,6 +52,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// Gets the name of the collection for display configurations.
|
||||
/// </summary>
|
||||
/// <returns>The collection name from API settings.</returns>
|
||||
/// <!-- aidoc:v1 sig=94e22ff body=f8787a2 -->
|
||||
public override string GetCollectionName()
|
||||
{
|
||||
return _apiSettings.DisplaysConfig;
|
||||
@@ -59,6 +62,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// Retrieves all display configurations from the database.
|
||||
/// </summary>
|
||||
/// <returns>A list of all DisplayConfig entities.</returns>
|
||||
/// <!-- aidoc:v1 sig=fb4ed8e body=24446a1 -->
|
||||
public async Task<List<DisplayConfig>> GetAll()
|
||||
{
|
||||
var result = await Collection.Find(Builders<DisplayConfig>.Filter.Empty).ToListAsync();
|
||||
@@ -71,6 +75,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="filter">The pagination and filtering parameters.</param>
|
||||
/// <returns>A fluent queryable for DisplayConfigSummary results.</returns>
|
||||
/// <exception cref="BadRequestException">Thrown when the text filter exceeds 100 characters.</exception>
|
||||
/// <!-- aidoc:v1 sig=02e1b9c body=5dc4416 -->
|
||||
public IFindFluent<DisplayConfig, DisplayConfigSummary> GetAllPaginated(PaginationFilter filter)
|
||||
{
|
||||
var filterBuilder = Builders<DisplayConfig>.Filter;
|
||||
@@ -116,6 +121,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="type">The display type to filter by.</param>
|
||||
/// <returns>A list of DisplayConfig entities matching the specified type.</returns>
|
||||
/// <!-- aidoc:v1 sig=8122d6c body=0e1c2e7 -->
|
||||
public async Task<List<DisplayConfig>> GetByType(DisplayConfigEnums.DisplayType type)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq(p => p.Type, type);
|
||||
@@ -129,6 +135,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="id">The ObjectId of the display configuration to retrieve.</param>
|
||||
/// <returns>The DisplayConfig with related data, or null if not found.</returns>
|
||||
/// <!-- aidoc:v1 sig=a9a2204 body=4378765 -->
|
||||
public async Task<DisplayConfig?> GetById(ObjectId id)
|
||||
{
|
||||
try
|
||||
@@ -231,6 +238,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="type">The display type to search for.</param>
|
||||
/// <returns>The default DisplayConfig for the specified type, or null if not found.</returns>
|
||||
/// <!-- aidoc:v1 sig=2078a2a body=724ce64 -->
|
||||
public async Task<DisplayConfig?> GetDefault(DisplayConfigEnums.DisplayType type)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.And(
|
||||
@@ -248,6 +256,8 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="config">The DisplayConfig to insert.</param>
|
||||
/// The inserted DisplayConfig, or null if insertion fails.
|
||||
/// <returns></returns>
|
||||
/// <!-- aidoc-review:v1 severity=low kind=wrong_returns
|
||||
/// "The <returns> tag is empty; the description 'The inserted DisplayConfig, or null if insertion fails.' is placed outside the tag, making the returns documentation structurally malformed." -->
|
||||
public async Task<DisplayConfig?> InsertOneAsyncAndReturn(DisplayConfig config)
|
||||
{
|
||||
try
|
||||
@@ -268,6 +278,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="displayConfigId">The ObjectId of the display configuration to update.</param>
|
||||
/// <param name="newDisplayConfig">The new SmartDisplay configuration to apply.</param>
|
||||
/// <returns>The updated SmartDisplay configuration, or null if update fails.</returns>
|
||||
/// <!-- aidoc:v1 sig=58bdfe0 body=590507f -->
|
||||
public async Task<SmartDisplay?> UpdateSmartDisplay(ObjectId displayConfigId, SmartDisplay? newDisplayConfig)
|
||||
{
|
||||
try
|
||||
@@ -315,6 +326,8 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="colorConfig">The new ColorConfig to apply.</param>
|
||||
/// <returns>True if the update was successful; otherwise, false.</returns>
|
||||
/// <exception cref="Exception">Throws an exception if MongoDB update fails.</exception>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_exception
|
||||
/// "The documentation claims the method throws an exception if the MongoDB update fails, but the method catches all exceptions internally and returns false instead of throwing." -->
|
||||
public async Task<bool> UpdateConfigColor(ObjectId objectIdConfigDisplay, ColorConfig colorConfig)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq("Id", objectIdConfigDisplay);
|
||||
@@ -362,6 +375,8 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="headerConfig">The new HeaderConfig to apply.</param>
|
||||
/// <returns>True if the update was successful; otherwise, false.</returns>
|
||||
/// <exception cref="Exception">Throws an exception if MongoDB update fails.</exception>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_exception
|
||||
/// "The method catches all exceptions internally and returns false rather than throwing; the documented exception is never propagated to callers." -->
|
||||
public async Task<bool> UpdateHeaderConfig(ObjectId objectIdConfigDisplay, HeaderConfig headerConfig)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq("Id", objectIdConfigDisplay);
|
||||
@@ -419,6 +434,8 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="bannerItems">The list of banner items to set.</param>
|
||||
/// <returns>True if the update was successful; otherwise, false.</returns>
|
||||
/// <exception cref="Exception">Throws an exception if MongoDB update fails.</exception>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_exception
|
||||
/// "The method catches all exceptions and returns false; it never throws an exception as documented." -->
|
||||
public async Task<bool> UpdateSetHomeBanner(ObjectId objectIdConfigDisplay, List<BannerItem> bannerItems)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq("Id", objectIdConfigDisplay);
|
||||
@@ -445,6 +462,8 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="baseConfig">The base DisplayConfig with updated values.</param>
|
||||
/// <returns>True if the update was successful; otherwise, false.</returns>
|
||||
/// <exception cref="Exception">Throws an exception if MongoDB update fails.</exception>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=extra_exception
|
||||
/// "The method catches all exceptions internally (try/catch logs and returns false) and never propagates an exception to the caller, yet the doc claims it throws Exception on MongoDB update failure." -->
|
||||
public async Task<bool> UpdateBaseConfig(ObjectId objectIdConfigDisplay, DisplayConfig baseConfig)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq("Id", objectIdConfigDisplay);
|
||||
@@ -475,6 +494,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="newDisplayConfig">The new DisplayNurseDto configuration to apply.</param>
|
||||
/// <param name="nurseObs">List of observation names to mark as "last".</param>
|
||||
/// <returns>The updated DisplayNurse configuration, or null if update fails.</returns>
|
||||
/// <!-- aidoc:v1 sig=0cb9b52 body=d8fcae3 -->
|
||||
public async Task<DisplayNurse?> UpdateDisplayNurse(ObjectId displayConfigId, DisplayNurseDto? newDisplayConfig,
|
||||
List<string> nurseObs)
|
||||
{
|
||||
@@ -537,6 +557,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="objectIdConfigDisplay">The ObjectId of the display configuration to update.</param>
|
||||
/// <param name="name">The new hospital name.</param>
|
||||
/// <returns>True if the update was successful; otherwise, false.</returns>
|
||||
/// <!-- aidoc:v1 sig=d760b75 body=7083954 -->
|
||||
public async Task<bool> UpdateDisplayConfigHospitalName(ObjectId objectIdConfigDisplay, string name)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq(c => c.Id, objectIdConfigDisplay);
|
||||
@@ -563,6 +584,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="objectIdConfigDisplay">The ObjectId of the display configuration to update.</param>
|
||||
/// <param name="fields">The new list of fields to set.</param>
|
||||
/// <returns>True if the update was successful; otherwise, false.</returns>
|
||||
/// <!-- aidoc:v1 sig=43fa539 body=cc10b03 -->
|
||||
public async Task<bool> UpdateFieldList(ObjectId objectIdConfigDisplay, List<Field> fields)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq(x => x.Id, objectIdConfigDisplay);
|
||||
@@ -578,6 +600,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="unitId">The ObjectId of the unit.</param>
|
||||
/// <param name="displayType">The type of display configuration to retrieve.</param>
|
||||
/// <returns>The default DisplayConfig for the unit, or null if not found.</returns>
|
||||
/// <!-- aidoc:v1 sig=af33a33 body=295e51e -->
|
||||
public async Task<DisplayConfig?> GetDefaultByUnitIdAndType(ObjectId unitId,
|
||||
DisplayConfigEnums.DisplayType displayType)
|
||||
{
|
||||
@@ -602,6 +625,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="objectIdConfigDisplay">The ObjectId of the display configuration to delete.</param>
|
||||
/// <returns>The deleted DisplayConfig, or null if not found.</returns>
|
||||
/// <!-- aidoc:v1 sig=cb87e31 body=36ac5e8 -->
|
||||
public async Task<DisplayConfig?> DeleteDisplayConfig(ObjectId objectIdConfigDisplay)
|
||||
{
|
||||
return await DeleteAsync(objectIdConfigDisplay);
|
||||
@@ -611,6 +635,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// Retrieves all display configurations in compact format (minimal response).
|
||||
/// </summary>
|
||||
/// <returns>A list of DisplayConfigMinimalResponse containing Id, Hospital, and Type.</returns>
|
||||
/// <!-- aidoc:v1 sig=5f61162 body=223c235 -->
|
||||
public Task<List<DisplayConfigMinimalResponse>> GetAllCompact()
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Empty;
|
||||
@@ -629,6 +654,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="cardConfigId">The ObjectId of the card configuration.</param>
|
||||
/// <returns>A list of ObjectIds for display configurations using the specified card config.</returns>
|
||||
/// <!-- aidoc:v1 sig=019036b body=4e73250 -->
|
||||
public async Task<List<ObjectId>> GetAllByCardConfigId(ObjectId cardConfigId)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq(d => d.CardConfigId, cardConfigId);
|
||||
@@ -645,6 +671,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="cardConfigId">The ObjectId of the card configuration.</param>
|
||||
/// <returns>A list of ObjectIds for display configurations using the specified card config in main or rotating layout.</returns>
|
||||
/// <!-- aidoc:v1 sig=295400b body=1b55ad2 -->
|
||||
public async Task<List<ObjectId>> GetAllByCardConfigIdAndRotating(ObjectId cardConfigId)
|
||||
{
|
||||
var mainFilter = Builders<DisplayConfig>.Filter.Eq(d => d.CardConfigId, cardConfigId);
|
||||
@@ -669,6 +696,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="displayConfigId">The ObjectId of the display configuration to update.</param>
|
||||
/// <param name="resultId">The new card configuration ID to set.</param>
|
||||
/// <returns>True if the update was successful; otherwise, false.</returns>
|
||||
/// <!-- aidoc:v1 sig=bdfb090 body=66dd0a1 -->
|
||||
public async Task<bool> UpdateCardConfigId(ObjectId? displayConfigId, ObjectId? resultId)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq(x => x.Id, displayConfigId);
|
||||
@@ -684,6 +712,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="displayConfigId">The ObjectId of the display configuration to update.</param>
|
||||
/// <param name="newChartIdToAdd">The new chart configuration ID to add.</param>
|
||||
/// <returns>True if the update was successful; otherwise, false.</returns>
|
||||
/// <!-- aidoc:v1 sig=1b8d34f body=b651a1f -->
|
||||
public async Task<bool> AddChartId(ObjectId? displayConfigId, ObjectId newChartIdToAdd)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq(x => x.Id, displayConfigId);
|
||||
@@ -700,6 +729,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="deletedId">The ObjectId of the chart configuration that was deleted.</param>
|
||||
/// <returns>The MongoDB UpdateResult indicating the number of modified documents.</returns>
|
||||
/// <exception cref="Exception">Throws an exception if MongoDB operation fails.</exception>
|
||||
/// <!-- aidoc:v1 sig=075b13a body=f79af77 -->
|
||||
public async Task<UpdateResult> UpdateDeletedChartConfig(ObjectId deletedId)
|
||||
{
|
||||
try
|
||||
@@ -723,6 +753,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="objectIdConfigChart">The ObjectId of the chart configuration.</param>
|
||||
/// <returns>Always throws NotImplementedException.</returns>
|
||||
/// <exception cref="NotImplementedException">This method is not implemented.</exception>
|
||||
/// <!-- aidoc:v1 sig=a5f05a4 body=bfa6f2f -->
|
||||
public Task<ChartConfig> GetChartConfig(ObjectId objectIdConfigChart)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -734,6 +765,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="displayConfigId">The ObjectId of the display configuration to update.</param>
|
||||
/// <param name="resultId">The new detail configuration ID to set.</param>
|
||||
/// <returns>True if the update was successful; otherwise, false.</returns>
|
||||
/// <!-- aidoc:v1 sig=4dd76a3 body=4d42278 -->
|
||||
public async Task<bool> UpdateDetailConfigId(ObjectId? displayConfigId, ObjectId? resultId)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq(x => x.Id, displayConfigId);
|
||||
@@ -748,6 +780,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="baseConfigId">The ObjectId of the detail configuration.</param>
|
||||
/// <returns>A list of ObjectIds for display configurations using the specified detail config.</returns>
|
||||
/// <!-- aidoc:v1 sig=63a6ce8 body=8cc75f6 -->
|
||||
public async Task<List<ObjectId>> GetAllByCardDetailConfigId(ObjectId baseConfigId)
|
||||
{
|
||||
var filter = Builders<DisplayConfig>.Filter.Eq(d => d.DetailConfigId, baseConfigId);
|
||||
@@ -768,6 +801,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// - SmartDisplay
|
||||
/// - StandarDisplay
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=ccdefcf body=119a973 -->
|
||||
public sealed override async Task InsertInitialLoad()
|
||||
{
|
||||
// 1. Obtener todos los valores y castear al tipo IEnumerable<DisplayType>
|
||||
@@ -828,6 +862,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="newDisplayConfig">The DisplayNurseDto configuration to extract fields from.</param>
|
||||
/// <param name="nurseObs">List of observation names to mark as "last" priority.</param>
|
||||
/// <returns>A list of Field objects with extracted observation names.</returns>
|
||||
/// <!-- aidoc:v1 sig=be49f7a body=ac425f2 -->
|
||||
private List<Field> ExtractObservationFields(DisplayNurseDto newDisplayConfig, List<string> nurseObs)
|
||||
{
|
||||
var fieldSet = new HashSet<string>();
|
||||
@@ -859,6 +894,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="newDisplayConfig">The JSON string to search for observation names.</param>
|
||||
/// <param name="regex">The regex pattern to match observation name arrays.</param>
|
||||
/// <param name="fieldSet">The hash set to populate with field names.</param>
|
||||
/// <!-- aidoc:v1 sig=04f2381 body=6fed3f0 -->
|
||||
private void FillHashSet(string newDisplayConfig, Regex regex, HashSet<string> fieldSet)
|
||||
{
|
||||
var matches = regex.Matches(newDisplayConfig);
|
||||
@@ -877,6 +913,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="cells">The list of cells to extract from.</param>
|
||||
/// <param name="fieldSet">The hash set to populate with field names.</param>
|
||||
/// <!-- aidoc:v1 sig=dc14082 body=a8faa74 -->
|
||||
private void ExtractFromCells(List<Cell>? cells, HashSet<string> fieldSet)
|
||||
{
|
||||
if (cells is null)
|
||||
@@ -900,6 +937,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="cells">The list of detail cells to extract from.</param>
|
||||
/// <param name="fieldSet">The hash set to populate with field names.</param>
|
||||
/// <!-- aidoc:v1 sig=263c487 body=3b85da1 -->
|
||||
private void ExtractFromDetailsCells(List<CellDetails>? cells, HashSet<string> fieldSet)
|
||||
{
|
||||
if (cells is null)
|
||||
@@ -924,6 +962,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// <param name="filters">List of filter definitions to apply.</param>
|
||||
/// <param name="sort">Sort definition for the query results.</param>
|
||||
/// <returns>A fluent queryable for DisplayConfigSummary.</returns>
|
||||
/// <!-- aidoc:v1 sig=2b4f3c2 body=ceac316 -->
|
||||
private IFindFluent<DisplayConfig, DisplayConfigSummary> CreateFindFluentMinimal(
|
||||
List<FilterDefinition<DisplayConfig>> filters,
|
||||
SortDefinition<DisplayConfig> sort)
|
||||
@@ -948,6 +987,7 @@ public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayC
|
||||
/// </summary>
|
||||
/// <param name="baseConfig">The base DisplayConfig with values to update.</param>
|
||||
/// <returns>A tuple containing list of update definitions and list of field names.</returns>
|
||||
/// <!-- aidoc:v1 sig=9aca42d body=1c04095 -->
|
||||
private (List<UpdateDefinition<DisplayConfig>> Updates, List<string> Fields) GetBaseUpdateDefinition(
|
||||
DisplayConfig baseConfig)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user