summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/factories/mso.factory.ts
diff options
context:
space:
mode:
authorSonsino, Ofir (os0695) <os0695@intl.att.com>2018-07-10 15:57:37 +0300
committerSonsino, Ofir (os0695) <os0695@intl.att.com>2018-07-10 15:57:37 +0300
commitff76b5ed0aa91d5fdf9dc4f95e8b20f91ed9d072 (patch)
treeaae42404a93fdffdd16ff050eaa28129959f7577 /vid-webpack-master/src/app/factories/mso.factory.ts
parentc72d565bb58226b20625b2bce5f0019046bee649 (diff)
New Angular UI from 1806
Change-Id: I39c160db0e0a6ec2e587ccf007ee1b23c6a08666 Issue-ID: VID-208 Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app/factories/mso.factory.ts')
-rw-r--r--vid-webpack-master/src/app/factories/mso.factory.ts92
1 files changed, 92 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/factories/mso.factory.ts b/vid-webpack-master/src/app/factories/mso.factory.ts
new file mode 100644
index 000000000..c26296edf
--- /dev/null
+++ b/vid-webpack-master/src/app/factories/mso.factory.ts
@@ -0,0 +1,92 @@
+import { RequestInfo, RequestDetails, ModelInfo, CloudConfiguration, LineOfBusiness, Platform, RelatedInstanceList, VfcModel } from "./models/requestDetails.model";
+import * as _ from "lodash";
+
+function extractModelInfoFromNodeTemplate(node: any, type: string) {
+ let modelInfo: ModelInfo = <ModelInfo>{};
+ if (node["customizationUuid"] !== undefined) {
+ modelInfo.modelCustomizationId = node["customizationUuid"];
+ }
+ if (node["modelCustomizationName"] !== undefined) {
+ modelInfo.modelCustomizationName = node["modelCustomizationName"];
+ }
+ modelInfo.modelVersionId = node["uuid"];
+ modelInfo.modelName = node["name"];
+ modelInfo.modelInvariantId = node["invariantUuid"];
+ modelInfo.modelType = type;
+ modelInfo.modelVersion = node["version"];
+ return modelInfo;
+}
+
+function extractRequestInfo(userInputs: any, userId: string): RequestInfo {
+ let requestInfo: RequestInfo = <RequestInfo>{};
+ if (userInputs["instanceName"] !== undefined) requestInfo.instanceName = userInputs["instanceName"];
+ requestInfo.productFamilyId = userInputs["productFamily"];
+ requestInfo.source = "VID";
+ requestInfo.suppressRollback = userInputs["rollback"] === "false";
+ requestInfo.requestorId = userId;
+ return requestInfo;
+}
+
+function extractPlatform(userInputs: any): Platform {
+ let platform: Platform = <Platform>{};
+ platform.platformName = userInputs["platformName"];
+ return platform;
+}
+
+function extractVfcGroupModelAccordingToUuid(vnfModel: any, vfcUuid: string) {
+ return _.find(vnfModel.vfcInstanceGroups, { uuid: vfcUuid });
+}
+
+function extractLineOfBusiness(userInputs: any) {
+ let lob: LineOfBusiness = <LineOfBusiness>{};
+ lob.lineOfBusinessName = userInputs["lineOfBusiness"];
+ return lob;
+}
+
+function extractCloudConfiguration(userInputs: any) {
+ let cloudConfig: CloudConfiguration = <CloudConfiguration>{};
+ cloudConfig.lcpCloudRegionId = userInputs["lcpRegion"];
+ cloudConfig.tenantId = userInputs["tenantId"];
+ return cloudConfig;
+}
+
+function extractModelInfoFromVfcNode(vfcModel: VfcModel): ModelInfo {
+ let modelinfo: ModelInfo = <ModelInfo>{};
+ modelinfo.modelName = vfcModel.name;
+ modelinfo.modelType = "networkCollection";
+ modelinfo.modelVersion = vfcModel.version;
+ modelinfo.modelVersionId = vfcModel.uuid;
+ modelinfo.modelInvariantId = vfcModel.invariantUuid;
+ return modelinfo;
+}
+
+export function createRequest(userId: string, userInputs: any, service: any, serviceInstanceId: string, networkInstanceGroups: any, vnfCustomizationName: string, vnfCustomizationId: string) {
+ let request: RequestDetails = <RequestDetails>{};
+ request.requestInfo = extractRequestInfo(userInputs, userId);
+ request.lineOfBusiness = extractLineOfBusiness(userInputs);
+ request.cloudConfiguration = extractCloudConfiguration(userInputs);
+ request.platform = extractPlatform(userInputs);
+ request.modelInfo = extractModelInfoFromNodeTemplate(service.vnfs[vnfCustomizationName], "vnf");
+ request.requestParameters = { userParams: [], testApi: sessionStorage.getItem("msoRequestParametersTestApiValue")};
+ request.relatedInstanceList = [];
+ let serviceRelatedInstance: RelatedInstanceList = {
+ relatedInstance: {
+ instanceId: serviceInstanceId,
+ modelInfo: extractModelInfoFromNodeTemplate(service.service, "service")
+ }
+ };
+ request.relatedInstanceList.push(serviceRelatedInstance);
+ _.forOwn(networkInstanceGroups, function(group) {
+ let modelUuid = group["instance-group"]["model-version-id"];
+ let vfcModel = extractVfcGroupModelAccordingToUuid(service.vnfs[vnfCustomizationName], modelUuid);
+ let networkInstanceGroup: RelatedInstanceList = {
+ relatedInstance: {
+ instanceId: group["instance-group"].id,
+ modelInfo: extractModelInfoFromVfcNode(vfcModel)
+ }
+ };
+ request.relatedInstanceList.push(networkInstanceGroup);
+ });
+
+ return request;
+}