Skip to content

Commit b654a4d

Browse files
committed
Added staging error column information.
1 parent bdfa972 commit b654a4d

File tree

8 files changed

+158
-57
lines changed

8 files changed

+158
-57
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ Versions supported:
5050

5151
## Download
5252

53-
To download [the beta version of staging library - TNMStagingCSharp_v22.zip](https://github.com/imsweb/staging-client-csharp/releases/download/v2.2-beta/TNMStagingCSharp_v22.zip).
53+
To download [the beta version of staging library - TNMStagingCSharp_v23.zip](https://github.com/imsweb/staging-client-csharp/releases/download/v2.3-beta/TNMStagingCSharp_v23.zip).
5454

5555
The download zip file contains the TNM Staging DLL and associated files. For more information, please reference the accompanying readme.txt file. Detailed documentation on how to use the DLL can be found in the [Wiki](https://github.com/imsweb/staging-client-csharp/wiki/).
5656

5757
## Requirements
5858

5959
Functional Requirements: You will need the .NET Framework 4.5.2 or higher installed to use this library.
6060

61-
Data Requirements: You will need the algorithm data files for the TNM Staging Library to work properly. At present there are CS 02.05.50, TNM 1.9, and EOD 1.3 algorithms. You can find a copy of these data files within the TNM Staging source code in the Resources\Algorithms directory. The algorithm data files can be either in separate JSON files, or can be collected together in a compressed file such as .ZIP or .GZ. You can download the zip versions of [CS 02.05.50](https://github.com/imsweb/staging-client-csharp/releases/download/v2.2-beta/CS_02_05_50.zip), [TNM 1.9](https://github.com/imsweb/staging-client-csharp/releases/download/v2.2-beta/TNM_19.zip), and [EOD Public 1.3](https://github.com/imsweb/staging-client-csharp/releases/download/v2.2-beta/EOD_Public_13.zip) here.
61+
Data Requirements: You will need the algorithm data files for the TNM Staging Library to work properly. At present there are CS 02.05.50, TNM 1.9, and EOD 1.3 algorithms. You can find a copy of these data files within the TNM Staging source code in the Resources\Algorithms directory. The algorithm data files can be either in separate JSON files, or can be collected together in a compressed file such as .ZIP or .GZ. You can download the zip versions of [CS 02.05.50](https://github.com/imsweb/staging-client-csharp/releases/download/v2.3-beta/CS_02_05_50.zip), [TNM 1.9](https://github.com/imsweb/staging-client-csharp/releases/download/v2.3-beta/TNM_19.zip), and [EOD Public 1.3](https://github.com/imsweb/staging-client-csharp/releases/download/v2.3-beta/EOD_Public_13.zip) here.
6262

6363
## Usage
6464

TNMStagingCSharp/TNMStagingCSharp/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.2.0.0")]
36-
[assembly: AssemblyFileVersion("2.2.0.0")]
35+
[assembly: AssemblyVersion("2.3.0.0")]
36+
[assembly: AssemblyFileVersion("2.3.0.0")]

TNMStagingCSharp/TNMStagingCSharp/Src/DecisionEngine/DecisionEngine.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,22 @@ protected bool process(String mappingId, String tableId, ITablePath path, Result
987987
// look for the match in the mapping table; if no match is found, used the table-specific no_match value
988988
IEnumerable<IEndpoint> endpoints = DecisionEngineFuncs.matchTable(table, result.getContext());
989989

990-
991990
if (endpoints == null)
992-
result.addError(new Error.ErrorBuilder(Error.Type.MATCH_NOT_FOUND).message("Match not found in table '" + tableId + "' (" + DecisionEngineFuncs.getTableInputsAsString(table, result.getContext()) + ")").table(tableId)
991+
{
992+
List<String> colList = new List<String>();
993+
foreach (IColumnDefinition c in table.getColumnDefinitions())
994+
{
995+
if (c.getType() == ColumnType.ENDPOINT)
996+
colList.Add(c.getKey());
997+
}
998+
999+
// if a match is not found, include all the endpoints as columns in the error
1000+
result.addError(new Error.ErrorBuilder(Error.Type.MATCH_NOT_FOUND)
1001+
.message("Match not found in table '" + tableId + "' (" + DecisionEngineFuncs.getTableInputsAsString(table, result.getContext()) + ")")
1002+
.table(tableId)
1003+
.columns(colList)
9931004
.build());
1005+
}
9941006
else
9951007
{
9961008
EndpointType endpType = 0;
@@ -1014,9 +1026,9 @@ protected bool process(String mappingId, String tableId, ITablePath path, Result
10141026
{
10151027
String message = endpValue;
10161028
if (message == null || message.Length == 0)
1017-
message = "Matching resulted in an error in table '" + tableId + "' (" + DecisionEngineFuncs.getTableInputsAsString(table, result.getContext()) + ")";
1029+
message = "Matching resulted in an error in table '" + tableId + "' for column '" + endpoint.getResultKey() + "' (" + DecisionEngineFuncs.getTableInputsAsString(table, result.getContext()) + ")";
10181030

1019-
result.addError(new Error.ErrorBuilder(Error.Type.STAGING_ERROR).message(message).table(tableId).build());
1031+
result.addError(new Error.ErrorBuilder(Error.Type.STAGING_ERROR).message(message).table(tableId).columns(new List<String>{endpoint.getResultKey()}).build());
10201032
}
10211033
else if (EndpointType.VALUE == endpType)
10221034
{

TNMStagingCSharp/TNMStagingCSharp/Src/DecisionEngine/Error.cs

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Copyright (C) 2017 Information Management Services, Inc.
22

33
using System;
4+
using System.Collections.Generic;
45
using Newtonsoft.Json;
56

7+
68
namespace TNMStagingCSharp.Src.DecisionEngine
79
{
810
// An error object
@@ -12,42 +14,14 @@ public class Error
1214
private Type _type;
1315
[JsonProperty("table", Order = 2)]
1416
private String _table;
15-
[JsonProperty("key", Order = 3)]
17+
[JsonProperty("columns", Order = 3)]
18+
private List<String> _columns;
19+
[JsonProperty("key", Order = 4)]
1620
private String _key;
17-
[JsonProperty("message", Order = 4)]
21+
[JsonProperty("message", Order = 5)]
1822
private String _message;
1923

2024

21-
public enum Type
22-
{
23-
// an input key was supplied that is not defined in the input definition
24-
UNKNOWN_INPUT,
25-
26-
// a required input value was not contained in the input definition table
27-
INVALID_REQUIRED_INPUT,
28-
29-
// a non-required input value was not contained in the input definition table
30-
INVALID_NON_REQUIRED_INPUT,
31-
32-
// an input mapping from value did not exist
33-
UNKNOWN_INPUT_MAPPING,
34-
35-
// an ERROR endpoint was hit during staging processing
36-
STAGING_ERROR,
37-
38-
// a table was processed during staging and no match was found
39-
MATCH_NOT_FOUND,
40-
41-
// a specified table does not exist
42-
UNKNOWN_TABLE,
43-
44-
// processing a table ended up in an infinite loop due to JUMPs
45-
INFINITE_LOOP,
46-
47-
// an output value was produced which was not contained in the output definition table
48-
INVALID_OUTPUT
49-
}
50-
5125
//========================================================================================================================
5226
// Default constructor
5327
//========================================================================================================================
@@ -96,6 +70,21 @@ public void setTable(String table)
9670
_table = table;
9771
}
9872

73+
//========================================================================================================================
74+
//
75+
//========================================================================================================================
76+
public List<String> getColumns()
77+
{
78+
return _columns;
79+
}
80+
81+
//========================================================================================================================
82+
//
83+
//========================================================================================================================
84+
public void setColumns(List<String> columns)
85+
{
86+
_columns = columns;
87+
}
9988
//========================================================================================================================
10089
//
10190
//========================================================================================================================
@@ -128,6 +117,39 @@ public void setMessage(String message)
128117
_message = message;
129118
}
130119

120+
//========================================================================================================================
121+
//
122+
//========================================================================================================================
123+
public enum Type
124+
{
125+
// an input key was supplied that is not defined in the input definition
126+
UNKNOWN_INPUT,
127+
128+
// a required input value was not contained in the input definition table
129+
INVALID_REQUIRED_INPUT,
130+
131+
// a non-required input value was not contained in the input definition table
132+
INVALID_NON_REQUIRED_INPUT,
133+
134+
// an input mapping from value did not exist
135+
UNKNOWN_INPUT_MAPPING,
136+
137+
// an ERROR endpoint was hit during staging processing
138+
STAGING_ERROR,
139+
140+
// a table was processed during staging and no match was found
141+
MATCH_NOT_FOUND,
142+
143+
// a specified table does not exist
144+
UNKNOWN_TABLE,
145+
146+
// processing a table ended up in an infinite loop due to JUMPs
147+
INFINITE_LOOP,
148+
149+
// an output value was produced which was not contained in the output definition table
150+
INVALID_OUTPUT
151+
}
152+
131153
//========================================================================================================================
132154
// Build class for Error
133155
//========================================================================================================================
@@ -162,6 +184,15 @@ public ErrorBuilder table(String table)
162184
return this;
163185
}
164186

187+
//========================================================================================================================
188+
//
189+
//========================================================================================================================
190+
public ErrorBuilder columns(List<String> columns)
191+
{
192+
_error.setColumns(columns);
193+
return this;
194+
}
195+
165196
//========================================================================================================================
166197
//
167198
//========================================================================================================================

TNMStagingCSharp/TNMStagingCSharp/Src/Staging/StagingDataProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ public static StagingTable initTable(StagingTable table)
174174
break;
175175
case ColumnType.ENDPOINT:
176176
StagingEndpoint endpoint = parseEndpoint(cellValue);
177-
if (EndpointType.VALUE == endpoint.getType())
178-
endpoint.setResultKey(col.getKey());
177+
endpoint.setResultKey(col.getKey());
179178
tableRowEntity.addEndpoint(endpoint);
180179

181180
// if there are key references used (values that reference other inputs) like {{key}}, then add them to the extra inputs list

TNMStagingCSharp/TNMStaging_UnitTestApp/Src/DecisionEngine/Basic/BasicDataProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ public void initTable(BasicTable table)
110110
break;
111111
case ColumnType.ENDPOINT:
112112
BasicEndpoint endpoint = parseEndpoint(cellValue);
113-
if (EndpointType.VALUE == endpoint.getType())
114-
endpoint.setResultKey(col.getKey());
113+
endpoint.setResultKey(col.getKey());
115114
tableRowEntity.addEndpoint(endpoint);
116115

117116
// if there are key references used (values that reference other inputs) like {{key}}, then add them to the extra inputs list

TNMStagingCSharp/TNMStaging_UnitTestApp/Src/DecisionEngine/Basic/BasicEndpoint.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,24 @@ public BasicEndpoint()
2020
}
2121

2222
/**
23-
* Construct with a type and value
24-
* @param type a type
25-
* @param value a value
23+
* Constructor
2624
*/
2725
public BasicEndpoint(EndpointType type, String value)
2826
{
2927
_type = type;
3028
_value = value;
3129
}
3230

31+
/**
32+
* Constructor
33+
*/
34+
public BasicEndpoint(EndpointType type, String value, String resultKey)
35+
{
36+
_type = type;
37+
_value = value;
38+
_resultKey = resultKey;
39+
}
40+
3341
public EndpointType getType()
3442
{
3543
return _type;

0 commit comments

Comments
 (0)