summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epsdk-app-onap/src/main/resources/db.changelog-01.sql5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/InstantiationTemplatesController.java60
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java38
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/DaoUtils.java51
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/ServiceInfoTest.java58
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java20
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/utils/DaoUtilsStringToLongMapAttributeConverter.java69
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/templateSummarize3Networks.json27
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/templateSummarize3Vnfs8Vfmodule2VolumeGroups.json89
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json19
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java2
-rw-r--r--vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts2
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts8
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.spec.ts (renamed from vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts)64
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.ts (renamed from vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts)170
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts181
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts10
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts263
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts189
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts137
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts18
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts173
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts24
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts11
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts10
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts8
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/shared.module.ts6
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.spec.ts41
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts1
-rw-r--r--vid-webpack-master/src/app/shared/utils/constants.ts2
50 files changed, 1191 insertions, 704 deletions
diff --git a/epsdk-app-onap/src/main/resources/db.changelog-01.sql b/epsdk-app-onap/src/main/resources/db.changelog-01.sql
index acc061796..9a24692a9 100644
--- a/epsdk-app-onap/src/main/resources/db.changelog-01.sql
+++ b/epsdk-app-onap/src/main/resources/db.changelog-01.sql
@@ -318,3 +318,8 @@ INSERT IGNORE `fn_user_role` VALUES (1,20,NULL,1);
INSERT IGNORE `fn_user_role` VALUES (1,21,NULL,1);
INSERT IGNORE `fn_user_role` VALUES (1,22,NULL,1);
UPDATE `fn_app` SET `APP_IMAGE_URL`=null,`APP_URL`=null,`APP_ALTERNATE_URL`=null WHERE `APP_ID`=1;
+
+
+--changeset vid:service_info_request_summary
+ALTER TABLE `vid_openecomp_epsdk`.`vid_service_info`
+ ADD COLUMN `REQUEST_SUMMARY` VARCHAR(400) NULL DEFAULT NULL COLLATE 'utf8_bin';
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
index c73a01877..3260656ff 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
@@ -36,10 +36,8 @@ import org.onap.vid.properties.Features;
import org.onap.vid.roles.RoleProvider;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
import org.onap.vid.services.AuditService;
-import org.onap.vid.services.InstantiationTemplatesService;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -56,7 +54,6 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
public static final String ASYNC_INSTANTIATION = "asyncInstantiation";
protected final AsyncInstantiationBusinessLogic asyncInstantiationBL;
- protected final InstantiationTemplatesService instantiationTemplates;
protected final AsyncInstantiationRepository asyncInstantiationRepository;
private final SystemPropertiesWrapper systemPropertiesWrapper;
@@ -68,12 +65,10 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
@Autowired
public AsyncInstantiationController(AsyncInstantiationBusinessLogic asyncInstantiationBL,
- InstantiationTemplatesService instantiationTemplates,
AsyncInstantiationRepository asyncInstantiationRepository, RoleProvider roleProvider,
FeatureManager featureManager, SystemPropertiesWrapper systemPropertiesWrapper,
AuditService auditService) {
this.asyncInstantiationBL = asyncInstantiationBL;
- this.instantiationTemplates = instantiationTemplates;
this.asyncInstantiationRepository = asyncInstantiationRepository;
this.roleProvider = roleProvider;
this.featureManager = featureManager;
@@ -95,7 +90,6 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
return asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(serviceModelId);
}
}
-
@RequestMapping(value = "bulk", method = RequestMethod.POST)
public MsoResponseWrapper2<List<String>> createBulkOfServices(@RequestBody ServiceInstantiation request, HttpServletRequest httpServletRequest) {
//Push to DB according the model
@@ -174,11 +168,6 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
return new MsoResponseWrapper2(200, uuids);
}
- @GetMapping("templateTopology/{jobId}")
- public ServiceInstantiation getTemplateTopology(HttpServletRequest request, @PathVariable(value="jobId") UUID jobId) {
- return instantiationTemplates.getJobRequestAsTemplate(jobId);
- }
-
@RequestMapping(value = "/auditStatusForRetry/{trackById}", method = RequestMethod.GET)
public JobAuditStatus getResourceAuditStatus(HttpServletRequest request, @PathVariable(value="trackById") String trackById) {
return auditService.getResourceAuditStatus(trackById);
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/InstantiationTemplatesController.java b/vid-app-common/src/main/java/org/onap/vid/controller/InstantiationTemplatesController.java
new file mode 100644
index 000000000..8aae3d805
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/InstantiationTemplatesController.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.controller;
+
+
+import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
+import org.onap.vid.dal.AsyncInstantiationRepository;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.services.InstantiationTemplatesService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(InstantiationTemplatesController.INSTANTIATION_TEMPLATES)
+public class InstantiationTemplatesController extends VidRestrictedBaseController {
+
+ public static final String INSTANTIATION_TEMPLATES = "instantiationTemplates";
+
+ protected final AsyncInstantiationBusinessLogic asyncInstantiationBL;
+ protected final InstantiationTemplatesService instantiationTemplates;
+ protected final AsyncInstantiationRepository asyncInstantiationRepository;
+
+
+ @Autowired
+ public InstantiationTemplatesController(AsyncInstantiationBusinessLogic asyncInstantiationBL,
+ InstantiationTemplatesService instantiationTemplates,
+ AsyncInstantiationRepository asyncInstantiationRepository) {
+ this.asyncInstantiationBL = asyncInstantiationBL;
+ this.instantiationTemplates = instantiationTemplates;
+ this.asyncInstantiationRepository = asyncInstantiationRepository;
+ }
+
+ @GetMapping("templateTopology/{jobId}")
+ public ServiceInstantiation getTemplateTopology(HttpServletRequest request, @PathVariable(value="jobId") UUID jobId) {
+ return instantiationTemplates.getJobRequestAsTemplate(jobId);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java
index 85c83eb98..677d67c8e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java
@@ -24,10 +24,12 @@ package org.onap.vid.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.Date;
+import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@@ -41,6 +43,8 @@ import org.hibernate.annotations.SelectBeforeUpdate;
import org.hibernate.annotations.Type;
import org.onap.portalsdk.core.domain.support.DomainVo;
import org.onap.vid.job.Job;
+import org.onap.vid.job.Job.JobStatus;
+import org.onap.vid.utils.DaoUtils.StringToLongMapAttributeConverter;
/*
The following 2 annotations let hibernate to update only fields that actually have been changed.
@@ -91,17 +95,19 @@ public class ServiceInfo extends DomainVo {
private String serviceModelVersion;
private Date createdBulkDate;
private ServiceAction action;
+ private Map<String, Long> requestSummary;
public ServiceInfo(){
}
- public ServiceInfo(String userId, Boolean aLaCarte, Job.JobStatus jobStatus, boolean pause, UUID jobId, UUID templateId,
- String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName,
- String tenantId, String tenantName, String regionId, String regionName, String serviceType,
- String subscriberName, String subscriberId, String serviceInstanceId, String serviceInstanceName,
- String serviceModelId, String serviceModelName, String serviceModelVersion, Date createdBulkDate,
- ServiceAction action, boolean retryEnabled) {
+ public ServiceInfo(String userId, Boolean aLaCarte, JobStatus jobStatus, boolean pause, UUID jobId,
+ UUID templateId,
+ String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName,
+ String tenantId, String tenantName, String regionId, String regionName, String serviceType,
+ String subscriberName, String subscriberId, String serviceInstanceId, String serviceInstanceName,
+ String serviceModelId, String serviceModelName, String serviceModelVersion, Date createdBulkDate,
+ ServiceAction action, boolean retryEnabled, Map<String, Long> requestSummary) {
this.userId = userId;
this.aLaCarte = aLaCarte;
this.jobStatus = jobStatus;
@@ -128,6 +134,7 @@ public class ServiceInfo extends DomainVo {
this.createdBulkDate = createdBulkDate;
this.action = action;
this.retryEnabled = retryEnabled;
+ this.requestSummary = requestSummary;
}
@Column(name = "JOB_ID", columnDefinition = "CHAR(36)")
@@ -287,6 +294,12 @@ public class ServiceInfo extends DomainVo {
return action;
}
+ @Column(name="REQUEST_SUMMARY")
+ @Convert(converter = StringToLongMapAttributeConverter.class)
+ public Map<String, Long> getRequestSummary() {
+ return requestSummary;
+ }
+
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Override
@@ -454,6 +467,10 @@ public class ServiceInfo extends DomainVo {
public void setAction(ServiceAction action) { this.action = action; }
+ public void setRequestSummary(Map<String, Long> requestSummary) {
+ this.requestSummary = requestSummary;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -488,6 +505,7 @@ public class ServiceInfo extends DomainVo {
Objects.equals(getServiceModelName(), that.getServiceModelName()) &&
Objects.equals(getServiceModelVersion(), that.getServiceModelVersion()) &&
Objects.equals(getCreatedBulkDate(), that.getCreatedBulkDate()) &&
+ Objects.equals(getRequestSummary(), that.getRequestSummary()) &&
getAction() == that.getAction();
}
@@ -497,6 +515,6 @@ public class ServiceInfo extends DomainVo {
getStatusModifiedDate(), isHidden(), isPause(), isRetryEnabled(), getDeletedAt(), getOwningEntityId(), getOwningEntityName(),
getProject(), getAicZoneId(), getAicZoneName(), getTenantId(), getTenantName(), getRegionId(), getRegionName(), getServiceType(),
getSubscriberName(), getSubscriberId(), getServiceInstanceId(), getServiceInstanceName(), getServiceModelId(), getServiceModelName(),
- getServiceModelVersion(), getCreatedBulkDate(), getAction());
+ getServiceModelVersion(), getCreatedBulkDate(), getAction(), getRequestSummary());
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
index c0ee7ea4f..6729bdac8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
@@ -20,11 +20,13 @@
package org.onap.vid.services;
+import static com.google.common.collect.Streams.concat;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
-import static java.util.stream.Stream.concat;
+import static java.util.stream.Stream.empty;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
@@ -41,7 +43,6 @@ import java.util.Objects;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.Stream;
-import org.apache.commons.lang3.StringUtils;
import org.hibernate.SessionFactory;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.AaiClientInterface;
@@ -63,6 +64,7 @@ import org.onap.vid.model.ResourceInfo;
import org.onap.vid.model.ServiceInfo;
import org.onap.vid.model.serviceInstantiation.BaseResource;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.vid.model.serviceInstantiation.VfModule;
import org.onap.vid.mso.MsoBusinessLogicImpl;
import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.MsoUtil;
@@ -188,9 +190,8 @@ public class AsyncInstantiationBusinessLogicImpl implements
public Map<String, Long> getSummarizedChildrenMap(ServiceInstantiation serviceInstantiation){
Stream<String> existingTypesStream =
allDeepChildResources(serviceInstantiation)
- .map(BaseResource::getModelInfo)
- .filter(Objects::nonNull)
- .map(ModelInfo::getModelType);
+ .map(this::getModelTypes)
+ .flatMap(identity());
Map<String, Long> existingTypesCounters =
existingTypesStream.collect(groupingBy(identity(), counting()));
@@ -198,6 +199,28 @@ public class AsyncInstantiationBusinessLogicImpl implements
return existingTypesCounters;
}
+ private Stream<String> getModelTypes(BaseResource resource) {
+ return concat(
+ Stream.of(resource)
+ .map(BaseResource::getModelInfo)
+ .filter(Objects::nonNull)
+ .map(ModelInfo::getModelType),
+ streamVolumeGroups(resource)
+ );
+ }
+
+ private Stream<String> streamVolumeGroups(BaseResource resource) {
+ return hasVolumeGroup(resource)
+ ? Stream.of("volumeGroup")
+ : empty();
+ }
+
+ private boolean hasVolumeGroup(BaseResource resource) {
+ return
+ resource instanceof VfModule
+ && isNotEmpty(((VfModule) resource).getVolumeGroupInstanceName());
+ }
+
private Stream<BaseResource> allDeepChildResources(BaseResource resource) {
return resource
.getChildren()
@@ -216,7 +239,7 @@ public class AsyncInstantiationBusinessLogicImpl implements
private String getOptimisticUniqueServiceInstanceName(String instanceName) {
- return StringUtils.isNotEmpty(instanceName) ? getUniqueNameFromDbOnly(instanceName) : instanceName;
+ return isNotEmpty(instanceName) ? getUniqueNameFromDbOnly(instanceName) : instanceName;
}
protected ServiceInfo createServiceInfo(String userId, ServiceInstantiation serviceInstantiation, UUID jobId, UUID templateId, Date createdBulkDate, String optimisticUniqueServiceInstanceName, ServiceInfo.ServiceAction serviceAction) {
@@ -243,7 +266,8 @@ public class AsyncInstantiationBusinessLogicImpl implements
serviceInstantiation.getModelInfo().getModelVersion(),
createdBulkDate,
serviceAction,
- false);
+ false,
+ null);
}
@Override
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/DaoUtils.java b/vid-app-common/src/main/java/org/onap/vid/utils/DaoUtils.java
index 7d3b926ea..7fb03aea8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/utils/DaoUtils.java
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/DaoUtils.java
@@ -20,14 +20,21 @@
package org.onap.vid.utils;
+import static java.util.Objects.isNull;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Function;
+import javax.persistence.AttributeConverter;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
-import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.portalsdk.core.domain.FusionObject;
-
-import java.util.HashMap;
-import java.util.function.Function;
+import org.onap.vid.exceptions.GenericUncheckedException;
public class DaoUtils {
@@ -70,4 +77,40 @@ public class DaoUtils {
props.put(FusionObject.Parameters.PARAM_USERID, 0);
return props;
}
+
+ public static class StringToLongMapAttributeConverter extends JsonAttributeConverter<Map<String, Long>> {
+
+ private final TypeReference<Map<String, Long>> typeReference =
+ new TypeReference<Map<String, Long>>() {};
+
+ @Override
+ public TypeReference<Map<String, Long>> getTypeReference() {
+ return typeReference;
+ }
+ }
+
+ private static abstract class JsonAttributeConverter<T> implements AttributeConverter<T, String> {
+
+ abstract public TypeReference<T> getTypeReference();
+
+ @Override
+ public String convertToDatabaseColumn(T attribute) {
+ try {
+ return isNull(attribute) ? null
+ : JACKSON_OBJECT_MAPPER.writeValueAsString(attribute);
+ } catch (JsonProcessingException e) {
+ return ExceptionUtils.rethrow(e);
+ }
+ }
+
+ @Override
+ public T convertToEntityAttribute(String dbData) {
+ try {
+ return isNull(dbData) ? null
+ : JACKSON_OBJECT_MAPPER.readValue(dbData, getTypeReference());
+ } catch (JsonProcessingException e) {
+ return ExceptionUtils.rethrow(e);
+ }
+ }
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/ServiceInfoTest.java b/vid-app-common/src/test/java/org/onap/vid/model/ServiceInfoTest.java
new file mode 100644
index 000000000..23391cabd
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/model/ServiceInfoTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.model;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.onap.vid.testUtils.TestUtils.allPropertiesOf;
+
+import org.onap.portalsdk.core.domain.support.DomainVo;
+import org.testng.annotations.Test;
+
+public class ServiceInfoTest {
+ final private String[] excludedProperties = allPropertiesOf(DomainVo.class);
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(ServiceInfo.class, hasValidGettersAndSetters());
+ }
+
+ @Test
+ public void shouldHaveValidBeanConstructor() {
+ assertThat(ServiceInfo.class, hasValidBeanConstructor());
+ }
+
+ @Test
+ public void shouldHaveValidBeanHashCode() {
+ assertThat(ServiceInfo.class, hasValidBeanHashCodeExcluding(excludedProperties));
+ }
+
+ @Test
+ public void shouldHaveValidBeanEquals() {
+ assertThat(ServiceInfo.class, hasValidBeanEqualsExcluding(excludedProperties));
+ }
+
+}
+
+
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
index 29d614cb2..0cfe8059a 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
@@ -491,15 +491,21 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
return prepareServiceInstantiation(PROJECT_NAME, isUserProvidedNaming, bulkSize);
}
- @Test
- public void getSummarizedMap(){
+ @DataProvider
+ public static Object[][] dataProviderSummarizedMap() {
+ return new Object[][]{
+ {"/payload_jsons/templateSummarize4vnfs6vfmodules.json", ImmutableMap.of("vnf", 4L, "vfModule", 6L, "volumeGroup", 1L, "network", 2L)},
+ {"/payload_jsons/templateSummarize3Vnfs8Vfmodule2VolumeGroups.json", ImmutableMap.of("vnf", 3L, "vfModule", 8L, "volumeGroup", 2L)},
+ {"/payload_jsons/templateSummarize3Networks.json", ImmutableMap.of("network", 3L)},
+
+ };
+ }
+
+ @Test(dataProvider = "dataProviderSummarizedMap")
+ public void getSummarizedMap(String pathInResource, Map<String, Long> expectedMap){
ServiceInstantiation serviceInstantiation = TestUtils.readJsonResourceFileAsObject(
- "/payload_jsons/templateSummarize4vnfs6vfmodules.json", ServiceInstantiation.class);
+ pathInResource, ServiceInstantiation.class);
Map<String, Long> childrenMap = asyncInstantiationBL.getSummarizedChildrenMap(serviceInstantiation);
- Map<String, Long> expectedMap = ImmutableMap.of(
- "vnf", 4L,
- "vfModule", 6L
- );
assertEquals(childrenMap,expectedMap);
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/utils/DaoUtilsStringToLongMapAttributeConverter.java b/vid-app-common/src/test/java/org/onap/vid/utils/DaoUtilsStringToLongMapAttributeConverter.java
new file mode 100644
index 000000000..e71f75bb3
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/utils/DaoUtilsStringToLongMapAttributeConverter.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.utils;
+
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import com.google.common.collect.ImmutableMap;
+import org.onap.vid.utils.DaoUtils.StringToLongMapAttributeConverter;
+import org.testng.annotations.Test;
+
+public class DaoUtilsStringToLongMapAttributeConverter {
+
+ private final StringToLongMapAttributeConverter stringToLongMapAttributeConverter = new StringToLongMapAttributeConverter();
+
+ @Test
+ public void toEntity_givenNullString_yieldNullMap() {
+ assertThat(
+ stringToLongMapAttributeConverter.convertToEntityAttribute(null),
+ is(nullValue()));
+ }
+
+ @Test
+ public void toEntity_givenValidString_yieldGoodMap() {
+ assertThat(
+ stringToLongMapAttributeConverter.convertToEntityAttribute("{\"a\": 5}"),
+ is(ImmutableMap.of("a", 5L)));
+ }
+
+ @Test(expectedExceptions = Exception.class)
+ public void toEntity_givenBadString_throws() {
+ stringToLongMapAttributeConverter.convertToEntityAttribute("{a: not-good}");
+ }
+
+ @Test
+ public void fromEntity_givenNullMap_yieldNullString() {
+ assertThat(
+ stringToLongMapAttributeConverter.convertToDatabaseColumn(null),
+ is(nullValue()));
+ }
+
+ @Test
+ public void fromEntity_givenValidMap_yieldString() {
+ assertThat(
+ stringToLongMapAttributeConverter.convertToDatabaseColumn(ImmutableMap.of("a", 5L)),
+ jsonEquals("{\"a\": 5}"));
+ }
+
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/templateSummarize3Networks.json b/vid-app-common/src/test/resources/payload_jsons/templateSummarize3Networks.json
new file mode 100644
index 000000000..6d83a5c5e
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/templateSummarize3Networks.json
@@ -0,0 +1,27 @@
+{
+ "action": "Create",
+ "instanceName": "vProbe_NC_Service_DG_new_SI",
+ "modelInfo": {
+ "modelType": "service"
+ },
+ "networks": {
+ "Network-1": {
+ "instanceName": "myBestNetwork",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ },
+ "Network-2": {
+ "instanceName": "myBestNetwork2",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ },
+ "Network-3": {
+ "instanceName": "myBestNetwork3",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
+ }
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/templateSummarize3Vnfs8Vfmodule2VolumeGroups.json b/vid-app-common/src/test/resources/payload_jsons/templateSummarize3Vnfs8Vfmodule2VolumeGroups.json
new file mode 100644
index 000000000..815c7b861
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/templateSummarize3Vnfs8Vfmodule2VolumeGroups.json
@@ -0,0 +1,89 @@
+{
+ "action": "Create",
+ "instanceName": "vProbe_NC_Service_DG_new_SI",
+ "modelInfo": {
+ "modelType": "service"
+ },
+ "vnfs": {
+ "vProbe_NC_VNF 0": {
+ "modelInfo": {
+ "modelType": "vnf"
+ },
+ "vfModules": {
+ "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0": {
+ "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg": {
+ "modelInfo": {
+ "modelType": "vfModule"
+ }
+ }
+ },
+ "vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1": {
+ "vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1yprvi": {
+ "modelInfo": {
+ "modelType": "vfModule"
+ },
+ "volumeGroupName": "my_first_volume_group"
+ }
+ }
+ }
+ },
+ "2017-488_PASQUALE-vPE 0:0001": {
+ "vfModules": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot": {
+ "modelInfo": {
+ "modelType": "vfModule"
+ }
+ }
+ },
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc": {
+ "modelInfo": {
+ "modelType": "vfModule"
+ },
+ "volumeGroupName": "my_second_volume_group"
+
+ }
+ }
+ },
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ },
+ "2017-488_PASQUALE-vPE 0:0002": {
+ "vfModules": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot": {
+ "modelInfo": {
+ "modelType": "vfModule"
+ }
+ }
+ },
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc": {
+ "modelInfo": {
+ "modelType": "vfModule"
+ }
+ }
+ },
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-2": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc": {
+ "modelInfo": {
+ "modelType": "vfModule"
+ }
+ }
+ },
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-3": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc": {
+ "modelInfo": {
+ "modelType": "vfModule"
+ }
+ }
+ }
+ },
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json b/vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json
index b00448296..8579efe89 100644
--- a/vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json
+++ b/vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json
@@ -21,7 +21,8 @@
"vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1yprvi": {
"modelInfo": {
"modelType": "vfModule"
- }
+ },
+ "volumeGroupName": "my_special_hvf6arlba007_lba_dj_01_vol"
}
}
}
@@ -73,5 +74,21 @@
"modelType": "vnf"
}
}
+ },
+ "networks": {
+ "Network-1": {
+ "instanceName": "myBestNetwork",
+ "instanceId": "884b373f-41c0-4a96-9785-7f075cb4ae9d",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ },
+ "Network-2": {
+ "instanceName": "myBestNetwork2",
+ "instanceId": "884b373f-41c0-4a96-9785-7f075cb4ae9d",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
}
}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java
index 828562041..5e4d83af6 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java
@@ -71,7 +71,7 @@ public class InstantiationTemplatesApiTest extends AsyncInstantiationBase {
}
protected String templateTopologyUri(String jobId) {
- return uri.toASCIIString() + "/asyncInstantiation/templateTopology/" + jobId;
+ return uri.toASCIIString() + "/instantiationTemplates/templateTopology/" + jobId;
}
@Test
diff --git a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
index 0075dc240..bf9c01803 100644
--- a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
@@ -152,7 +152,7 @@ function loadDrawingBoardWithRecreateMode() {
'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
.as('serviceModel');
- cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
+ cy.route(`**/instantiationTemplates/${templateTopologyEndpoint}/${templateUuid}`,
'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
.as('templateTopology');
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts
index c17d9c74c..1cec62b2c 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts
@@ -11,7 +11,7 @@ import {ObjectToTreeService} from "../objectToTree.service";
import {DrawingBoardModes} from "../../drawing-board.modes";
import {DialogService} from "ng2-bootstrap-modal";
import {VnfPopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service";
-import {BasicControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../../shared/components/genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../shared/services/aaiService/aai.service";
import {FeatureFlagsService} from "../../../../shared/services/featureFlag/feature-flags.service";
import {VnfControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator";
@@ -33,6 +33,7 @@ import {ComponentInfoService} from "../../component-info/component-info.service"
import {NetworkStepService} from "../models/vrf/vrfModal/networkStep/network.step.service";
import {VpnStepService} from "../models/vrf/vrfModal/vpnStep/vpn.step.service";
import {VfModuleUpgradePopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../../shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -65,7 +66,8 @@ describe('Model Tree Generator service', () => {
SharedTreeService,
VnfPopupService,
VnfGroupPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
GenericFormService,
FormBuilder,
LogService,
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts
index 8674a619e..0f7bf9a61 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts
@@ -14,7 +14,7 @@ import {
} from "../../available-models-tree/available-models-tree.service";
import {DialogService} from "ng2-bootstrap-modal";
import {VnfPopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service";
-import {BasicControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../../shared/components/genericForm/formControlsServices/control.generator.util.service";
import {GenericFormService} from "../../../../shared/components/genericForm/generic-form.service";
import {FormBuilder} from "@angular/forms";
import {LogService} from "../../../../shared/utils/log/log.service";
@@ -36,6 +36,7 @@ import {IModelTreeNodeModel} from "../../../objectsToTree/objectToModelTree/mode
import {VpnStepService} from "../models/vrf/vrfModal/vpnStep/vpn.step.service";
import {NetworkStepService} from "../models/vrf/vrfModal/networkStep/network.step.service";
import {VfModuleUpgradePopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../../shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -90,7 +91,7 @@ describe('Model Tree Generator service', () => {
DialogService,
VnfPopupService,
VnfGroupPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
GenericFormService,
FormBuilder,
LogService,
@@ -111,6 +112,7 @@ describe('Model Tree Generator service', () => {
ComponentInfoService,
NetworkStepService,
VpnStepService,
+ SharedControllersService,
{provide: NgRedux, useClass: MockAppStore},
MockNgRedux ]
}).compileComponents();
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts
index 277ea941e..3a65b93ef 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts
@@ -8,7 +8,7 @@ import {DefaultDataGeneratorService} from "../../../shared/services/defaultDataS
import {DynamicInputsService} from "./dynamicInputs.service";
import {DialogService} from "ng2-bootstrap-modal";
import {VnfPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service";
-import {BasicControlGenerator} from "../../../shared/components/genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../shared/components/genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../shared/services/aaiService/aai.service";
import {NetworkPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service";
import {NetworkControlGenerator} from "../../../shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator";
@@ -41,6 +41,7 @@ import {ModelInformationItem} from "../../../shared/components/model-information
import {VpnStepService} from "./models/vrf/vrfModal/vpnStep/vpn.step.service";
import {NetworkStepService} from "./models/vrf/vrfModal/networkStep/network.step.service";
import {VfModuleUpgradePopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -82,11 +83,12 @@ describe('Shared Tree Service', () => {
imports: [HttpClientTestingModule, NgReduxTestingModule, SdcUiComponentsModule],
providers: [
SharedTreeService,
+ SharedControllersService,
ObjectToTreeService,
DefaultDataGeneratorService,
DialogService,
VnfPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
AaiService,
LogService,
BasicPopupService,
@@ -165,7 +167,7 @@ describe('Shared Tree Service', () => {
let modelInfoServiceMock: ILevelNodeInfo = new VnfModelInfo(null, null,
null, null, null, null, null,
- null, null, null, null,null);
+ null, null, null, null,null, null);
const modelMock = {"a": "a"};
const instanceMock = {"instance": "instance", "trackById": "123456789"};
const instanceTypeMock = "instanceTypeMock";
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.spec.ts
index 7e2d3f942..9aefa98b8 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.spec.ts
@@ -1,27 +1,28 @@
import {getTestBed, TestBed} from '@angular/core/testing';
import {AaiService} from "../../../services/aaiService/aai.service";
-import {FormControlModel} from "../../../models/formControlModels/formControl.model";
import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service";
-import {BasicControlGenerator} from "./basic.control.generator";
+import {ControlGeneratorUtil} from "./control.generator.util.service";
import {NgRedux} from '@angular-redux/store';
import each from "jest-each";
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {FileFormControl} from "../../../models/formControlModels/fileFormControl.model";
+import {AppState} from "../../../store/reducers";
+import {SelectOption} from "../../../models/selectOption";
+import {SharedControllersService} from "./sharedControlles/shared.controllers.service";
-class MockAppStore<T> {}
-
-class MockFeatureFlagsService {}
-
-describe('Basic Control Generator', () => {
+describe('Control Generator Util', () => {
let injector;
- let service: BasicControlGenerator;
+ let service: ControlGeneratorUtil;
+ let sharedControllersService : SharedControllersService;
let httpMock: HttpTestingController;
+ let store: NgRedux<AppState>;
beforeAll(done => (async () => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
- providers: [BasicControlGenerator,
+ providers: [ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
{provide:FeatureFlagsService, useClass: MockFeatureFlagsService},
{provide: NgRedux, useClass: MockAppStore}]
@@ -29,31 +30,14 @@ describe('Basic Control Generator', () => {
await TestBed.compileComponents();
injector = getTestBed();
- service = injector.get(BasicControlGenerator);
+ service = injector.get(ControlGeneratorUtil);
httpMock = injector.get(HttpTestingController);
+ sharedControllersService = injector.get(SharedControllersService);
+ store = injector.get(NgRedux);
})().then(done).catch(done.fail));
- test('getlegacyRegion with AAIAIC25 - isVisible true', () => {
- const instance = {lcpCloudRegionId : 'AAIAIC25'};
- const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
- expect(legacyRegionControl.isVisible).toBeTruthy();
- });
-
- test('getlegacyRegion without AAIAIC25 - isVisible false', () => {
- const instance = {lcpCloudRegionId : 'olson3'};
- const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
- expect(legacyRegionControl.isVisible).toBeFalsy();
- });
-
- test('sdn-preload checkbox is visible', () => {
- const instance = {};
- const sdncPreload: FormControlModel = service.getSDNCControl(instance);
- expect (sdncPreload.displayName).toEqual('SDN-C pre-load');
- expect (sdncPreload.value).toBeFalsy();
- });
-
test('given instance, get supp file from getSupplementaryFile ', () => {
const instance = {};
const suppFileForInstance: FileFormControl = service.getSupplementaryFile(instance);
@@ -66,7 +50,7 @@ describe('Basic Control Generator', () => {
//given
const instance = {};
- const controls = [service.getLegacyRegion(instance)];
+ const controls = [sharedControllersService.getLegacyRegion(instance)];
expect(controls).toHaveLength(1);
//when
@@ -105,4 +89,24 @@ describe('Basic Control Generator', () => {
});
+ test('getRollBackOnFailureOptions', async (done)=> {
+ service.getRollBackOnFailureOptions().subscribe((rollBackOnFailureOptions : SelectOption[])=>{
+ expect(rollBackOnFailureOptions[0].id).toEqual('true');
+ expect(rollBackOnFailureOptions[0].name).toEqual('Rollback');
+ expect(rollBackOnFailureOptions[1].id).toEqual('false');
+ expect(rollBackOnFailureOptions[1].name).toEqual('Don\'t Rollback');
+ done();
+ });
+ });
+
+
});
+
+
+class MockAppStore<T> {
+ getState() {
+ return {}
+ }
+}
+
+class MockFeatureFlagsService {}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.ts
index aff33982f..08575bcad 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.ts
@@ -1,7 +1,12 @@
import {Injectable} from "@angular/core";
import {DropdownFormControl} from "../../../models/formControlModels/dropdownFormControl.model";
import {FormGroup} from "@angular/forms";
-import {CustomValidatorOptions, FormControlModel, ValidatorModel, ValidatorOptions} from "../../../models/formControlModels/formControl.model";
+import {
+ CustomValidatorOptions,
+ FormControlModel,
+ ValidatorModel,
+ ValidatorOptions
+} from "../../../models/formControlModels/formControl.model";
import {InputFormControl} from "../../../models/formControlModels/inputFormControl.model";
import {AppState} from "../../../store/reducers";
import {NgRedux} from "@angular-redux/store";
@@ -9,28 +14,27 @@ import {NumberFormControl} from "../../../models/formControlModels/numberFormCon
import {FormControlType} from "../../../models/formControlModels/formControlTypes.enum";
import {FileFormControl} from "../../../models/formControlModels/fileFormControl.model";
import {SelectOption} from "../../../models/selectOption";
-import * as _ from 'lodash';
import {DynamicInputLabelPipe} from "../../../pipes/dynamicInputLabel/dynamic-input-label.pipe";
-import {AaiService} from "../../../services/aaiService/aai.service";
import {FormGeneralErrorsService} from "../../formGeneralErrors/formGeneralErrors.service";
import {Observable, of} from "rxjs";
import {NodeModel} from "../../../models/nodeModel";
import {Constants} from "../../../utils/constants";
import {FileUnit} from "../../formControls/component/file/fileUnit.enum";
-import {CheckboxFormControl} from "../../../models/formControlModels/checkboxFormControl.model";
+import * as _ from 'lodash';
export const SUPPLEMENTARY_FILE = 'supplementaryFile';
export const SDN_C_PRE_LOAD = 'sdncPreLoad';
@Injectable()
-export class BasicControlGenerator {
+export class ControlGeneratorUtil {
- public static readonly INSTANCE_NAME_REG_EX:RegExp = /^[a-zA-Z0-9._-]*$/;
- public static readonly GENERATED_NAME_REG_EX:RegExp = /[^a-zA-Z0-9._-]/g;
+ public static readonly INSTANCE_NAME_REG_EX: RegExp = /^[a-zA-Z0-9._-]*$/;
+ public static readonly GENERATED_NAME_REG_EX: RegExp = /[^a-zA-Z0-9._-]/g;
+
+ constructor(private _store: NgRedux<AppState>) {
+ }
- constructor(private _store : NgRedux<AppState>,
- private _aaiService : AaiService){}
- getSubscribeResult(subscribeFunction : Function, control : DropdownFormControl) : Observable<any>{
+ getSubscribeResult(subscribeFunction: Function, control: DropdownFormControl): Observable<any> {
return subscribeFunction(this).subscribe((res) => {
control.options$ = res;
control.hasEmptyOptions = res.length === 0;
@@ -39,16 +43,16 @@ export class BasicControlGenerator {
});
}
- getSubscribeInitResult(subscribeFunction : Function, control : DropdownFormControl, form : FormGroup) : Observable<any>{
+ getSubscribeInitResult(subscribeFunction: Function, control: DropdownFormControl, form: FormGroup): Observable<any> {
return subscribeFunction(this).subscribe((res) => {
- if(!_.isNil(control['onInitSelectedField'])){
+ if (!_.isNil(control['onInitSelectedField'])) {
let result = res;
- for(let key of control['onInitSelectedField']){
+ for (let key of control['onInitSelectedField']) {
result = !_.isNil(result[key]) ? result[key] : [];
}
control.options$ = result;
control.hasEmptyOptions = _.isNil(result) || result.length === 0;
- } else{
+ } else {
control.options$ = !_.isNil(res) ? res : [];
control.hasEmptyOptions = _.isNil(res) || res.length === 0;
}
@@ -58,58 +62,16 @@ export class BasicControlGenerator {
});
}
- getInstanceNameController(instance: any, serviceId: string, isEcompGeneratedNaming: boolean, model: NodeModel): FormControlModel {
- let validations: ValidatorModel[] = this.createValidationsForInstanceName(instance, serviceId, isEcompGeneratedNaming);
- return new InputFormControl({
- controlName: 'instanceName',
- displayName: 'Instance name',
- dataTestId: 'instanceName',
- placeHolder: (!isEcompGeneratedNaming) ? 'Instance name' : 'Automatically generated when not provided',
- validations: validations,
- isVisible : true,
- value : (!isEcompGeneratedNaming || (!_.isNil(instance) && !_.isNil(instance.instanceName)))
- ? this.getDefaultInstanceName(instance, model) : null,
- onKeypress : (event) => {
- const pattern:RegExp = BasicControlGenerator.INSTANCE_NAME_REG_EX;
- if(pattern){
- if(!pattern.test(event['key'])){
- event.preventDefault();
- }
- }
- return event;
- }
- });
- }
-
- getInstanceName(instance : any, serviceId : string, isEcompGeneratedNaming: boolean): FormControlModel {
- let formControlModel:FormControlModel = this.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, new NodeModel());
- formControlModel.value = instance ? instance.instanceName : null;
- return formControlModel;
- }
-
- isLegacyRegionShouldBeVisible(instance : any) : boolean {
- if(!_.isNil(instance) && !_.isNil(instance.lcpCloudRegionId)) {
+ isLegacyRegionShouldBeVisible(instance: any): boolean {
+ if (!_.isNil(instance) && !_.isNil(instance.lcpCloudRegionId)) {
return Constants.LegacyRegion.MEGA_REGION.indexOf(instance.lcpCloudRegionId) !== -1;
}
return false;
}
- getLegacyRegion(instance: any): FormControlModel {
- return new InputFormControl({
- controlName: 'legacyRegion',
- displayName: 'Legacy Region',
- dataTestId: 'lcpRegionText',
- placeHolder: 'Type Legacy Region',
- validations: [],
- isVisible: this.isLegacyRegionShouldBeVisible(instance),
- isDisabled : _.isNil(instance) ? true : Constants.LegacyRegion.MEGA_REGION.indexOf(instance.lcpCloudRegionId),
- value: instance ? instance.legacyRegion : null
- });
- }
-
- private createValidationsForInstanceName(instance: any, serviceId: string, isEcompGeneratedNaming: boolean): ValidatorModel[] {
+ createValidationsForInstanceName(instance: any, serviceId: string, isEcompGeneratedNaming: boolean): ValidatorModel[] {
let validations: ValidatorModel[] = [
- new ValidatorModel(ValidatorOptions.pattern, 'Instance name may include only alphanumeric characters and underscore.', BasicControlGenerator.INSTANCE_NAME_REG_EX),
+ new ValidatorModel(ValidatorOptions.pattern, 'Instance name may include only alphanumeric characters and underscore.', ControlGeneratorUtil.INSTANCE_NAME_REG_EX),
new ValidatorModel(CustomValidatorOptions.uniqueInstanceNameValidator, 'some error', [this._store, serviceId, instance && instance.instanceName])
];
if (!isEcompGeneratedNaming) {
@@ -118,7 +80,7 @@ export class BasicControlGenerator {
return validations;
}
- getInputsOptions = (options: any[]) : Observable<SelectOption[]> =>{
+ getInputsOptions = (options: any[]): Observable<SelectOption[]> => {
let optionList: SelectOption[] = [];
options.forEach((option) => {
optionList.push(new SelectOption({
@@ -129,26 +91,9 @@ export class BasicControlGenerator {
return of(optionList);
};
- getProductFamilyControl = (instance : any, controls : FormControlModel[], isMandatory?: boolean) : DropdownFormControl => {
- return new DropdownFormControl({
- type : FormControlType.DROPDOWN,
- controlName : 'productFamilyId',
- displayName : 'Product family',
- dataTestId : 'productFamily',
- placeHolder : 'Select Product Family',
- isDisabled : false,
- name : "product-family-select",
- value : instance ? instance.productFamilyId : null,
- validations : _.isNil(isMandatory) || isMandatory === true ? [new ValidatorModel(ValidatorOptions.required, 'is required')]: [],
- onInit : this.getSubscribeResult.bind(this, this._aaiService.getProductFamilies),
- })
- };
-
-
-
- getDynamicInputsByType(dynamicInputs : any, serviceModelId : string, storeKey : string, type: string ) : FormControlModel[] {
- let result : FormControlModel[] = [];
- if(dynamicInputs) {
+ getDynamicInputsByType(dynamicInputs: any, serviceModelId: string, storeKey: string, type: string): FormControlModel[] {
+ let result: FormControlModel[] = [];
+ if (dynamicInputs) {
let nodeInstance = null;
if (_.has(this._store.getState().service.serviceInstance[serviceModelId][type], storeKey)) {
nodeInstance = Object.assign({}, this._store.getState().service.serviceInstance[serviceModelId][type][storeKey]);
@@ -158,8 +103,7 @@ export class BasicControlGenerator {
return result;
}
-
- getServiceDynamicInputs(dynamicInputs : any, serviceModelId : string) : FormControlModel[] {
+ getServiceDynamicInputs(dynamicInputs: any, serviceModelId: string): FormControlModel[] {
let result: FormControlModel[] = [];
if (dynamicInputs) {
let serviceInstance = null;
@@ -171,23 +115,23 @@ export class BasicControlGenerator {
return result;
}
- getDynamicInputs(dynamicInputs : any, instance :any) : FormControlModel[]{
- let result : FormControlModel[] = [];
- if(dynamicInputs) {
- dynamicInputs.forEach((input)=> {
+ getDynamicInputs(dynamicInputs: any, instance: any): FormControlModel[] {
+ let result: FormControlModel[] = [];
+ if (dynamicInputs) {
+ dynamicInputs.forEach((input) => {
let validations: ValidatorModel[] = [];
- if(input.isRequired) {
+ if (input.isRequired) {
validations.push(new ValidatorModel(ValidatorOptions.required, 'is required'))
}
- if(input.minLength) {
+ if (input.minLength) {
validations.push(new ValidatorModel(ValidatorOptions.minLength, '', input.minLength))
}
- if(input.maxLength) {
+ if (input.maxLength) {
validations.push(new ValidatorModel(ValidatorOptions.maxLength, '', input.maxLength))
}
let dynamicInputLabelPipe: DynamicInputLabelPipe = new DynamicInputLabelPipe();
- let data:any = {
+ let data: any = {
controlName: input.name,
displayName: dynamicInputLabelPipe.transform(input.name).slice(0, -1),
dataTestId: input.id,
@@ -200,9 +144,9 @@ export class BasicControlGenerator {
switch (input.type) {
case 'select' :
- case 'boolean' :{
- data.value = data.value || input.optionList.filter((option) => option.isDefault ? option.id || option.name: null);
- data.onInit = this.getSubscribeInitResult.bind(null, this.getInputsOptions.bind(this, input.optionList));
+ case 'boolean' : {
+ data.value = data.value || input.optionList.filter((option) => option.isDefault ? option.id || option.name : null);
+ data.onInit = this.getSubscribeInitResult.bind(null, this.getInputsOptions.bind(this, input.optionList));
result.push(new DropdownFormControl(data));
break;
}
@@ -231,8 +175,8 @@ export class BasicControlGenerator {
return result;
}
- getDefaultInstanceName(instance: any, model: NodeModel) : string {
- const initialInstanceName = (!_.isNil(instance) && instance.instanceName) || (!_.isNil(model.name) ? model.name.replace(BasicControlGenerator.GENERATED_NAME_REG_EX, "") : model.name);
+ getDefaultInstanceName(instance: any, model: NodeModel): string {
+ const initialInstanceName = (!_.isNil(instance) && instance.instanceName) || (!_.isNil(model.name) ? model.name.replace(ControlGeneratorUtil.GENERATED_NAME_REG_EX, "") : model.name);
return initialInstanceName;
}
@@ -241,26 +185,16 @@ export class BasicControlGenerator {
return originalArray.concat([suppFileInput], suppFileInput.hiddenFile);
}
- getSDNCControl = (instance: any): FormControlModel => {
- return new CheckboxFormControl({
- controlName: SDN_C_PRE_LOAD,
- displayName: 'SDN-C pre-load',
- dataTestId: 'sdncPreLoad',
- value: instance ? instance.sdncPreLoad : false,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')]
- })
- };
-
getSupplementaryFile(instance: any): FileFormControl {
return new FileFormControl({
controlName: SUPPLEMENTARY_FILE,
displayName: 'Supplementary Data File (JSON format)',
dataTestId: 'SupplementaryFile',
placeHolder: 'Choose file',
- selectedFile: !_.isNil(instance) ? instance.supplementaryFileName: null,
+ selectedFile: !_.isNil(instance) ? instance.supplementaryFileName : null,
isVisible: true,
acceptedExtentions: "application/json",
- hiddenFile : [new InputFormControl({
+ hiddenFile: [new InputFormControl({
controlName: SUPPLEMENTARY_FILE + "_hidden",
isVisible: false,
validations: [new ValidatorModel(CustomValidatorOptions.isFileTooBig, "File size exceeds 5MB.", [FileUnit.MB, 5])]
@@ -269,18 +203,18 @@ export class BasicControlGenerator {
controlName: SUPPLEMENTARY_FILE + "_hidden_content",
isVisible: false,
validations: [new ValidatorModel(CustomValidatorOptions.isValidJson,
- "File is invalid, please make sure a legal JSON file is uploaded using name:value pairs.",[]),
+ "File is invalid, please make sure a legal JSON file is uploaded using name:value pairs.", []),
new ValidatorModel(CustomValidatorOptions.isStringContainTags,
- "File is invalid, please remove tags <>.",[])],
- value: !_.isNil(instance) ? (instance.supplementaryFile_hidden_content): null,
+ "File is invalid, please remove tags <>.", [])],
+ value: !_.isNil(instance) ? (instance.supplementaryFile_hidden_content) : null,
})
],
- onDelete : this.getOnDeleteForSupplementaryFile(),
- onChange : this.getOnChangeForSupplementaryFile()
+ onDelete: this.getOnDeleteForSupplementaryFile(),
+ onChange: this.getOnChangeForSupplementaryFile()
})
};
- retrieveInstanceIfUpdateMode(store: NgRedux<AppState>, instance: any): any{
+ retrieveInstanceIfUpdateMode(store: NgRedux<AppState>, instance: any): any {
return store.getState().global.isUpdateModalMode ? instance : null;
}
@@ -307,4 +241,12 @@ export class BasicControlGenerator {
}
};
}
+
+ getRollBackOnFailureOptions = (): Observable<SelectOption[]> => {
+ return of([
+ new SelectOption({id: 'true', name: 'Rollback'}),
+ new SelectOption({id: 'false', name: 'Don\'t Rollback'})
+ ]);
+ };
+
}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts
index 0bb278a8e..b5277b48d 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts
@@ -1,7 +1,7 @@
import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {GenericFormService} from "../../generic-form.service";
import {FormBuilder} from "@angular/forms";
@@ -9,6 +9,7 @@ import {LogService} from "../../../../utils/log/log.service";
import {FormControlNames, NetworkControlGenerator} from "./network.control.generator";
import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState(){
@@ -1812,7 +1813,8 @@ describe('Network Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [NetworkControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
FormBuilder,
LogService,
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts
index 19c85a1ff..a7f16db4b 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts
@@ -3,53 +3,33 @@ import {GenericFormService} from "../../generic-form.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {NgRedux} from "@angular-redux/store";
import {HttpClient} from "@angular/common/http";
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import * as _ from 'lodash';
-import {Observable, of} from "rxjs";
-import {
- FormControlModel,
- ValidatorModel,
- ValidatorOptions
-} from "../../../../models/formControlModels/formControl.model";
+import {FormControlModel,} from "../../../../models/formControlModels/formControl.model";
import {LogService} from "../../../../utils/log/log.service";
import {AppState} from "../../../../store/reducers";
-import {FormGroup} from "@angular/forms";
import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
-import {SelectOption} from "../../../../models/selectOption";
import {NetworkInstance} from "../../../../models/networkInstance";
import {NetworkModel} from "../../../../models/networkModel";
-import {Constants} from "../../../../utils/constants";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
export enum FormControlNames {
INSTANCE_NAME = 'instanceName',
- GLOBAL_SUBSCRIBER_ID = 'globalSubscriberId',
PRODUCT_FAMILY_ID = 'productFamilyId',
LCPCLOUD_REGION_ID = 'lcpCloudRegionId',
- TENANT_ID = 'tenantId',
- AICZONE_ID = 'aicZoneId',
- ROLLBACK_ON_FAILURE = 'rollbackOnFailure',
- LEGACY_REGION = 'legacyRegion'
+ ROLLBACK_ON_FAILURE = 'rollbackOnFailure'
}
-enum InputType {
- LCP_REGION = "lcpCloudRegionId",
- TENANT = "tenantId",
- LOB = "lineOfBusiness",
- PLATFORM = "platformName",
- ROLLBACK = "rollbackOnFailure",
- PRODUCT_FAMILY = "productFamilyId",
- VG = "volumeGroupName"
-}
-
@Injectable()
export class NetworkControlGenerator {
aaiService: AaiService;
constructor(private genericFormService: GenericFormService,
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
+ private _sharedControllersService: SharedControllersService,
private store: NgRedux<AppState>,
private http: HttpClient,
private _aaiService: AaiService,
@@ -57,8 +37,8 @@ export class NetworkControlGenerator {
this.aaiService = _aaiService;
}
- getNetworkInstance = (serviceId: string, networkName: string, isUpdateMode : boolean): NetworkInstance => {
- let networkInstance : NetworkInstance = null;
+ getNetworkInstance = (serviceId: string, networkName: string, isUpdateMode: boolean): NetworkInstance => {
+ let networkInstance: NetworkInstance = null;
if (isUpdateMode && this.store.getState().service.serviceInstance[serviceId] && _.has(this.store.getState().service.serviceInstance[serviceId].networks, networkName)) {
networkInstance = Object.assign({}, this.store.getState().service.serviceInstance[serviceId].networks[networkName]);
}
@@ -66,7 +46,7 @@ export class NetworkControlGenerator {
};
- getMacroFormControls(serviceId: string, networkStoreKey: string, networkName: string, isUpdateMode : boolean): FormControlModel[] {
+ getMacroFormControls(serviceId: string, networkStoreKey: string, networkName: string, isUpdateMode: boolean): FormControlModel[] {
networkStoreKey = _.isNil(networkStoreKey) ? networkName : networkStoreKey;
if (_.isNil(serviceId) || _.isNil(networkStoreKey) || _.isNil(networkName)) {
@@ -79,18 +59,18 @@ export class NetworkControlGenerator {
if (!_.isNil(networkModel)) {
result.push(this.getInstanceName(networkInstance, serviceId, networkName, networkModel.isEcompGeneratedNaming));
- result.push(this._basicControlGenerator.getProductFamilyControl(networkInstance, result, false));
- result.push(this.getLcpRegionControl(serviceId, networkInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(networkInstance));
- result.push(this.getTenantControl(serviceId, networkInstance, result));
- result.push(this.getPlatformControl(networkInstance, result));
- result.push(this.getLineOfBusinessControl(networkInstance, result));
+ result.push(this._sharedControllersService.getProductFamilyControl(networkInstance, result, false));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, networkInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(networkInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, networkInstance));
+ result.push(this.getPlatformControl(networkInstance));
+ result.push(this._sharedControllersService.getLineOfBusinessControl(networkInstance));
}
return result;
}
- getAlaCarteFormControls(serviceId: string, networkStoreKey: string, networkName: string, isUpdateMode : boolean): FormControlModel[] {
+ getAlaCarteFormControls(serviceId: string, networkStoreKey: string, networkName: string, isUpdateMode: boolean): FormControlModel[] {
networkStoreKey = _.isNil(networkStoreKey) ? networkName : networkStoreKey;
if (_.isNil(serviceId) || _.isNil(networkStoreKey) || _.isNil(networkName)) {
this._logService.error('should provide serviceId, networkName, networkStoreKey', serviceId);
@@ -103,45 +83,24 @@ export class NetworkControlGenerator {
if (!_.isNil(networkModel)) {
result.push(this.getInstanceName(networkInstance, serviceId, networkName, networkModel.isEcompGeneratedNaming));
- result.push(this._basicControlGenerator.getProductFamilyControl(networkInstance, result, false));
- result.push(this.getLcpRegionControl(serviceId, networkInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(networkInstance));
- result.push(this.getTenantControl(serviceId, networkInstance, result));
- result.push(this.getPlatformControl(networkInstance, result));
- result.push(this.getLineOfBusinessControl(networkInstance, result));
- result.push(this.getRollbackOnFailureControl(networkInstance, result));
+ result.push(this._sharedControllersService.getProductFamilyControl(networkInstance, result, false));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, networkInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(networkInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, networkInstance));
+ result.push(this.getPlatformControl(networkInstance));
+ result.push(this._sharedControllersService.getLineOfBusinessControl(networkInstance));
+ result.push(this._sharedControllersService.getRollbackOnFailureControl(networkInstance));
}
return result;
-
}
- isInputShouldBeShown = (inputType: any): boolean => {
- let networkInputs = [InputType.LCP_REGION, InputType.LOB, InputType.TENANT, InputType.PRODUCT_FAMILY, InputType.PLATFORM, InputType.ROLLBACK];
- return networkInputs.indexOf(inputType) > -1;
- };
- getInstanceName(instance : any, serviceId : string, networkName : string, isEcompGeneratedNaming: boolean): FormControlModel {
- const networkModel : NetworkModel = this.store.getState().service.serviceHierarchy[serviceId].networks[networkName];
- return this._basicControlGenerator.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, networkModel);
+ getInstanceName(instance: any, serviceId: string, networkName: string, isEcompGeneratedNaming: boolean): FormControlModel {
+ const networkModel: NetworkModel = this.store.getState().service.serviceHierarchy[serviceId].networks[networkName];
+ return this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, networkModel);
}
- getLineOfBusinessControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lineOfBusiness',
- displayName: 'Line of business',
- dataTestId: 'lineOfBusiness',
- placeHolder: 'Select Line Of Business',
- isDisabled: false,
- name: "lineOfBusiness",
- value: instance ? instance.lineOfBusiness : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lineOfBusinessList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
- })
- };
-
- getPlatformControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
+ getPlatformControl = (instance: any): DropdownFormControl => {
return new DropdownFormControl({
type: FormControlType.DROPDOWN,
controlName: 'platformName',
@@ -156,90 +115,4 @@ export class NetworkControlGenerator {
onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
})
};
-
- getTenantControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.TENANT_ID,
- displayName: 'Tenant',
- dataTestId: 'tenant',
- placeHolder: 'Select Tenant',
- name: "tenant",
- isDisabled: _.isNil(instance) || _.isNil(instance.lcpCloudRegionId),
- onInitSelectedField: instance ? ['lcpRegionsTenantsMap', instance.lcpCloudRegionId] : null,
- value: instance ? instance.tenantId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInit : instance ? this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this.aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) : ()=>{},
- })
- };
-
- getLcpRegionControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lcpCloudRegionId',
- displayName: 'LCP region',
- dataTestId: 'lcpRegion',
- placeHolder: 'Select LCP Region',
- name: "lcpRegion",
- isDisabled: false,
- value: instance ? instance.lcpCloudRegionId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lcpRegionList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)),
- onChange: (param: string, form: FormGroup) => {
- form.controls[FormControlNames.TENANT_ID].enable();
- form.controls[FormControlNames.TENANT_ID].reset();
- if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) {
- this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType).subscribe(res => {
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['options$'] = res.lcpRegionsTenantsMap[param];
- if(res.lcpRegionsTenantsMap[param]){
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['hasEmptyOptions'] = res.lcpRegionsTenantsMap[param].length === 0;
- }
- }));
- }
-
- if (Constants.LegacyRegion.MEGA_REGION.indexOf(param) !== -1) {
- form.controls['legacyRegion'].enable();
- controls.find(item => item.controlName === 'legacyRegion').isVisible = true;
-
- } else {
- controls.find(item => item.controlName === 'legacyRegion').isVisible = false;
- form.controls['legacyRegion'].setValue(null);
- form.controls['legacyRegion'].reset();
- form.controls['legacyRegion'].disable();
- }
- }
- })
- };
-
- getRollbackOnFailureControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.ROLLBACK_ON_FAILURE,
- displayName: 'Rollback on failure',
- dataTestId: 'rollback',
- placeHolder: 'Rollback on failure',
- isDisabled: false,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- value: instance ? instance.rollbackOnFailure : 'true',
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this.getRollBackOnFailureOptions)
- })
- };
-
- getRollBackOnFailureOptions = (): Observable<SelectOption[]> => {
- return of([
- new SelectOption({id: 'true', name: 'Rollback'}),
- new SelectOption({id: 'false', name: 'Don\'t Rollback'})
- ]);
- };
}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts
index 6bcec09c4..88a8a53d6 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts
@@ -2,7 +2,7 @@ import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
import {FormControlNames, ServiceControlGenerator} from "./service.control.generator";
-import {BasicControlGenerator} from "./basic.control.generator";
+import {ControlGeneratorUtil} from "./control.generator.util.service";
import {AaiService} from "../../../services/aaiService/aai.service";
import {GenericFormService} from "../generic-form.service";
import {FormBuilder} from "@angular/forms";
@@ -13,6 +13,7 @@ import {DropdownFormControl} from "../../../models/formControlModels/dropdownFor
import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service";
import each from 'jest-each';
import {VidNotions} from "../../../models/vidNotions";
+import {SharedControllersService} from "./sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -912,7 +913,8 @@ describe('Service Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [ServiceControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
FormBuilder,
LogService,
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts
index 12054a8a7..da13b0be4 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts
@@ -5,7 +5,7 @@ import {AppState} from "../../../store/reducers";
import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../models/formControlModels/formControl.model";
import {DropdownFormControl} from "../../../models/formControlModels/dropdownFormControl.model";
import * as _ from 'lodash';
-import {BasicControlGenerator} from "./basic.control.generator";
+import {ControlGeneratorUtil} from "./control.generator.util.service";
import {AaiService} from "../../../services/aaiService/aai.service";
import {FormGroup} from "@angular/forms";
import {FormControlType} from "../../../models/formControlModels/formControlTypes.enum";
@@ -17,6 +17,7 @@ import {ServiceModel} from "../../../models/serviceModel";
import {CheckboxFormControl} from "../../../models/formControlModels/checkboxFormControl.model";
import {VidNotions} from "../../../models/vidNotions";
+import {SharedControllersService} from "./sharedControlles/shared.controllers.service";
export enum FormControlNames {
INSTANCE_NAME = 'instanceName',
@@ -36,7 +37,8 @@ export enum FormControlNames {
export class ServiceControlGenerator {
aaiService : AaiService;
constructor(private genericFormService : GenericFormService,
- private _basicControlGenerator : BasicControlGenerator,
+ private _basicControlGenerator : ControlGeneratorUtil,
+ private _sharedControllersService : SharedControllersService,
private store: NgRedux<AppState>,
private http: HttpClient,
private _aaiService : AaiService,
@@ -64,7 +66,7 @@ export class ServiceControlGenerator {
const serviceModel = new ServiceModel(this.store.getState().service.serviceHierarchy[serviceId]);
if(!_.isNil(serviceModel)){
- result.push(this._basicControlGenerator.getInstanceName(serviceInstance, serviceId, serviceModel.isEcompGeneratedNaming));
+ result.push(this._sharedControllersService.getInstanceName(serviceInstance, serviceId, serviceModel.isEcompGeneratedNaming));
result.push(this.getGlobalSubscriberControl(serviceInstance, result));
result.push(this.getServiceTypeControl(serviceInstance, result, false));
result.push(this.getOwningEntityControl(serviceInstance, result));
@@ -87,7 +89,7 @@ export class ServiceControlGenerator {
let result : FormControlModel[] = [];
const serviceModel = new ServiceModel(this.store.getState().service.serviceHierarchy[serviceId]);
if(!_.isNil(serviceModel)){
- result.push(this._basicControlGenerator.getInstanceName(serviceInstance, serviceId, serviceModel.isEcompGeneratedNaming));
+ result.push(this._sharedControllersService.getInstanceName(serviceInstance, serviceId, serviceModel.isEcompGeneratedNaming));
result.push(this.getGlobalSubscriberControl(serviceInstance, result));
result.push(this.getServiceTypeControl(serviceInstance, result, true));
result.push(this.getOwningEntityControl(serviceInstance, result));
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts
new file mode 100644
index 000000000..58ee33b53
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts
@@ -0,0 +1,263 @@
+import * as _ from "lodash";
+import {getTestBed, TestBed} from '@angular/core/testing';
+import {SharedControllersService} from "./shared.controllers.service";
+import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing";
+import {AppState} from "../../../../store/reducers";
+import {NgRedux} from "@angular-redux/store";
+import {AaiService} from "../../../../services/aaiService/aai.service";
+import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
+import {FormControlModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
+
+
+
+describe('Shared Controllers Service', () => {
+ let injector;
+ let service: SharedControllersService;
+ let httpMock: HttpTestingController;
+ let store: NgRedux<AppState>;
+ let basicControlGenerator : ControlGeneratorUtil;
+
+ beforeAll(done => (async () => {
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [SharedControllersService,
+ AaiService,
+ ControlGeneratorUtil,
+ {provide:FeatureFlagsService, useClass: MockFeatureFlagsService},
+ {provide: NgRedux, useClass: MockAppStore}]
+ });
+ await TestBed.compileComponents();
+
+ injector = getTestBed();
+ service = injector.get(SharedControllersService);
+ basicControlGenerator = injector.get(ControlGeneratorUtil);
+ httpMock = injector.get(HttpTestingController);
+ store = injector.get(NgRedux);
+
+ })().then(done).catch(done.fail));
+
+
+
+
+
+ test('getLineOfBusinessControl', ()=> {
+ const lineOfBusinessControl :DropdownFormControl = service.getLineOfBusinessControl();
+ expect(lineOfBusinessControl.name).toEqual('lineOfBusiness');
+ expect(lineOfBusinessControl.controlName).toEqual('lineOfBusiness');
+ expect(lineOfBusinessControl.displayName).toEqual('Line of business');
+ expect(lineOfBusinessControl.dataTestId).toEqual('lineOfBusiness');
+ expect(lineOfBusinessControl.placeHolder).toEqual('Select Line Of Business');
+ expect(lineOfBusinessControl.onInitSelectedField).toEqual(['lineOfBusinessList']);
+ expect(lineOfBusinessControl.onInit).toBeDefined();
+ expect(lineOfBusinessControl.value).toBeNull();
+ expect(lineOfBusinessControl.validations.find((validation)=> validation.validatorName === ValidatorOptions.required)).toBeDefined();
+ expect(lineOfBusinessControl.isDisabled).toBeFalsy();
+ });
+
+ test('getTenantControl', ()=> {
+ const serviceId : string = Object.keys(store.getState().service.serviceInstance)[0];
+ const vnfs = store.getState().service.serviceInstance[serviceId].vnfs;
+ const currentVnf = vnfs[Object.keys(vnfs)[0]];
+
+ const tanantControl :DropdownFormControl = service.getTenantControl(serviceId, currentVnf);
+ expect(tanantControl.name).toEqual('tenant');
+ expect(tanantControl.controlName).toEqual('tenantId');
+ expect(tanantControl.displayName).toEqual('Tenant');
+ expect(tanantControl.dataTestId).toEqual('tenant');
+ expect(tanantControl.placeHolder).toEqual('Select Tenant');
+ expect(tanantControl.onInitSelectedField).toEqual(['lcpRegionsTenantsMap', currentVnf.lcpCloudRegionId]);
+ expect(tanantControl.onInit).toBeDefined();
+ expect(tanantControl.validations.find((validation)=> validation.validatorName === ValidatorOptions.required)).toBeDefined();
+ expect(tanantControl.isDisabled).toEqual(_.isNil(currentVnf.lcpCloudRegionId));
+ });
+
+
+ test('getRollbackOnFailureControl', ()=> {
+ const rollbackOnFailureControl :DropdownFormControl = service.getRollbackOnFailureControl();
+ expect(rollbackOnFailureControl.controlName).toEqual('rollbackOnFailure');
+ expect(rollbackOnFailureControl.displayName).toEqual('Rollback on failure');
+ expect(rollbackOnFailureControl.dataTestId).toEqual('rollback');
+ expect(rollbackOnFailureControl.placeHolder).toEqual('Rollback on failure');
+ expect(rollbackOnFailureControl.onInit).toBeDefined();
+ expect(rollbackOnFailureControl.validations.find((validation)=> validation.validatorName === ValidatorOptions.required)).toBeDefined();
+ expect(rollbackOnFailureControl.isDisabled).toBeFalsy();
+ });
+
+ test('getLcpRegionControl', ()=> {
+ const serviceId : string = Object.keys(store.getState().service.serviceInstance)[0];
+ const vnfs = store.getState().service.serviceInstance[serviceId].vnfs;
+ const currentVnf = vnfs[Object.keys(vnfs)[0]];
+ const lcpRegionControl :DropdownFormControl = service.getLcpRegionControl(serviceId, currentVnf, []);
+ expect(lcpRegionControl.controlName).toEqual('lcpCloudRegionId');
+ expect(lcpRegionControl.displayName).toEqual('LCP region');
+ expect(lcpRegionControl.dataTestId).toEqual('lcpRegion');
+ expect(lcpRegionControl.placeHolder).toEqual('Select LCP Region');
+ expect(lcpRegionControl.onInit).toBeDefined();
+ expect(lcpRegionControl.onChange).toBeDefined();
+ expect(lcpRegionControl.validations.find((validation)=> validation.validatorName === ValidatorOptions.required)).toBeDefined();
+ expect(lcpRegionControl.isDisabled).toBeFalsy();
+ });
+
+ test('sdn-preload checkbox is visible', () => {
+ const instance = {};
+ const sdncPreload: FormControlModel = service.getSDNCControl(instance);
+ expect (sdncPreload.displayName).toEqual('SDN-C pre-load');
+ expect (sdncPreload.value).toBeFalsy();
+ });
+
+ test('getlegacyRegion with AAIAIC25 - isVisible true', () => {
+ const instance = {lcpCloudRegionId : 'AAIAIC25'};
+ const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
+ expect(legacyRegionControl.isVisible).toBeTruthy();
+ });
+
+ test('getlegacyRegion without AAIAIC25 - isVisible false', () => {
+ const instance = {lcpCloudRegionId : 'olson3'};
+ const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
+ expect(legacyRegionControl.isVisible).toBeFalsy();
+ });
+});
+
+class MockAppStore<T> {
+ getState() {
+ return {
+ "global": {
+ "flags": {
+ "FLAG_NETWORK_TO_ASYNC_INSTANTIATION": false,
+ "FLAG_SHOW_ASSIGNMENTS": true,
+ "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true,
+ "FLAG_SHOW_VERIFY_SERVICE": false,
+ "FLAG_SERVICE_MODEL_CACHE": true,
+ "FLAG_ADD_MSO_TESTAPI_FIELD": true
+ }
+ },
+ "service": {
+ "serviceHierarchy": {
+ "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc": {
+ "service": {
+ "uuid": "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc",
+ "invariantUuid": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+ "name": "ComplexService",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Emanuel",
+ "serviceType": "",
+ "serviceRole": "",
+ "description": "ComplexService",
+ "serviceEcompNaming": "false",
+ "instantiationType": "Macro",
+ "inputs": {}
+ },
+ "vnfs": {
+ "VF_vGeraldine 0": {
+ "uuid": "d6557200-ecf2-4641-8094-5393ae3aae60",
+ "invariantUuid": "4160458e-f648-4b30-a176-43881ffffe9e",
+ "description": "VSP_vGeraldine",
+ "name": "VF_vGeraldine",
+ "version": "2.0",
+ "customizationUuid": "91415b44-753d-494c-926a-456a9172bbb9",
+ "inputs": {},
+ "commands": {},
+ "properties": {
+ "max_instances": 10,
+ "min_instances": 1,
+
+ },
+ "type": "VF",
+ "modelCustomizationName": "VF_vGeraldine 0",
+ "vfModules": {
+ "vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1": {
+ "uuid": "522159d5-d6e0-4c2a-aa44-5a542a12a830",
+ "invariantUuid": "98a7c88b-b577-476a-90e4-e25a5871e02b",
+ "customizationUuid": "55b1be94-671a-403e-a26c-667e9c47d091",
+ "description": null,
+ "name": "VfVgeraldine..vflorence_vlc..module-1",
+ "version": "2",
+ "modelCustomizationName": "VfVgeraldine..vflorence_vlc..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "vflorence_vlc"
+ },
+ "inputs": {},
+ "volumeGroupAllowed": true
+ }
+ }
+ }
+ }
+ }
+ },
+ "serviceInstance": {
+ "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc": {
+ "vnfs": {
+ "2017-388_PASQUALE-vPE 0": {
+ "action": "Create",
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "2017-388_PASQUALE-vPE 0",
+ "isMissingData": false,
+ "trackById": "eymgwlevh54",
+ "vfModules": {},
+ "vnfStoreKey": "2017-388_PASQUALE-vPE 0",
+ "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "lineOfBusiness": "ONAP",
+ "platformName": "platform",
+ "modelInfo": {
+ "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
+ "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168",
+ "modelName": "2017-388_PASQUALE-vPE",
+ "modelVersion": "4.0",
+ "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c",
+ "modelCustomizationName": "2017-388_PASQUALE-vPE 0",
+ "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
+ "modelUniqueId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c"
+ },
+ "instanceName": "2017-388_PASQUALE-vPEAjXzainstanceName",
+ "legacyRegion": "some legacy region",
+ "instanceParams": [
+ {
+ "vnf_config_template_version": "17.2",
+ "bandwidth_units": "Gbps",
+ "bandwidth": "10",
+ "AIC_CLLI": "ATLMY8GA",
+ "ASN": "AV_vPE",
+ "vnf_instance_name": "mtnj309me6"
+ }
+ ]
+ }
+ },
+ "service": {
+ "vidNotions": {
+ "instantiationUI": "serviceWithVRF",
+ "modelCategory": "other",
+ "viewEditUI": "serviceWithVRF",
+ "instantiationType": "ALaCarte"
+ },
+ "uuid": "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc",
+ "invariantUuid": "7ee41ce4-4827-44b0-a48e-2707a59905d2",
+ "name": "VRF Service for Test",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Network L4+",
+ "serviceType": "INFRASTRUCTURE",
+ "serviceRole": "Configuration",
+ "description": "xxx",
+ "serviceEcompNaming": "true",
+ "instantiationType": "A-La-Carte",
+ "inputs": {}
+ },
+ "isALaCarte": true
+ }
+ }
+ }
+ }
+ }
+}
+
+class MockFeatureFlagsService {}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts
new file mode 100644
index 000000000..e82ea5d85
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts
@@ -0,0 +1,189 @@
+import {Injectable} from "@angular/core";
+import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
+import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
+import {
+ FormControlModel,
+ ValidatorModel,
+ ValidatorOptions
+} from "../../../../models/formControlModels/formControl.model";
+import {NgRedux} from "@angular-redux/store";
+import {AppState} from "../../../../store/reducers";
+import {AaiService} from "../../../../services/aaiService/aai.service";
+import {ControlGeneratorUtil, SDN_C_PRE_LOAD} from "../control.generator.util.service";
+import * as _ from "lodash";
+import {FormGroup} from "@angular/forms";
+import {Constants} from "../../../../utils/constants";
+import {CheckboxFormControl} from "../../../../models/formControlModels/checkboxFormControl.model";
+import {InputFormControl} from "../../../../models/formControlModels/inputFormControl.model";
+import {NodeModel} from "../../../../models/nodeModel";
+
+@Injectable()
+export class SharedControllersService {
+ constructor(private _store : NgRedux<AppState>,
+ private _aaiService : AaiService,
+ private _basicControlGenerator : ControlGeneratorUtil){}
+
+
+ getLineOfBusinessControl = (instance?: any): DropdownFormControl => {
+ return new DropdownFormControl({
+ type: FormControlType.DROPDOWN,
+ controlName: 'lineOfBusiness',
+ displayName: 'Line of business',
+ dataTestId: 'lineOfBusiness',
+ placeHolder: 'Select Line Of Business',
+ isDisabled: false,
+ name: "lineOfBusiness",
+ value: instance ? instance.lineOfBusiness : null,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
+ onInitSelectedField: ['lineOfBusinessList'],
+ onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
+ })
+ };
+
+ getTenantControl = (serviceId: string, instance?: any): DropdownFormControl => {
+ const service = this._store.getState().service.serviceInstance[serviceId];
+ const globalCustomerId: string = service.globalSubscriberId;
+ const serviceType: string = service.subscriptionServiceType;
+ return new DropdownFormControl({
+ type: FormControlType.DROPDOWN,
+ controlName: 'tenantId',
+ displayName: 'Tenant',
+ dataTestId: 'tenant',
+ placeHolder: 'Select Tenant',
+ name: 'tenant',
+ isDisabled: _.isNil(instance) || _.isNil(instance.lcpCloudRegionId),
+ onInitSelectedField: instance ? ['lcpRegionsTenantsMap', instance.lcpCloudRegionId] : null,
+ value: instance ? instance.tenantId : null,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
+ onInit: instance ? this._basicControlGenerator.getSubscribeInitResult.bind(
+ this._aaiService,
+ this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) : () => {
+ }
+ })
+ };
+
+ getRollbackOnFailureControl = (instance?: any): DropdownFormControl => {
+ return new DropdownFormControl({
+ type: FormControlType.DROPDOWN,
+ controlName: 'rollbackOnFailure',
+ displayName: 'Rollback on failure',
+ dataTestId: 'rollback',
+ placeHolder: 'Rollback on failure',
+ isDisabled: false,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
+ value: instance ? instance.rollbackOnFailure : 'true',
+ onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._basicControlGenerator.getRollBackOnFailureOptions)
+ })
+ };
+
+ getLegacyRegion(instance: any): FormControlModel {
+ return new InputFormControl({
+ controlName: 'legacyRegion',
+ displayName: 'Legacy Region',
+ dataTestId: 'lcpRegionText',
+ placeHolder: 'Type Legacy Region',
+ validations: [],
+ isVisible: this._basicControlGenerator.isLegacyRegionShouldBeVisible(instance),
+ isDisabled : _.isNil(instance) ? true : Constants.LegacyRegion.MEGA_REGION.indexOf(instance.lcpCloudRegionId),
+ value: instance ? instance.legacyRegion : null
+ });
+ }
+
+ getLcpRegionControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
+ const service = this._store.getState().service.serviceInstance[serviceId];
+ const globalCustomerId: string = service.globalSubscriberId;
+ const serviceType: string = service.subscriptionServiceType;
+ return new DropdownFormControl({
+ type: FormControlType.DROPDOWN,
+ controlName: 'lcpCloudRegionId',
+ displayName: 'LCP region',
+ dataTestId: 'lcpRegion',
+ placeHolder: 'Select LCP Region',
+ name: "lcpRegion",
+ isDisabled: false,
+ value: instance ? instance.lcpCloudRegionId : null,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
+ onInitSelectedField: ['lcpRegionList'],
+ onInit: this._basicControlGenerator.getSubscribeInitResult.bind(
+ this._aaiService,
+ this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)),
+ onChange: (param: string, form: FormGroup) => {
+ form.controls['tenantId'].enable();
+ form.controls['tenantId'].reset();
+ if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) {
+ this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType).subscribe(res => {
+ controls.find(item => item.controlName === 'tenantId')['options$'] = res.lcpRegionsTenantsMap[param];
+ if (res.lcpRegionsTenantsMap[param]) {
+ controls.find(item => item.controlName === 'tenantId')['hasEmptyOptions'] = res.lcpRegionsTenantsMap[param].length === 0;
+ }
+ }));
+ }
+
+ if (Constants.LegacyRegion.MEGA_REGION.indexOf(param) !== -1) {
+ form.controls['legacyRegion'].enable();
+ controls.find(item => item.controlName === 'legacyRegion').isVisible = true;
+
+ } else {
+ controls.find(item => item.controlName === 'legacyRegion').isVisible = false;
+ form.controls['legacyRegion'].setValue(null);
+ form.controls['legacyRegion'].reset();
+ form.controls['legacyRegion'].disable();
+ }
+ }
+ })
+ };
+
+ getSDNCControl = (instance: any): FormControlModel => {
+ return new CheckboxFormControl({
+ controlName: SDN_C_PRE_LOAD,
+ displayName: 'SDN-C pre-load',
+ dataTestId: 'sdncPreLoad',
+ value: instance ? instance.sdncPreLoad : false,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')]
+ })
+ };
+
+ getProductFamilyControl = (instance : any, controls : FormControlModel[], isMandatory?: boolean) : DropdownFormControl => {
+ return new DropdownFormControl({
+ type : FormControlType.DROPDOWN,
+ controlName : 'productFamilyId',
+ displayName : 'Product family',
+ dataTestId : 'productFamily',
+ placeHolder : 'Select Product Family',
+ isDisabled : false,
+ name : "product-family-select",
+ value : instance ? instance.productFamilyId : null,
+ validations : _.isNil(isMandatory) || isMandatory === true ? [new ValidatorModel(ValidatorOptions.required, 'is required')]: [],
+ onInit : this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getProductFamilies),
+ })
+ };
+
+ getInstanceNameController(instance: any, serviceId: string, isEcompGeneratedNaming: boolean, model: NodeModel): FormControlModel {
+ let validations: ValidatorModel[] = this._basicControlGenerator.createValidationsForInstanceName(instance, serviceId, isEcompGeneratedNaming);
+ return new InputFormControl({
+ controlName: 'instanceName',
+ displayName: 'Instance name',
+ dataTestId: 'instanceName',
+ placeHolder: (!isEcompGeneratedNaming) ? 'Instance name' : 'Automatically generated when not provided',
+ validations: validations,
+ isVisible : true,
+ value : (!isEcompGeneratedNaming || (!_.isNil(instance) && !_.isNil(instance.instanceName)))
+ ? this._basicControlGenerator.getDefaultInstanceName(instance, model) : null,
+ onKeypress : (event) => {
+ const pattern:RegExp = ControlGeneratorUtil.INSTANCE_NAME_REG_EX;
+ if(pattern){
+ if(!pattern.test(event['key'])){
+ event.preventDefault();
+ }
+ }
+ return event;
+ }
+ });
+ }
+
+ getInstanceName(instance : any, serviceId : string, isEcompGeneratedNaming: boolean): FormControlModel {
+ let formControlModel:FormControlModel = this.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, new NodeModel());
+ formControlModel.value = instance ? instance.instanceName : null;
+ return formControlModel;
+ }
+}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts
index deb1a784a..f3d32b9bb 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts
@@ -1,7 +1,7 @@
import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
-import {BasicControlGenerator, SDN_C_PRE_LOAD} from "../basic.control.generator";
+import {ControlGeneratorUtil, SDN_C_PRE_LOAD} from "../control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {GenericFormService} from "../../generic-form.service";
import {FormBuilder} from "@angular/forms";
@@ -11,6 +11,7 @@ import {FormControlNames, VfModuleControlGenerator} from "./vfModule.control.gen
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {VfModuleInstance} from "../../../../models/vfModuleInstance";
import {VfModule} from "../../../../models/vfModule";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -919,7 +920,8 @@ describe('VFModule Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [VfModuleControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ SharedControllersService,
+ ControlGeneratorUtil,
AaiService,
FormBuilder,
LogService,
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts
index 011f43447..60ffc3e96 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts
@@ -3,10 +3,7 @@ import {GenericFormService} from "../../generic-form.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {NgRedux} from "@angular-redux/store";
import {HttpClient} from "@angular/common/http";
-import {BasicControlGenerator} from "../basic.control.generator";
-import * as _ from 'lodash';
-import {Observable, of} from "rxjs";
-
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {
CustomValidatorOptions,
FormControlModel,
@@ -16,19 +13,13 @@ import {
import {LogService} from "../../../../utils/log/log.service";
import {AppState} from "../../../../store/reducers";
import {FormGroup} from "@angular/forms";
-import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
-import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
import {InputFormControl} from "../../../../models/formControlModels/inputFormControl.model";
-import {SelectOption} from "../../../../models/selectOption";
import {VfModuleInstance} from "../../../../models/vfModuleInstance";
import {VfModule} from "../../../../models/vfModule";
import {VNFModel} from "../../../../models/vnfModel";
import {VnfInstance} from "../../../../models/vnfInstance";
-import {FileFormControl} from "../../../../models/formControlModels/fileFormControl.model";
-import {CheckboxFormControl} from "../../../../models/formControlModels/checkboxFormControl.model";
-import {FileUnit} from "../../../formControls/component/file/fileUnit.enum";
-import {Constants} from "../../../../utils/constants";
-
+import * as _ from 'lodash';
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
export enum FormControlNames {
INSTANCE_NAME = 'instanceName',
@@ -47,7 +38,8 @@ export class VfModuleControlGenerator {
isUpdateMode : boolean;
constructor(private genericFormService: GenericFormService,
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
+ private _sharedControllersService: SharedControllersService,
private store: NgRedux<AppState>,
private http: HttpClient,
private _aaiService: AaiService,
@@ -55,17 +47,6 @@ export class VfModuleControlGenerator {
this.aaiService = _aaiService;
}
- setVFModuleStoreKey = (serviceId: string, vfModuleUuid: string) => {
- const vfModules = this.store.getState().service.serviceHierarchy[serviceId].vfModules;
- const vfModulesKeys = Object.keys(vfModules);
- for(let key of vfModulesKeys){
- if(vfModules[key].uuid === vfModuleUuid){
- return;
- }
- }
- };
-
-
getVfModuleInstance = (serviceId: string, vnfStoreKey: string, UUIDData: Object, isUpdateMode: boolean): VfModuleInstance => {
let vfModuleInstance: VfModuleInstance = null;
if (isUpdateMode && this.store.getState().service.serviceInstance[serviceId] &&
@@ -133,11 +114,11 @@ export class VfModuleControlGenerator {
const vfModuleInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode));
let result: FormControlModel[] = [];
this.pushInstanceAndVGToForm(result, vfModuleInstance, serviceId, vnfModel, true);
- result.push(this.getLcpRegionControl(serviceId, vfModuleInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(vfModuleInstance));
- result.push(this.getTenantControl(serviceId, vfModuleInstance, result));
- result.push(this.getRollbackOnFailureControl(vfModuleInstance, result));
- result.push(this._basicControlGenerator.getSDNCControl(vfModuleInstance));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vfModuleInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(vfModuleInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, vfModuleInstance));
+ result.push(this._sharedControllersService.getRollbackOnFailureControl(vfModuleInstance));
+ result.push(this._sharedControllersService.getSDNCControl(vfModuleInstance));
if(this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) {
result = this._basicControlGenerator.concatSupplementaryFile(result, vfModuleInstance);
}
@@ -145,7 +126,7 @@ export class VfModuleControlGenerator {
}
getInstanceName(instance: any, serviceId: string, isEcompGeneratedNaming: boolean): FormControlModel {
- let formControlModel:FormControlModel = this._basicControlGenerator.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, this.vfModuleModel);
+ let formControlModel:FormControlModel = this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, this.vfModuleModel);
formControlModel.onBlur = (event, form : FormGroup) => {
if(!_.isNil(form.controls['volumeGroupName'])&& event.target.value.length > 0){
form.controls['volumeGroupName'].setValue(event.target.value + "_vol");
@@ -167,25 +148,21 @@ export class VfModuleControlGenerator {
getVolumeGroupData(instance: any, serviceId: string, isEcompGeneratedNaming: boolean, isALaCarte: boolean): FormControlModel {
let validations: ValidatorModel[] = [
- new ValidatorModel(ValidatorOptions.pattern, 'Instance name may include only alphanumeric characters and underscore.', BasicControlGenerator.INSTANCE_NAME_REG_EX),
+ new ValidatorModel(ValidatorOptions.pattern, 'Instance name may include only alphanumeric characters and underscore.', ControlGeneratorUtil.INSTANCE_NAME_REG_EX),
new ValidatorModel(CustomValidatorOptions.uniqueInstanceNameValidator, 'Volume Group instance name is already in use, please pick another name', [this.store, serviceId, instance && instance.volumeGroupName])
];
- // comment out because if not provided vid won't create VG
- // if (!isEcompGeneratedNaming) {
- // validations.push(new ValidatorModel(ValidatorOptions.required, 'is required'));
- // }
+
return new InputFormControl({
controlName: 'volumeGroupName',
displayName: 'Volume Group Name',
dataTestId: 'volumeGroupName',
- // placeHolder: (!isEcompGeneratedNaming) ? 'Volume Group Name' : 'Automatically generated when not provided',
validations: validations,
tooltip : 'When filled, VID will create a Volume Group by this name and associate with this module.\n' +
'When empty, the module is created without a Volume Group.',
isVisible: this.shouldVGNameBeVisible(isEcompGeneratedNaming,isALaCarte),
value: this.getDefaultVolumeGroupName(instance, isEcompGeneratedNaming),
onKeypress: (event) => {
- const pattern:RegExp = BasicControlGenerator.INSTANCE_NAME_REG_EX;
+ const pattern:RegExp = ControlGeneratorUtil.INSTANCE_NAME_REG_EX;
if (pattern) {
if (!pattern.test(event['key'])) {
event.preventDefault();
@@ -203,90 +180,4 @@ export class VfModuleControlGenerator {
return false;
}
-
- getTenantControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.TENANT_ID,
- displayName: 'Tenant',
- dataTestId: 'tenant',
- placeHolder: 'Select Tenant',
- name: "tenant",
- isDisabled: _.isNil(instance) || _.isNil(instance.lcpCloudRegionId),
- onInitSelectedField: instance ? ['lcpRegionsTenantsMap', instance.lcpCloudRegionId] : null,
- value: instance ? instance.tenantId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInit: instance ? this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this.aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) : () => {
- },
- })
- };
-
- getLcpRegionControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lcpCloudRegionId',
- displayName: 'LCP region',
- dataTestId: 'lcpRegion',
- placeHolder: 'Select LCP Region',
- name: "lcpRegion",
- isDisabled: false,
- value: instance ? instance.lcpCloudRegionId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lcpRegionList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)),
- onChange: (param: string, form: FormGroup) => {
- form.controls[FormControlNames.TENANT_ID].enable();
- form.controls[FormControlNames.TENANT_ID].reset();
- if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) {
- this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType).subscribe(res => {
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['options$'] = res.lcpRegionsTenantsMap[param];
- if (res.lcpRegionsTenantsMap[param]) {
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['hasEmptyOptions'] = res.lcpRegionsTenantsMap[param].length === 0;
- }
- }));
- }
-
- if (Constants.LegacyRegion.MEGA_REGION.indexOf(param) !== -1) {
- form.controls['legacyRegion'].enable();
- controls.find(item => item.controlName === 'legacyRegion').isVisible = true;
-
- } else {
- controls.find(item => item.controlName === 'legacyRegion').isVisible = false;
- form.controls['legacyRegion'].setValue(null);
- form.controls['legacyRegion'].reset();
- form.controls['legacyRegion'].disable();
- }
- }
- })
- };
-
- getRollbackOnFailureControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.ROLLBACK_ON_FAILURE,
- displayName: 'Rollback on failure',
- dataTestId: 'rollback',
- isDisabled: false,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- value: instance ? instance.rollbackOnFailure : 'true',
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this.getRollBackOnFailureOptions)
- })
- };
-
- getRollBackOnFailureOptions = (): Observable<SelectOption[]> => {
- return of([
- new SelectOption({id: 'true', name: 'Rollback'}),
- new SelectOption({id: 'false', name: 'Don\'t Rollback'})
- ]);
- };
}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts
index 28d49d51b..018130eec 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts
@@ -2,17 +2,16 @@ import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
import {FormControlNames} from "../service.control.generator";
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {GenericFormService} from "../../generic-form.service";
import {FormBuilder} from "@angular/forms";
import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
import {LogService} from "../../../../utils/log/log.service";
import {VnfControlGenerator} from "./vnf.control.generator";
-import {Observable} from "rxjs";
-import {SelectOption} from "../../../../models/selectOption";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState(){
@@ -918,7 +917,8 @@ describe('VNF Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [VnfControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
FormBuilder,
LogService,
@@ -1053,15 +1053,5 @@ describe('VNF Control Generator', () => {
const instanceNameValidator: ValidatorModel = instanceNameControl.validations.find(val => val.validatorName === ValidatorOptions.pattern);
expect(instanceNameValidator.validatorArg).toEqual(/^[a-zA-Z0-9._-]*$/);
});
-
- test('rollback should return observable of true, false', () => {
- let result : Observable<SelectOption[]> = service.getRollBackOnFailureOptions();
- result.subscribe((val)=>{
- expect(val).toEqual([
- new SelectOption({id: 'true', name: 'Rollback'}),
- new SelectOption({id: 'false', name: 'Don\'t Rollback'})
- ]);
- });
- });
});
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts
index c45fa968f..14b31b4b7 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts
@@ -3,54 +3,24 @@ import {GenericFormService} from "../../generic-form.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {NgRedux} from "@angular-redux/store";
import {HttpClient} from "@angular/common/http";
-import {BasicControlGenerator} from "../basic.control.generator";
-import {
- FormControlModel,
- ValidatorModel,
- ValidatorOptions
-} from "../../../../models/formControlModels/formControl.model";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
+import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
import {LogService} from "../../../../utils/log/log.service";
import {VNFModel} from "../../../../models/vnfModel";
import {AppState} from "../../../../store/reducers";
import {FormGroup} from "@angular/forms";
-import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
-import {Observable, of} from "rxjs";
-import {SelectOption} from "../../../../models/selectOption";
import * as _ from 'lodash';
-import {Constants} from "../../../../utils/constants";
import {MultiselectFormControl} from "../../../../models/formControlModels/multiselectFormControl.model";
import {MultiSelectItem} from "../../../formControls/component/multiselect/multiselect.model";
-
-export enum FormControlNames {
- INSTANCE_NAME = 'instanceName',
- GLOBAL_SUBSCRIBER_ID = 'globalSubscriberId',
- SUBSCRIPTION_SERVICE_TYPE = 'subscriptionServiceType',
- PRODUCT_FAMILY_ID = 'productFamilyId',
- LCPCLOUD_REGION_ID = 'lcpCloudRegionId',
- TENANT_ID = 'tenantId',
- AICZONE_ID = 'aicZoneId',
- PROJECT_NAME = 'projectName',
- OWNING_ENTITY_ID = 'owningEntityId',
- ROLLBACK_ON_FAILURE = 'rollbackOnFailure',
- PAUSE = 'pause'
-}
-
-enum InputType {
- LCP_REGION = "lcpCloudRegionId",
- TENANT = "tenantId",
- LOB = "lineOfBusiness",
- PLATFORM = "platformName",
- ROLLBACK = "rollbackOnFailure",
- PRODUCT_FAMILY = "productFamilyId",
- VG = "volumeGroupName"
-}
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
@Injectable()
export class VnfControlGenerator {
aaiService: AaiService;
constructor(private genericFormService: GenericFormService,
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
+ private _sharedControllersService : SharedControllersService,
private store: NgRedux<AppState>,
private http: HttpClient,
private _aaiService: AaiService,
@@ -80,12 +50,12 @@ export class VnfControlGenerator {
if (!_.isNil(vnfModel)) {
result.push(this.getInstanceName(vnfInstance, serviceId, vnfName, vnfModel.isEcompGeneratedNaming));
- result.push(this._basicControlGenerator.getProductFamilyControl(vnfInstance, result, false));
- result.push(this.getLcpRegionControl(serviceId, vnfInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(vnfInstance));
- result.push(this.getTenantControl(serviceId, vnfInstance, result));
+ result.push(this._sharedControllersService.getProductFamilyControl(vnfInstance, result, false));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vnfInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(vnfInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, vnfInstance));
result.push(this.getPlatformMultiselectControl(vnfInstance, result, flags['FLAG_2002_VNF_PLATFORM_MULTI_SELECT']));
- result.push(this.getLineOfBusinessControl(vnfInstance, result));
+ result.push(this._sharedControllersService.getLineOfBusinessControl(vnfInstance));
}
return result;
}
@@ -104,45 +74,22 @@ export class VnfControlGenerator {
if (!_.isNil(vnfModel)) {
const flags = this.store.getState().global.flags;
result.push(this.getInstanceName(vnfInstance, serviceId, vnfName, vnfModel.isEcompGeneratedNaming));
- result.push(this._basicControlGenerator.getProductFamilyControl(vnfInstance, result, false));
- result.push(this.getLcpRegionControl(serviceId, vnfInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(vnfInstance));
- result.push(this.getTenantControl(serviceId, vnfInstance, result));
+ result.push(this._sharedControllersService.getProductFamilyControl(vnfInstance, result, false));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vnfInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(vnfInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, vnfInstance));
result.push(this.getPlatformMultiselectControl(vnfInstance, result, flags['FLAG_2002_VNF_PLATFORM_MULTI_SELECT']));
- result.push(this.getLineOfBusinessControl(vnfInstance, result));
- result.push(this.getRollbackOnFailureControl(vnfInstance, result));
+ result.push(this._sharedControllersService.getLineOfBusinessControl(vnfInstance));
+ result.push(this._sharedControllersService.getRollbackOnFailureControl(vnfInstance));
}
return result;
}
- isInputShouldBeShown = (inputType: any): boolean => {
- let vnfInputs = [InputType.LCP_REGION, InputType.LOB, InputType.TENANT, InputType.PRODUCT_FAMILY, InputType.PLATFORM, InputType.ROLLBACK];
- return vnfInputs.indexOf(inputType) > -1;
- };
-
getInstanceName(instance : any, serviceId : string, vnfName : string, isEcompGeneratedNaming: boolean): FormControlModel {
const vnfModel : VNFModel = this.store.getState().service.serviceHierarchy[serviceId].vnfs[vnfName];
- return this._basicControlGenerator.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, vnfModel);
+ return this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, vnfModel);
}
- getLineOfBusinessControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lineOfBusiness',
- displayName: 'Line of business',
- dataTestId: 'lineOfBusiness',
- placeHolder: 'Select Line Of Business',
- isDisabled: false,
- name: "lineOfBusiness",
- value: instance ? instance.lineOfBusiness : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lineOfBusinessList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
- })
- };
-
-
-
getPlatformMultiselectControl = (instance: any, controls: FormControlModel[], isMultiSelected: boolean) : MultiselectFormControl => {
return new MultiselectFormControl({
type: FormControlType.MULTI_SELECT ,
@@ -170,90 +117,4 @@ export class VnfControlGenerator {
}
});
};
-
- getTenantControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.TENANT_ID,
- displayName: 'Tenant',
- dataTestId: 'tenant',
- placeHolder: 'Select Tenant',
- name: "tenant",
- isDisabled: _.isNil(instance) || _.isNil(instance.lcpCloudRegionId),
- onInitSelectedField: instance ? ['lcpRegionsTenantsMap', instance.lcpCloudRegionId] : null,
- value: instance ? instance.tenantId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInit : instance ? this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this.aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) : ()=>{},
- })
- };
-
- getLcpRegionControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lcpCloudRegionId',
- displayName: 'LCP region',
- dataTestId: 'lcpRegion',
- placeHolder: 'Select LCP Region',
- name: "lcpRegion",
- isDisabled: false,
- value: instance ? instance.lcpCloudRegionId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lcpRegionList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)),
- onChange: (param: string, form: FormGroup) => {
- form.controls[FormControlNames.TENANT_ID].enable();
- form.controls[FormControlNames.TENANT_ID].reset();
- if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) {
- this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType).subscribe(res => {
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['options$'] = res.lcpRegionsTenantsMap[param];
- if(res.lcpRegionsTenantsMap[param]){
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['hasEmptyOptions'] = res.lcpRegionsTenantsMap[param].length === 0;
- }
- }));
- }
-
- if (Constants.LegacyRegion.MEGA_REGION.indexOf(param) !== -1) {
- form.controls['legacyRegion'].enable();
- controls.find(item => item.controlName === 'legacyRegion').isVisible = true;
-
- } else {
- controls.find(item => item.controlName === 'legacyRegion').isVisible = false;
- form.controls['legacyRegion'].setValue(null);
- form.controls['legacyRegion'].reset();
- form.controls['legacyRegion'].disable();
- }
- }
- })
- };
-
- getRollbackOnFailureControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.ROLLBACK_ON_FAILURE,
- displayName: 'Rollback on failure',
- dataTestId: 'rollback',
- placeHolder: 'Rollback on failure',
- isDisabled: false,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- value: instance ? instance.rollbackOnFailure : 'true',
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this.getRollBackOnFailureOptions)
- })
- };
-
- getRollBackOnFailureOptions = (): Observable<SelectOption[]> => {
- return of([
- new SelectOption({id: 'true', name: 'Rollback'}),
- new SelectOption({id: 'false', name: 'Don\'t Rollback'})
- ]);
- };
}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts
index 81cfd9614..c485dc04e 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts
@@ -2,7 +2,7 @@ import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
import {FormControlNames} from "../service.control.generator";
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {GenericFormService} from "../../generic-form.service";
import {FormBuilder} from "@angular/forms";
@@ -12,6 +12,7 @@ import {VnfGroupControlGenerator} from "./vnfGroup.control.generator";
import {Observable} from "rxjs";
import {SelectOption} from "../../../../models/selectOption";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState(){
@@ -217,7 +218,8 @@ describe('VNF Group Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [VnfGroupControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
FormBuilder,
LogService,
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts
index 45f5ffa63..0fee0c223 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts
@@ -1,7 +1,7 @@
import {Injectable} from "@angular/core";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {
FormControlModel,
ValidatorModel,
@@ -15,6 +15,7 @@ import {SelectOption} from "../../../../models/selectOption";
import {VnfGroupModel} from "../../../../models/vnfGroupModel";
import * as _ from 'lodash';
import {Observable, of} from "rxjs";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
export enum FormControlNames {
@@ -22,14 +23,12 @@ export enum FormControlNames {
ROLLBACK_ON_FAILURE = 'rollbackOnFailure',
}
-enum InputType {
- ROLLBACK = "rollbackOnFailure"
-}
-
@Injectable()
export class VnfGroupControlGenerator {
aaiService: AaiService;
- constructor(private _basicControlGenerator: BasicControlGenerator,
+
+ constructor(private _basicControlGenerator: ControlGeneratorUtil,
+ private _sharedControllersService: SharedControllersService,
private store: NgRedux<AppState>,
private _aaiService: AaiService,
private _logService: LogService) {
@@ -80,19 +79,14 @@ export class VnfGroupControlGenerator {
return result;
}
- isInputShouldBeShown = (inputType: any): boolean => {
- let vnfGroupInputs = [InputType.ROLLBACK];
- return vnfGroupInputs.indexOf(inputType) > -1;
- };
-
- getDefaultInstanceName(instance : any, serviceId : string, vnfGroupName : string) : string {
+ getDefaultInstanceName(instance: any, serviceId: string, vnfGroupName: string): string {
const vnfGroupModel: VnfGroupModel = this.store.getState().service.serviceHierarchy[serviceId].vnfGroups[vnfGroupName];
return this._basicControlGenerator.getDefaultInstanceName(instance, vnfGroupModel);
}
- getInstanceName(instance : any, serviceId : string, vnfGroupName : string, isEcompGeneratedNaming: boolean): FormControlModel {
- const vnfGroupModel : VnfGroupModel = this.store.getState().service.serviceHierarchy[serviceId].vnfGroups[vnfGroupName];
- return this._basicControlGenerator.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, vnfGroupModel);
+ getInstanceName(instance: any, serviceId: string, vnfGroupName: string, isEcompGeneratedNaming: boolean): FormControlModel {
+ const vnfGroupModel: VnfGroupModel = this.store.getState().service.serviceHierarchy[serviceId].vnfGroups[vnfGroupName];
+ return this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, vnfGroupModel);
}
getRollbackOnFailureControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts
index 514b9bfef..ac417ed6e 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts
@@ -5,7 +5,7 @@ import {GenericFormPopupService} from "./generic-form-popup.service";
import {IframeService} from "../../utils/iframe.service";
import {NgRedux} from "@angular-redux/store";
import {ServicePopupService} from "./genericFormServices/service/service.popup.service";
-import {BasicControlGenerator} from "../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../services/aaiService/aai.service";
import {ServiceControlGenerator} from "../genericForm/formControlsServices/service.control.generator";
import {GenericFormService} from "../genericForm/generic-form.service";
@@ -21,6 +21,7 @@ import {VfModulePopupService} from "./genericFormServices/vfModule/vfModule.popu
import {VfModuleControlGenerator} from "../genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator";
import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service";
import {VfModuleUpgradePopupService} from "./genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T>{
getState() {
@@ -958,7 +959,8 @@ describe('Generic Form popup Service', () => {
FormBuilder,
IframeService,
ServicePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
ServiceControlGenerator,
GenericFormService,
LogService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts
index ebabc89b7..9bcc02d73 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts
@@ -1,7 +1,7 @@
import {NetworkPopupService} from "./network/network.popup.service";
import {LogService} from "../../../utils/log/log.service";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {NetworkControlGenerator} from "../../genericForm/formControlsServices/networkGenerator/network.control.generator";
@@ -1984,7 +1984,7 @@ describe('Basic popup service', () => {
TestBed.configureTestingModule({
providers : [
NetworkPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
NetworkControlGenerator,
DefaultDataGeneratorService,
GenericFormService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts
index f8b40dd99..9340a155a 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts
@@ -5,7 +5,7 @@ import {AppState} from "../../../store/reducers";
import {NgRedux} from "@angular-redux/store";
import {FormControlModel} from "../../../models/formControlModels/formControl.model";
import {DefaultDataGeneratorService} from "../../../services/defaultDataServiceGenerator/default.data.generator.service";
-import {BasicControlGenerator} from "../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../genericForm/formControlsServices/control.generator.util.service";
import * as _ from 'lodash';
import {VfModule} from "../../../models/vfModule";
import {VNFModel} from "../../../models/vnfModel";
@@ -18,7 +18,7 @@ import {Constants} from "../../../utils/constants";
export class BasicPopupService {
constructor(private _store: NgRedux<AppState>,
private _defaultDataGeneratorService : DefaultDataGeneratorService,
- private _basicControlGenerator : BasicControlGenerator){}
+ private _basicControlGenerator : ControlGeneratorUtil){}
extractSubscriberNameBySubscriberId(subsriberId: string) {
let result: string = null;
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts
index 67c371212..34d6850eb 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts
@@ -2,7 +2,7 @@ import {NetworkPopupService} from "./network.popup.service";
import {LogService} from "../../../../utils/log/log.service";
import {SdcUiServices} from "onap-ui-angular";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {NetworkControlGenerator} from "../../../genericForm/formControlsServices/networkGenerator/network.control.generator";
@@ -13,6 +13,7 @@ import {DefaultDataGeneratorService} from "../../../../services/defaultDataServi
import {BasicPopupService} from "../basic.popup.service";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {getTestBed, TestBed} from "@angular/core/testing";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {}
@@ -1987,7 +1988,8 @@ describe('Network popup service', () => {
TestBed.configureTestingModule({
providers : [
NetworkPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
NetworkControlGenerator,
DefaultDataGeneratorService,
GenericFormService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts
index a352e770f..ff444f087 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts
@@ -1,6 +1,6 @@
import {Injectable} from "@angular/core";
import {FormPopupDetails, PopupType} from "../../../../models/formControlModels/formPopupDetails.model";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {NetworkInstance} from "../../../../models/networkInstance";
import {AppState} from "../../../../store/reducers";
import {NgRedux} from "@angular-redux/store";
@@ -33,7 +33,7 @@ export class NetworkPopupService implements GenericPopupInterface {
isUpdateMode: boolean;
- constructor(private _basicControlGenerator: BasicControlGenerator,
+ constructor(private _basicControlGenerator: ControlGeneratorUtil,
private _networkControlGenerator: NetworkControlGenerator,
private _iframeService: IframeService,
private _defaultDataGeneratorService: DefaultDataGeneratorService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts
index ebea695f7..0ce051cf4 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts
@@ -1,6 +1,6 @@
import {LogService} from "../../../../utils/log/log.service";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {GenericFormService} from "../../../genericForm/generic-form.service";
@@ -14,6 +14,7 @@ import {FormControlModel} from "../../../../models/formControlModels/formControl
import {SdcUiServices} from "onap-ui-angular";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {getTestBed, TestBed} from "@angular/core/testing";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockModalService<T> {}
@@ -2053,8 +2054,9 @@ describe('Service popup service', () => {
TestBed.configureTestingModule({
providers : [
ServicePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
ServiceControlGenerator,
+ SharedControllersService,
DefaultDataGeneratorService,
GenericFormService,
FormBuilder,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts
index 3e7e8c1e5..d25ab2c7f 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts
@@ -5,7 +5,7 @@ import {ModelInformationItem} from "../../../model-information/model-information
import {Subject} from "rxjs";
import {ITreeNode} from "angular-tree-component/dist/defs/api";
import {FormPopupDetails, PopupType} from "../../../../models/formControlModels/formPopupDetails.model";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {IframeService} from "../../../../utils/iframe.service";
import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
@@ -35,7 +35,7 @@ export class ServicePopupService implements GenericPopupInterface {
- constructor(private _basicControlGenerator: BasicControlGenerator,
+ constructor(private _basicControlGenerator: ControlGeneratorUtil,
private _serviceControlGenerator: ServiceControlGenerator,
private _iframeService: IframeService,
private _defaultDataGeneratorService: DefaultDataGeneratorService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts
index 935454752..b16c5bdc0 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts
@@ -1,6 +1,6 @@
import {LogService} from "../../../../utils/log/log.service";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {GenericFormService} from "../../../genericForm/generic-form.service";
@@ -13,6 +13,7 @@ import {VfModuleControlGenerator} from "../../../genericForm/formControlsService
import {SdcUiServices} from "onap-ui-angular";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {getTestBed, TestBed} from "@angular/core/testing";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockModalService<T> {}
@@ -1982,7 +1983,8 @@ describe('VFModule popup service', () => {
TestBed.configureTestingModule({
providers : [
VfModulePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
VfModuleControlGenerator,
DefaultDataGeneratorService,
GenericFormService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts
index 6a31bb7ee..18dc65590 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts
@@ -1,6 +1,6 @@
import {Injectable} from "@angular/core";
import {FormPopupDetails, PopupType} from "../../../../models/formControlModels/formPopupDetails.model";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AppState} from "../../../../store/reducers";
import {NgRedux} from "@angular-redux/store";
import {ITreeNode} from "angular-tree-component/dist/defs/api";
@@ -20,6 +20,7 @@ import {VfModuleControlGenerator} from "../../../genericForm/formControlsService
import {FormControlModel} from "../../../../models/formControlModels/formControl.model";
import * as _ from 'lodash';
import {createVFModuleInstance, updateVFModuleInstance} from "../../../../storeUtil/utils/vfModule/vfModule.actions";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
export abstract class VfModulePopupServiceBase {
dynamicInputs: any;
@@ -43,7 +44,8 @@ export abstract class VfModulePopupServiceBase {
};
protected constructor(
- protected _basicControlGenerator: BasicControlGenerator,
+ protected _basicControlGenerator: ControlGeneratorUtil,
+ protected _sharedControllersService : SharedControllersService,
protected _vfModuleControlGenerator: VfModuleControlGenerator,
protected _iframeService: IframeService,
protected _defaultDataGeneratorService: DefaultDataGeneratorService,
@@ -156,14 +158,15 @@ export abstract class VfModulePopupServiceBase {
export class VfModulePopupService extends VfModulePopupServiceBase implements GenericPopupInterface {
- constructor(_basicControlGenerator: BasicControlGenerator,
+ constructor(_basicControlGenerator: ControlGeneratorUtil,
+ _sharedControllersService : SharedControllersService,
_vfModuleControlGenerator: VfModuleControlGenerator,
_iframeService: IframeService,
_defaultDataGeneratorService: DefaultDataGeneratorService,
_aaiService: AaiService,
_basicPopupService : BasicPopupService,
_store: NgRedux<AppState>) {
- super(_basicControlGenerator, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store);
+ super(_basicControlGenerator, _sharedControllersService, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store);
}
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts
index 667e79678..5181318dc 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts
@@ -6,7 +6,7 @@ import {upgradeVFModule} from "../../../../storeUtil/utils/vfModule/vfModule.act
import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service";
import {NgRedux} from "@angular-redux/store";
import {AppState} from "../../../../store/reducers";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {VfModuleControlGenerator} from "../../../genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator";
import {IframeService} from "../../../../utils/iframe.service";
import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service";
@@ -18,6 +18,7 @@ import {FormControlType} from "../../../../models/formControlModels/formControlT
import {mergeObjectByPathAction} from "../../../../storeUtil/utils/general/general.actions";
import * as _ from "lodash";
import {VfModuleInstance} from "../../../../models/vfModuleInstance";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
export enum UpgradeFormControlNames {
RETAIN_VOLUME_GROUPS = 'retainVolumeGroups',
@@ -26,7 +27,8 @@ export enum UpgradeFormControlNames {
@Injectable()
export class VfModuleUpgradePopupService extends VfModulePopupServiceBase {
- constructor(protected _basicControlGenerator: BasicControlGenerator,
+ constructor(protected _basicControlGenerator: ControlGeneratorUtil,
+ protected _sharedControllersService : SharedControllersService,
protected _vfModuleControlGenerator: VfModuleControlGenerator,
protected _iframeService: IframeService,
protected _defaultDataGeneratorService: DefaultDataGeneratorService,
@@ -34,7 +36,7 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase {
protected _basicPopupService: BasicPopupService,
protected _store: NgRedux<AppState>,
private _sharedTreeService: SharedTreeService) {
- super(_basicControlGenerator, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store);
+ super(_basicControlGenerator, _sharedControllersService, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store);
}
node: ITreeNode;
@@ -44,7 +46,7 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase {
getControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, isUpdateMode: boolean): FormControlModel[] {
let result: FormControlModel[] =[
this.getRetainAssignmentsControl(),
- this._basicControlGenerator.getSDNCControl(null)
+ this._sharedControllersService.getSDNCControl(null)
];
const vfModuleInstance :VfModuleInstance = this._vfModuleControlGenerator.getVfModuleInstance(serviceId, vnfStoreKey, this.uuidData, isUpdateMode);
if(this._store.getState().service.serviceHierarchy[serviceId].vfModules[this.uuidData['modelName']].volumeGroupAllowed){
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts
index 4003b4dcc..2ca992f08 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts
@@ -1,10 +1,10 @@
import {LogService} from "../../../../utils/log/log.service";
import {NgRedux} from "@angular-redux/store";
import {
- BasicControlGenerator,
+ ControlGeneratorUtil,
SDN_C_PRE_LOAD,
SUPPLEMENTARY_FILE
-} from "../../../genericForm/formControlsServices/basic.control.generator";
+} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {GenericFormService} from "../../../genericForm/generic-form.service";
@@ -25,6 +25,7 @@ import {VfModuleActions} from "../../../../storeUtil/utils/vfModule/vfModule.act
import {ServiceActions} from "../../../../storeUtil/utils/service/service.actions";
import {FormControlModel} from "../../../../models/formControlModels/formControl.model";
import * as _ from "lodash";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockModalService<T> {}
@@ -72,7 +73,8 @@ describe('VFModule popup service', () => {
TestBed.configureTestingModule({
providers: [
VfModuleUpgradePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
VfModuleControlGenerator,
DefaultDataGeneratorService,
GenericFormService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts
index 60f0f361e..6d5cf7cfe 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts
@@ -9,12 +9,13 @@ import {AaiService} from "../../../../services/aaiService/aai.service";
import {LogService} from "../../../../utils/log/log.service";
import {HttpClient} from "@angular/common/http";
import {VnfPopupService} from "./vnf.popup.service";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {VnfControlGenerator} from "../../../genericForm/formControlsServices/vnfGenerator/vnf.control.generator";
import {UUIDData} from "../../generic-form-popup.component";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {getTestBed, TestBed} from "@angular/core/testing";
import {VfModuleUpgradePopupService} from "../vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {}
@@ -2260,7 +2261,8 @@ describe('vnf new popup service', () => {
BasicPopupService,
VfModulePopupService,
VfModuleUpgradePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
VnfControlGenerator,
{provide: NgRedux, useClass: MockReduxStore},
{provide: HttpClient, useClass: MockAppStore},
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts
index 3e117ca74..2748b04c9 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts
@@ -6,7 +6,7 @@ import {FormGroup} from "@angular/forms";
import {ModelInformationItem} from "../../../model-information/model-information.component";
import {ServiceModel} from "../../../../models/serviceModel";
import {Subject} from "rxjs/Subject";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {VnfControlGenerator} from "../../../genericForm/formControlsServices/vnfGenerator/vnf.control.generator";
import {IframeService} from "../../../../utils/iframe.service";
import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service";
@@ -34,7 +34,7 @@ export class VnfPopupService implements GenericPopupInterface{
isUpdateMode: boolean;
constructor(
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
private _vnfControlGenerator: VnfControlGenerator,
private _iframeService: IframeService,
private _defaultDataGeneratorService: DefaultDataGeneratorService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts
index 8ee48e675..4c6db2cb5 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts
@@ -8,13 +8,14 @@ import {BasicPopupService} from "../basic.popup.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {LogService} from "../../../../utils/log/log.service";
import {HttpClient} from "@angular/common/http";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {UUIDData} from "../../generic-form-popup.component";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {VnfGroupPopupService} from "./vnfGroup.popup.service";
import {VnfGroupControlGenerator} from "../../../genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator";
import {getTestBed, TestBed} from "@angular/core/testing";
import {VfModuleUpgradePopupService} from "../vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {}
@@ -2257,7 +2258,8 @@ describe('vnf group new popup service', () => {
BasicPopupService,
VfModulePopupService,
VfModuleUpgradePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
VnfGroupControlGenerator,
{provide: NgRedux, useClass: MockReduxStore},
{provide: HttpClient, useClass: MockAppStore}]
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts
index 851d5d514..14512d3d8 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts
@@ -6,7 +6,7 @@ import {FormGroup} from "@angular/forms";
import {ModelInformationItem} from "../../../model-information/model-information.component";
import {ServiceModel} from "../../../../models/serviceModel";
import {Subject} from "rxjs/Subject";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {IframeService} from "../../../../utils/iframe.service";
import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
@@ -34,7 +34,7 @@ export class VnfGroupPopupService implements GenericPopupInterface{
isUpdateMode: boolean;
constructor(
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
private _vnfGroupControlGenerator: VnfGroupControlGenerator,
private _iframeService: IframeService,
private _defaultDataGeneratorService: DefaultDataGeneratorService,
diff --git a/vid-webpack-master/src/app/shared/shared.module.ts b/vid-webpack-master/src/app/shared/shared.module.ts
index 0f7c92060..f95f86149 100644
--- a/vid-webpack-master/src/app/shared/shared.module.ts
+++ b/vid-webpack-master/src/app/shared/shared.module.ts
@@ -32,7 +32,7 @@ import {CheckboxFormControlComponent} from "./components/formControls/component/
import {GenericFormService} from "./components/genericForm/generic-form.service";
import {GenericFormComponent} from "./components/genericForm/generic-form.component";
import {ServiceControlGenerator} from "./components/genericForm/formControlsServices/service.control.generator";
-import {BasicControlGenerator} from "./components/genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "./components/genericForm/formControlsServices/control.generator.util.service";
import {CustomValidators} from "./validators/uniqueName/uniqueName.validator";
import {FileFormControlComponent} from "./components/formControls/component/file/file.formControl.component";
import {NumberFormControlComponent} from "./components/formControls/component/number/number.formControl.component";
@@ -79,6 +79,7 @@ import {InstantiationTemplatesModalService} from "./components/genericFormPopup/
import {SearchFilterPipe} from "./pipes/searchFilter/search-filter.pipe";
import {RecreateResolver} from "./resolvers/recreate/recreate.resolver";
import {InstantiationTemplatesService} from "./services/templateService/instantiationTemplates.service";
+import {SharedControllersService} from "./components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
@NgModule({
@@ -190,7 +191,8 @@ import {InstantiationTemplatesService} from "./services/templateService/instanti
ServicePopupService,
VnfControlGenerator,
VfModuleControlGenerator,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
CustomValidators,
NetworkPopupService,
VfModulePopupService,
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.spec.ts
index 952a92842..4bad61326 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.spec.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.spec.ts
@@ -178,7 +178,7 @@ describe('generalReducer', () => {
expect(userState).toEqual(userId);
});
- test('#DELETE_VNF_INSTANCE : should delete existing vnf', () => {
+ test('#REMOVE_INSTANCE : should delete existing vnf', () => {
let state = generalReducer(<any>{serviceInstance : {
'serviceModelId' : {
vnfs : {
@@ -202,7 +202,7 @@ describe('generalReducer', () => {
expect(state.serviceInstance[ 'serviceModelId'].vnfs['modelName']).not.toBeDefined();
});
- test('#DELETE_VNF_INSTANCE : should delete existing network', () => {
+ test('#REMOVE_INSTANCE : should delete existing network', () => {
let state = generalReducer(<any>{serviceInstance : {
'serviceModelId' : {
'networks' : {
@@ -226,6 +226,43 @@ describe('generalReducer', () => {
expect(state.serviceInstance['serviceModelId'].networks['modelName']).not.toBeDefined();
});
+ test('#REMOVE_INSTANCE : remove VNF should remove VFModules ', () => {
+ let state = generalReducer(<any>
+ {serviceInstance : {
+ 'serviceModelId' : {
+ 'validationCounter' : 2,
+ 'vnfs' : {
+ 'SDC_Automation_15Aug 0' : {
+ 'isMissingData' :true,
+ 'modelName' : {},
+ 'vfModules' : {
+ 'vfModule_1' : {
+ 'vfModule_1_1' : {
+ 'isMissingData' :true
+ }
+ }
+ }
+ }
+ }
+ }
+ }},
+ <RemoveInstanceAction>{
+ type: GeneralActions.REMOVE_INSTANCE,
+ modelName : 'modelName',
+ serviceModelId : 'serviceModelId',
+ storeKey : 'SDC_Automation_15Aug 0',
+ node : {
+ data : {
+ type : 'VF'
+ }
+ }
+ });
+
+ expect(state).toBeDefined();
+ expect(state.serviceInstance['serviceModelId'].vnfs['modelName']).not.toBeDefined();
+ expect(state.serviceInstance['serviceModelId'].validationCounter).toEqual(0);
+ });
+
test('#CHANGE_VNF_INSTANCE_COUNTER : should init existingVNFCounterMap to 1', () => {
let state = generalReducer(<any>{serviceInstance : {
'serviceModelId' : {
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts
index f87a97397..924d58a8a 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts
@@ -55,6 +55,7 @@ export function generalReducer(state: ServiceState, action: Action) : ServiceSta
_.forOwn(state.serviceInstance[actionData.serviceModelId][typeNodeInformation.hierarchyName][actionData.storeKey].vfModules, (vfModuleMap) => {
_.forOwn(vfModuleMap, (vfModuleInstance) => {
updateUniqueNames(vfModuleInstance.instanceName, null, state.serviceInstance[actionData.serviceModelId]);
+ updateServiceValidationCounter(state, vfModuleInstance.isMissingData, false, actionData.serviceModelId);
})
});
}
diff --git a/vid-webpack-master/src/app/shared/utils/constants.ts b/vid-webpack-master/src/app/shared/utils/constants.ts
index 6bf5ff1f4..f09ab088d 100644
--- a/vid-webpack-master/src/app/shared/utils/constants.ts
+++ b/vid-webpack-master/src/app/shared/utils/constants.ts
@@ -95,7 +95,7 @@ export module Constants {
public static SERVICES_JOB_INFO_PATH = '../../asyncInstantiation';
public static SERVICE_MODEL_ID = 'serviceModelId';
public static SERVICES_RETRY_TOPOLOGY = '../../asyncInstantiation/bulkForRetry';
- public static INSTANTIATION_TEMPLATE_TOPOLOGY = '../../asyncInstantiation/templateTopology';
+ public static INSTANTIATION_TEMPLATE_TOPOLOGY = '../../instantiationTemplates/templateTopology';
public static CONFIGURATION_PATH = '../../get_property/{name}/defaultvalue';
public static SERVICES_JOB_AUDIT_PATH = '/auditStatus';
public static SERVICES_PROBE_PATH = "../../probe";