-
Notifications
You must be signed in to change notification settings - Fork 1
LEGLINK-697: Create Separate DMRP C# Project & Module Structure #1776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d5b0c3e
Create/scaffold DMRP service
smailliwcs 09767f8
Add DMRP health check to UI
smailliwcs 2808bfd
Merge branch 'dev' into user/steven.williams/LEGLINK-697
smailliwcs e9b4657
Add TODOs for entity mapping
smailliwcs f697409
Rethrow `OperationCanceledException`
smailliwcs 7e5ef62
Sanitize user-provided values
smailliwcs aff5e6a
Add range check for page size
smailliwcs 1568517
Fix typos
smailliwcs f439adf
Return paged responses for search
smailliwcs a41eeb0
Add unit tests
smailliwcs eb99358
Merge branch 'dev' into user/steven.williams/LEGLINK-697
smailliwcs 5507a0e
Configure DMRP service URLs
smailliwcs d0f9fb9
Merge branch 'dev' into user/steven.williams/LEGLINK-697
smailliwcs e35d748
Convert DMRP to class library
smailliwcs 518536e
Tweak routes to match ADR
smailliwcs f6aa2b6
Merge branch 'dev' into user/steven.williams/LEGLINK-697
smailliwcs 298f94a
Remove explicit null-body checks
smailliwcs 680972a
Use `AddDmrpModule` directly in test fixture
smailliwcs af34db9
Log at startup whether DMRP is enabled
smailliwcs 8866ac1
Revert whitespace-only change
smailliwcs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ trigger: | |
| paths: | ||
| include: | ||
| - DotNet/Tenant/* | ||
| - DotNet/DMRP/* | ||
| - DotNet/Shared/* | ||
| exclude: | ||
| - '*' | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
DotNet/DMRP/Business/Managers/FacilityReportingPlanManager.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| using LantanaGroup.Link.DMRP.Data.Entities; | ||
| using LantanaGroup.Link.Shared.Application.Models; | ||
| using LantanaGroup.Link.Shared.Application.Services.Security; | ||
| using LantanaGroup.Link.Shared.Domain.Repositories.Interfaces; | ||
| using OpenTelemetry.Trace; | ||
| using System.Diagnostics; | ||
|
|
||
| namespace LantanaGroup.Link.DMRP.Business.Managers | ||
| { | ||
| public interface IFacilityReportingPlanManager | ||
| { | ||
| Task<FacilityReportingPlan> CreateAsync(FacilityReportingPlan newFacilityReportingPlan, CancellationToken cancellationToken = default); | ||
| Task UpdateAsync(string id, FacilityReportingPlan facilityReportingPlan, CancellationToken cancellationToken = default); | ||
| Task DeleteAsync(string id, CancellationToken cancellationToken = default); | ||
| } | ||
|
|
||
| public class FacilityReportingPlanManager : IFacilityReportingPlanManager | ||
| { | ||
| private readonly ILogger<FacilityReportingPlanManager> _logger; | ||
| private readonly IEntityRepository<FacilityReportingPlan> _repository; | ||
|
|
||
| public FacilityReportingPlanManager(ILogger<FacilityReportingPlanManager> logger, IEntityRepository<FacilityReportingPlan> repository) | ||
| { | ||
| _logger = logger ?? throw new ArgumentNullException(nameof(logger)); | ||
| _repository = repository ?? throw new ArgumentNullException(nameof(repository)); | ||
| } | ||
|
|
||
| public async Task<FacilityReportingPlan> CreateAsync(FacilityReportingPlan newFacilityReportingPlan, CancellationToken cancellationToken = default) | ||
| { | ||
| using Activity? activity = ServiceActivitySource.Instance.StartActivity("Create Facility Reporting Plan"); | ||
|
|
||
| try | ||
| { | ||
| await _repository.AddAsync(newFacilityReportingPlan, cancellationToken); | ||
| await _repository.SaveChangesAsync(cancellationToken); | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| throw; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Activity.Current?.SetStatus(ActivityStatusCode.Error); | ||
| Activity.Current?.AddException(ex); | ||
| throw new ApplicationException("Facility reporting plan failed to create. " + ex.Message); | ||
| } | ||
|
|
||
| return newFacilityReportingPlan; | ||
| } | ||
|
|
||
| public async Task UpdateAsync(string id, FacilityReportingPlan facilityReportingPlan, CancellationToken cancellationToken = default) | ||
| { | ||
| using Activity? activity = ServiceActivitySource.Instance.StartActivity("Update Facility Reporting Plan"); | ||
|
|
||
| var existing = await _repository.GetAsync(id, cancellationToken); | ||
| if (existing is null) | ||
| { | ||
| _logger.LogError("Facility reporting plan with Id: {Id} not found", id.SanitizeForLog()); | ||
| throw new ApplicationException($"Facility reporting plan with Id: {id} not found"); | ||
| } | ||
|
|
||
| // TODO: Map `facilityReportingPlan` to `existing` | ||
|
|
||
| try | ||
| { | ||
| _repository.Update(existing); | ||
| await _repository.SaveChangesAsync(cancellationToken); | ||
|
smailliwcs marked this conversation as resolved.
|
||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| throw; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Activity.Current?.SetStatus(ActivityStatusCode.Error); | ||
| Activity.Current?.AddException(ex); | ||
| throw new ApplicationException($"Facility reporting plan {id} failed to update. " + ex.Message); | ||
| } | ||
| } | ||
|
|
||
| public async Task DeleteAsync(string id, CancellationToken cancellationToken = default) | ||
| { | ||
| using Activity? activity = ServiceActivitySource.Instance.StartActivity("Delete Facility Reporting Plan"); | ||
|
|
||
| var existing = await _repository.GetAsync(id, cancellationToken); | ||
| if (existing is null) | ||
| { | ||
| _logger.LogError("Facility reporting plan with Id: {Id} not found", id.SanitizeForLog()); | ||
| throw new ApplicationException($"Facility reporting plan with Id: {id} not found"); | ||
| } | ||
|
|
||
| try | ||
| { | ||
| _repository.Remove(existing); | ||
| await _repository.SaveChangesAsync(cancellationToken); | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| throw; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Activity.Current?.SetStatus(ActivityStatusCode.Error); | ||
| Activity.Current?.AddException(ex); | ||
| throw new ApplicationException($"Facility reporting plan {id} failed to delete. " + ex.Message); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| using LantanaGroup.Link.DMRP.Data.Entities; | ||
| using LantanaGroup.Link.Shared.Application.Models; | ||
| using LantanaGroup.Link.Shared.Application.Services.Security; | ||
| using LantanaGroup.Link.Shared.Domain.Repositories.Interfaces; | ||
| using OpenTelemetry.Trace; | ||
| using System.Diagnostics; | ||
|
|
||
| namespace LantanaGroup.Link.DMRP.Business.Managers | ||
| { | ||
| public interface IMeasureMappingManager | ||
| { | ||
| Task<MeasureMapping> CreateAsync(MeasureMapping newMeasureMapping, CancellationToken cancellationToken = default); | ||
| Task UpdateAsync(string id, MeasureMapping measureMapping, CancellationToken cancellationToken = default); | ||
| Task DeleteAsync(string id, CancellationToken cancellationToken = default); | ||
| } | ||
|
|
||
| public class MeasureMappingManager : IMeasureMappingManager | ||
| { | ||
| private readonly ILogger<MeasureMappingManager> _logger; | ||
| private readonly IEntityRepository<MeasureMapping> _repository; | ||
|
|
||
| public MeasureMappingManager(ILogger<MeasureMappingManager> logger, IEntityRepository<MeasureMapping> repository) | ||
| { | ||
| _logger = logger ?? throw new ArgumentNullException(nameof(logger)); | ||
| _repository = repository ?? throw new ArgumentNullException(nameof(repository)); | ||
| } | ||
|
|
||
| public async Task<MeasureMapping> CreateAsync(MeasureMapping newMeasureMapping, CancellationToken cancellationToken = default) | ||
| { | ||
| using Activity? activity = ServiceActivitySource.Instance.StartActivity("Create Measure Mapping"); | ||
|
|
||
| try | ||
| { | ||
| await _repository.AddAsync(newMeasureMapping, cancellationToken); | ||
| await _repository.SaveChangesAsync(cancellationToken); | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| throw; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Activity.Current?.SetStatus(ActivityStatusCode.Error); | ||
| Activity.Current?.AddException(ex); | ||
| throw new ApplicationException("Measure mapping failed to create. " + ex.Message); | ||
| } | ||
|
|
||
| return newMeasureMapping; | ||
| } | ||
|
|
||
| public async Task UpdateAsync(string id, MeasureMapping measureMapping, CancellationToken cancellationToken = default) | ||
| { | ||
| using Activity? activity = ServiceActivitySource.Instance.StartActivity("Update Measure Mapping"); | ||
|
|
||
| var existing = await _repository.GetAsync(id, cancellationToken); | ||
| if (existing is null) | ||
| { | ||
| _logger.LogError("Measure mapping with Id: {Id} not found", id.SanitizeForLog()); | ||
| throw new ApplicationException($"Measure mapping with Id: {id} not found"); | ||
| } | ||
|
|
||
| // TODO: Map `measureMapping` to `existing` | ||
|
|
||
| try | ||
| { | ||
| _repository.Update(existing); | ||
| await _repository.SaveChangesAsync(cancellationToken); | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| throw; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Activity.Current?.SetStatus(ActivityStatusCode.Error); | ||
| Activity.Current?.AddException(ex); | ||
| throw new ApplicationException($"Measure mapping {id} failed to update. " + ex.Message); | ||
| } | ||
| } | ||
|
|
||
| public async Task DeleteAsync(string id, CancellationToken cancellationToken = default) | ||
| { | ||
| using Activity? activity = ServiceActivitySource.Instance.StartActivity("Delete Measure Mapping"); | ||
|
|
||
| var existing = await _repository.GetAsync(id, cancellationToken); | ||
| if (existing is null) | ||
| { | ||
| _logger.LogError("Measure mapping with Id: {Id} not found", id.SanitizeForLog()); | ||
| throw new ApplicationException($"Measure mapping with Id: {id} not found"); | ||
| } | ||
|
|
||
| try | ||
| { | ||
| _repository.Remove(existing); | ||
| await _repository.SaveChangesAsync(cancellationToken); | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| throw; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Activity.Current?.SetStatus(ActivityStatusCode.Error); | ||
| Activity.Current?.AddException(ex); | ||
| throw new ApplicationException($"Measure mapping {id} failed to delete. " + ex.Message); | ||
| } | ||
| } | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
DotNet/DMRP/Business/Queries/FacilityReportingPlanQueries.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| using LantanaGroup.Link.DMRP.Data.Entities; | ||
| using LantanaGroup.Link.DMRP.Models; | ||
| using LantanaGroup.Link.Shared.Application.Enums; | ||
| using LantanaGroup.Link.Shared.Application.Models.Integration.DMRP; | ||
| using LantanaGroup.Link.Shared.Domain.Repositories.Interfaces; | ||
|
|
||
| namespace LantanaGroup.Link.DMRP.Business.Queries | ||
| { | ||
| public interface IFacilityReportingPlanQueries | ||
| { | ||
| Task<FacilityReportingPlanModel?> GetAsync(string id, CancellationToken cancellationToken = default); | ||
|
|
||
| Task<PagedFacilityReportingPlanDto> PagedSearchAsync(string sortBy = "Id", SortOrder sortOrder = SortOrder.Descending, | ||
| int pageSize = 10, int pageNumber = 1, CancellationToken cancellationToken = default); | ||
| } | ||
|
|
||
| public class FacilityReportingPlanQueries : IFacilityReportingPlanQueries | ||
| { | ||
| private readonly IEntityRepository<FacilityReportingPlan> _repository; | ||
|
|
||
| public FacilityReportingPlanQueries(IEntityRepository<FacilityReportingPlan> repository) | ||
| { | ||
| _repository = repository ?? throw new ArgumentNullException(nameof(repository)); | ||
| } | ||
|
|
||
| public async Task<FacilityReportingPlanModel?> GetAsync(string id, CancellationToken cancellationToken = default) | ||
| { | ||
| var entity = await _repository.FirstOrDefaultAsync(p => p.Id == id, cancellationToken); | ||
|
|
||
| return entity == null ? null : ToModel(entity); | ||
| } | ||
|
|
||
| public async Task<PagedFacilityReportingPlanDto> PagedSearchAsync(string sortBy = "Id", | ||
| SortOrder sortOrder = SortOrder.Descending, int pageSize = 10, int pageNumber = 1, | ||
| CancellationToken cancellationToken = default) | ||
| { | ||
| var (records, metadata) = await _repository.SearchAsync(p => true, sortBy, sortOrder, | ||
| pageSize, pageNumber, cancellationToken); | ||
|
|
||
| return new PagedFacilityReportingPlanDto | ||
| { | ||
| Metadata = metadata, | ||
| Records = records.Select(ToModel).ToList() | ||
| }; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| private static FacilityReportingPlanModel ToModel(FacilityReportingPlan entity) => new() { Id = entity.Id }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| using LantanaGroup.Link.DMRP.Data.Entities; | ||
| using LantanaGroup.Link.DMRP.Models; | ||
| using LantanaGroup.Link.Shared.Application.Enums; | ||
| using LantanaGroup.Link.Shared.Application.Models.Integration.DMRP; | ||
| using LantanaGroup.Link.Shared.Domain.Repositories.Interfaces; | ||
|
|
||
| namespace LantanaGroup.Link.DMRP.Business.Queries | ||
| { | ||
| public interface IMeasureMappingQueries | ||
| { | ||
| Task<MeasureMappingModel?> GetAsync(string id, CancellationToken cancellationToken = default); | ||
|
|
||
| Task<PagedMeasureMappingDto> PagedSearchAsync(string sortBy = "Id", SortOrder sortOrder = SortOrder.Descending, | ||
| int pageSize = 10, int pageNumber = 1, CancellationToken cancellationToken = default); | ||
| } | ||
|
|
||
| public class MeasureMappingQueries : IMeasureMappingQueries | ||
| { | ||
| private readonly IEntityRepository<MeasureMapping> _repository; | ||
|
|
||
| public MeasureMappingQueries(IEntityRepository<MeasureMapping> repository) | ||
| { | ||
| _repository = repository ?? throw new ArgumentNullException(nameof(repository)); | ||
| } | ||
|
|
||
| public async Task<MeasureMappingModel?> GetAsync(string id, CancellationToken cancellationToken = default) | ||
| { | ||
| var entity = await _repository.FirstOrDefaultAsync(m => m.Id == id, cancellationToken); | ||
|
|
||
| return entity == null ? null : ToModel(entity); | ||
| } | ||
|
|
||
| public async Task<PagedMeasureMappingDto> PagedSearchAsync(string sortBy = "Id", | ||
| SortOrder sortOrder = SortOrder.Descending, int pageSize = 10, int pageNumber = 1, | ||
| CancellationToken cancellationToken = default) | ||
| { | ||
| var (records, metadata) = await _repository.SearchAsync(m => true, sortBy, sortOrder, | ||
| pageSize, pageNumber, cancellationToken); | ||
|
|
||
| return new PagedMeasureMappingDto | ||
| { | ||
| Metadata = metadata, | ||
| Records = records.Select(ToModel).ToList() | ||
| }; | ||
| } | ||
|
|
||
| private static MeasureMappingModel ToModel(MeasureMapping entity) => new() { Id = entity.Id }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| namespace LantanaGroup.Link.DMRP.Config | ||
| { | ||
| /// <summary> | ||
| /// Settings that control the DMRP module hosted by the Tenant service. | ||
| /// </summary> | ||
| public class DmrpSettings | ||
| { | ||
| public const string ConfigSectionName = "DMRP"; | ||
|
|
||
| /// <summary> | ||
| /// When false, none of the DMRP controllers, persistence or scheduling behavior is registered | ||
| /// and the host continues to perform facility dQM reporting on its own. | ||
| /// </summary> | ||
| public bool Enabled { get; set; } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.