aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2020-01-29 18:20:23 +0200
committerIttay Stern <ittay.stern@att.com>2020-02-02 12:54:38 +0200
commit74e6271d3c9a5f0f2f471c607ca7bc9b8f3d5fc0 (patch)
treec4cd63d23007d8b3d66939146db43fd95b3220f7 /vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts
parentaefc6a0e43b8ce36134dbbed71cf2b4cb9745a9f (diff)
originalName fallbacks to customizationId or invariantId
Issue-ID: VID-724 Change-Id: I3db8d09cabfb700dc1acd469d6fb8acb4764cd73 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts')
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts32
1 files changed, 24 insertions, 8 deletions
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 669f9b675..d60bbd3c9 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,23 +54,39 @@ export class SharedTreeService {
: (nodeInstance.modelInfo.modelCustomizationId || nodeInstance.modelInfo.modelInvariantId);
};
+ modelUniqueNameOrId = (instance): string =>
+ instance.originalName ? instance.originalName : this.modelUniqueId(instance);
+
/**
* 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.
+ * @param modelUniqueNameOrId Either an entry name (i.e. "originalName"), modelCustomizationId or modelInvariantId.
* Note that modelInvariantId will work only where model lacks a modelCustomizationId.
+ * @param modeName An optional entry name (i.e. "originalName"); will not try to use as id
*/
- modelByIdentifier = (serviceModelFromHierarchy, modelTypeName: string, modelUniqueIdOrName: string): any => {
- if (_.isNil(serviceModelFromHierarchy)) return undefined;
+ modelByIdentifiers = (serviceModelFromHierarchy, modelTypeName: string, modelUniqueNameOrId: string, modeName?: string): any => {
+ const logErrorAndReturnUndefined = () =>
+ console.info(`modelByIdentifiers: could not find a model matching query`, {
+ modelTypeName, modelUniqueNameOrId, modeName, serviceModelFromHierarchy
+ });
+
+ if (_.isNil(serviceModelFromHierarchy)) return logErrorAndReturnUndefined();
const modelsOfType = serviceModelFromHierarchy[modelTypeName];
- if (_.isNil(modelsOfType)) return undefined;
+ if (_.isNil(modelsOfType)) return logErrorAndReturnUndefined();
+
+ const modelIfModelIdentifierIsEntryName = modelsOfType[modelUniqueNameOrId];
+ const modelIfModeNameExists = _.isNil(modeName) ? null : modelsOfType[modeName];
- const modelIfModelIdentifierIsEntryName = modelsOfType[modelUniqueIdOrName];
- return _.isNil(modelIfModelIdentifierIsEntryName)
- ? _.find(modelsOfType, o => (o.customizationUuid || o.invariantUuid) === modelUniqueIdOrName)
- : modelIfModelIdentifierIsEntryName;
+ if (!_.isNil(modelIfModelIdentifierIsEntryName)) {
+ return modelIfModelIdentifierIsEntryName;
+ } else if (!_.isNil(modelIfModeNameExists)) {
+ return modelIfModeNameExists;
+ } else {
+ // try modelUniqueNameOrId as an id
+ return _.find(modelsOfType, o => (o.customizationUuid || o.invariantUuid) === modelUniqueNameOrId) || logErrorAndReturnUndefined()
+ }
};
hasMissingData(instance, dynamicInputs: any, isEcompGeneratedNaming: boolean, requiredFields: string[]): boolean {