Skip to content

Commit dc71bde

Browse files
committed
Improvements on parent object identification by adding filter criterion.
1 parent 2fa2743 commit dc71bde

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

TEAM/DataGridViewDataObjects.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,14 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
14891489

14901490
#endregion
14911491

1492+
#region Filter Criterion
1493+
1494+
var filterCriterion = dataObjectMappingGridViewRow.Cells[(int)DataObjectMappingGridColumns.FilterCriterion].Value.ToString();
1495+
1496+
dataObjectMapping.FilterCriterion = filterCriterion;
1497+
1498+
#endregion
1499+
14921500
#region Target Data Object
14931501

14941502
string targetConnectionInternalId = dataObjectMappingGridViewRow.Cells[DataObjectMappingGridColumns.TargetConnection.ToString()].Value.ToString();
@@ -1655,7 +1663,8 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
16551663

16561664
var relatedDataObjects = new List<DataObject>();
16571665

1658-
// Parent (referenced) data objects.
1666+
// Try to find the parent (referenced) data objects.
1667+
// The object that is reference to in the data model.
16591668
try
16601669
{
16611670
var parentRelatedDataObjects = JsonOutputHandling.GetParentRelatedDataObjectList(targetDataObjectName, dataObjectMapping.SourceDataObjects[0].Name, dataObjectMappingGridViewRow.Cells[DataObjectMappingGridColumns.BusinessKeyDefinition.ToString()].Value.ToString(), dataGridViewRowsDataObjects, JsonExportSetting, TeamConfiguration);
@@ -1685,7 +1694,7 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
16851694
TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"There was an issue adding the metadata connection as related data object. The error message is: {exception.Message}."));
16861695
}
16871696

1688-
// Next up (lineage) objects.
1697+
// Next up (lineage) objects (next up).
16891698
try
16901699
{
16911700
relatedDataObjects.AddRange(JsonOutputHandling.SetNextUpRelatedDataObjectList(targetDataObjectName, this, JsonExportSetting, TeamConfiguration, TeamEventLog, dataGridViewRowsPhysicalModel));
@@ -1817,6 +1826,7 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
18171826
dataObjectMapping.MappingClassifications[0].Classification != DataObjectTypes.NaturalBusinessRelationship.ToString())
18181827
{
18191828
// Auto-map any data items that are not yet manually mapped, but exist in source and target.
1829+
// This provides the list of columns to check further
18201830
var physicalModelTargetDataGridViewRows = _dataGridViewPhysicalModel.Rows
18211831
.Cast<DataGridViewRow>()
18221832
.Where(r => !r.IsNewRow)
@@ -1839,13 +1849,15 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
18391849
var physicalModelSourceDataItemLookup = _dataGridViewPhysicalModel.Rows
18401850
.Cast<DataGridViewRow>()
18411851
.Where(r => !r.IsNewRow)
1842-
.Where(r => r.Cells[(int)PhysicalModelMappingMetadataColumns.tableName].Value.ToString().Equals(sourceDataObject.Name))
1843-
.Where(r => r.Cells[(int)PhysicalModelMappingMetadataColumns.columnName].Value.ToString().Equals(autoMappedTargetDataItemName))
1852+
.Where(r => r.Cells[(int)PhysicalModelMappingMetadataColumns.tableName].Value.ToString().Equals(sourceDataObject.Name, StringComparison.CurrentCultureIgnoreCase))
1853+
.Where(r => r.Cells[(int)PhysicalModelMappingMetadataColumns.columnName].Value.ToString().Equals(autoMappedTargetDataItemName, StringComparison.CurrentCultureIgnoreCase))
18441854
.FirstOrDefault();
18451855

18461856
if (physicalModelSourceDataItemLookup == null)
18471857
continue;
18481858

1859+
var autoMappedSourceDataItemName = physicalModelSourceDataItemLookup.Cells[3].Value.ToString();
1860+
18491861
// If the data item is not on an exception list, it can also be ignored.
18501862
var businessKeyDefinition = dataObjectMappingGridViewRow.Cells[DataObjectMappingGridColumns.BusinessKeyDefinition.ToString()].Value.ToString();
18511863
var sourceDataObjectName = dataObjectMappingGridViewRow.Cells[DataObjectMappingGridColumns.SourceDataObjectName.ToString()].Value.ToString();
@@ -1855,9 +1867,9 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
18551867

18561868
var dataObjectType = GetDataObjectType(targetDataObject.Name, "", FormBase.TeamConfiguration);
18571869

1858-
var surrogateKey = JsonOutputHandling.DeriveSurrogateKey(targetDataObject, sourceDataObjectName, businessKeyDefinition, targetDataItemConnection, TeamConfiguration,
1859-
dataGridViewRowsDataObjects, TeamEventLog);
1870+
var surrogateKey = JsonOutputHandling.DeriveSurrogateKey(targetDataObject, sourceDataObjectName, businessKeyDefinition, targetDataItemConnection, TeamConfiguration, dataGridViewRowsDataObjects, TeamEventLog, filterCriterion);
18601871

1872+
// Check if the column neems to be ignored, for example the standard columns.
18611873
if (!autoMappedTargetDataItemName.IsIncludedDataItem(dataObjectType, surrogateKey, targetDataItemConnection, TeamConfiguration))
18621874
continue;
18631875

@@ -1870,7 +1882,7 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
18701882
var autoMappedTargetDataItem = new DataItem();
18711883

18721884
// One to one mapping.
1873-
autoMappedSourceDataItem.Name = autoMappedTargetDataItemName;
1885+
autoMappedSourceDataItem.Name = autoMappedSourceDataItemName;
18741886
autoMappedTargetDataItem.Name = autoMappedTargetDataItemName;
18751887

18761888
// Add data types to Data Item that are part of a data item mapping.
@@ -1929,14 +1941,6 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
19291941

19301942
#endregion
19311943

1932-
#region Filter Criterion
1933-
1934-
var filterCriterion = dataObjectMappingGridViewRow.Cells[(int)DataObjectMappingGridColumns.FilterCriterion].Value.ToString();
1935-
1936-
dataObjectMapping.FilterCriterion = filterCriterion;
1937-
1938-
#endregion
1939-
19401944
#region Business Key
19411945

19421946
try
@@ -1945,7 +1949,7 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
19451949
var sourceDataObjectName = dataObjectMappingGridViewRow.Cells[DataObjectMappingGridColumns.SourceDataObjectName.ToString()].Value.ToString();
19461950
var drivingKeyValue = dataObjectMappingGridViewRow.Cells[DataObjectMappingGridColumns.DrivingKeyDefinition.ToString()].Value.ToString();
19471951

1948-
JsonOutputHandling.SetBusinessKeys(dataObjectMapping, businessKeyDefinition, sourceDataObjectName, drivingKeyValue, targetConnection, JsonExportSetting, TeamConfiguration, dataGridViewRowsDataObjects, dataGridViewRowsPhysicalModel, TeamEventLog);
1952+
JsonOutputHandling.SetBusinessKeys(dataObjectMapping, businessKeyDefinition, sourceDataObjectName, drivingKeyValue, targetConnection, JsonExportSetting, TeamConfiguration, dataGridViewRowsDataObjects, dataGridViewRowsPhysicalModel, TeamEventLog, filterCriterion);
19491953
}
19501954
catch (Exception exception)
19511955
{

0 commit comments

Comments
 (0)