diff options
author | talig <talig@amdocs.com> | 2018-07-09 08:51:44 +0300 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-07-09 06:42:09 +0000 |
commit | 83ef2673b1ac333559e512a006316cf740172bd6 (patch) | |
tree | 1015ca3c26f2171a84acc85109ddd9669bf4ee4d /openecomp-be | |
parent | 5cd79e4b4a5dad5cbfab80148057076694d3365a (diff) |
Update ServiceModel element during healing
In order to fix service model which was saved without property "base" with the EntryDefinitionServiceTemplate, causing failure at submit
Change-Id: Iecb9a377f324040c3b3283f6799af3462a84ceb9
Issue-ID: SDC-1481
Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-be')
-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 | 27 |
1 files changed, 14 insertions, 13 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 ca6585c841..682ae30aee 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 @@ -82,20 +82,16 @@ public class ServiceModelDaoZusammenImpl logger.info("Storing service model for VendorSoftwareProduct id -> {}", vspId); ZusammenElement templatesElement = buildStructuralElement(ElementType.Templates, Action.UPDATE); - serviceModel.getServiceTemplates().entrySet().forEach(entry -> templatesElement.addSubElement( - buildServiceTemplateElement(entry.getKey(), entry.getValue(), - serviceModel.getEntryDefinitionServiceTemplate(), Action.CREATE))); + serviceModel.getServiceTemplates().forEach((key, value) -> templatesElement.addSubElement( + buildServiceTemplateElement(key, value, serviceModel.getEntryDefinitionServiceTemplate(), Action.CREATE))); ZusammenElement artifactsElement = buildStructuralElement(ElementType.Artifacts, Action.UPDATE); if (Objects.nonNull(serviceModel.getArtifactFiles())) { - serviceModel.getArtifactFiles().getFiles().entrySet() - .forEach(entry -> artifactsElement.addSubElement( - buildArtifactElement(entry.getKey(), entry.getValue(), Action.CREATE))); + serviceModel.getArtifactFiles().getFiles().forEach( + (key, value) -> artifactsElement.addSubElement(buildArtifactElement(key, value, Action.CREATE))); } - ZusammenElement serviceModelElement = buildStructuralElement(elementType, Action.UPDATE); - serviceModelElement.getInfo() - .addProperty(BASE_PROPERTY, serviceModel.getEntryDefinitionServiceTemplate()); + ZusammenElement serviceModelElement = buildServiceModelElement(serviceModel.getEntryDefinitionServiceTemplate()); serviceModelElement.addSubElement(templatesElement); serviceModelElement.addSubElement(artifactsElement); @@ -169,17 +165,16 @@ public class ServiceModelDaoZusammenImpl SessionContext context = ZusammenUtil.createSessionContext(); ElementContext elementContext = new ElementContext(vspId, version.getId()); - ZusammenElement serviceModelElement = buildStructuralElement(elementType, Action.IGNORE); - Optional<ElementInfo> origServiceModel = getServiceModelElementInfo(context, elementContext); if (!origServiceModel.isPresent()) { return; } - Id serviceModelElementId = origServiceModel.get().getId(); + + ZusammenElement serviceModelElement = buildServiceModelElement(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"); } @@ -249,6 +244,12 @@ public class ServiceModelDaoZusammenImpl return null; } + private ZusammenElement buildServiceModelElement(String entryDefinitionServiceTemplate) { + ZusammenElement serviceModelElement = buildStructuralElement(elementType, Action.UPDATE); + serviceModelElement.getInfo().addProperty(BASE_PROPERTY, entryDefinitionServiceTemplate); + return serviceModelElement; + } + private Element buildServiceTemplateElement(String name, ServiceTemplate serviceTemplate, String entryDefinitionServiceTemplate, Action action) { |