6
6
using System . Drawing ;
7
7
using System . IO ;
8
8
using System . Linq ;
9
- using System . Security . Permissions ;
10
9
using System . Text ;
11
10
using System . Threading ;
12
11
using System . Windows . Forms ;
13
12
using DataWarehouseAutomation ;
14
- using DataWarehouseAutomation . DwaModel ;
15
- using DataWarehouseAutomation . Utils ;
16
13
using Newtonsoft . Json ;
17
14
using Newtonsoft . Json . Linq ;
18
15
using TEAM_Library ;
@@ -43,7 +40,7 @@ public FormMain()
43
40
InitializeComponent ( ) ;
44
41
45
42
// Set the version of the build for everything
46
- const string versionNumberForApplication = "v1.6.14 " ;
43
+ const string versionNumberForApplication = "v1.7.0 " ;
47
44
48
45
Text = $ "Virtual Data Warehouse - { versionNumberForApplication } ";
49
46
labelWelcome . Text = $ "{ labelWelcome . Text } - { versionNumberForApplication } ";
@@ -586,7 +583,7 @@ internal class LocalTemplate
586
583
{
587
584
internal string classification { get ; set ; }
588
585
internal string notes { get ; set ; }
589
- internal Dictionary < string , VdwDataObjectMappingList > itemList { get ; set ; }
586
+ internal Dictionary < string , VdwDataObjectMappingList > vdwDataObjectMappingList { get ; set ; }
590
587
}
591
588
592
589
@@ -602,13 +599,12 @@ internal void InformUser(string text, EventTypes eventType)
602
599
/// <returns></returns>
603
600
internal List < LocalTemplate > GetMetadata ( )
604
601
{
605
-
606
602
var hideDisabled = checkBoxHideDisabled . Checked ;
607
603
608
604
#region Deserialisation
609
605
610
606
// Deserialise the Json files into a local List of Data Object Mappings (mappingList) for further use.
611
- List < VdwDataObjectMappingList > mappingList = new List < VdwDataObjectMappingList > ( ) ;
607
+ List < VdwDataObjectMappingList > vdwDataObjectMappigLists = new List < VdwDataObjectMappingList > ( ) ;
612
608
613
609
if ( Directory . Exists ( VdwConfigurationSettings . VdwMetadatPath ) )
614
610
{
@@ -632,6 +628,17 @@ internal List<LocalTemplate> GetMetadata()
632
628
"Production_TEAM_Table_Mapping.json"
633
629
} ;
634
630
631
+ var localConventions = new MetadataConfiguration ( ) ;
632
+ localConventions . recordSourceAttribute = TeamConfigurationSettings . RecordSourceAttribute ;
633
+ localConventions . recordChecksumAttribute = TeamConfigurationSettings . RecordChecksumAttribute ;
634
+ localConventions . changeDataCaptureAttribute = TeamConfigurationSettings . ChangeDataCaptureAttribute ;
635
+ localConventions . expiryDateTimeAttribute = TeamConfigurationSettings . ExpiryDateTimeAttribute ;
636
+ localConventions . eventDateTimeAttribute = TeamConfigurationSettings . EventDateTimeAttribute ;
637
+ localConventions . etlProcessAttribute = TeamConfigurationSettings . EtlProcessAttribute ;
638
+ localConventions . changeDataCaptureAttribute = TeamConfigurationSettings . ChangeDataCaptureAttribute ;
639
+ localConventions . loadDateTimeAttribute = TeamConfigurationSettings . LoadDateTimeAttribute ;
640
+ localConventions . sourceRowIdAttribute = TeamConfigurationSettings . RowIdAttribute ;
641
+
635
642
if ( fileEntries . Length > 0 )
636
643
{
637
644
foreach ( var fileName in fileEntries )
@@ -677,10 +684,13 @@ internal List<LocalTemplate> GetMetadata()
677
684
}
678
685
deserialisedMapping . DataObjectMappings = tempDOM ;
679
686
687
+
688
+
680
689
if ( deserialisedMapping != null )
681
690
{
682
691
deserialisedMapping . metadataFileName = fileName ;
683
- mappingList . Add ( deserialisedMapping ) ;
692
+ deserialisedMapping . metadataConfiguration = localConventions ;
693
+ vdwDataObjectMappigLists . Add ( deserialisedMapping ) ;
684
694
}
685
695
}
686
696
catch ( Exception exception )
@@ -716,23 +726,23 @@ internal List<LocalTemplate> GetMetadata()
716
726
// In the Tuple, Item1 is the classification, Item2 is the mapping name and Item 3 is notes.
717
727
Dictionary < VdwDataObjectMappingList , Tuple < string , string , string > > objectDictionary = new Dictionary < VdwDataObjectMappingList , Tuple < string , string , string > > ( ) ;
718
728
719
- if ( mappingList . Any ( ) )
729
+ if ( vdwDataObjectMappigLists . Any ( ) )
720
730
{
721
- foreach ( VdwDataObjectMappingList dataObjectMappings in mappingList )
731
+ foreach ( VdwDataObjectMappingList dataObjectMappings in vdwDataObjectMappigLists )
722
732
{
723
733
if ( dataObjectMappings . DataObjectMappings != null )
724
734
{
725
735
foreach ( DataObjectMapping dataObjectMapping in dataObjectMappings . DataObjectMappings )
726
736
{
727
- if ( dataObjectMapping . Name == null )
737
+ if ( dataObjectMapping . MappingName == null )
728
738
{
729
- dataObjectMapping . Name = dataObjectMapping . TargetDataObject . Name ;
739
+ dataObjectMapping . MappingName = dataObjectMapping . TargetDataObject . Name ;
730
740
InformUser ( $ "The Data Object Mapping for target { dataObjectMapping . TargetDataObject . Name } does not have a mapping name, so the target name is used.", EventTypes . Warning ) ;
731
741
}
732
742
// Check if there are classifications, as these are used to create the tabs.
733
- if ( dataObjectMapping . Classifications != null )
743
+ if ( dataObjectMapping . MappingClassifications != null )
734
744
{
735
- foreach ( DataClassification classification in dataObjectMapping . Classifications )
745
+ foreach ( DataClassification classification in dataObjectMapping . MappingClassifications )
736
746
{
737
747
if ( ! objectDictionary . ContainsKey ( dataObjectMappings ) )
738
748
{
@@ -747,7 +757,7 @@ internal List<LocalTemplate> GetMetadata()
747
757
objectDictionary . Add ( dataObjectMappings , new Tuple < string , string , string > ( "Miscellaneous" , dataObjectMapping . TargetDataObject . Name , "" ) ) ;
748
758
}
749
759
750
- InformUser ( $ "The Data Object Mapping { dataObjectMapping . Name } does not have a classification, and therefore will be placed under 'Miscellaneous'", EventTypes . Warning ) ;
760
+ InformUser ( $ "The Data Object Mapping { dataObjectMapping . MappingName } does not have a classification, and therefore will be placed under 'Miscellaneous'", EventTypes . Warning ) ;
751
761
}
752
762
}
753
763
}
@@ -799,7 +809,7 @@ internal List<LocalTemplate> GetMetadata()
799
809
800
810
localTemplateMapping . classification = classification . Key ;
801
811
localTemplateMapping . notes = classification . Value ;
802
- localTemplateMapping . itemList = itemList ;
812
+ localTemplateMapping . vdwDataObjectMappingList = itemList ;
803
813
804
814
finalMappingList . Add ( localTemplateMapping ) ;
805
815
}
@@ -839,6 +849,7 @@ internal void CreateCustomTabPages()
839
849
Dictionary < string , LocalTemplate > sortedMappingList = new Dictionary < string , LocalTemplate > ( ) ;
840
850
foreach ( var mapping in finalMappingList )
841
851
{
852
+ int counter = 1 ;
842
853
string orderNumber = mapping . classification switch
843
854
{
844
855
"Source" => "0" ,
@@ -862,16 +873,25 @@ internal void CreateCustomTabPages()
862
873
"NaturalBusinessRelationshipContextDrivingKey" => "71" ,
863
874
"Link-Satellite Driving Key" => "72" ,
864
875
"Presentation" => "80" ,
865
- _ => "900"
876
+ "Helper" => "85" ,
877
+ "Export" => "86" ,
878
+ _ => $ "{ 900 + counter } " // To ensure uniquness for all unknowns
866
879
} ;
867
880
868
- sortedMappingList . Add ( orderNumber , mapping ) ;
881
+ if ( ! sortedMappingList . ContainsKey ( orderNumber ) )
882
+ {
883
+ sortedMappingList . Add ( orderNumber , mapping ) ;
884
+ }
885
+ else
886
+ {
887
+ // TODO
888
+ }
869
889
}
870
890
871
891
// Add the Custom Tab Pages
872
892
foreach ( var template in sortedMappingList . OrderBy ( x => x . Key ) )
873
893
{
874
- CustomTabPage localCustomTabPage = new CustomTabPage ( template . Value . classification , template . Value . notes , template . Value . itemList ) ;
894
+ CustomTabPage localCustomTabPage = new CustomTabPage ( template . Value . classification , template . Value . notes , template . Value . vdwDataObjectMappingList ) ;
875
895
localCustomTabPage . OnChangeMainText += UpdateMainInformationTextBox ;
876
896
localCustomTabPage . OnClearMainText += ClearMainInformationTextBox ;
877
897
@@ -998,7 +1018,7 @@ private void RefreshMetadata()
998
1018
{
999
1019
if ( localTemplate . classification == tabName )
1000
1020
{
1001
- customTabPage . SetItemList ( localTemplate . itemList ) ;
1021
+ customTabPage . SetItemList ( localTemplate . vdwDataObjectMappingList ) ;
1002
1022
}
1003
1023
}
1004
1024
}
@@ -1249,24 +1269,23 @@ private void SaveTemplateCollectionFileToolStripMenuItem_Click(object sender, Ev
1249
1269
TemplateType = singleRow [ 1 ] . ToString ( ) ,
1250
1270
TemplateConnectionKey = singleRow [ 2 ] . ToString ( ) ,
1251
1271
TemplateOutputFileConvention = singleRow [ 3 ] . ToString ( ) ,
1252
- TemplateFilePath = singleRow [ 4 ] . ToString ( ) ,
1253
- TemplateNotes = singleRow [ 5 ] . ToString ( )
1272
+ TemplateOutputFileSplit = singleRow [ 4 ] . ToString ( ) ,
1273
+ TemplateFilePath = singleRow [ 5 ] . ToString ( ) ,
1274
+ TemplateNotes = singleRow [ 6 ] . ToString ( )
1254
1275
} ) ;
1255
1276
outputFileArray . Add ( individualRow ) ;
1256
1277
}
1257
1278
1258
1279
string json = JsonConvert . SerializeObject ( outputFileArray , Formatting . Indented ) ;
1259
1280
1260
-
1261
1281
File . WriteAllText ( chosenFile , json ) ;
1262
1282
1263
1283
SetTextMain ( "The file " + chosenFile + " was updated.\r \n " ) ;
1264
1284
1265
1285
try
1266
1286
{
1267
1287
// Quick fix, in the file again to commit changes to memory.
1268
- VdwConfigurationSettings . templateList =
1269
- JsonConvert . DeserializeObject < List < TemplateHandling > > ( File . ReadAllText ( chosenFile ) ) ;
1288
+ VdwConfigurationSettings . templateList = JsonConvert . DeserializeObject < List < TemplateHandling > > ( File . ReadAllText ( chosenFile ) ) ;
1270
1289
CreateCustomTabPages ( ) ;
1271
1290
}
1272
1291
catch ( Exception ex )
0 commit comments