Skip to content
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

CDMS-200 initial version of decision refactoring #27

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Btms.Analytics/MovementsAggregationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Btms.Common.Extensions;
using Btms.Model.Extensions;
using Btms.Model;
using Btms.Model.Alvs;
using Btms.Model.Cds;
using Btms.Model.Auditing;
using Btms.Model.Ipaffs;
using MongoDB.Bson;
Expand Down Expand Up @@ -344,7 +344,7 @@ public Task<SummarisedDataset<SingleSeriesDataset, StringBucketDimensionResult>>
.FirstOrDefault())
// Creates a default item & check so we don't lose
// it in the selectmany below
?? new AlvsClearanceRequest()
?? new CdsClearanceRequest()
{
Items = new []
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using TestDataGenerator;
using TestDataGenerator.Scenarios;
using Xunit;
using Check = Btms.Model.Alvs.Check;
using Check = Btms.Model.Cds.Check;
using Decision = Btms.Model.Ipaffs.Decision;

namespace Btms.Business.Tests.Services.Decisions;
Expand Down
8 changes: 4 additions & 4 deletions Btms.Business.Tests/Services/Linking/LinkingServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using Btms.Backend.Data.InMemory;
using Btms.Business.Services.Linking;
using Btms.Metrics;
using Btms.Model.Alvs;
using Btms.Model.Cds;
using Btms.Model.ChangeLog;
using Btms.Model.Ipaffs;
using FluentAssertions;
using Microsoft.Extensions.Logging.Abstractions;
using Xunit;
using Document = Btms.Model.Alvs.Document;
using Items = Btms.Model.Alvs.Items;
using Document = Btms.Model.Cds.Document;
using Items = Btms.Model.Cds.Items;
using Movement = Btms.Model.Movement;

namespace Btms.Business.Tests.Services.Linking;
Expand Down Expand Up @@ -393,7 +393,7 @@ private ImportNotificationLinkContext CreateNotificationContext(int chedReferenc
EntryReference = entryRef,
ClearanceRequests =
[
new AlvsClearanceRequest
new CdsClearanceRequest
{
Header = new() { EntryReference = entryRef, EntryVersionNumber = 3, DeclarationType = "F" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task<PreProcessingResult<Movement>> Process(PreProcessingContext<Al

}

public static Movement BuildMovement(Model.Alvs.AlvsClearanceRequest request)
public static Movement BuildMovement(Model.Cds.CdsClearanceRequest request)
{
return new Movement
{
Expand Down
4 changes: 2 additions & 2 deletions Btms.Business/Services/Decisions/DecisionMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static IEnumerable<Items> BuildItems(Movement movement, IGrouping<string
}
}

private static IEnumerable<Check> BuildChecks(Model.Alvs.Items item, IGrouping<int, DocumentDecisionResult> itemsGroup)
private static IEnumerable<Check> BuildChecks(Model.Cds.Items item, IGrouping<int, DocumentDecisionResult> itemsGroup)
{
if (item.Checks != null)
{
Expand All @@ -81,7 +81,7 @@ private static IEnumerable<Check> BuildChecks(Model.Alvs.Items item, IGrouping<i
}
}

public static string[] BuildDecisionReasons(Model.Alvs.Items item, DecisionCode decisionCode)
public static string[] BuildDecisionReasons(Model.Cds.Items item, DecisionCode decisionCode)
{
switch (decisionCode)
{
Expand Down
2 changes: 1 addition & 1 deletion Btms.Business/Services/Matching/MatchingContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;
using Btms.Model;
using Btms.Model.Alvs;
using Btms.Model.Cds;
using Btms.Model.Ipaffs;

namespace Btms.Business.Services.Matching;
Expand Down
8 changes: 5 additions & 3 deletions Btms.Model/Auditing/AuditEntry.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using Btms.Model.Cds;
using Btms.Model.ChangeLog;
using Btms.Model.Extensions;
using Json.Patch;
Expand All @@ -26,7 +27,9 @@ public class AuditEntry

public List<AuditDiffEntry> Diff { get; set; } = new();

public Dictionary<string, Dictionary<string, string>> Context { get; set; } = new();
// TODO - getting a serialisation error when using IAuditContext
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its a BSON error, then if you put BsonKnownTypes on the interface, i think that fixes it (it auto adds a _t field with the type name so it knows the concrete type to deserialise back into)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attribute 'MongoDB.Bson.Serialization.Attributes.BsonKnownTypesAttribute' is not valid on this declaration type. It is valid on 'Class, Struct' declarations only.

So not valid on either an interface or property :(

// But as we only do this for decisions ignoring!
public DecisionContext? Context { get; set; }

public bool IsCreatedOrUpdated()
{
Expand Down Expand Up @@ -131,7 +134,7 @@ public static AuditEntry CreateMatch(string id, int version)
}

public static AuditEntry CreateDecision(string id, int version,
DateTime? lastUpdated, string lastUpdatedBy, Dictionary<string, Dictionary<string, string>> context, bool isAlvs)
DateTime? lastUpdated, string lastUpdatedBy, DecisionContext context, bool isAlvs)
{
return new AuditEntry()
{
Expand All @@ -141,7 +144,6 @@ public static AuditEntry CreateDecision(string id, int version,
CreatedLocal = DateTime.UtcNow,
Status = "Decision",
Context = context

};
}

Expand Down
6 changes: 6 additions & 0 deletions Btms.Model/Auditing/IAuditContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Btms.Model.Auditing;

public interface IAuditContext
{

}
105 changes: 105 additions & 0 deletions Btms.Model/Cds/AlvsDecision.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable

using JsonApiDotNetCore.Resources.Annotations;
using System.Text.Json.Serialization;
using System.Dynamic;
using Btms.Model.Auditing;


namespace Btms.Model.Cds;

/// <summary>
///
/// </summary>
public partial class AlvsDecisionItem
{
[Attr]
[System.ComponentModel.Description("")]
public int ItemNumber { get; set; }

[Attr]
[System.ComponentModel.Description("")]
public required string CheckCode { get; set; }

[Attr]
[System.ComponentModel.Description("")]
public required string AlvsDecisionCode { get; set; }

[Attr]
[System.ComponentModel.Description("")]
public string? BtmsDecisionCode { get; set; }
}


/// <summary>
///
/// </summary>
public partial class DecisionContext : IAuditContext //
{
[Attr]
[System.ComponentModel.Description("")]
public int AlvsDecisionNumber { get; set; } = default;

[Attr]
[System.ComponentModel.Description("")]
public int BtmsDecisionNumber { get; set; } = default;

[Attr]
[System.ComponentModel.Description("")]
public int EntryVersionNumber { get; set; } = default;

[Attr]
[System.ComponentModel.Description("")]
public bool Paired { get; set; } = default;

[Attr]
[System.ComponentModel.Description("")]
public string? PairStatus { get; set; }

[Attr]
[System.ComponentModel.Description("")]
public bool AlvsAllNoMatch { get; set; } = default;

[Attr]
[System.ComponentModel.Description("")]
public bool AlvsAnyNoMatch { get; set; } = default;

[Attr]
[System.ComponentModel.Description("")]
public bool DecisionMatched { get; set; } = default;
//
// [Attr]
// [System.ComponentModel.Description("")]
// public required List<AlvsDecisionItem> Checks { get; set; }

}

/// <summary>
///
/// </summary>
public partial class AlvsDecision //
{
[Attr]
[System.ComponentModel.Description("")]
public required CdsClearanceRequest Decision { get; set; }

[Attr]
[System.ComponentModel.Description("")]
public required DecisionContext Context { get; set; }

// TODO - should we put this into context, and so into audit log?
[Attr]
[System.ComponentModel.Description("")]
public required List<AlvsDecisionItem> Checks { get; set; }

}


Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
using System.Dynamic;


namespace Btms.Model.Alvs;
namespace Btms.Model.Cds;

/// <summary>
///
/// </summary>
public partial class AlvsClearanceRequest //
public partial class CdsClearanceRequest //
{


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
using System.Dynamic;


namespace Btms.Model.Alvs;
namespace Btms.Model.Cds;

/// <summary>
/// Message sent to the server to send an ALVSClearanceRequest.
/// </summary>
public partial class AlvsClearanceRequestPost //
public partial class CdsClearanceRequestPost //
{


Expand Down Expand Up @@ -59,7 +59,7 @@ public partial class AlvsClearanceRequestPost //
/// </summary>
[Attr]
[System.ComponentModel.Description("")]
public AlvsClearanceRequest? AlvsClearanceRequest { get; set; }
public CdsClearanceRequest? AlvsClearanceRequest { get; set; }

}

Expand Down
2 changes: 1 addition & 1 deletion Btms.Model/Alvs/Check.g.cs → Btms.Model/Cds/Check.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using System.Dynamic;


namespace Btms.Model.Alvs;
namespace Btms.Model.Cds;

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using System.Dynamic;


namespace Btms.Model.Alvs;
namespace Btms.Model.Cds;

/// <summary>
///
Expand Down
2 changes: 1 addition & 1 deletion Btms.Model/Alvs/Header.g.cs → Btms.Model/Cds/Header.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using System.Dynamic;


namespace Btms.Model.Alvs;
namespace Btms.Model.Cds;

/// <summary>
///
Expand Down
2 changes: 1 addition & 1 deletion Btms.Model/Alvs/Items.cs → Btms.Model/Cds/Items.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#nullable enable


namespace Btms.Model.Alvs;
namespace Btms.Model.Cds;

/// <summary>
///
Expand Down
2 changes: 1 addition & 1 deletion Btms.Model/Alvs/Items.g.cs → Btms.Model/Cds/Items.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using System.Dynamic;


namespace Btms.Model.Alvs;
namespace Btms.Model.Cds;

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using System.Dynamic;


namespace Btms.Model.Alvs;
namespace Btms.Model.Cds;

/// <summary>
///
Expand Down
Loading
Loading