Skip to content

Commit

Permalink
143322 - Fixed review comments AB#143322
Browse files Browse the repository at this point in the history
  • Loading branch information
harshda15125 committed Feb 26, 2024
1 parent f2cb71f commit a4e528c
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/UKHO.ERPFacade.API/Helpers/EncContentSapMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace UKHO.ERPFacade.API.Helpers
{
public class EncContentSapMessageBuilder : IEncContentSapMessageBuilder
{
private static ILogger<EncContentSapMessageBuilder> s_logger;
private readonly ILogger<EncContentSapMessageBuilder> _logger;
private readonly IXmlHelper _xmlHelper;
private readonly IFileSystemHelper _fileSystemHelper;
private readonly IOptions<SapActionConfiguration> _sapActionConfig;
private static IWeekDetailsProvider s_weekDetailsProvider;
private readonly IWeekDetailsProvider _weekDetailsProvider;

private const string SapXmlPath = "SapXmlTemplates\\SAPRequest.xml";
private const string XpathImMatInfo = $"//*[local-name()='IM_MATINFO']";
Expand Down Expand Up @@ -50,11 +50,11 @@ public EncContentSapMessageBuilder(ILogger<EncContentSapMessageBuilder> logger,
IWeekDetailsProvider weekDetailsProvider
)
{
s_logger = logger;
_logger = logger;
_xmlHelper = xmlHelper;
_fileSystemHelper = fileSystemHelper;
_sapActionConfig = sapActionConfig;
s_weekDetailsProvider = weekDetailsProvider;
_weekDetailsProvider = weekDetailsProvider;
}

/// <summary>
Expand All @@ -70,7 +70,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat
//Check whether template file exists or not
if (!_fileSystemHelper.IsFileExists(sapXmlTemplatePath))
{
s_logger.LogError(EventIds.SapXmlTemplateNotFound.ToEventId(), "The SAP message xml template does not exist.");
_logger.LogError(EventIds.SapXmlTemplateNotFound.ToEventId(), "The SAP message xml template does not exist.");
throw new FileNotFoundException();
}

Expand All @@ -82,7 +82,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat
XmlNode actionItemNode = soapXml.SelectSingleNode(XpathActionItems);

bool IsConditionSatisfied = false;
s_logger.LogInformation(EventIds.BuildingSapActionStarted.ToEventId(), "Building SAP actions.");
_logger.LogInformation(EventIds.BuildingSapActionStarted.ToEventId(), "Building SAP actions.");
foreach (var product in eventData.Data.Products)
{
//Actions for ENC CELL
Expand Down Expand Up @@ -118,7 +118,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat
{
actionNode = BuildAction(soapXml, product, unitOfSale, action, ukhoWeekNumber);
actionItemNode.AppendChild(actionNode);
s_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
IsConditionSatisfied = false;
}
break;
Expand All @@ -129,7 +129,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat
{
actionNode = BuildAction(soapXml, product, unitOfSaleReplace, action, ukhoWeekNumber, null, replacedProduct);
actionItemNode.AppendChild(actionNode);
s_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
}
break;
}
Expand Down Expand Up @@ -166,7 +166,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat
{
actionNode = BuildAction(soapXml, product, unitofSale, action, ukhoWeekNumber);
actionItemNode.AppendChild(actionNode);
s_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);

IsConditionSatisfied = false;
}
Expand All @@ -193,7 +193,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat
{
actionNode = BuildAction(soapXml, product, unitofSale, action, ukhoWeekNumber);
actionItemNode.AppendChild(actionNode);
s_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);

IsConditionSatisfied = false;
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat

actionNode = BuildAction(soapXml, product, unitOfSale, action, ukhoWeekNumber);
actionItemNode.AppendChild(actionNode);
s_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);

IsConditionSatisfied = false;
}
Expand All @@ -248,7 +248,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat

actionNode = BuildAction(soapXml, product, unitOfSale, action, ukhoWeekNumber, addProduct);
actionItemNode.AppendChild(actionNode);
s_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
}
break;

Expand All @@ -259,7 +259,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat

