|
24 | 24 | "sample_TEAM_Attribute_Mapping.json"
|
25 | 25 | };
|
26 | 26 |
|
| 27 | + #region GUIDs |
| 28 | + // GUID for object, item, connection, classification, businessKeyDefinition, dataObjectMapping, dataItemMapping, mappinglist |
| 29 | + Dictionary<string, Guid> dataObjectGuids = new Dictionary<string, Guid>(); |
| 30 | + Dictionary<string, Guid> dataItemGuids = new Dictionary<string, Guid>(); |
| 31 | + Dictionary<string, Guid> connectionGuids = new Dictionary<string, Guid>(); |
| 32 | + Dictionary<string, Guid> classificationGuids = new Dictionary<string, Guid>(); |
| 33 | + Dictionary<string, Guid> dataObjectMappingGuids = new Dictionary<string, Guid>(); |
| 34 | + Dictionary<string, Guid> businessKeyDefinitionGuids = new Dictionary<string, Guid>(); |
| 35 | + Dictionary<string, Guid> dataItemMappingGuids = new Dictionary<string, Guid>(); |
| 36 | + |
| 37 | + #endregion |
| 38 | + |
27 | 39 | foreach (string file in Directory.EnumerateFiles(inputMetadataDirectory, "*.json", SearchOption.TopDirectoryOnly))
|
28 | 40 | {
|
29 | 41 | if (!exceptionList.Contains(Path.GetFileName(file)))
|
|
36 | 48 | // Create a JSON object, which can be modified at runtime.
|
37 | 49 | var jsonObject = JsonNode.Parse(jsonFile).AsObject();
|
38 | 50 |
|
39 |
| - #region GUIDs |
40 |
| - // GUID for object, item, connection, classification, businessKeyDefinition, dataObjectMapping, dataItemMapping, mappinglist |
41 |
| - Dictionary<string, Guid> dataObjectGuids = new Dictionary<string, Guid>(); |
42 |
| - Dictionary<string, Guid> dataItemGuids = new Dictionary<string, Guid>(); |
43 |
| - Dictionary<string, Guid> connectionGuids = new Dictionary<string, Guid>(); |
44 |
| - Dictionary<string, Guid> classificationGuids = new Dictionary<string, Guid>(); |
45 |
| - Dictionary<string, Guid> dataObjectMappingGuids = new Dictionary<string, Guid>(); |
46 |
| - Dictionary<string, Guid> businessKeyDefinitionGuids = new Dictionary<string, Guid>(); |
47 |
| - Dictionary<string, Guid> dataItemMappingGuids = new Dictionary<string, Guid>(); |
48 |
| - |
49 |
| - #endregion |
50 |
| - |
51 | 51 | #region Generation Specific Data Object
|
52 | 52 |
|
53 | 53 | if (jsonObject["generationSpecificMetadata"] != null)
|
|
404 | 404 | var jsonObjectTargetDataItem = JsonNode.Parse(jsonNodeTargetDataItem.ToJsonString()).AsObject();
|
405 | 405 | AddGuid(jsonObjectTargetDataItem, dataItemGuids, "name");
|
406 | 406 | jsonObjectDataItemMapping["targetDataItem"] = jsonObjectTargetDataItem;
|
407 |
| - |
408 |
| - |
| 407 | + |
409 | 408 | foreach (var sourceDataItemJsonObject in sourceDataItemList)
|
410 | 409 | {
|
411 | 410 | jsonObjectDataItemMapping["sourceDataItems"]![sourceDataItemList.IndexOf(sourceDataItemJsonObject)] = sourceDataItemJsonObject;
|
|
448 | 447 | {
|
449 | 448 | var dataMappingJsonObject = JsonNode.Parse(dataItemMapping.ToJsonString()).AsObject();
|
450 | 449 |
|
451 |
| - var dataItemList = new List<JsonObject>(); |
| 450 | + // Source data items. |
| 451 | + var sourceDataItemList = new List<JsonObject>(); |
452 | 452 | foreach (var dataItem in dataItemMapping!["sourceDataItems"]?.AsArray())
|
453 | 453 | {
|
454 | 454 | // Source data item.
|
|
505 | 505 | dataItemJsonObject.Remove("isHardCodedValue");
|
506 | 506 | }
|
507 | 507 |
|
508 |
| - dataItemList.Add(dataItemJsonObject); |
| 508 | + sourceDataItemList.Add(dataItemJsonObject); |
509 | 509 |
|
510 |
| - foreach (var sourceDataItemJsonObject in dataItemList) |
| 510 | + foreach (var sourceDataItemJsonObject in sourceDataItemList) |
511 | 511 | {
|
512 |
| - dataMappingJsonObject["sourceDataItems"]![dataItemList.IndexOf(sourceDataItemJsonObject)] = sourceDataItemJsonObject; |
| 512 | + dataMappingJsonObject["sourceDataItems"]![sourceDataItemList.IndexOf(sourceDataItemJsonObject)] = sourceDataItemJsonObject; |
513 | 513 | }
|
514 | 514 |
|
| 515 | + // Target data item |
| 516 | + var jsonNodeTargetDataItem = dataMappingJsonObject["targetDataItem"]; |
| 517 | + var jsonObjectTargetDataItem = JsonNode.Parse(jsonNodeTargetDataItem.ToJsonString()).AsObject(); |
| 518 | + AddGuid(jsonObjectTargetDataItem, dataItemGuids, "name"); |
| 519 | + dataMappingJsonObject["targetDataItem"] = jsonObjectTargetDataItem; |
| 520 | + |
515 | 521 | dataItemMappingList.Add(dataMappingJsonObject);
|
516 | 522 | }
|
517 | 523 | }
|
518 | 524 |
|
519 | 525 | // Ensure each item has a GUID
|
520 | 526 | AddGuid(businessKeyComponentMappingJsonObject, businessKeyDefinitionGuids);
|
521 | 527 |
|
| 528 | + // Ensdure that each business key definition has a name. |
| 529 | + var businessKeyDefinitionName = $"{jsonObjectDataObjectMapping["name"]} for {businessKeyComponentMappingJsonObject["surrogateKey"]}"; |
| 530 | + |
| 531 | + businessKeyComponentMappingJsonObject.Add("name", businessKeyDefinitionName); |
| 532 | + |
522 | 533 | foreach (var dataItemMappingJsonObject in dataItemMappingList)
|
523 | 534 | {
|
524 | 535 | businessKeyComponentMappingJsonObject["businessKeyComponentMapping"]![dataItemMappingList.IndexOf(dataItemMappingJsonObject)] = dataItemMappingJsonObject;
|
|
532 | 543 | {
|
533 | 544 | jsonObjectDataObjectMapping["businessKeyDefinitions"]![businessKeyDefinitions.IndexOf(businessKeyComponent)] = businessKeyComponent;
|
534 | 545 | }
|
535 |
| - |
536 |
| - |
537 | 546 | }
|
538 | 547 | }
|
539 | 548 | catch (Exception ex)
|
|
627 | 636 | AddGuid(jsonObjectDataObjectMapping, dataObjectMappingGuids, "name");
|
628 | 637 |
|
629 | 638 | dataObjectMappingJsonArray.Add(jsonObjectDataObjectMapping);
|
630 |
| - |
631 |
| - |
632 | 639 | }
|
633 | 640 |
|
634 | 641 | // Put the data object mappings back into the main object.
|
|
657 | 664 | }
|
658 | 665 | finally
|
659 | 666 | {
|
660 |
| - |
| 667 | + // To do. |
661 | 668 | }
|
662 | 669 |
|
663 | 670 | // Save the file to disk.
|
|
0 commit comments