aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
diff options
context:
space:
mode:
authorEinat Vinouze <einat.vinouze@intl.att.com>2019-07-16 17:17:36 +0300
committerIttay Stern <ittay.stern@att.com>2019-07-30 06:01:44 +0300
commite601bbdc43bae9a08e2e10c5139a6f76b47860d7 (patch)
tree1913f0b369ead3f2ea5557e5649d8281eca9871c /vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
parent76c6ee4a697617ec4cdee2f3b48bc83136c858c5 (diff)
Implant vid-app-common org.onap.vid.job (main and test)
Issue-ID: VID-378 Change-Id: I41b0bdc2c4e3635f3f3319b1cd63cefc61912dfc Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com> Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java142
1 files changed, 114 insertions, 28 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
index a28695211..c9c2649ae 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,36 +20,75 @@
package org.onap.vid.asdc.parser;
+import static org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase;
+import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
+import static org.apache.commons.lang3.StringUtils.isEmpty;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.Nullable;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.vid.model.ServiceModel;
import org.onap.vid.model.VidNotions;
import org.onap.vid.properties.Features;
import org.togglz.core.manager.FeatureManager;
-import static org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase;
-import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
-
public class VidNotionsBuilder {
private final FeatureManager featureManager;
+ //map of service type that are always macro services, and their relevant featureFlag
+ private static final Map<VidNotions.ModelCategory, Features> macroServicesByModelCategory = ImmutableMap.of(
+ VidNotions.ModelCategory.INFRASTRUCTURE_VPN, Features.FLAG_1908_INFRASTRUCTURE_VPN,
+ VidNotions.ModelCategory.Transport, Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI,
+ VidNotions.ModelCategory.SERVICE_WITH_COLLECTION_RESOURCE, Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI
+ );
+
public VidNotionsBuilder(FeatureManager featureManager) {
this.featureManager = featureManager;
}
- public VidNotions buildVidNotions(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
- final VidNotions.InstantiationUI instantiationUI = suggestInstantiationUI(csarHelper);
+ VidNotions buildVidNotions(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
+ VidNotions.ModelCategory modelCategory = suggestModelCategory(csarHelper, serviceModel);
+ return new VidNotions(
+ suggestInstantiationUI(csarHelper, serviceModel),
+ modelCategory,
+ suggestViewEditUI(csarHelper, serviceModel),
+ suggestInstantiationType(serviceModel, modelCategory));
+ }
- return new VidNotions(instantiationUI, suggestModelCategory(csarHelper), suggestViewEditUI(csarHelper, serviceModel));
+ private boolean isMacroTypeByModelCategory(VidNotions.ModelCategory modelCategory) {
+ Features featureOfMacroType = macroServicesByModelCategory.get(modelCategory);
+ //if featureOfMacroType is null this service is not a macro by its type
+ return (featureOfMacroType!=null && featureManager.isActive(featureOfMacroType));
+ }
+
+ VidNotions.InstantiationType suggestInstantiationType(ServiceModel serviceModel, VidNotions.ModelCategory modelCategory) {
+ if (isMacroTypeByModelCategory(modelCategory)) {
+ return VidNotions.InstantiationType.Macro;
+ }
+ if (serviceModel==null || serviceModel.getService()==null || isEmpty(serviceModel.getService().getInstantiationType())) {
+ return VidNotions.InstantiationType.ClientConfig;
+ }
+ String instantiationType = serviceModel.getService().getInstantiationType();
+ if (instantiationType.equals(ToscaParserImpl2.Constants.MACRO)) {
+ return VidNotions.InstantiationType.Macro;
+ }
+ if (instantiationType.equals(ToscaParserImpl2.Constants.A_LA_CARTE)) {
+ return VidNotions.InstantiationType.ALaCarte;
+ }
+
+ return VidNotions.InstantiationType.ClientConfig;
}
//UI route a-la-carte services to old UI only if InstantiationUI is LEGACY
//So any other value for InstantiationUI other than LEGACY make UI to route
//a-la-carte services to new UI
- VidNotions.InstantiationUI suggestInstantiationUI(ISdcCsarHelper csarHelper) {
+ VidNotions.InstantiationUI suggestInstantiationUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
if(featureManager.isActive(Features.FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI) && isALaCarte(csarHelper)) {
return VidNotions.InstantiationUI.ANY_ALACARTE_NEW_UI;
}
@@ -57,42 +96,91 @@ public class VidNotionsBuilder {
return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING;
}
if (featureManager.isActive(Features.FLAG_5G_IN_NEW_INSTANTIATION_UI)) {
- if (isUuidExactlyHardCoded1ffce89fef3f(csarHelper)) {
- return VidNotions.InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de;
- } else if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)) {
- return VidNotions.InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS;
- } else if (isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
- return VidNotions.InstantiationUI.SERVICE_WITH_FABRIC_CONFIGURATION;
- }
+ VidNotions.InstantiationUI instantiationUI = determine5GInstantiationUI(csarHelper);
+ if ( instantiationUI != null ) return instantiationUI;
+ }
+ if (featureManager.isActive(Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI) && isTransportService(csarHelper)){
+ return VidNotions.InstantiationUI.TRANSPORT_SERVICE;
+ }
+ if (featureManager.isActive(Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI) && isServiceWithCollectionResource(serviceModel)){
+ return VidNotions.InstantiationUI.SERVICE_WITH_COLLECTION_RESOURCE;
+ }
+ if (featureManager.isActive(Features.FLAG_1908_INFRASTRUCTURE_VPN) && isInfraStructureVpn(csarHelper)){
+ return VidNotions.InstantiationUI.INFRASTRUCTURE_VPN;
+ }
+ if (featureManager.isActive(Features.FLAG_1908_A_LA_CARTE_VNF_NEW_INSTANTIATION_UI) && isVnfServiceRole(csarHelper)){
+ return VidNotions.InstantiationUI.A_LA_CARTE_VNF_SERVICE_ROLE;
}
-
return VidNotions.InstantiationUI.LEGACY;
}
- VidNotions.ModelCategory suggestModelCategory(ISdcCsarHelper csarHelper) {
+ private boolean isVnfServiceRole(ISdcCsarHelper csarHelper) {
+ final String serviceRole = csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.SERVICE_ROLE );
+ return StringUtils.equalsIgnoreCase("VNF" , serviceRole);
+ }
+
+ @Nullable
+ private VidNotions.InstantiationUI determine5GInstantiationUI(ISdcCsarHelper csarHelper) {
+ if (isUuidExactlyHardCoded1ffce89fef3f(csarHelper)) {
+ return VidNotions.InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de;
+ } else if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)) {
+ return VidNotions.InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS;
+ } else if (isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
+ return VidNotions.InstantiationUI.SERVICE_WITH_FABRIC_CONFIGURATION;
+ }
+ return null;
+ }
+
+ private boolean isTransportService(ISdcCsarHelper csarHelper) {
+ return ("TRANSPORT".equalsIgnoreCase(csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.SERVICE_TYPE)));
+ }
+
+ private boolean isServiceWithCollectionResource(ServiceModel serviceModel){
+ return MapUtils.isNotEmpty(serviceModel.getCollectionResources());
+ }
+
+ private boolean isInfraStructureVpn(ISdcCsarHelper csarHelper) {
+ Metadata serviceMetadata = csarHelper.getServiceMetadata();
+ return ("BONDING".equalsIgnoreCase(serviceMetadata.getValue(ToscaParserImpl2.Constants.SERVICE_TYPE)) &&
+ "INFRASTRUCTURE-VPN".equalsIgnoreCase(serviceMetadata.getValue(ToscaParserImpl2.Constants.SERVICE_ROLE)));
+ }
+
+ VidNotions.ModelCategory suggestModelCategory(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)){
return VidNotions.ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL;
- } else if(isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
+ }
+ if(isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
return VidNotions.ModelCategory.IS_5G_FABRIC_CONFIGURATION_MODEL;
- } else {
- return VidNotions.ModelCategory.OTHER;
}
+ if (isInfraStructureVpn(csarHelper)) {
+ return VidNotions.ModelCategory.INFRASTRUCTURE_VPN;
+ }
+ if (isTransportService(csarHelper)) {
+ return VidNotions.ModelCategory.Transport;
+ }
+ if (isServiceWithCollectionResource(serviceModel)) {
+ return VidNotions.ModelCategory.SERVICE_WITH_COLLECTION_RESOURCE;
+ }
+ return VidNotions.ModelCategory.OTHER;
}
VidNotions.InstantiationUI suggestViewEditUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
- if (!featureManager.isActive(Features.FLAG_ASYNC_INSTANTIATION)){
- return VidNotions.InstantiationUI.LEGACY;
- }
if (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && isGrouping(csarHelper)) {
return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING;
}
+ if (featureManager.isActive(Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI) &&
+ featureManager.isActive(Features.FLAG_1908_RESUME_MACRO_SERVICE) &&
+ isServiceWithCollectionResource(serviceModel)) {
+ return VidNotions.InstantiationUI.SERVICE_WITH_COLLECTION_RESOURCE;
+ }
+
if (featureManager.isActive(Features.FLAG_1902_NEW_VIEW_EDIT)) {
if (isMacro(serviceModel) && !isMacroExcludedFromAsyncFlow(serviceModel)) {
return VidNotions.InstantiationUI.MACRO_SERVICE;
}
- VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper);
+ VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper, serviceModel);
if (instantiationUISuggestion!=VidNotions.InstantiationUI.LEGACY) {
return instantiationUISuggestion;
}
@@ -137,10 +225,8 @@ public class VidNotionsBuilder {
boolean isMacroExcludedFromAsyncFlow(ServiceModel serviceModel) {
return (MapUtils.isNotEmpty(serviceModel.getPnfs()) ||
- MapUtils.isNotEmpty(serviceModel.getCollectionResource()) ||
+ MapUtils.isNotEmpty(serviceModel.getCollectionResources()) ||
(MapUtils.isNotEmpty(serviceModel.getNetworks()) && !featureManager.isActive(Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION)));
-
-
}
private boolean isGrouping(ISdcCsarHelper csarHelper) {