actionNode = BuildAction(soapXml, product, unitOfSale, action, ukhoWeekNumber);
actionItemNode.AppendChild(actionNode);
s_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
_logger.LogInformation(EventIds.SapActionCreated.ToEventId(), "SAP action {ActionName} created.", action.Action);
}
break;
}
Expand All @@ -283,7 +283,7 @@ public XmlDocument BuildSapMessageXml(EncEventPayload eventData, string correlat
return soapXml;
}

private static XmlElement BuildAction(XmlDocument soapXml, Product product, UnitOfSale unitOfSale, SapAction action, UkhoWeekNumber ukhoWeekNumber, string childCell = null, string replacedByProduct = null)
private XmlElement BuildAction(XmlDocument soapXml, Product product, UnitOfSale unitOfSale, SapAction action, UkhoWeekNumber ukhoWeekNumber, string childCell = null, string replacedByProduct = null)
{
XmlElement itemNode = soapXml.CreateElement(Item);

Expand Down Expand Up @@ -363,7 +363,7 @@ private static XmlElement BuildAction(XmlDocument soapXml, Product product, Unit
switch (node.XmlNodeName)
{
case ValidFrom:
string thursdayDate = s_weekDetailsProvider.GetThursdayDateOfWeek(
string thursdayDate = _weekDetailsProvider.GetThursdayDateOfWeek(
ukhoWeekNumber.Year, ukhoWeekNumber.Week);
itemSubNode.InnerText = GetXmlNodeValue(thursdayDate);
break;
Expand All @@ -380,7 +380,7 @@ private static XmlElement BuildAction(XmlDocument soapXml, Product product, Unit
}
else
{
s_logger.LogError(EventIds.InvalidUkhoWeekNumber.ToEventId(), "Invalid UkhoWeekNumber field received in enccontentpublished event.");
_logger.LogError(EventIds.InvalidUkhoWeekNumber.ToEventId(), "Invalid UkhoWeekNumber field received in enccontentpublished event.");
itemSubNode.InnerText = string.Empty;
}
}
Expand All @@ -401,7 +401,7 @@ private static XmlElement BuildAction(XmlDocument soapXml, Product product, Unit
return itemNode;
}

private static XmlNode SortXmlPayload(XmlNode actionItemNode)
private XmlNode SortXmlPayload(XmlNode actionItemNode)
{
List<XmlNode> actionItemList = new();
int sequenceNumber = 1;
Expand All @@ -426,7 +426,7 @@ private static XmlNode SortXmlPayload(XmlNode actionItemNode)
return actionItemNode;
}

private static string GetXmlNodeValue(string fieldValue, string xmlNodeName = null)
private string GetXmlNodeValue(string fieldValue, string xmlNodeName = null)
{
if (!string.IsNullOrWhiteSpace(fieldValue))
{
Expand All @@ -440,7 +440,7 @@ private static string GetXmlNodeValue(string fieldValue, string xmlNodeName = nu
return string.Empty;
}

private static string GetProdType(string prodType)
private string GetProdType(string prodType)
{
if (!string.IsNullOrEmpty(prodType))
{
Expand Down Expand Up @@ -488,15 +488,15 @@ private UnitOfSale GetUnitOfSaleForEncCell(List<UnitOfSale> listOfUnitOfSales, P
return unitOfSale!;
}

private static string GetUkhoWeekNumberData(UkhoWeekNumber ukhoWeekNumber)
private string GetUkhoWeekNumberData(UkhoWeekNumber ukhoWeekNumber)
{
var validWeek = ukhoWeekNumber.Week.ToString("D2");
var weekNumber = string.Join("", ukhoWeekNumber.Year, validWeek);

return weekNumber;
}

private static bool IsValidWeekNumber(UkhoWeekNumber ukhoWeekNumber)
private bool IsValidWeekNumber(UkhoWeekNumber ukhoWeekNumber)
{
bool isValid = ukhoWeekNumber != null!;
if (!isValid) return isValid;
Expand Down

0 comments on commit a4e528c

Please sign in to comment.