diff options
author | 2018-04-12 13:20:36 +0530 | |
---|---|---|
committer | 2018-04-12 11:45:55 +0000 | |
commit | c9786d9a863181176c0a4aa5c38d2c202a94b41b (patch) | |
tree | d99c2b5baf40472c314d1872f53a48a39016239b /openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org | |
parent | f2ea4a540c824b1b6c7223d14eba4d9f14386895 (diff) |
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 <ojas.dubey@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org')
-rw-r--r-- | openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java | 48 |
1 files changed, 15 insertions, 33 deletions
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<ToscaServiceModel, ServiceElement> { 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<ElementInfo> 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> 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<Element> 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> 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<ElementInfo> getServiceModelElementInfo(SessionContext context, |