@@ -1489,6 +1489,14 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
1489
1489
1490
1490
#endregion
1491
1491
1492
+ #region Filter Criterion
1493
+
1494
+ var filterCriterion = dataObjectMappingGridViewRow . Cells [ ( int ) DataObjectMappingGridColumns . FilterCriterion ] . Value . ToString ( ) ;
1495
+
1496
+ dataObjectMapping . FilterCriterion = filterCriterion ;
1497
+
1498
+ #endregion
1499
+
1492
1500
#region Target Data Object
1493
1501
1494
1502
string targetConnectionInternalId = dataObjectMappingGridViewRow . Cells [ DataObjectMappingGridColumns . TargetConnection . ToString ( ) ] . Value . ToString ( ) ;
@@ -1655,7 +1663,8 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
1655
1663
1656
1664
var relatedDataObjects = new List < DataObject > ( ) ;
1657
1665
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.
1659
1668
try
1660
1669
{
1661
1670
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
1685
1694
TeamEventLog . Add ( Event . CreateNewEvent ( EventTypes . Error , $ "There was an issue adding the metadata connection as related data object. The error message is: { exception . Message } .") ) ;
1686
1695
}
1687
1696
1688
- // Next up (lineage) objects.
1697
+ // Next up (lineage) objects (next up) .
1689
1698
try
1690
1699
{
1691
1700
relatedDataObjects . AddRange ( JsonOutputHandling . SetNextUpRelatedDataObjectList ( targetDataObjectName , this , JsonExportSetting , TeamConfiguration , TeamEventLog , dataGridViewRowsPhysicalModel ) ) ;
@@ -1817,6 +1826,7 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
1817
1826
dataObjectMapping . MappingClassifications [ 0 ] . Classification != DataObjectTypes . NaturalBusinessRelationship . ToString ( ) )
1818
1827
{
1819
1828
// 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
1820
1830
var physicalModelTargetDataGridViewRows = _dataGridViewPhysicalModel . Rows
1821
1831
. Cast < DataGridViewRow > ( )
1822
1832
. Where ( r => ! r . IsNewRow )
@@ -1839,13 +1849,15 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
1839
1849
var physicalModelSourceDataItemLookup = _dataGridViewPhysicalModel . Rows
1840
1850
. Cast < DataGridViewRow > ( )
1841
1851
. 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 ) )
1844
1854
. FirstOrDefault ( ) ;
1845
1855
1846
1856
if ( physicalModelSourceDataItemLookup == null )
1847
1857
continue ;
1848
1858
1859
+ var autoMappedSourceDataItemName = physicalModelSourceDataItemLookup . Cells [ 3 ] . Value . ToString ( ) ;
1860
+
1849
1861
// If the data item is not on an exception list, it can also be ignored.
1850
1862
var businessKeyDefinition = dataObjectMappingGridViewRow . Cells [ DataObjectMappingGridColumns . BusinessKeyDefinition . ToString ( ) ] . Value . ToString ( ) ;
1851
1863
var sourceDataObjectName = dataObjectMappingGridViewRow . Cells [ DataObjectMappingGridColumns . SourceDataObjectName . ToString ( ) ] . Value . ToString ( ) ;
@@ -1855,9 +1867,9 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
1855
1867
1856
1868
var dataObjectType = GetDataObjectType ( targetDataObject . Name , "" , FormBase . TeamConfiguration ) ;
1857
1869
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 ) ;
1860
1871
1872
+ // Check if the column neems to be ignored, for example the standard columns.
1861
1873
if ( ! autoMappedTargetDataItemName . IsIncludedDataItem ( dataObjectType , surrogateKey , targetDataItemConnection , TeamConfiguration ) )
1862
1874
continue ;
1863
1875
@@ -1870,7 +1882,7 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
1870
1882
var autoMappedTargetDataItem = new DataItem ( ) ;
1871
1883
1872
1884
// One to one mapping.
1873
- autoMappedSourceDataItem . Name = autoMappedTargetDataItemName ;
1885
+ autoMappedSourceDataItem . Name = autoMappedSourceDataItemName ;
1874
1886
autoMappedTargetDataItem . Name = autoMappedTargetDataItemName ;
1875
1887
1876
1888
// Add data types to Data Item that are part of a data item mapping.
@@ -1929,14 +1941,6 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
1929
1941
1930
1942
#endregion
1931
1943
1932
- #region Filter Criterion
1933
-
1934
- var filterCriterion = dataObjectMappingGridViewRow . Cells [ ( int ) DataObjectMappingGridColumns . FilterCriterion ] . Value . ToString ( ) ;
1935
-
1936
- dataObjectMapping . FilterCriterion = filterCriterion ;
1937
-
1938
- #endregion
1939
-
1940
1944
#region Business Key
1941
1945
1942
1946
try
@@ -1945,7 +1949,7 @@ public DataObjectMapping GetDataObjectMapping(DataGridViewRow dataObjectMappingG
1945
1949
var sourceDataObjectName = dataObjectMappingGridViewRow . Cells [ DataObjectMappingGridColumns . SourceDataObjectName . ToString ( ) ] . Value . ToString ( ) ;
1946
1950
var drivingKeyValue = dataObjectMappingGridViewRow . Cells [ DataObjectMappingGridColumns . DrivingKeyDefinition . ToString ( ) ] . Value . ToString ( ) ;
1947
1951
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 ) ;
1949
1953
}
1950
1954
catch ( Exception exception )
1951
1955
{
0 commit comments