diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2019-11-21 12:01:58 +0200 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2019-11-25 15:30:52 +0200 |
commit | cbe6877e50b69370170bea4057bb8d5baf42946e (patch) | |
tree | d68c31c9ecd55a371944fe08e5c45025c9dca9ef /vid-app-common/src/main/java | |
parent | c1777f478aa421c35667a99fd2199569bc9e4a8a (diff) |
identify macro services without instantiation type in BE by feature flag
Issue-ID: VID-705
Change-Id: Ia618f91133cdecbd35eac4346496a6ff38a3753e
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Diffstat (limited to 'vid-app-common/src/main/java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java | 57 | ||||
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/properties/Features.java | 1 |
2 files changed, 38 insertions, 20 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 3f18a5ace..760eb4251 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 @@ -24,6 +24,7 @@ import static java.util.stream.Collectors.toSet; 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 static org.hibernate.annotations.common.util.StringHelper.isNotEmpty; import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER; import com.google.common.collect.ImmutableMap; @@ -42,6 +43,7 @@ import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.model.ServiceModel; import org.onap.vid.model.VidNotions; +import org.onap.vid.model.VidNotions.InstantiationType; import org.onap.vid.model.VidNotions.InstantiationUI; import org.onap.vid.model.VidNotions.ModelCategory; import org.onap.vid.properties.Features; @@ -78,11 +80,13 @@ public class VidNotionsBuilder { VidNotions buildVidNotions(ISdcCsarHelper csarHelper, ServiceModel serviceModel) { VidNotions.ModelCategory modelCategory = suggestModelCategory(csarHelper, serviceModel); + final InstantiationType instantiationType = suggestInstantiationType(serviceModel, modelCategory); return new VidNotions( - suggestInstantiationUI(csarHelper, serviceModel, modelCategory), + suggestInstantiationUI(csarHelper, serviceModel, modelCategory, instantiationType), modelCategory, - suggestViewEditUI(csarHelper, serviceModel, modelCategory), - suggestInstantiationType(serviceModel, modelCategory)); + suggestViewEditUI(csarHelper, serviceModel, modelCategory, instantiationType), + instantiationType + ); } private boolean isMacroTypeByModelCategory(VidNotions.ModelCategory modelCategory) { @@ -91,34 +95,47 @@ public class VidNotionsBuilder { return (featureOfMacroType!=null && featureManager.isActive(featureOfMacroType)); } - VidNotions.InstantiationType suggestInstantiationType(ServiceModel serviceModel, VidNotions.ModelCategory modelCategory) { + InstantiationType suggestInstantiationType(ServiceModel serviceModel, VidNotions.ModelCategory modelCategory) { if (isMacroTypeByModelCategory(modelCategory)) { - return VidNotions.InstantiationType.Macro; + return InstantiationType.Macro; } - if (serviceModel==null || serviceModel.getService()==null || isEmpty(serviceModel.getService().getInstantiationType())) { - return VidNotions.InstantiationType.ClientConfig; + if (serviceModel==null || serviceModel.getService()==null) { + return defaultInstantiationType(); } - String instantiationType = serviceModel.getService().getInstantiationType(); - if (instantiationType.equals(ToscaParserImpl2.Constants.MACRO)) { - return VidNotions.InstantiationType.Macro; + + if (StringUtils.equals(serviceModel.getService().getInstantiationType(), ToscaParserImpl2.Constants.MACRO)) { + return InstantiationType.Macro; } - if (instantiationType.equals(ToscaParserImpl2.Constants.A_LA_CARTE)) { - return VidNotions.InstantiationType.ALaCarte; + + if (StringUtils.equals(serviceModel.getService().getInstantiationType(), ToscaParserImpl2.Constants.A_LA_CARTE)) { + return InstantiationType.ALaCarte; } - return VidNotions.InstantiationType.ClientConfig; + if (!featureManager.isActive(Features.FLAG_2002_IDENTIFY_INVARIANT_MACRO_UUID_BY_BACKEND)) + return InstantiationType.ClientConfig; + + return isMacroByInvariantUuid(serviceModel.getService().getInvariantUuid()) ? + InstantiationType.Macro : + InstantiationType.ALaCarte; + } + + @NotNull + private InstantiationType defaultInstantiationType() { + return featureManager.isActive(Features.FLAG_2002_IDENTIFY_INVARIANT_MACRO_UUID_BY_BACKEND) ? + InstantiationType.ALaCarte : + 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, ServiceModel serviceModel, ModelCategory modelCategory) { + VidNotions.InstantiationUI suggestInstantiationUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel, ModelCategory modelCategory, InstantiationType instantiationType) { if(featureManager.isActive(Features.FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI) && isALaCarte(csarHelper)) { return VidNotions.InstantiationUI.ANY_ALACARTE_NEW_UI; } if (featureManager.isActive(Features.FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI) && - !isMacro(serviceModel) && + !isMacro(instantiationType) && !isAlacarteExcludedByCategory(modelCategory)) { return InstantiationUI.ANY_ALACARTE_WHICH_NOT_EXCLUDED; } @@ -206,13 +223,13 @@ public class VidNotionsBuilder { return VidNotions.ModelCategory.OTHER; } - VidNotions.InstantiationUI suggestViewEditUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel, ModelCategory modelCategory) { + VidNotions.InstantiationUI suggestViewEditUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel, ModelCategory modelCategory, InstantiationType instantiationType) { if (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && isGrouping(csarHelper)) { return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING; } if (featureManager.isActive(Features.FLAG_1908_MACRO_NOT_TRANSPORT_NEW_VIEW_EDIT) && - isMacro(serviceModel) && + isMacro(instantiationType) && !isTransportService(csarHelper) && //till new view/edit would support fabric service activation !hasFabricConfiguration(csarHelper)) { @@ -220,7 +237,7 @@ public class VidNotionsBuilder { } if (featureManager.isActive(Features.FLAG_1902_NEW_VIEW_EDIT)) { - VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper, serviceModel, modelCategory); + VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper, serviceModel, modelCategory, instantiationType); if (instantiationUISuggestion!=VidNotions.InstantiationUI.LEGACY) { return instantiationUISuggestion; } @@ -229,8 +246,8 @@ public class VidNotionsBuilder { return VidNotions.InstantiationUI.LEGACY; } - private boolean isMacro(ServiceModel serviceModel) { - return ToscaParserImpl2.Constants.MACRO.equals(serviceModel.getService().getInstantiationType()); + private boolean isMacro(InstantiationType instantiationType) { + return instantiationType==InstantiationType.Macro; } private boolean isUuidExactlyHardCoded1ffce89fef3f(ISdcCsarHelper csarHelper) { diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java index 5bf4fbdc0..b53ddbe2f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java +++ b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java @@ -82,6 +82,7 @@ public enum Features implements Feature { FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE, FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI, FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS, + FLAG_2002_IDENTIFY_INVARIANT_MACRO_UUID_BY_BACKEND, ; |