originalName may be model's "entry name", customizationId or invariantId
The classic originalName is the "entry name". So two more options
were added through SharedTreeService::modelByIdentifier()
function.
Issue-ID: VID-724
Change-Id: I9f192d2b24c9c1659a95baabd21252bed392e9da
Signed-off-by: Ittay Stern <ittay.stern@att.com>
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts
index 1115d1b..6c985ec 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts
@@ -54,6 +54,25 @@
: (nodeInstance.modelInfo.modelCustomizationId || nodeInstance.modelInfo.modelInvariantId);
};
+ /**
+ * Finds a model inside a full service model
+ * @param serviceModelFromHierarchy
+ * @param modelTypeName "vnfs" | "networks" | "vfModules" | "collectionResources" | ...
+ * @param modelUniqueIdOrName Either an entry name (i.e. "originalName"), modelCustomizationId or modelInvariantId.
+ * Note that modelInvariantId will work only where model lacks a modelCustomizationId.
+ */
+ modelByIdentifier = (serviceModelFromHierarchy, modelTypeName: string, modelUniqueIdOrName: string): any => {
+ if (_.isNil(serviceModelFromHierarchy)) return undefined;
+
+ const modelsOfType = serviceModelFromHierarchy[modelTypeName];
+ if (_.isNil(modelsOfType)) return undefined;
+
+ const modelIfModelIdentifierIsEntryName = modelsOfType[modelUniqueIdOrName];
+ return _.isNil(modelIfModelIdentifierIsEntryName)
+ ? _.find(modelsOfType, o => (o.customizationUuid || o.invariantUuid) === modelUniqueIdOrName)
+ : modelIfModelIdentifierIsEntryName;
+ };
+
hasMissingData(instance, dynamicInputs: any, isEcompGeneratedNaming: boolean, requiredFields: string[]): boolean {
if (!isEcompGeneratedNaming && _.isEmpty(instance.instanceName)) {
return true;