From c9786d9a863181176c0a4aa5c38d2c202a94b41b Mon Sep 17 00:00:00 2001 From: ojasdubey Date: Thu, 12 Apr 2018 13:20:36 +0530 Subject: Fixed healing for vlan tagging and annotations Updated code to fix healing for vlan tagging and sriov annotations Change-Id: I2ce87f8ecd0dc171a0e73468b1f0020173da3fea Issue-ID: SDC-1214 Signed-off-by: ojasdubey --- .../impl/zusammen/ServiceModelDaoZusammenImpl.java | 48 +++++++--------------- 1 file changed, 15 insertions(+), 33 deletions(-) (limited to 'openecomp-be/lib') diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java index c73a304c97..7bc3436f22 100644 --- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java @@ -1,5 +1,8 @@ package org.openecomp.sdc.model.impl.zusammen; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; + import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; @@ -32,9 +35,6 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; -import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; -import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; - public class ServiceModelDaoZusammenImpl implements ServiceModelDao { private static final String BASE_PROPERTY = "base"; @@ -169,7 +169,7 @@ public class ServiceModelDaoZusammenImpl SessionContext context = ZusammenUtil.createSessionContext(); ElementContext elementContext = new ElementContext(vspId, version.getId()); - ZusammenElement serviceModelElement = buildStructuralElement(elementType, Action.UPDATE); + ZusammenElement serviceModelElement = buildStructuralElement(elementType, Action.IGNORE); Optional origServiceModel = getServiceModelElementInfo(context, elementContext); if (!origServiceModel.isPresent()) { @@ -177,13 +177,11 @@ public class ServiceModelDaoZusammenImpl } Id serviceModelElementId = origServiceModel.get().getId(); - overrideServiceTemplates(serviceModelElementId, serviceModel, context, elementContext, - serviceModelElement); - serviceModelElement.getInfo() - .addProperty(BASE_PROPERTY, serviceModel.getEntryDefinitionServiceTemplate()); + serviceModelElement.setElementId(serviceModelElementId); + overrideServiceTemplates(serviceModelElementId, serviceModel, context, elementContext, serviceModelElement); + serviceModelElement.getInfo().addProperty(BASE_PROPERTY, serviceModel.getEntryDefinitionServiceTemplate()); - zusammenAdaptor - .saveElement(context, elementContext, serviceModelElement, "Override service model"); + zusammenAdaptor.saveElement(context, elementContext, serviceModelElement, "Override service model"); } @@ -193,32 +191,16 @@ public class ServiceModelDaoZusammenImpl ElementContext elementContext, ZusammenElement serviceModelElement) { Optional elementInfo = zusammenAdaptor.getElementInfoByName( - context, elementContext, serviceModelElementId, ElementType.ServiceTemplate.name()); + context, elementContext, serviceModelElementId, ElementType.Templates.name()); if (!elementInfo.isPresent()) { return; } - ZusammenElement zusammenElement = - buildStructuralElement(ElementType.ServiceTemplate, Action.UPDATE); - Collection elements = zusammenAdaptor.listElementData(context, elementContext, - elementInfo.get().getId()); - - elements - .forEach(element -> zusammenElement - .addSubElement(overrideServiceTemplateInElement(element, serviceModel))); - - serviceModelElement.addSubElement(zusammenElement); - } - - private ZusammenElement overrideServiceTemplateInElement(Element element, - ToscaServiceModel serviceModel) { - ZusammenElement serviceTemplateElement = (ZusammenElement) element; - String templateName = element.getInfo().getName(); - Optional serviceTemplate = serviceModel.getServiceTemplate(templateName); - serviceTemplate.ifPresent(serviceTemplateFile -> { - String yaml = new ToscaExtensionYamlUtil().objectToYaml(serviceTemplateFile); - serviceTemplateElement.setData(new ByteArrayInputStream(yaml.getBytes())); - }); - return serviceTemplateElement; + ZusammenElement templateElement = buildStructuralElement(ElementType.Templates, Action.UPDATE); + templateElement.setElementId(elementInfo.get().getId()); + serviceModel.getServiceTemplates().forEach((templateName, serviceTemplate) -> templateElement.addSubElement( + buildServiceTemplateElement(templateName, serviceTemplate, + serviceModel.getEntryDefinitionServiceTemplate(), Action.UPDATE))); + serviceModelElement.addSubElement(templateElement); } private Optional getServiceModelElementInfo(SessionContext context, -- cgit 1.2.3-korg