|
19 | 19 |
|
20 | 20 | if (!string.IsNullOrEmpty(jsonSchema))
|
21 | 21 | {
|
22 |
| - var inputMetadataDirectory = @"C:\AutomationEnvironments\VDW\Metadata"; |
23 |
| - var outputMetadataDirectory = @"C:\AutomationEnvironments\VDW\MetadataV2"; |
| 22 | + var inputMetadataDirectory = @"D:\TeamEnvironments\VDW\Metadata"; |
| 23 | + var outputMetadataDirectory = @"D:\TeamEnvironments\VDW\MetadataV2"; |
24 | 24 |
|
25 | 25 | var exceptionList = new List<string>
|
26 | 26 | {
|
|
64 | 64 | // Connection.
|
65 | 65 | UpdateDataConnection(dataObjectJsonObject);
|
66 | 66 |
|
| 67 | + // Update the classifications |
| 68 | + UpdateClassifications(dataObjectJsonObject); |
| 69 | + |
67 | 70 | jsonObject["generationSpecificMetadata"]!["selectedDataObject"] = dataObjectJsonObject;
|
68 | 71 |
|
69 | 72 | // Data items.
|
|
126 | 129 | jsonObjectDataObjectMapping.Add("classifications", mappingClassificationsNode);
|
127 | 130 |
|
128 | 131 | // Update the classifications
|
129 |
| - if (jsonObjectDataObjectMapping["classifications"] != null) |
130 |
| - { |
131 |
| - try |
132 |
| - { |
133 |
| - foreach (var classification in jsonObjectDataObjectMapping["classifications"].AsArray()) |
134 |
| - { |
135 |
| - var classificationJsonObject = JsonNode.Parse(classification.ToJsonString()).AsObject(); |
136 |
| - var getClassification = classificationJsonObject |
137 |
| - .TryGetPropertyValue("classification", out var classificationValue).ToString(); |
138 |
| - |
139 |
| - string groupValue = classificationValue.ToString() switch |
140 |
| - { |
141 |
| - "Source" => "Solution Layer", |
142 |
| - "Core Business Concept" => "Logical", |
143 |
| - "CoreBusinessConcept" => "Logical", |
144 |
| - "Integration" => "Solution Layer", |
145 |
| - "Context" => "Logical", |
146 |
| - "Persistent Staging" => "Solution Layer", |
147 |
| - "PersistentStaging" => "Solution Layer", |
148 |
| - "Staging" => "Solution Layer", |
149 |
| - "StagingArea" => "Solution Layer", |
150 |
| - "Thing" => "Conceptual", |
151 |
| - "Presentation" => "Solution Layer", |
152 |
| - "Natural Business Relationship" => "Logical", |
153 |
| - "NaturalBusinessRelationship" => "Logical", |
154 |
| - "Natural Business Relationship Context" => "Logical", |
155 |
| - "NaturalBusinessRelationshipContext" => "Logical", |
156 |
| - "Natural Business Relationship Context Driving Key" => "Logical", |
157 |
| - "NaturalBusinessRelationshipContextDrivingKey" => "Logical", |
158 |
| - "Person" => "Conceptual", |
159 |
| - "Place" => "Conceptual", |
160 |
| - "Hub" => "Physical", |
161 |
| - "Event" => "Physical", |
162 |
| - "Satellite" => "Conceptual", |
163 |
| - "Link" => "Physical", |
164 |
| - _ => "Unknown" |
165 |
| - }; |
166 |
| - |
167 |
| - classificationJsonObject.Add("group",groupValue); |
168 |
| - } |
169 |
| - |
170 |
| - |
171 |
| - } |
172 |
| - catch (Exception ex) |
173 |
| - { |
174 |
| - |
175 |
| - } |
176 |
| - } |
| 132 | + UpdateClassifications(jsonObjectDataObjectMapping); |
177 | 133 |
|
178 | 134 | // Rename the business key definitions.
|
179 |
| - var businessKeyDefinitionsNode = jsonObjectDataObjectMapping["businessKeys"]; |
| 135 | + var businessKeyDefinitionsNode = jsonObjectDataObjectMapping["businessKeys"]; |
180 | 136 | jsonObjectDataObjectMapping.Remove("businessKeys");
|
181 | 137 | jsonObjectDataObjectMapping.Add("businessKeyDefinitions", businessKeyDefinitionsNode);
|
182 | 138 |
|
|
199 | 155 | // Replace properties with newer names (upgrade).
|
200 | 156 | ReplaceDataObjectProperties(dataObjectJsonObject);
|
201 | 157 |
|
| 158 | + // Update the classifications |
| 159 | + UpdateClassifications(dataObjectJsonObject); |
| 160 | + |
202 | 161 | var getSourceDataObjectName = dataObjectJsonObject.TryGetPropertyValue("name", out var sourceDataObjectNameJsonNode).ToString();
|
203 | 162 |
|
204 | 163 | // Add the mapping name as a 'name' to the list of mappings, only once.
|
|
276 | 235 | // Connection.
|
277 | 236 | UpdateDataConnection(dataObjectJsonObject);
|
278 | 237 |
|
| 238 | + // Update the classifications |
| 239 | + UpdateClassifications(dataObjectJsonObject); |
| 240 | + |
279 | 241 | jsonObjectDataObjectMapping["targetDataObject"] = dataObjectJsonObject;
|
280 | 242 |
|
281 | 243 | /// Data items.
|
|
334 | 296 | // Connection.
|
335 | 297 | UpdateDataConnection(dataObjectJsonObject);
|
336 | 298 |
|
| 299 | + // Update the classifications |
| 300 | + UpdateClassifications(dataObjectJsonObject); |
| 301 | + |
337 | 302 | // Data Items.
|
338 | 303 | var dataItems = new List<JsonObject>();
|
339 | 304 | foreach (var dataItem in dataObjectJsonObject["dataItems"].AsArray())
|
|
458 | 423 | // Change isHardCodedValue into extension.
|
459 | 424 | if (dataItemJsonObject.ContainsKey("isHardCodedValue"))
|
460 | 425 | {
|
461 |
| - var keyExists = dataItemJsonObject.TryGetPropertyValue("key", out var jsonNode).ToString(); |
| 426 | + var keyExists = dataItemJsonObject.TryGetPropertyValue("isHardCodedValue", out var jsonNode).ToString(); |
462 | 427 |
|
463 | 428 | if (keyExists == "True")
|
464 | 429 | {
|
465 | 430 | if (jsonNode != null && jsonNode.ToString() == "true")
|
466 | 431 | {
|
467 |
| - // Create an extension. |
468 |
| - var extension = new JsonObject() |
469 |
| - { |
470 |
| - ["key"] = "isHardCodedValue", |
471 |
| - ["value"] = "true", |
472 |
| - ["notes"] = "database name" |
473 |
| - }; |
474 |
| - |
475 |
| - // Extensions |
476 |
| - if (dataItemJsonObject["extensions"] == null) |
477 |
| - { |
478 |
| - dataItemJsonObject.Add("extensions", extension); |
479 |
| - } |
480 |
| - else |
| 432 | + try |
481 | 433 | {
|
| 434 | + // Create an extension. |
| 435 | + var extension = new JsonObject() |
| 436 | + { |
| 437 | + ["key"] = "isHardCodedValue", |
| 438 | + ["value"] = "true", |
| 439 | + ["notes"] = "database name" |
| 440 | + }; |
| 441 | + |
| 442 | + // Extensions |
482 | 443 | var extensionArray = new JsonArray();
|
| 444 | + if (dataItemJsonObject["extensions"] == null) |
| 445 | + { |
| 446 | + dataItemJsonObject.Add("extensions", extensionArray); |
| 447 | + } |
| 448 | + |
483 | 449 | extensionArray = dataItemJsonObject["extensions"]?.AsArray();
|
484 | 450 | extensionArray.Add(extension);
|
485 | 451 | dataItemJsonObject["extensions"] = extensionArray;
|
486 | 452 | }
|
| 453 | + catch (Exception ex) |
| 454 | + { |
| 455 | + // |
| 456 | + } |
487 | 457 | }
|
488 | 458 | }
|
489 | 459 |
|
@@ -625,6 +595,60 @@ void ReplaceDataItemProperties(JsonObject jsonObject)
|
625 | 595 | RenameProperty("dataItemClassification", "classifications", jsonObject);
|
626 | 596 | }
|
627 | 597 |
|
| 598 | +void UpdateClassifications(JsonObject jsonObject) |
| 599 | +{ |
| 600 | + if (jsonObject["classifications"] != null) |
| 601 | + { |
| 602 | + var classificationArray = new JsonArray(); |
| 603 | + try |
| 604 | + { |
| 605 | + foreach (var classification in jsonObject["classifications"].AsArray()) |
| 606 | + { |
| 607 | + var classificationJsonObject = JsonNode.Parse(classification.ToJsonString()).AsObject(); |
| 608 | + var getClassification = classificationJsonObject.TryGetPropertyValue("classification", out var classificationValue).ToString(); |
| 609 | + |
| 610 | + string groupValue = classificationValue.ToString() switch |
| 611 | + { |
| 612 | + "Source" => "Solution Layer", |
| 613 | + "Core Business Concept" => "Logical", |
| 614 | + "CoreBusinessConcept" => "Logical", |
| 615 | + "Integration" => "Solution Layer", |
| 616 | + "Context" => "Logical", |
| 617 | + "Persistent Staging" => "Solution Layer", |
| 618 | + "PersistentStaging" => "Solution Layer", |
| 619 | + "Staging" => "Solution Layer", |
| 620 | + "StagingArea" => "Solution Layer", |
| 621 | + "Thing" => "Conceptual", |
| 622 | + "Presentation" => "Solution Layer", |
| 623 | + "Natural Business Relationship" => "Logical", |
| 624 | + "NaturalBusinessRelationship" => "Logical", |
| 625 | + "Natural Business Relationship Context" => "Logical", |
| 626 | + "NaturalBusinessRelationshipContext" => "Logical", |
| 627 | + "Natural Business Relationship Context Driving Key" => "Logical", |
| 628 | + "NaturalBusinessRelationshipContextDrivingKey" => "Logical", |
| 629 | + "Person" => "Conceptual", |
| 630 | + "Place" => "Conceptual", |
| 631 | + "Hub" => "Physical", |
| 632 | + "Event" => "Physical", |
| 633 | + "Satellite" => "Conceptual", |
| 634 | + "Link" => "Physical", |
| 635 | + _ => "Unknown" |
| 636 | + }; |
| 637 | + |
| 638 | + classificationJsonObject.Add("group", groupValue); |
| 639 | + |
| 640 | + classificationArray.Add(classificationJsonObject); |
| 641 | + } |
| 642 | + } |
| 643 | + catch (Exception ex) |
| 644 | + { |
| 645 | + // To do |
| 646 | + } |
| 647 | + |
| 648 | + jsonObject["classifications"] = classificationArray; |
| 649 | + } |
| 650 | +} |
| 651 | + |
628 | 652 | void UpdateDataConnection(JsonObject dataObjectJsonObject)
|
629 | 653 | {
|
630 | 654 | // Connection.
|
|
0 commit comments