diff options
author | 2018-01-03 17:53:32 +0530 | |
---|---|---|
committer | 2018-01-04 11:28:53 +0000 | |
commit | c09a82325a1518bd1fce7221b9be2fac32511f2d (patch) | |
tree | 68d9218cbb8db5edb73a57091486d4f5a8668655 /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp | |
parent | a9602f8f97a64cc1855b5228bfc3c7502c82fe92 (diff) |
Heat reupload component dependency issue fix
Resolved merge conflict
Change-Id: Ib9561aa7d5814c3dd9c6015214d656a2800984a9
Issue-ID: SDC-872
Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp')
2 files changed, 33 insertions, 21 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java index 8211749fe1..73598a2aee 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java @@ -16,6 +16,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.model.dao.ServiceModelDao; @@ -77,8 +79,6 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME; - public class OrchestrationUtil { public static final String ORCHESTRATION_CONFIG_NAMESPACE = "orchestration"; @@ -344,39 +344,42 @@ public class OrchestrationUtil { } public void updateVspComponentDependencies(String vspId, Version version, - Map<String, String> vspComponentIdNameInfoBeforeProcess) { + Map<String, String> + vspComponentIdNameInfoBeforeProcess, + Collection<ComponentDependencyModelEntity> + componentDependenciesBeforeDelete) { Map<String, String> updatedVspComponentNameIdInfo = getVspComponentNameIdInfo(vspId, version); if (MapUtils.isNotEmpty(updatedVspComponentNameIdInfo)) { Set<String> updatedVspComponentNames = updatedVspComponentNameIdInfo.keySet(); - Collection<ComponentDependencyModelEntity> componentDependencies = - componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, - version, null)); - if (CollectionUtils.isNotEmpty(componentDependencies)) { - updateComponentDependency(vspComponentIdNameInfoBeforeProcess, componentDependencies, - updatedVspComponentNames, updatedVspComponentNameIdInfo); + if (CollectionUtils.isNotEmpty(componentDependenciesBeforeDelete)) { + restoreComponentDependencies(vspId, version, vspComponentIdNameInfoBeforeProcess, + componentDependenciesBeforeDelete, updatedVspComponentNames, + updatedVspComponentNameIdInfo); } } } - private void updateComponentDependency(Map<String, String> vspComponentIdNameInfoBeforeProcess, - Collection<ComponentDependencyModelEntity> - componentDependencies, - Set<String> updatedVspComponentNames, - Map<String, String> updatedVspComponentNameIdInfo) { - for (ComponentDependencyModelEntity componentDependency : componentDependencies) { + private void restoreComponentDependencies(String vspId, Version version, + Map<String, String> vspComponentIdNameInfoBeforeProcess, + Collection<ComponentDependencyModelEntity> + componentDependenciesBeforeDelete, + Set<String> updatedVspComponentNames, + Map<String, String> updatedVspComponentNameIdInfo) { + for (ComponentDependencyModelEntity componentDependency : componentDependenciesBeforeDelete) { String sourceComponentName = vspComponentIdNameInfoBeforeProcess.get(componentDependency .getSourceComponentId()); String targetComponentName = vspComponentIdNameInfoBeforeProcess.get(componentDependency .getTargetComponentId()); if (updatedVspComponentNames.contains(sourceComponentName) && (updatedVspComponentNames.contains(targetComponentName))) { + ComponentDependencyModelEntity restoredDependency = + new ComponentDependencyModelEntity(vspId, version, null); String newSourceComponentId = updatedVspComponentNameIdInfo.get(sourceComponentName); - componentDependency.setSourceComponentId(newSourceComponentId); + restoredDependency.setSourceComponentId(newSourceComponentId); String newTargetComponentId = updatedVspComponentNameIdInfo.get(targetComponentName); - componentDependency.setTargetComponentId(newTargetComponentId); - componentDependencyModelDao.update(componentDependency); - } else { - componentDependencyModelDao.delete(componentDependency); + restoredDependency.setTargetComponentId(newTargetComponentId); + restoredDependency.setRelation(componentDependency.getRelation()); + componentDependencyModelDao.create(restoredDependency); } } } @@ -395,6 +398,12 @@ public class OrchestrationUtil { return vspComponentIdNameMap; } + public Collection<ComponentDependencyModelEntity> getComponentDependenciesBeforeDelete(String + vspId, Version version) { + return componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, + version, null)); + } + private Map<String, String> getVspComponentNameIdInfo(String vspId, Version version) { Collection<ComponentEntity> updatedVspComponents = diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java index 13728b0c72..41ca8ace9a 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java @@ -35,6 +35,7 @@ import org.openecomp.sdc.logging.messages.AuditMessages; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil; import org.openecomp.sdc.validation.util.ValidationManagerUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; @@ -122,6 +123,8 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp OrchestrationUtil orchestrationUtil = new OrchestrationUtil(); Map<String, String> vspComponentIdNameInfoBeforeProcess = orchestrationUtil.getVspComponentIdNameInfo(vspId, version); + Collection<ComponentDependencyModelEntity> componentDependenciesBeforeDelete = + orchestrationUtil.getComponentDependenciesBeforeDelete(vspId, version); orchestrationUtil .backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQuestionnaire, componentNicsQuestionnaire, componentMibList, processes, processArtifact); @@ -150,7 +153,7 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp orchestrationUtil.retainComponentQuestionnaireData(vspId, version, componentsQuestionnaire, componentNicsQuestionnaire, componentMibList, processes, processArtifact); orchestrationUtil.updateVspComponentDependencies(vspId, version, - vspComponentIdNameInfoBeforeProcess); + vspComponentIdNameInfoBeforeProcess, componentDependenciesBeforeDelete); LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_TRANSLATION_COMPLETED + vspId); uploadFileResponse.addStructureErrors(uploadErrors); |