Skip to content

Commit

Permalink
Add Catch for Junk CHI in SCI Store Loader (#78)
Browse files Browse the repository at this point in the history
* add sci update

* use specified release

* update shared assembly

* clone dt columns

* add better logging

* fix bad error message

* throw for bad chi

* tidy up code
  • Loading branch information
JFriel authored Jul 17, 2024
1 parent cadb652 commit fd421e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
15 changes: 7 additions & 8 deletions SCIStorePlugin/Attachers/SciStoreAttacher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace SCIStorePlugin.Attachers;
[Description(@"Populates the RAW database from XML files retrieved from the SCI Store web service in the ForLoading directory")]
public class SciStoreAttacher : Attacher
{
public string HeaderTable ="Header";
public string HeaderTable = "Header";
public string SamplesTable = "SampleDetails";
public string ResultsTable = "Results";
private Stopwatch _timer;
Expand All @@ -31,7 +31,7 @@ public class SciStoreAttacher : Attacher

[DemandsInitialization(@"Determines behaviour when bad reports are encountered e.g. LabNumbers like 000000000.
True - Report warning and continue (not loading file)
False - Stop the data load with an error",DefaultValue = true)]
False - Stop the data load with an error", DefaultValue = true)]
public bool IgnoreBadData { get; set; }

public SciStoreAttacher()
Expand All @@ -45,7 +45,7 @@ public SciStoreAttacher()
/// <param name="job"></param>
/// <returns></returns>
/// <exception cref="BadCombinedReportDataException"></exception>
public override ExitCodeType Attach(IDataLoadJob job,GracefulCancellationToken token)
public override ExitCodeType Attach(IDataLoadJob job, GracefulCancellationToken token)
{
// Create the DataTable repository into which the XML files will be loaded into prior to their bulk insert into RAW
var dataTableSchemaSource = new DataTableSchemaFromDatabase(_dbInfo);
Expand Down Expand Up @@ -78,7 +78,7 @@ public override ExitCodeType Attach(IDataLoadJob job,GracefulCancellationToken t
{
labs = reports
.Select(report => reportFactory.Create(report, job))
.Where(r=>r != null) //bad reports are null
.Where(r => r != null) //bad reports are null
.ToList();
}
catch (BadCombinedReportDataException e)
Expand Down Expand Up @@ -111,7 +111,6 @@ public override ExitCodeType Attach(IDataLoadJob job,GracefulCancellationToken t
BulkInsertDataTable(destRepo.HeadersTable, job);
BulkInsertDataTable(destRepo.SampleDetailsTable, job);
BulkInsertDataTable(destRepo.ResultsTable, job);

_timer.Stop();

job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "SciStoreAttacher::Attach complete"));
Expand Down Expand Up @@ -162,7 +161,7 @@ private void CreateReadCodeConstraint()
};
}

public override void LoadCompletedSoDispose(ExitCodeType exitCode,IDataLoadEventListener postLoadEventListener)
public override void LoadCompletedSoDispose(ExitCodeType exitCode, IDataLoadEventListener postLoadEventListener)
{
}

Expand All @@ -172,9 +171,9 @@ private void ResolveTestResultOrderDuplication(List<SciStoreReport> labs, IDataL
{
foreach (var sample in lab.Samples)
{
var recordsRemoved = sample.ResolveTestResultOrderDuplication();
var recordsRemoved = sample.ResolveTestResultOrderDuplication();
if (recordsRemoved > 0)
job.OnNotify(this,new NotifyEventArgs(ProgressEventType.Warning,
job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning,
$"Resolved duplicate TestResultOrder using method 'ResolveTestResultOrderDuplication' in lab number:{lab.Header.LabNumber}"));
}
}
Expand Down
3 changes: 2 additions & 1 deletion SCIStorePlugin/Data/SciStoreHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ private static string CleanCHI(string chi)
// encountered in Fife Haematology load
if (!string.IsNullOrWhiteSpace(chi) && chi.Equals("Temp Residen"))
return chi[..10];

if (chi.Length > 10)
throw new Exception($"CHI '{chi}' was too long");
return chi;
}

Expand Down
2 changes: 1 addition & 1 deletion SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
// These should be overwritten by release builds
[assembly: AssemblyVersion("6.1.6")]
[assembly: AssemblyFileVersion("6.1.6")]
[assembly: AssemblyInformationalVersion("6.1.6")]
[assembly: AssemblyInformationalVersion("6.1.7")]

0 comments on commit fd421e2

Please sign in to comment.