-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
015460d
commit ce04332
Showing
4 changed files
with
170 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="DataWarehouseAutomation" Version="1.3.4" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System.Dynamic; | ||
using DataWarehouseAutomation; | ||
using HandlebarsDotNet; | ||
using Newtonsoft.Json; | ||
|
||
var inputMetadataDirectory = @"D:\Git_Repos\jarvis-TEAM-metadata\Development\TEAM\Metadata"; | ||
var outputMetadataDirectory = @"D:\Git_Repos\"; | ||
|
||
var exceptionList = new List<string> | ||
{ | ||
"VDW_Samples_TEAM_Attribute_Mapping.json", | ||
"Development_TEAM_Attribute_Mapping.json", | ||
"sample_TEAM_Attribute_Mapping.json" | ||
}; | ||
|
||
List<DataItemMappingTuple> exportOutput = new List<DataItemMappingTuple>(); | ||
|
||
foreach (string file in Directory.EnumerateFiles(inputMetadataDirectory, "*.json", SearchOption.TopDirectoryOnly)) | ||
{ | ||
if (!exceptionList.Contains(Path.GetFileName(file))) | ||
{ | ||
try | ||
{ | ||
Console.WriteLine(file); | ||
var json = File.ReadAllText(file); | ||
var deserializedMapping = JsonConvert.DeserializeObject<DataWarehouseAutomation.DataObjectMappingList>(json); | ||
|
||
foreach (var dataObjectMapping in deserializedMapping.DataObjectMappings) | ||
{ | ||
var sourceDataObjectRaw = dataObjectMapping.SourceDataObjects.FirstOrDefault(); | ||
|
||
if (dataObjectMapping.DataItemMappings != null) | ||
{ | ||
foreach (var dataItemMapping in dataObjectMapping.DataItemMappings) | ||
{ | ||
var sourceDataItemRaw = dataItemMapping.SourceDataItems.FirstOrDefault(); | ||
|
||
var localDataItemMappingTuple = new DataItemMappingTuple | ||
{ | ||
SourceDataObject = sourceDataObjectRaw.name, | ||
SourceDataItem = sourceDataItemRaw.name, | ||
TargetDataObject = dataObjectMapping.TargetDataObject.Name, | ||
TargetDataItem = dataItemMapping.TargetDataItem.Name | ||
}; | ||
|
||
if (!exportOutput.Contains(localDataItemMappingTuple)) | ||
{ | ||
exportOutput.Add(localDataItemMappingTuple); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
catch (Exception exception) | ||
{ | ||
Console.WriteLine($"Issue: "+exception.Message); | ||
} | ||
} | ||
} | ||
|
||
// Export to file | ||
using (StreamWriter writer = new StreamWriter(outputMetadataDirectory+"TEAM-export.csv")) | ||
{ | ||
foreach (var exportRow in exportOutput) | ||
{ | ||
writer.WriteLine($"{exportRow.SourceDataObject},{exportRow.SourceDataItem},{exportRow.TargetDataObject},{exportRow.TargetDataItem}"); | ||
} | ||
} | ||
|
||
// Finish the application. | ||
Console.ReadKey(); | ||
|
||
internal class DataItemMappingTuple | ||
{ | ||
internal string SourceDataObject | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
internal string SourceDataItem | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
internal string TargetDataObject | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
internal string TargetDataItem | ||
{ | ||
get; | ||
set; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters