summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDao.java34
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java31
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java127
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java35
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java16
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java25
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java (renamed from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java)35
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java90
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java53
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java24
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java24
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java42
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java31
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java34
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java323
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java15
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java17
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java158
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java198
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java210
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java195
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java175
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java146
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java13
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java165
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java148
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java193
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java160
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java180
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java265
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java24
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java262
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java41
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java45
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java21
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java45
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java40
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java19
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java40
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java40
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java19
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java23
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java39
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java21
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java20
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java53
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java20
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java78
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java17
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java23
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java91
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java173
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java1028
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/factoryConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java307
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java32
89 files changed, 3134 insertions, 2898 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java
index 8010c40023..bf48bfb40e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java
@@ -22,14 +22,14 @@ package org.openecomp.sdc.vendorsoftwareproduct;
public final class VendorSoftwareProductConstants {
public static final String VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE = "VendorSoftwareProduct";
- public static final String GENERAL_COMPONENT_ID = "General";
public static final String VSP_PACKAGE_ZIP = "VSPPackage.zip";
public static final String CSAR = "CSAR";
public static final String UPLOAD_RAW_DATA = "UPLOAD_RAW_DATA";
public static final String INFORMATION_ARTIFACT_NAME = "VSP_%s_Information.txt";
- public static final String UNSUPPORTED_OPERATION_ERROR =
- "An error has occurred: Unsupported operation for 1707 release.";
+ public static final String UNSUPPORTED_OPERATION_ERROR =
+ "An error has occurred: Unsupported operation for 1707 release.";
public static final String NAME_PATTERN = "^[a-zA-Z0-9_]*$";
+ public static final String VALIDATION_VSP_NAME = "validationOnlyVspName";
public final class UniqueValues {
public static final String VENDOR_SOFTWARE_PRODUCT_NAME = "Vendor Software Product name";
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java
index a980918c36..cbbb97b3c7 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java
@@ -3,10 +3,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao;
import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.versioning.dao.VersionableDao;
-import org.openecomp.sdc.versioning.dao.types.Version;
public interface ComponentDependencyModelDao extends VersionableDao,
BaseDao<ComponentDependencyModelEntity> {
-
- public void deleteAll(String vspId, Version version);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java
index fceac0ac98..3d7c621d67 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java
@@ -31,7 +31,9 @@ public interface OrchestrationTemplateCandidateDao extends VersionableDao {
OrchestrationTemplateCandidateData get(String vspId, Version version);
- void update(String vspId, OrchestrationTemplateCandidateData candidateData);
+ OrchestrationTemplateCandidateData getInfo(String vspId, Version version);
+
+ void update(String vspId, Version version, OrchestrationTemplateCandidateData candidateData);
void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java
index a8c2eb8f7b..4d82ed37af 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java
@@ -20,17 +20,16 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.VersionableDao;
import org.openecomp.sdc.versioning.dao.types.Version;
public interface OrchestrationTemplateDao extends VersionableDao {
- String getValidationData(String vspId, Version version);
+ OrchestrationTemplateEntity getInfo(String vspId, Version version);
- UploadDataEntity getOrchestrationTemplate(String vspId, Version version);
+ OrchestrationTemplateEntity get(String vspId, Version version);
- void updateOrchestrationTemplateData(String vspId, UploadData uploadData);
+ void update(String vspId, Version version, OrchestrationTemplateEntity uploadData);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java
index d12069f480..36fff1e534 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java
@@ -22,17 +22,9 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao;
import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import java.nio.ByteBuffer;
import java.util.List;
public interface PackageInfoDao extends BaseDao<PackageInfo> {
List<PackageInfo> listByCategory(String category, String subCategory);
-
- public void deleteRowTranslateContent(String vspId, Version version);
-
- void updateTranslatedContent(String vspId, Version version, ByteBuffer translateContent);
-
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java
index c6622ef8e5..aea93a352e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java
@@ -12,6 +12,11 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public interface ProcessDao extends VersionableDao, BaseDao<ProcessEntity> {
void deleteAll(ProcessEntity entity);
-
void deleteVspAll(String vspId, Version version);
+
+ ProcessEntity getArtifact(ProcessEntity entity);
+
+ void uploadArtifact(ProcessEntity entity);
+
+ void deleteArtifact(ProcessEntity entity);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDao.java
deleted file mode 100644
index cdc3a770db..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDao.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
-
-import org.openecomp.core.dao.BaseDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.nio.ByteBuffer;
-
-public interface UploadDataDao extends BaseDao<UploadDataEntity> {
-
- void deleteContentDataAndValidationData(String vspId, Version version);
-
- ByteBuffer getContentData(String vspId, Version version);
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
deleted file mode 100644
index 9654551f8f..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
-
-import org.openecomp.core.factory.api.AbstractComponentFactory;
-import org.openecomp.core.factory.api.AbstractFactory;
-
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
-
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
- }
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java
deleted file mode 100644
index 48d1e1606a..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
-
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.versioning.dao.VersionableDao;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.Collection;
-import java.util.List;
-
-
-public interface VendorSoftwareProductDao extends VersionableDao {
-
- //VspDetails getVendorSoftwareProductInfo(VspDetails vspDetails);
-
- Collection<ComponentEntity> listComponents(String vspId, Version version);
-
- Collection<ComponentEntity> listComponentsQuestionnaire(String vspId, Version version);
-
- Collection<ComponentEntity> listComponentsCompositionAndQuestionnaire(String vspId,
- Version version);
-
-
- Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId);
-
- void deleteProcesses(String vspId, Version version, String componentId);
-
- ProcessEntity getProcess(String vspId, Version version, String componentId, String processId);
-
- void createProcess(ProcessEntity processEntity);
-
- void updateProcess(ProcessEntity processEntity);
-
- void deleteProcess(String vspId, Version version, String componentId, String processId);
-
-
- void uploadProcessArtifact(String vspId, Version version, String componentId, String processId,
- byte[] artifact, String artifactFileName);
-
- ProcessEntity getProcessArtifact(String vspId, Version version, String componentId,
- String processId);
-
- void deleteProcessArtifact(String vspId, Version version, String componentId, String processId);
-
-
- Collection<NicEntity> listNicsByVsp(String vspId, Version version);
-
-
- void deleteUploadData(String vspId, Version version);
-
- //void updateVspLatestModificationTime(String vspId, Version version);
- void createComponentDependencyModel(
- List<ComponentDependencyModelEntity> componentDependencyModelEntity, String vspId,
- Version version);
-
- Collection<ComponentDependencyModelEntity> listComponentDependencies(String vspId,Version
- version);
-
- void createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor);
-
- Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version);
-
- DeploymentFlavorEntity getDeploymentFlavor(String vspId, Version version, String
- deploymentFlavorId);
- void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId);
-
-
- void createImage(ImageEntity imageEntity);
-
- Collection<ImageEntity> listImages(String vspId, Version version, String componentId);
-
- ImageEntity getImage(String vspId, Version version, String componentId, String imageId);
-
- Collection<ImageEntity> listImagesByVsp(String vspId, Version version);
-
- void createCompute(ComputeEntity computeEntity);
-
- Collection<ComputeEntity> listComputes(String vspId, Version version, String componentId);
-
- Collection<ComputeEntity> listComputesByVsp(String vspId, Version version);
-
- ComputeEntity getCompute(String vspId, Version version, String componentId, String
- computeFlavorId);
-
- void deleteImage(String vspId, Version version, String componentId, String imageId);
-
- void updateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity);
-
- void updateImage(ImageEntity imageEntity);
-
- void updateImageQuestionnaire(String vspId, Version activeVersion, String componentId,
- String imageId, String questionnaireData);
-
- void updateComputeQuestionnaire(String vspId, Version activeVersion, String componentId,
- String computeId, String questionnaireData);
-
- void updateCompute(ComputeEntity compute);
-
- void deleteCompute(String vspId, Version version, String componentId, String computeFlavorId);
-
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java
deleted file mode 100644
index 32070fe06a..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
-
-import org.openecomp.core.factory.api.AbstractComponentFactory;
-import org.openecomp.core.factory.api.AbstractFactory;
-
-
-public abstract class VendorSoftwareProductDaoFactory extends
- AbstractComponentFactory<VendorSoftwareProductDao> {
-
-
- public static VendorSoftwareProductDaoFactory getInstance() {
- return AbstractFactory.getInstance(VendorSoftwareProductDaoFactory.class);
- }
-
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java
index 0481829ebd..c44a9cd89e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java
@@ -28,15 +28,9 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public interface VendorSoftwareProductInfoDao extends VersionableDao, BaseDao<VspDetails> {
- void updateOldVersionIndication(VspDetails vspDetails);
-
void updateQuestionnaireData(String vspId, Version version, String questionnaireData);
- String getQuestionnaireData(String vspId, Version version);
-
VspQuestionnaireEntity getQuestionnaire(String vspId, Version version);
- void deleteAll(String vspId, Version version);
-
boolean isManual(String vspId, Version version);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java
new file mode 100644
index 0000000000..c9525bfbd8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao;
+
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public interface VspMergeDao {
+
+ boolean isVspModelConflicted(String vspId, Version version);
+
+ void updateVspModelId(String vspId, Version version);
+
+ // TODO: 11/7/2017 change to sdc Resolution
+ void updateVspModelConflictResolution(String vspId, Version version, Resolution resolution);
+
+ void applyVspModelConflictResolution(String vspId, Version version);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java
new file mode 100644
index 0000000000..40ef50a961
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class VspMergeDaoFactory extends AbstractComponentFactory<VspMergeDao> {
+
+ public static VspMergeDaoFactory getInstance() {
+ return AbstractFactory.getInstance(VspMergeDaoFactory.class);
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java
index b20e11077f..57161fbe2e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java
@@ -1,6 +1,10 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
-import com.datastax.driver.mapping.annotations.*;
+import com.datastax.driver.mapping.annotations.ClusteringColumn;
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.Frozen;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java
new file mode 100644
index 0000000000..108fd22c1b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java
@@ -0,0 +1,6 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
+
+public enum OnboardingMethod {
+ NetworkPackage,
+ Manual;
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java
index de70434d2f..7b19e8630c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java
@@ -5,15 +5,18 @@ import java.nio.ByteBuffer;
public class OrchestrationTemplateCandidateData {
private ByteBuffer contentData;
private String filesDataStructure;
-
+ private String fileSuffix;
+ private String fileName;
public OrchestrationTemplateCandidateData() {
}
- public OrchestrationTemplateCandidateData(ByteBuffer contentData,
- String dataStructureJson) {
+ public OrchestrationTemplateCandidateData(ByteBuffer contentData, String dataStructureJson,
+ String fileSuffix, String fileName) {
this.contentData = contentData;
this.filesDataStructure = dataStructureJson;
+ this.fileSuffix = fileSuffix;
+ this.fileName = fileName;
}
public ByteBuffer getContentData() {
@@ -31,4 +34,20 @@ public class OrchestrationTemplateCandidateData {
public void setFilesDataStructure(String filesDataStructure) {
this.filesDataStructure = filesDataStructure;
}
+
+ public String getFileSuffix() {
+ return fileSuffix;
+ }
+
+ public void setFileSuffix(String fileSuffix) {
+ this.fileSuffix = fileSuffix;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java
index 2ade95b025..ef3a4b6012 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,25 +27,22 @@ import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
import java.nio.ByteBuffer;
-public class UploadDataEntity implements VersionableEntity {
- private static final String ENTITY_TYPE = "Vendor Software Product Upload data";
+public class OrchestrationTemplateEntity implements VersionableEntity {
+ private static final String ENTITY_TYPE = "Vendor Software Product Orchestration Template";
private String id;
-
private Version version;
-
+ private String fileSuffix;
+ private String fileName;
private String packageName;
-
private String packageVersion;
-
private String validationData;
-
private ByteBuffer contentData;
- public UploadDataEntity() {
+ public OrchestrationTemplateEntity() {
}
- public UploadDataEntity(String id, Version version) {
+ public OrchestrationTemplateEntity(String id, Version version) {
this.id = id;
this.version = version;
}
@@ -78,6 +75,22 @@ public class UploadDataEntity implements VersionableEntity {
this.version = version;
}
+ public String getFileSuffix() {
+ return fileSuffix;
+ }
+
+ public void setFileSuffix(String fileSuffix) {
+ this.fileSuffix = fileSuffix;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
public String getPackageName() {
return packageName;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java
index ad02883b2e..3403f28ab2 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
import com.datastax.driver.mapping.annotations.Column;
-import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -38,8 +37,7 @@ public class PackageInfo {
private String vspId;
@PartitionKey(value = 1)
- @Frozen
- private Version version;
+ private String version;
@Column(name = "display_name")
private String displayName;
@@ -75,7 +73,7 @@ public class PackageInfo {
public PackageInfo(String packageId, Version version) {
this.vspId = packageId;
- this.version = version;
+ this.version = version.getName();
}
public String getDisplayName() {
@@ -94,11 +92,11 @@ public class PackageInfo {
this.vspDescription = vspDescription;
}
- public Version getVersion() {
+ public String getVersion() {
return version;
}
- public void setVersion(Version version) {
+ public void setVersion(String version) {
this.version = version;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java
deleted file mode 100644
index 071af919a4..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
-
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
-
-import java.nio.ByteBuffer;
-
-
-public class UploadData {
-
- private String id;
-
- private String packageName;
-
- private String packageVersion;
-
- private String validationData;
-
- private ByteBuffer contentData;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-
- public String getPackageVersion() {
- return packageVersion;
- }
-
- public void setPackageVersion(String packageVersion) {
- this.packageVersion = packageVersion;
- }
-
- public String getValidationData() {
- return validationData;
- }
-
- public void setValidationData(String validationData) {
- this.validationData = validationData;
- }
-
- public ValidationStructureList getValidationDataStructure() {
- return validationData == null ? null
- : JsonUtil.json2Object(validationData, ValidationStructureList.class);
- }
-
- public void setValidationDataStructure(ValidationStructureList validationData) {
- this.validationData = validationData == null ? null
- : JsonUtil.object2Json(validationData);
- }
-
- public ByteBuffer getContentData() {
- return contentData;
- }
-
- public void setContentData(ByteBuffer contentData) {
- this.contentData = contentData;
- }
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
index 3f9768b9d7..3ba77ad0ee 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
@@ -20,13 +20,10 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
import java.util.List;
-import java.util.Objects;
public class VspDetails implements VersionableEntity {
@@ -55,18 +52,10 @@ public class VspDetails implements VersionableEntity {
private List<String> featureGroups;
- private String validationData;
-
- private String oldVersion;
-
private Long writetimeMicroSeconds;
private String onboardingMethod;
- private String onboardingOrigin;
-
- private String networkPackageName;
-
public VspDetails() {
}
@@ -183,24 +172,6 @@ public class VspDetails implements VersionableEntity {
this.featureGroups = featureGroups;
}
- public String getValidationData() {
- return validationData;
- }
-
- public void setValidationData(String validationData) {
- this.validationData = validationData;
- }
-
- public ValidationStructureList getValidationDataStructure() {
- return validationData == null ? null
- : JsonUtil.json2Object(validationData, ValidationStructureList.class);
- }
-
- public void setValidationDataStructure(ValidationStructureList validationData) {
- this.validationData = validationData == null ? null
- : JsonUtil.object2Json(validationData);
- }
-
public Long getWritetimeMicroSeconds() {
return this.writetimeMicroSeconds;
}
@@ -213,36 +184,14 @@ public class VspDetails implements VersionableEntity {
return this.oldVersion;
}*/
- public String getOldVersion(){
- return this.oldVersion;
- }
-
- public void setOldVersion(String oldVersion) {
- this.oldVersion = oldVersion;
- }
-
- public String getOnboardingOrigin() {
- return onboardingOrigin;
- }
-
- public void setOnboardingOrigin(String onboardingOrigin) {
- this.onboardingOrigin = onboardingOrigin;
- }
-
public String getOnboardingMethod() {
return onboardingMethod;
}
+
public void setOnboardingMethod(String onboardingMethod) {
this.onboardingMethod = onboardingMethod;
}
- public String getNetworkPackageName() {
- return networkPackageName;
- }
-
- public void setNetworkPackageName(String networkPackageName) {
- this.networkPackageName = networkPackageName;
- }
@Override
public String toString() {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java
index b77012e5cf..ff78fff689 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.services.composition;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
@@ -64,12 +63,10 @@ public interface CompositionEntityDataManager {
void saveComponents(String vspId, Version version, CompositionData compositionData,
Map<String, String> networkIdByName);
- void saveNicsByComponent(String vspId, Version version,
- Map<String, String> networkIdByName, Component component,
- String componentId);
+ void saveNicsByComponent(String vspId, Version version, Map<String, String> networkIdByName,
+ Component component, String componentId);
- Map<String, String> saveNetworks(String vspId, Version version,
- CompositionData compositionData);
+ Map<String, String> saveNetworks(String vspId, Version version, CompositionData compositionData);
NetworkEntity createNetwork(NetworkEntity network);
@@ -77,15 +74,14 @@ public interface CompositionEntityDataManager {
NicEntity createNic(NicEntity nic);
- public ComputeEntity createCompute(ComputeEntity compute);
+ DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor);
- public DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor);
+ ImageEntity createImage(ImageEntity image);
- public ImageEntity createImage(ImageEntity image);
+ void saveComputesFlavorByComponent(String vspId, Version version, Component component,
+ String componentId);
- public void saveComputesFlavorByComponent(String vspId, Version version, Component component, String
- componentId);
- public void saveImagesByComponent(String vspId, Version version, Component component, String
- componentId);
+ void saveImagesByComponent(String vspId, Version version, Component component,
+ String componentId);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
index 6cc639fac0..697dab27e9 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
@@ -45,19 +45,23 @@ public interface CandidateService {
Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData);
OrchestrationTemplateCandidateData createCandidateDataEntity(
- CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest, AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception;
+ CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception;
- void updateCandidateUploadData(OrchestrationTemplateCandidateData uploadData, String
- itemId);
+ void updateCandidateUploadData(String vspId, Version version,
+ OrchestrationTemplateCandidateData uploadData);
Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId,
- Version activeVersion);
+ Version version);
- void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version activeVersion,
- FilesDataStructure fileDataStructure);
+ void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version,
+ FilesDataStructure fileDataStructure);
OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId,
- Version activeVersion);
+ Version version);
+
+ OrchestrationTemplateCandidateData getOrchestrationTemplateCandidateInfo(String vspId,
+ Version version);
Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
OrchestrationTemplateCandidateData candidateDataEntity,
@@ -66,11 +70,11 @@ public interface CandidateService {
Map<String, List<ErrorMessage>> uploadErrors);
byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId,
- OnboardingTypesEnum type)
- throws IOException;
+ OnboardingTypesEnum type) throws IOException;
Optional<ManifestContent> createManifest(VspDetails vspDetails,
- FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles);
+ FileContentHandler fileContentHandler,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles);
String createManifest(VspDetails vspDetails, FilesDataStructure structure);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
index dd303c7bb9..8ed51603aa 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
@@ -28,7 +28,11 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
import java.util.regex.Pattern;
public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
index 41510ecc13..c34e6541e9 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
@@ -57,22 +57,22 @@ public class CandidateEntityBuilder {
public OrchestrationTemplateCandidateData buildCandidateEntityFromZip(
VspDetails vspDetails, byte[] uploadedFileData, FileContentHandler contentMap,
- Map<String, List<ErrorMessage>> uploadErrors, String user) throws Exception {
+ Map<String, List<ErrorMessage>> uploadErrors) throws Exception {
//mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
try (InputStream zipFileManifest = contentMap.getFileContent(SdcCommon.MANIFEST_NAME)) {
HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl();
AnalyzedZipHeatFiles analyzedZipHeatFiles =
- heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
+ heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles);
CandidateDataEntityTo candidateDataEntityTo =
- new CandidateDataEntityTo(vspDetails.getId(), user, uploadedFileData, tree, contentMap,
- vspDetails.getVersion());
+ new CandidateDataEntityTo(vspDetails.getId(), vspDetails.getVersion(), uploadedFileData,
+ tree, contentMap);
candidateDataEntityTo.setErrors(uploadErrors);
OrchestrationTemplateCandidateData candidateDataEntity =
- candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest,
- analyzedZipHeatFiles);
+ candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest,
+ analyzedZipHeatFiles);
MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP Id", vspDetails.getId());
return candidateDataEntity;
@@ -81,7 +81,8 @@ public class CandidateEntityBuilder {
private HeatStructureTree getHeatStructureTree(VspDetails vspDetails,
FileContentHandler contentMap,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException {
+ AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws IOException {
addManifestToFileContentMapIfNotExist(vspDetails, contentMap, analyzedZipHeatFiles);
HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(contentMap);
heatTreeManager.createTree();
@@ -90,21 +91,22 @@ public class CandidateEntityBuilder {
private void addManifestToFileContentMapIfNotExist(VspDetails vspDetails,
FileContentHandler fileContentHandler,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException {
+ AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws IOException {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP Id", vspDetails.getId());
try (InputStream manifest = fileContentHandler.getFileContent(SdcCommon.MANIFEST_NAME)) {
if (Objects.isNull(manifest)) {
Optional<ManifestContent> manifestContentOptional =
- candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
+ candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
if (!manifestContentOptional.isPresent()) {
throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
}
ManifestContent manifestContent = manifestContentOptional.get();
fileContentHandler.addFile(
- SdcCommon.MANIFEST_NAME,
- String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
+ SdcCommon.MANIFEST_NAME,
+ String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
}
} finally {
MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP Id", vspDetails.getId());
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java
index 4ea0a02053..cf6e6f7181 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java
@@ -31,32 +31,26 @@ import java.util.Map;
public class CandidateDataEntityTo {
private final String vspId;
- private final String user;
-// private final UploadFileResponse uploadFileResponse;
- private Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ private final Version version;
private final byte[] uploadedFileData;
private final HeatStructureTree tree;
- private final Version activeVersion;
private final FileContentHandler contentMap;
+ private Map<String, List<ErrorMessage>> errors = new HashMap<>();
/**
* Instantiates a new Candidate data entity to.
- * @param vspId the vsp id
- * @param user the user
- * @param uploadedFileData the uploaded file data
- * @param tree the tree
- * @param contentMap the content map
- * @param activeVersion the active version
+ *
+ * @param vspId the vsp id
+ * @param uploadedFileData the uploaded file data
+ * @param tree the tree
+ * @param contentMap the content map
*/
- public CandidateDataEntityTo(String vspId, String user,
- byte[] uploadedFileData, HeatStructureTree tree,
- FileContentHandler contentMap, Version activeVersion) {
+ public CandidateDataEntityTo(String vspId, Version version, byte[] uploadedFileData,
+ HeatStructureTree tree, FileContentHandler contentMap) {
this.vspId = vspId;
- this.user = user;
- this.errors = errors;
+ this.version = version;
this.uploadedFileData = uploadedFileData;
this.tree = tree;
- this.activeVersion = activeVersion;
this.contentMap = contentMap;
}
@@ -64,10 +58,6 @@ public class CandidateDataEntityTo {
return vspId;
}
- public String getUser() {
- return user;
- }
-
public byte[] getUploadedFileData() {
return uploadedFileData;
}
@@ -76,15 +66,19 @@ public class CandidateDataEntityTo {
return tree;
}
- public Version getActiveVersion() {
- return activeVersion;
+ public Version getVersion() {
+ return version;
}
public FileContentHandler getContentMap() {
return contentMap;
}
- public Map<String, List<ErrorMessage>> getErrors() {return errors;}
+ public Map<String, List<ErrorMessage>> getErrors() {
+ return errors;
+ }
- public void setErrors(Map<String, List<ErrorMessage>> errors) {this.errors = errors;}
+ public void setErrors(Map<String, List<ErrorMessage>> errors) {
+ this.errors = errors;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java
index db22b3a3ee..489557cf08 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java
@@ -26,7 +26,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.co
public class GuestOS {
private String name;
private String tools;
- private int bitSize;
+ private Number bitSize;
public String getName() {
return name;
@@ -44,11 +44,11 @@ public class GuestOS {
this.tools = tools;
}
- public int getBitSize() {
+ public Number getBitSize() {
return bitSize;
}
- public void setBitSize(int bitSize) {
+ public void setBitSize(Number bitSize) {
this.bitSize = bitSize;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java
index fb4aaa61f1..a6a8b406cf 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java
@@ -23,8 +23,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.co
public class VmSizing {
private int numOfCPUs;
private String fileSystemSizeGB;
- private int persistentStorageVolumeSize;
- private int IOOperationsPerSec;
+ private Number persistentStorageVolumeSize;
+ private Number IOOperationsPerSec;
private String cpuOverSubscriptionRatio;
private String memoryRAM;
@@ -44,19 +44,19 @@ public class VmSizing {
this.fileSystemSizeGB = fileSystemSizeGB;
}
- public int getPersistentStorageVolumeSize() {
+ public Number getPersistentStorageVolumeSize() {
return persistentStorageVolumeSize;
}
- public void setPersistentStorageVolumeSize(int persistentStorageVolumeSize) {
+ public void setPersistentStorageVolumeSize(Number persistentStorageVolumeSize) {
this.persistentStorageVolumeSize = persistentStorageVolumeSize;
}
- public int getIOOperationsPerSec() {
+ public Number getIOOperationsPerSec() {
return IOOperationsPerSec;
}
- public void setIOOperationsPerSec(int IOOperationsPerSec) {
+ public void setIOOperationsPerSec(Number IOOperationsPerSec) {
this.IOOperationsPerSec = IOOperationsPerSec;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java
index 09e83b875f..e87c0fd2ce 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java
@@ -26,8 +26,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ge
public class Image {
private String format;
private String providedBy;
- private int bootDiskSizePerVM;
- private int ephemeralDiskSizePerVM;
+ private Number bootDiskSizePerVM;
+ private Number ephemeralDiskSizePerVM;
public String getFormat() {
return format;
@@ -45,19 +45,19 @@ public class Image {
this.providedBy = providedBy;
}
- public int getBootDiskSizePerVM() {
+ public Number getBootDiskSizePerVM() {
return bootDiskSizePerVM;
}
- public void setBootDiskSizePerVM(int bootDiskSizePerVM) {
+ public void setBootDiskSizePerVM(Number bootDiskSizePerVM) {
this.bootDiskSizePerVM = bootDiskSizePerVM;
}
- public int getEphemeralDiskSizePerVM() {
+ public Number getEphemeralDiskSizePerVM() {
return ephemeralDiskSizePerVM;
}
- public void setEphemeralDiskSizePerVM(int ephemeralDiskSizePerVM) {
+ public void setEphemeralDiskSizePerVM(Number ephemeralDiskSizePerVM) {
this.ephemeralDiskSizePerVM = ephemeralDiskSizePerVM;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java
index 4a13829d71..f1f8017689 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java
@@ -24,23 +24,23 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ge
* Created by TALIO on 11/22/2016.
*/
public class Recovery {
- private int pointObjective;
- private int timeObjective;
+ private Number pointObjective;
+ private Number timeObjective;
private String vmProcessFailuresHandling;
- public int getPointObjective() {
+ public Number getPointObjective() {
return pointObjective;
}
- public void setPointObjective(int pointObjective) {
+ public void setPointObjective(Number pointObjective) {
this.pointObjective = pointObjective;
}
- public int getTimeObjective() {
+ public Number getTimeObjective() {
return timeObjective;
}
- public void setTimeObjective(int timeObjective) {
+ public void setTimeObjective(Number timeObjective) {
this.timeObjective = timeObjective;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java
index df5bcb0a02..2357ddfaa1 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java
@@ -27,7 +27,7 @@ public class Backup {
private String backupType;
private String backupSolution;
private String backupNIC;
- private int backupStorageSize;
+ private Number backupStorageSize;
public String getBackupType() {
return backupType;
@@ -53,11 +53,11 @@ public class Backup {
this.backupNIC = backupNIC;
}
- public int getBackupStorageSize() {
+ public Number getBackupStorageSize() {
return backupStorageSize;
}
- public void setBackupStorageSize(int backupStorageSize) {
+ public void setBackupStorageSize(Number backupStorageSize) {
this.backupStorageSize = backupStorageSize;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java
index cbf1fbeb78..1b6453ac86 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java
@@ -24,24 +24,24 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.st
* Created by TALIO on 11/22/2016.
*/
public class LogBackup {
- private int sizeOfLogFiles;
- private int logBackupFrequency;
+ private Number sizeOfLogFiles;
+ private Number logBackupFrequency;
private int logRetentionPeriod;
private String logFileLocation;
- public int getSizeOfLogFiles() {
+ public Number getSizeOfLogFiles() {
return sizeOfLogFiles;
}
- public void setSizeOfLogFiles(int sizeOfLogFiles) {
+ public void setSizeOfLogFiles(Number sizeOfLogFiles) {
this.sizeOfLogFiles = sizeOfLogFiles;
}
- public int getLogBackupFrequency() {
+ public Number getLogBackupFrequency() {
return logBackupFrequency;
}
- public void setLogBackupFrequency(int logBackupFrequency) {
+ public void setLogBackupFrequency(Number logBackupFrequency) {
this.logBackupFrequency = logBackupFrequency;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java
index 3d80224698..1e443277f4 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java
@@ -25,7 +25,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic;
*/
public class PeakAndAvg {
private int peak;
- private int avg;
+ private Number avg;
public int getPeak() {
return peak;
@@ -35,11 +35,11 @@ public class PeakAndAvg {
this.peak = peak;
}
- public int getAvg() {
+ public Number getAvg() {
return avg;
}
- public void setAvg(int avg) {
+ public void setAvg(Number avg) {
this.avg = avg;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java
index 32a9e5a186..4160cba554 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java
@@ -25,7 +25,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic;
*/
public class Sizing {
private String describeQualityOfService;
- private int acceptablePacketLoss;
+ private Number acceptablePacketLoss;
private PacketsAndBytes inflowTrafficPerSecond;
private PacketsAndBytes outflowTrafficPerSecond;
private PacketsAndBytes flowLength;
@@ -39,11 +39,11 @@ public class Sizing {
this.describeQualityOfService = describeQualityOfService;
}
- public int getAcceptablePacketLoss() {
+ public Number getAcceptablePacketLoss() {
return acceptablePacketLoss;
}
- public void setAcceptablePacketLoss(int acceptablePacketLoss) {
+ public void setAcceptablePacketLoss(Number acceptablePacketLoss) {
this.acceptablePacketLoss = acceptablePacketLoss;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java
index 7c073af422..cf48703371 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java
@@ -25,8 +25,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general;
*/
public class StorageDataReplication {
private boolean storageReplicationAcrossRegion;
- private int storageReplicationSize;
- private int storageReplicationFrequency;
+ private Number storageReplicationSize;
+ private Number storageReplicationFrequency;
private String storageReplicationSource;
private String storageReplicationDestination;
@@ -38,19 +38,19 @@ public class StorageDataReplication {
this.storageReplicationDestination = storageReplicationDestination;
}
- public int getStorageReplicationSize() {
+ public Number getStorageReplicationSize() {
return storageReplicationSize;
}
- public void setStorageReplicationSize(int storageReplicationSize) {
+ public void setStorageReplicationSize(Number storageReplicationSize) {
this.storageReplicationSize = storageReplicationSize;
}
- public int getStorageReplicationFrequency() {
+ public Number getStorageReplicationFrequency() {
return storageReplicationFrequency;
}
- public void setStorageReplicationFrequency(int storageReplicationFrequency) {
+ public void setStorageReplicationFrequency(Number storageReplicationFrequency) {
this.storageReplicationFrequency = storageReplicationFrequency;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json
index 52c6119ae6..90160c4b12 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json
@@ -1,8 +1,6 @@
{
- "org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VendorSoftwareProductDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.VspDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VspDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VendorSoftwareProductInfoDaoFactoryImpl",
- "org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.UploadDataDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.OrchestrationTemplateCandidateDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.OrchestrationTemplateDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.PackageInfoDaoFactoryImpl",
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java
index aa611c0bd2..2fcbc1aae8 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java
@@ -52,12 +52,6 @@ public class ComponentDependencyModelDaoCassandraImpl extends CassandraBaseDao
}
@Override
- public void deleteAll(String vspId, Version version) {
- accessor.deleteAll(vspId, versionMapper.toUDT(version));
- }
-
-
- @Override
public void registerVersioning(String versionableEntityType) {
VersionableEntityMetadata metadata = new VersionableEntityMetadata(
mapper.getTableMetadata().getName(),
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java
index 0b29fdab27..41ab1a35ae 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java
@@ -20,10 +20,8 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
-import com.datastax.driver.core.UDTValue;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.UDTMapper;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
import org.openecomp.core.dao.impl.CassandraBaseDao;
@@ -32,9 +30,7 @@ import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -46,8 +42,6 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements
noSqlDb.getMappingManager().mapper(PackageInfo.class);
private static final PackageInfoAccessor accessor =
noSqlDb.getMappingManager().createAccessor(PackageInfoAccessor.class);
- private static final UDTMapper<Version> versionMapper =
- noSqlDb.getMappingManager().udtMapper(Version.class);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@@ -58,7 +52,7 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements
@Override
protected Object[] getKeys(PackageInfo entity) {
- return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion())};
+ return new Object[]{entity.getVspId(), entity.getVersion()};
}
@Override
@@ -68,8 +62,7 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements
@Override
public List<PackageInfo> listByCategory(String category, String subCategory) {
-
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Result<PackageInfo> packages = accessor.listInfo();
List<PackageInfo> filteredPackages = new ArrayList<>();
@@ -86,20 +79,10 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements
filteredPackages.add(packageInfo);
}
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return filteredPackages;
}
- @Override
- public void deleteRowTranslateContent(String vspId, Version version) {
- accessor.deleteRowTranslateContent(vspId, version);
- }
-
- @Override
- public void updateTranslatedContent(String vspId, Version version, ByteBuffer translateContent){
- accessor.updateTranslateContent(translateContent, vspId, versionMapper.toUDT(version));
- }
-
@Accessor
interface PackageInfoAccessor {
@@ -107,13 +90,5 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements
"SELECT vsp_id,version,display_name,vsp_name,vsp_description,vendor_name,category"
+ " ,sub_category, vendor_release,package_checksum,package_type FROM package_details")
Result<PackageInfo> listInfo();
-
- @Query("DELETE TRANSLATE_CONTENT FROM package_details WHERE vsp_id=? and version=?")
- Result<PackageInfo> deleteRowTranslateContent(String vspId, Version version);
-
- @Query("UPDATE package_details set translate_content = ? where vsp_id = ? and version = ?")
- Result<PackageInfo> updateTranslateContent(ByteBuffer translateContent, String vspId,
- UDTValue version);
-
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java
index ada76e790a..0205446ae8 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java
@@ -21,8 +21,8 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ProcessDaoZusammenImpl;
public class ProcessDaoFactoryImpl extends ProcessDaoFactory {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java
deleted file mode 100644
index 0a80b2ae51..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
-
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-
-
-public class VendorSoftwareProductDaoFactoryImpl extends VendorSoftwareProductDaoFactory {
- private static final VendorSoftwareProductDao INSTANCE = new VendorSoftwareProductDaoImpl();
-
- @Override
- public VendorSoftwareProductDao createInterface() {
- return INSTANCE;
- }
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java
deleted file mode 100644
index 832f36b3b9..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
-
-import org.openecomp.core.model.dao.EnrichedServiceArtifactDao;
-import org.openecomp.core.model.dao.EnrichedServiceArtifactDaoFactory;
-import org.openecomp.core.model.dao.EnrichedServiceModelDao;
-import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
-import org.openecomp.core.model.dao.ServiceArtifactDaoFactory;
-import org.openecomp.core.model.dao.ServiceArtifactDaoInter;
-import org.openecomp.core.model.dao.ServiceModelDao;
-import org.openecomp.core.model.dao.ServiceModelDaoFactory;
-import org.openecomp.core.model.dao.ServiceTemplateDaoFactory;
-import org.openecomp.core.model.dao.ServiceTemplateDaoInter;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.nio.ByteBuffer;
-import java.util.Collection;
-import java.util.List;
-
-public class VendorSoftwareProductDaoImpl implements VendorSoftwareProductDao {
-
- private static final VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory
- .getInstance().createInterface();
- private static final PackageInfoDao packageInfoDao =
- PackageInfoDaoFactory.getInstance().createInterface();
- private static final OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao =
- OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface();
- private static final NetworkDao networkDao = NetworkDaoFactory.getInstance().createInterface();
- private static final ComponentDao componentDao =
- ComponentDaoFactory.getInstance().createInterface();
- private static final NicDao nicDao = NicDaoFactory.getInstance().createInterface();
- private static final ProcessDao processDao = ProcessDaoFactory.getInstance().createInterface();
- private static final ServiceArtifactDaoInter
- artifactDao = ServiceArtifactDaoFactory.getInstance().createInterface();
- public static final ServiceTemplateDaoInter
- templateDao = ServiceTemplateDaoFactory.getInstance().createInterface();
- private static final EnrichedServiceArtifactDao enrichArtifactDao =
- EnrichedServiceArtifactDaoFactory.getInstance().createInterface();
- private static final EnrichedServiceModelDao enrichedServiceModelDao =
- EnrichedServiceModelDaoFactory.getInstance().createInterface();
- private static final ServiceModelDao serviceModelDao =
- ServiceModelDaoFactory.getInstance().createInterface();
- private static final ComponentDependencyModelDao componentDependencyModelDao =
- ComponentDependencyModelDaoFactory.getInstance().createInterface();
- private static final DeploymentFlavorDao
- deploymentFlavorDao = DeploymentFlavorDaoFactory.getInstance().createInterface();
- private static final ImageDao imageDao = ImageDaoFactory.getInstance().createInterface();
- private static final ComputeDao computeDao = ComputeDaoFactory.getInstance().createInterface();
-
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- vspInfoDao.registerVersioning(versionableEntityType);
- networkDao.registerVersioning(versionableEntityType);
- componentDao.registerVersioning(versionableEntityType);
- nicDao.registerVersioning(versionableEntityType);
- processDao.registerVersioning(versionableEntityType);
- orchestrationTemplateCandidateDataDao.registerVersioning(versionableEntityType);
- componentDependencyModelDao.registerVersioning(versionableEntityType);
- computeDao.registerVersioning(versionableEntityType);
- deploymentFlavorDao.registerVersioning(versionableEntityType);
- imageDao.registerVersioning(versionableEntityType);
- }
-
- @Override
- public Collection<ComponentEntity> listComponents(String vspId, Version version) {
- return componentDao.list(new ComponentEntity(vspId, version, null));
- }
-
- @Override
- public Collection<ComponentEntity> listComponentsQuestionnaire(String vspId, Version version) {
- return componentDao.listQuestionnaires(vspId, version);
- }
-
- @Override
- public Collection<ComponentEntity> listComponentsCompositionAndQuestionnaire(String vspId,
- Version version) {
- return componentDao.listCompositionAndQuestionnaire(vspId, version);
- }
-
- @Override
- public Collection<ProcessEntity> listProcesses(String vspId, Version version,
- String componentId) {
- return processDao.list(new ProcessEntity(vspId, version, componentId, null));
- }
-
- @Override
- public void deleteProcesses(String vspId, Version version, String componentId) {
- processDao.delete(new ProcessEntity(vspId, version, componentId, null));
- }
-
- @Override
- public ProcessEntity getProcess(String vspId, Version version, String componentId,
- String processId) {
- return processDao.get(new ProcessEntity(vspId, version, componentId, processId));
- }
-
- @Override
- public void createProcess(ProcessEntity processEntity) {
- processDao.create(processEntity);
- }
-
- @Override
- public void updateProcess(ProcessEntity processEntity) {
- ProcessEntity process = processDao.get(new ProcessEntity(processEntity.getVspId(), processEntity.getVersion(),
- processEntity.getComponentId(), processEntity.getId()));
- processEntity.setArtifact(process.getArtifact());
- processEntity.setArtifactName(process.getArtifactName());
- processDao.update(processEntity);
- }
-
- @Override
- public void deleteProcess(String vspId, Version version, String componentId, String processId) {
- processDao.delete(new ProcessEntity(vspId, version, componentId, processId));
- }
-
- @Override
- public void uploadProcessArtifact(String vspId, Version version, String componentId,
- String processId, byte[] artifact, String artifactName) {
- ProcessEntity
- processArtifact = new ProcessEntity(vspId, version, componentId, processId);
- processArtifact = processDao.get(processArtifact);
- processArtifact.setArtifact(ByteBuffer.wrap(artifact));
- processArtifact.setArtifactName(artifactName);
- processDao.update(processArtifact);
- }
-
- @Override
- public ProcessEntity getProcessArtifact(String vspId, Version version, String componentId,
- String processId) {
- return processDao
- .get(new ProcessEntity(vspId, version, componentId, processId));
- }
-
- @Override
- public void deleteProcessArtifact(String vspId, Version version, String componentId,
- String processId) {
- processDao.delete(new ProcessEntity(vspId, version, componentId, processId));
- }
-
- @Override
- public Collection<NicEntity> listNicsByVsp(String vspId, Version version) {
- return nicDao.listByVsp(vspId, version);
- }
-
- @Override
- public void deleteUploadData(String vspId, Version version) {
- networkDao.deleteAll(vspId, version);
- enrichedServiceModelDao.deleteAll(vspId, version);
- serviceModelDao.deleteAll(vspId, version);
- componentDao.deleteAll(vspId, version);
- }
-
- @Override
- public void createComponentDependencyModel(List<ComponentDependencyModelEntity>
- componentDependencyModel, String vspId,
- Version version) {
- componentDependencyModelDao.deleteAll(vspId, version);
- for (ComponentDependencyModelEntity entity : componentDependencyModel) {
- entity.setId(CommonMethods.nextUuId());
- componentDependencyModelDao.create(entity);
- }
- }
-
- @Override
- public Collection<ComponentDependencyModelEntity> listComponentDependencies(String vspId,
- Version version) {
- return componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version,
- null));
- }
-
- @Override
- public void createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor) {
- deploymentFlavorDao.create(deploymentFlavor);
- }
-
- @Override
- public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
- return deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
- }
-
- @Override
- public DeploymentFlavorEntity getDeploymentFlavor(String vspId, Version version,
- String deploymentFlavorId) {
- return deploymentFlavorDao.get(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
- }
-
- @Override
- public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
- deploymentFlavorDao.delete(new DeploymentFlavorEntity(vspId,version,
- deploymentFlavorId));
- }
-
- @Override
- public void createImage(ImageEntity imageEntity) {
- imageDao.create(imageEntity);
- }
-
- @Override
- public Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
- return imageDao.list(new ImageEntity(vspId, version, componentId, null));
- }
-
- @Override
- public ImageEntity getImage(String vspId, Version version, String componentId, String imageId) {
- return imageDao.get(new ImageEntity(vspId, version, componentId, imageId));
- }
-
- @Override
- public Collection<ImageEntity> listImagesByVsp(String vspId, Version version) {
- return imageDao.listByVsp(vspId, version);
- }
-
- @Override
- public void createCompute(ComputeEntity computeEntity) {
- computeDao.create(computeEntity);
- }
-
- @Override
- public Collection<ComputeEntity> listComputes(String vspId, Version version, String componentId) {
- return computeDao.list(new ComputeEntity(vspId, version, componentId, null));
- }
-
- @Override
- public Collection<ComputeEntity> listComputesByVsp(String vspId, Version version) {
- return computeDao.listByVsp(vspId, version);
- }
-
- @Override
- public ComputeEntity getCompute(String vspId, Version version, String componentId,
- String computeFlavorId) {
- return computeDao.get(new ComputeEntity(vspId, version, componentId, computeFlavorId));
- }
-
- @Override
- public void deleteImage(String vspId, Version version, String componentId, String imageId) {
- ImageEntity imageEntity = new ImageEntity(vspId, version, componentId, imageId);
- imageDao.delete(imageEntity);
- }
-
- @Override
- public void updateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity) {
- deploymentFlavorDao.update(deploymentFlavorEntity);
- }
-
- @Override
- public void updateImage(ImageEntity imageEntity) {
- imageDao.update(imageEntity);
- }
-
- @Override
- public void updateImageQuestionnaire(String vspId, Version version, String componentId,
- String imageId, String questionnaireData) {
- imageDao.updateQuestionnaireData(vspId, version, componentId, imageId, questionnaireData);
- }
-
- @Override
- public void updateComputeQuestionnaire(String vspId, Version version, String componentId,
- String computeId, String questionnaireData) {
- computeDao.updateQuestionnaireData(vspId, version, componentId, computeId, questionnaireData);
- }
-
- @Override
- public void updateCompute(ComputeEntity compute) {
- computeDao.update(compute);
- }
-
- @Override
- public void deleteCompute(String vspId, Version version, String componentId, String
- computeFlavorId) {
- computeDao.delete(new ComputeEntity(vspId, version, componentId, computeFlavorId));
- }
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java
index d9b629cc60..fef49c8199 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java
@@ -73,32 +73,17 @@ public class VendorSoftwareProductInfoDaoImpl extends CassandraBaseDao<VspDetail
}
@Override
- public void updateOldVersionIndication(VspDetails vspDetails) {
-
- }
-
- @Override
public void updateQuestionnaireData(String vspId, Version version,
String questionnaireData) {
}
@Override
- public String getQuestionnaireData(String vspId, Version version) {
- return null;
- }
-
- @Override
public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) {
return null;
}
@Override
- public void deleteAll(String vspId, Version version) {
-
- }
-
- @Override
public boolean isManual(String vspId, Version version) {
return false;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java
new file mode 100644
index 0000000000..478681f193
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
+
+
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDaoFactory;
+
+public class VspMergeDaoFactoryImpl extends VspMergeDaoFactory {
+
+ private static final VspMergeDao INSTANCE = new
+ VspMergeDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public VspMergeDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java
new file mode 100644
index 0000000000..2ccc47a651
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java
@@ -0,0 +1,158 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
+public class VspMergeDaoImpl implements VspMergeDao {
+ private static final String VSP_MODEL_NOT_EXIST =
+ "Vsp model does not exist for Vsp %s, version %s.";
+
+ private static VspMergeHintAccessor accessor =
+ NoSqlDbFactory.getInstance().createInterface()
+ .getMappingManager().createAccessor(VspMergeHintAccessor.class);
+
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public VspMergeDaoImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public boolean isVspModelConflicted(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId()));
+
+ return listVspModels(context, elementContext).size() > 1;
+ }
+
+ @Override
+ public void updateVspModelId(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId()));
+
+ String vspModelId = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name())
+ .orElseThrow(() -> new IllegalStateException(
+ String.format(VSP_MODEL_NOT_EXIST, vspId, version.getId())))
+ .getId().getValue();
+
+ updateVspModelId(vspId, version, vspModelId);
+ }
+
+ @Override
+ public void updateVspModelConflictResolution(String vspId, Version version,
+ Resolution resolution) {
+ accessor.updateModelResolution(resolution, getUser(), vspId, version.getId());
+ }
+
+ @Override
+ public void applyVspModelConflictResolution(String vspId, Version version) {
+ //called only when no conflicts
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId()));
+
+ List<ElementInfo> vspModels = listVspModels(context, elementContext);
+ if (vspModels.size() == 1) {
+ updateVspModelId(vspId, version, vspModels.iterator().next().getId().getValue());
+ return;
+ }
+
+ if (vspModels.size() != 2) {
+ return;
+ }
+
+ String user = getUser();
+ Row row = accessor.getModelMergeHint(user, vspId, version.getId()).one();
+ if (row == null) {
+ throw new IllegalStateException(
+ "Vsp model id must exists if its conflict is being resolved");
+ }
+ String resolutionValue = row.getString("model_resolution");
+ if (resolutionValue == null) {
+ return; // model conflict is not resolved yet
+ }
+
+ Resolution resolution = Resolution.valueOf(resolutionValue);
+ String localModelId = row.getString("model_id");
+
+ String chosenModelId =
+ keepOnlyChosenVspModel(context, elementContext, vspModels, resolution, localModelId);
+
+ accessor.updateModelMergeHint(chosenModelId, null, user, vspId, version.getId());
+ }
+
+ private String keepOnlyChosenVspModel(SessionContext context, ElementContext elementContext,
+ List<ElementInfo> vspModels, Resolution resolution,
+ String localModelId) {
+ String newLocalModelId = null;
+ for (ElementInfo vspModel : vspModels) {
+ if (isRedundantModel(vspModel.getId().getValue(), localModelId, resolution)) {
+ zusammenAdaptor
+ .saveElement(context, elementContext, buildElement(vspModel.getId(), Action.DELETE),
+ "Delete Redundant Vsp Model");
+ } else {
+ newLocalModelId = vspModel.getId().getValue();
+ }
+ }
+ return newLocalModelId;
+ }
+
+ private boolean isRedundantModel(String modelId, String localModelId, Resolution resolution) {
+ return resolution == Resolution.THEIRS && modelId.equals(localModelId) ||
+ resolution == Resolution.YOURS && !modelId.equals(localModelId);
+ }
+
+ private List<ElementInfo> listVspModels(SessionContext context, ElementContext elementContext) {
+ return zusammenAdaptor.listElements(context, elementContext, null).stream()
+ .filter(elementInfo -> ElementType.VspModel.name().equals(elementInfo.getInfo().getName()))
+ .collect(Collectors.toList());
+ }
+
+ private void updateVspModelId(String vspId, Version version, String vspModelId) {
+ accessor.updateModelMergeHint(vspModelId, null, getUser(), vspId, version.getId());
+ }
+
+ private String getUser() {
+ return SessionContextProviderFactory.getInstance().createInterface()
+ .get().getUser().getUserId();
+ }
+
+ @Accessor
+ interface VspMergeHintAccessor {
+
+ @Query("UPDATE vsp_merge_hint SET model_id=?, model_resolution=? " +
+ "WHERE space=? AND item_id=? AND version_id=?")
+ void updateModelMergeHint(String vspModelId, Resolution modelResolution, String space,
+ String itemId, String versionId);
+
+ @Query(
+ "UPDATE vsp_merge_hint SET model_resolution=? WHERE space=? AND item_id=? AND version_id=?")
+ void updateModelResolution(Resolution modelResolution, String space, String itemId,
+ String versionId);
+
+ @Query("SELECT model_id, model_resolution FROM vsp_merge_hint " +
+ "WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet getModelMergeHint(String space, String itemId, String versionId);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java
index 517f2fd19b..01be738b56 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java
@@ -1,7 +1,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
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;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -10,10 +9,10 @@ import com.amdocs.zusammen.datatypes.item.ElementContext;
import org.openecomp.core.enrichment.types.MonitoringUploadType;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentMonitoringUploadConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
import java.nio.ByteBuffer;
@@ -21,13 +20,17 @@ import java.util.Collection;
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;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
/**
* @author Avrahamg.
* @since March 21, 2017
*/
public class ComponentArtifactDaoZusammenImpl implements ComponentArtifactDao {
- private static final String ARTIFACT_NAME = "name";
+ private static final String ARTIFACT_NAME = "artifactName";
private ZusammenAdaptor zusammenAdaptor;
@@ -43,28 +46,25 @@ public class ComponentArtifactDaoZusammenImpl implements ComponentArtifactDao {
@Override
public Optional<ComponentMonitoringUploadEntity> getByType(
ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(componentMonitoringUploadEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(componentMonitoringUploadEntity.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ componentMonitoringUploadEntity.getVersion().getId());
+
Optional<Element> mibsElement =
- zusammenAdaptor.getElementByName(context, elementContext, new Id(
- componentMonitoringUploadEntity
- .getComponentId()), StructureElement.Mibs.toString());
+ zusammenAdaptor.getElementByName(context, elementContext,
+ new Id(componentMonitoringUploadEntity.getComponentId()), ElementType.Mibs.toString());
if (mibsElement.isPresent()) {
Optional<Element> monitoringElement = zusammenAdaptor
.getElementByName(context, elementContext, mibsElement.get().getElementId(),
- getMonitoringStructuralElement(componentMonitoringUploadEntity.getType())
- .toString());
+ getMonitoringStructuralElement(componentMonitoringUploadEntity.getType()).toString());
if (monitoringElement.isPresent()) {
- componentMonitoringUploadEntity.setId(monitoringElement.get().getElementId().getValue());
- componentMonitoringUploadEntity
- .setArtifactName(
- (String) monitoringElement.get().getInfo().getProperties().get(ARTIFACT_NAME));
- componentMonitoringUploadEntity
- .setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(monitoringElement.get().getData())));
- return Optional.of(componentMonitoringUploadEntity);
+ ComponentMonitoringUploadEntity entity =
+ new ElementToComponentMonitoringUploadConvertor().convert(monitoringElement.get());
+ entity.setVspId(componentMonitoringUploadEntity.getVspId());
+ entity.setVersion(componentMonitoringUploadEntity.getVersion());
+ entity.setComponentId(componentMonitoringUploadEntity.getComponentId());
+ return Optional.of(entity);
}
}
@@ -75,93 +75,113 @@ public class ComponentArtifactDaoZusammenImpl implements ComponentArtifactDao {
public void create(ComponentMonitoringUploadEntity entity) {
ZusammenElement mibElement = buildMibElement(entity);
- ZusammenElement mibsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Mibs, null);
+ ZusammenElement mibsElement = buildStructuralElement(ElementType.Mibs, null);
- ZusammenElement componentElement = buildComponentElement(entity);
+ ZusammenElement componentElement = buildElement(new Id(entity.getComponentId()), Action.IGNORE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(entity.getVspId(), entity.getVersion().getId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, elementContext,
+ Element savedElement = zusammenAdaptor.saveElement(context, elementContext,
VspZusammenUtil.aggregateElements(componentElement, mibsElement, mibElement),
"Create monitoring upload");
- savedElement.ifPresent(element ->
- entity.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ entity.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void delete(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- ZusammenElement mibElement = new ZusammenElement();
- mibElement.setElementId(new Id(componentMonitoringUploadEntity.getId()));
- mibElement.setAction(Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(componentMonitoringUploadEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ZusammenElement mibElement = buildMibElementStructure(componentMonitoringUploadEntity);
+ mibElement.setElementId(new Id(componentMonitoringUploadEntity.getId()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ componentMonitoringUploadEntity.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, mibElement,
String.format("Delete mib with id %s", componentMonitoringUploadEntity.getId()));
}
+
+
@Override
- public Collection<ComponentMonitoringUploadEntity> list(ComponentMonitoringUploadEntity mib) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(mib.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(mib.getVersion()));
-
- return zusammenAdaptor.listElementsByName(context, elementContext, new Id(mib.getComponentId()),
- StructureElement.Mibs.toString()).stream()
- .map(elementInfo ->
- mapElementInfoToMib(mib.getVspId(), mib.getVersion(), mib.getComponentId(),
- elementInfo))
+ public Collection<ComponentMonitoringUploadEntity> list(
+ ComponentMonitoringUploadEntity mibEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(mibEntity.getVspId(), mibEntity.getVersion().getId());
+ ElementToComponentMonitoringUploadConvertor
+ convertor = new ElementToComponentMonitoringUploadConvertor();
+ return zusammenAdaptor
+ .listElementsByName(context, elementContext, new Id(mibEntity.getComponentId()),
+ ElementType.Mibs.toString()).stream()
+ .map(elementInfo -> convertor.convert(elementInfo))
+ .map(mib -> {
+ mib.setVspId(mibEntity.getVspId());
+ mib.setVersion(mibEntity.getVersion());
+ mib.setComponentId(mibEntity.getComponentId());
+ return mib;
+ })
.collect(Collectors.toList());
}
@Override
public void deleteAll(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- ZusammenElement mibsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Mibs, Action.DELETE);
+ /*ZusammenElement mibsElement =
+ buildStructuralElement(ElementType.Mibs, Action.DELETE);
ZusammenElement componentElement = buildComponentElement(componentMonitoringUploadEntity);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(componentMonitoringUploadEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ componentMonitoringUploadEntity.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext,
- VspZusammenUtil.aggregateElements(componentElement, mibsElement), "Delete mibs");
+ VspaggregateElements(componentElement, mibsElement), "Delete mibs");
+
+*/
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ componentMonitoringUploadEntity.getVersion().getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, new Id(componentMonitoringUploadEntity.getComponentId()), ElementType.Mibs
+ .name());
+
+ if (optionalElement.isPresent()) {
+ Element mibsElement = optionalElement.get();
+ Collection<Element> mibs = mibsElement.getSubElements();
+
+ mibs.forEach(mib -> {
+ ZusammenElement mibZusammenElement = buildElement(mib.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, mibZusammenElement,
+ "Delete mib with id " + mib.getElementId());
+ });
+ }
}
@Override
public Collection<ComponentMonitoringUploadEntity> listArtifacts(
ComponentMonitoringUploadEntity monitoringUploadEntity) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(monitoringUploadEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(monitoringUploadEntity.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(monitoringUploadEntity.getVspId(),
+ monitoringUploadEntity.getVersion().getId());
final Optional<Element> elementByName =
zusammenAdaptor.getElementByName(context, elementContext,
- new Id(monitoringUploadEntity.getComponentId()
- ), StructureElement.Mibs.name());
+ new Id(monitoringUploadEntity.getComponentId()), ElementType.Mibs.name());
- if(!elementByName.isPresent())
+ if (!elementByName.isPresent()) {
return null;
- else {
+ } else {
final Id elementId = elementByName.get().getElementId();
return zusammenAdaptor.listElementData(context, elementContext, elementId).stream()
- .map(element ->
- buildMibEntity(element, monitoringUploadEntity)
- ).collect(Collectors.toList());
+ .map(element -> buildMibEntity(element, monitoringUploadEntity))
+ .collect(Collectors.toList());
}
}
@@ -179,18 +199,10 @@ public class ComponentArtifactDaoZusammenImpl implements ComponentArtifactDao {
return createdMib;
}
- private ZusammenElement buildComponentElement(
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(componentMonitoringUploadEntity.getComponentId()));
- componentElement.setAction(Action.IGNORE);
- return componentElement;
- }
+ private ZusammenElement buildMibElement(
+ ComponentMonitoringUploadEntity monitoringUploadEntity) {
- private ZusammenElement buildMibElement(ComponentMonitoringUploadEntity monitoringUploadEntity) {
- ZusammenElement monitoringElement = VspZusammenUtil
- .buildStructuralElement(getMonitoringStructuralElement(monitoringUploadEntity.getType()),
- Action.UPDATE);
+ ZusammenElement monitoringElement = buildMibElementStructure(monitoringUploadEntity);
monitoringElement.getInfo().getProperties()
.put(ARTIFACT_NAME, monitoringUploadEntity.getArtifactName());
monitoringElement
@@ -198,27 +210,23 @@ public class ComponentArtifactDaoZusammenImpl implements ComponentArtifactDao {
return monitoringElement;
}
- private ComponentMonitoringUploadEntity mapElementInfoToMib(String vspId, Version version,
- String componentId,
- ElementInfo elementInfo) {
- ComponentMonitoringUploadEntity
- monitoringUploadEntity = new ComponentMonitoringUploadEntity(vspId, version, componentId,
- elementInfo.getId().getValue());
- monitoringUploadEntity
- .setArtifactName((String) elementInfo.getInfo().getProperties().get(ARTIFACT_NAME));
- monitoringUploadEntity.setType(MonitoringUploadType.valueOf(elementInfo.getInfo().getName()));
- return monitoringUploadEntity;
+ private ZusammenElement buildMibElementStructure(
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ ZusammenElement monitoringElement =
+ buildStructuralElement(getMonitoringStructuralElement(componentMonitoringUploadEntity.getType()),
+ Action.UPDATE);
+ return monitoringElement;
}
- private StructureElement getMonitoringStructuralElement(MonitoringUploadType type)
+ private ElementType getMonitoringStructuralElement(MonitoringUploadType type)
throws IllegalArgumentException {
switch (type) {
case SNMP_POLL:
- return StructureElement.SNMP_POLL;
+ return ElementType.SNMP_POLL;
case SNMP_TRAP:
- return StructureElement.SNMP_TRAP;
+ return ElementType.SNMP_TRAP;
case VES_EVENTS:
- return StructureElement.VES_EVENTS;
+ return ElementType.VES_EVENTS;
default:
throw new IllegalArgumentException();
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java
index ed6a13d2a1..e658ea55ae 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java
@@ -8,20 +8,26 @@ import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentQuestionnnaireConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
-import java.util.Arrays;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
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;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class ComponentDaoZusammenImpl implements ComponentDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -36,105 +42,97 @@ public class ComponentDaoZusammenImpl implements ComponentDao {
@Override
public Collection<ComponentEntity> list(ComponentEntity component) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(component.getVersion()));
+ SessionContext context = createSessionContext();
- return listComponents(zusammenAdaptor, context, elementContext, component.getVspId(),
- component.getVersion());
+ return listComponents(zusammenAdaptor, context, component.getVspId(), component.getVersion());
}
static Collection<ComponentEntity> listComponents(ZusammenAdaptor zusammenAdaptor,
SessionContext context,
- ElementContext elementContext,
String vspId, Version version) {
- return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.Components.name())
- .stream().map(elementInfo -> mapElementInfoToComponent(vspId, version, elementInfo))
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return new ArrayList<>();
+ }
+
+ ElementToComponentConvertor convertor = new ElementToComponentConvertor();
+ return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(),
+ ElementType.Components.name()).stream()
+ .map(elementInfo -> {
+ ComponentEntity entity = convertor.convert(elementInfo);
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ return entity;
+ })
.collect(Collectors.toList());
}
- private static ComponentEntity mapElementInfoToComponent(String vspId, Version version,
- ElementInfo elementInfo) {
- ComponentEntity componentEntity =
- new ComponentEntity(vspId, version, elementInfo.getId().getValue());
- componentEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return componentEntity;
- }
@Override
public void create(ComponentEntity component) {
ZusammenElement componentElement = componentToZusammen(component, Action.CREATE);
+
ZusammenElement componentsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Components, null);
+ buildStructuralElement(ElementType.Components, Action.IGNORE);
componentsElement.getSubElements().add(componentElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- componentsElement, "Create component");
- savedElement.ifPresent(element ->
- component.setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(componentsElement);
+
+ SessionContext context = createSessionContext();
+ Element savedVspModel = zusammenAdaptor.saveElement(context,
+ new ElementContext(component.getVspId(), component.getVersion().getId()),
+ vspModel, "Create component");
+ component.setId(savedVspModel.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(ComponentEntity component) {
ZusammenElement componentElement = componentToZusammen(component, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
+ SessionContext context = createSessionContext();
zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ new ElementContext(component.getVspId(), component.getVersion().getId()),
componentElement, String.format("Update component with id %s", component.getId()));
}
@Override
public ComponentEntity get(ComponentEntity component) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(component.getVersion()));
+ SessionContext context = createSessionContext();
Optional<Element> element =
- zusammenAdaptor.getElement(context, elementContext, component.getId());
+ zusammenAdaptor.getElement(context,
+ new ElementContext(component.getVspId(), component.getVersion().getId()),
+ component.getId());
if (element.isPresent()) {
- component.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return component;
+ ComponentEntity entity = new ElementToComponentConvertor().convert(element.get());
+ entity.setVspId(component.getVspId());
+ entity.setVersion(component.getVersion());
+ return entity;
}
return null;
}
@Override
public void delete(ComponentEntity component) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(component.getId()));
- componentElement.setAction(Action.DELETE);
+ ZusammenElement componentElement = buildElement(new Id(component.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
+ SessionContext context = createSessionContext();
zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ new ElementContext(component.getVspId(), component.getVersion().getId()),
componentElement, String.format("Delete component with id %s", component.getId()));
}
@Override
public ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
- return getQuestionnaire(context, elementContext,
+ return getQuestionnaire(context, new ElementContext(vspId, version.getId()),
new ComponentEntity(vspId, version, componentId));
}
@@ -142,14 +140,12 @@ public class ComponentDaoZusammenImpl implements ComponentDao {
ComponentEntity component) {
Optional<Element> questionnaireElement = zusammenAdaptor
.getElementByName(context, elementContext, new Id(component.getId()),
- StructureElement.Questionnaire.name());
- return questionnaireElement.map(
- element -> element.getData() == null
- ? null
- : new String(FileUtils.toByteArray(element.getData())))
- .map(questionnaireData -> {
- component.setQuestionnaireData(questionnaireData);
- return component;
+ ElementType.ComponentQuestionnaire.name());
+ return questionnaireElement.map(new ElementToComponentQuestionnnaireConvertor()::convert)
+ .map(entity -> {
+ entity.setVspId(component.getVspId());
+ entity.setVersion(component.getVersion());
+ return entity;
})
.orElse(null);
}
@@ -160,16 +156,11 @@ public class ComponentDaoZusammenImpl implements ComponentDao {
ZusammenElement questionnaireElement =
componentQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setAction(Action.IGNORE);
- componentElement.setElementId(new Id(componentId));
+ ZusammenElement componentElement = buildElement(new Id(componentId), Action.IGNORE);
componentElement.setSubElements(Collections.singletonList(questionnaireElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()),
componentElement, "Update component questionnaire");
}
@@ -181,45 +172,57 @@ public class ComponentDaoZusammenImpl implements ComponentDao {
@Override
public Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId,
Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
Collection<ComponentEntity> components =
- listComponents(zusammenAdaptor, context, elementContext, vspId, version);
+ listComponents(zusammenAdaptor, context, vspId, version);
- components.forEach(component -> getQuestionnaire(context, elementContext, component));
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ components.forEach(component -> component.setQuestionnaireData(
+ getQuestionnaire(context, elementContext, component).getQuestionnaireData()));
return components;
}
@Override
public void deleteAll(String vspId, Version version) {
- ZusammenElement componentsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Components, Action.DELETE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Collection<ElementInfo> vspModelSubs = zusammenAdaptor
+ .listElementsByName(context, elementContext, null, ElementType.VspModel.name());
+
+ Optional<ElementInfo> componentsElement = vspModelSubs.stream()
+ .filter(elementInfo -> elementInfo.getInfo() != null
+ && ElementType.Components.name().equals(elementInfo.getInfo().getName()))
+ .findFirst();
+ if (!componentsElement.isPresent()) {
+ return;
+ }
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- componentsElement, "Delete all components");
+ ZusammenElement components = buildElement(componentsElement.get().getId(), Action.IGNORE);
+ components.setSubElements(componentsElement.get().getSubElements().stream()
+ .map(component -> buildElement(component.getId(), Action.DELETE))
+ .collect(Collectors.toList()));
+
+ zusammenAdaptor.saveElement(context, elementContext, components, "Delete all components");
}
private ZusammenElement componentToZusammen(ComponentEntity component, Action action) {
ZusammenElement componentElement = buildComponentElement(component, action);
- if (action == Action.CREATE) {
- componentElement
- .setSubElements(Arrays.asList(
- componentQuestionnaireToZusammen(component.getQuestionnaireData(), Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Nics, Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Processes, Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Mibs, Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Computes, Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Images, Action.CREATE)));
-
+ if (action == Action.CREATE) {
+ ZusammenElement mibs = buildStructuralElement(ElementType.Mibs, Action.CREATE);
+ mibs.addSubElement(buildStructuralElement(ElementType.SNMP_TRAP, Action.CREATE));
+ mibs.addSubElement(buildStructuralElement(ElementType.VES_EVENTS, Action.CREATE));
+ mibs.addSubElement(buildStructuralElement(ElementType.SNMP_POLL, Action.CREATE));
+
+ componentElement.addSubElement(mibs);
+ componentElement.addSubElement(
+ componentQuestionnaireToZusammen(component.getQuestionnaireData(), Action.CREATE));
+ componentElement.addSubElement(buildStructuralElement(ElementType.Nics, Action.CREATE));
+ componentElement.addSubElement(buildStructuralElement(ElementType.Processes, Action.CREATE));
+ componentElement.addSubElement(buildStructuralElement(ElementType.Computes, Action.CREATE));
+ componentElement.addSubElement(buildStructuralElement(ElementType.Images, Action.CREATE));
}
return componentElement;
}
@@ -227,22 +230,21 @@ public class ComponentDaoZusammenImpl implements ComponentDao {
private ZusammenElement componentQuestionnaireToZusammen(String questionnaireData,
Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ buildStructuralElement(ElementType.ComponentQuestionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
private ZusammenElement buildComponentElement(ComponentEntity component, Action action) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setAction(action);
- if (component.getId() != null) {
- componentElement.setElementId(new Id(component.getId()));
- }
+ ZusammenElement componentElement =
+ buildElement(component.getId() == null ? null : new Id(component.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Component);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Component);
info.addProperty(ElementPropertyName.compositionData.name(), component.getCompositionData());
componentElement.setInfo(info);
componentElement.setData(new ByteArrayInputStream(component.getCompositionData().getBytes()));
return componentElement;
}
+
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java
index e36b6c7743..6741d72bd2 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java
@@ -9,17 +9,23 @@ import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentDependencyModelConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
+import java.util.ArrayList;
import java.util.Collection;
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;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
/**
* Created by ayalaben on 5/16/2017.
*/
@@ -35,19 +41,22 @@ public class ComponentDependencyModelDaoZusammenImpl implements ComponentDepende
}
@Override
- public ComponentDependencyModelEntity get(ComponentDependencyModelEntity entity) {
+ public ComponentDependencyModelEntity get(ComponentDependencyModelEntity dependency) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entity.getVspId()); // entity.getId()?
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(entity.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
Optional<ElementInfo> componentDependencyElement =
- zusammenAdaptor.getElementInfo(context, elementContext, new Id(entity.getId()));
+ zusammenAdaptor.getElementInfo(context, elementContext, new Id(dependency.getId()));
if (componentDependencyElement.isPresent()) {
- addComponentDependencyData(entity, componentDependencyElement.get());
+ ElementToComponentDependencyModelConvertor convertor = new
+ ElementToComponentDependencyModelConvertor();
+
+ ComponentDependencyModelEntity entity = convertor.convert(componentDependencyElement.get());
+ entity.setVspId(dependency.getVspId());
+ entity.setVersion(dependency.getVersion());
return entity;
}
@@ -55,70 +64,52 @@ public class ComponentDependencyModelDaoZusammenImpl implements ComponentDepende
}
@Override
- public void create(ComponentDependencyModelEntity entity) {
+ public void create(ComponentDependencyModelEntity dependency) {
+ ZusammenElement componentDependency =
+ buildComponentDependencyElement(dependency, Action.CREATE);
ZusammenElement componentDependencies =
- VspZusammenUtil.buildStructuralElement(StructureElement.ComponentDependencies, null);
+ buildStructuralElement(ElementType.ComponentDependencies, Action.IGNORE);
+ componentDependencies.addSubElement(componentDependency);
- ZusammenElement componentDependency = buildComponentDependencyElement(entity);
- componentDependency.setAction(Action.CREATE);
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(componentDependencies);
- Id itemId = new Id(entity.getVspId());
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, elementContext,
- VspZusammenUtil.aggregateElements(componentDependencies, componentDependency),
- "Create component dependency model");
+ Element compDepsSavedElement = zusammenAdaptor
+ .saveElement(context, elementContext, vspModel, "Create component dependency model");
- savedElement.ifPresent(element ->
- entity.setId(element.getSubElements().iterator().next().getElementId().getValue()));
- }
-
- @Override
- public void update(ComponentDependencyModelEntity entity) {
- ZusammenElement componentDependencyElement = buildComponentDependencyElement(entity);
- componentDependencyElement.setAction(Action.UPDATE);
-
- Id itemId = new Id(entity.getVspId());
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
-
- zusammenAdaptor.saveElement(context, elementContext,
- componentDependencyElement,
- String.format("Update component dependency model with id %s", entity.getId()));
+ dependency.setId(compDepsSavedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
- public void delete(ComponentDependencyModelEntity entity) {
- ZusammenElement componentDependencyElement = new ZusammenElement();
- componentDependencyElement.setElementId(new Id(entity.getId()));
- componentDependencyElement.setAction(Action.DELETE);
+ public void update(ComponentDependencyModelEntity dependency) {
+ ZusammenElement componentDependencyElement =
+ buildComponentDependencyElement(dependency, Action.UPDATE);
- Id itemId = new Id(entity.getVspId());
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
-
- zusammenAdaptor.saveElement(context, elementContext,
- componentDependencyElement,
- String.format("Delete component dependency model with id %s", entity.getId()));
+ zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement,
+ String.format("Update component dependency model with id %s", dependency.getId()));
}
@Override
- public void deleteAll(String vspId, Version version) {
- ZusammenElement componentDependenciesElement =
- VspZusammenUtil
- .buildStructuralElement(StructureElement.ComponentDependencies, Action.DELETE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- componentDependenciesElement, "Delete all component dependencies");
+ public void delete(ComponentDependencyModelEntity dependency) {
+ ZusammenElement componentDependencyElement =
+ buildElement(new Id(dependency.getId()), Action.DELETE);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
+
+ zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement,
+ String.format("Delete component dependency model with id %s", dependency.getId()));
}
@Override
@@ -127,75 +118,55 @@ public class ComponentDependencyModelDaoZusammenImpl implements ComponentDepende
}
@Override
- public Collection<ComponentDependencyModelEntity> list(ComponentDependencyModelEntity entity) {
-
- Id itemId = new Id(entity.getVspId());
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(entity.getVersion()));
-
- return zusammenAdaptor.listElementsByName(context, elementContext,
- null, StructureElement.ComponentDependencies.name())
- .stream().map(elementInfo -> mapElementInfoToComponentDependencyModel(entity.getVspId(),
- entity.getVersion(), elementInfo))
- .collect(Collectors.toList());
- }
+ public Collection<ComponentDependencyModelEntity> list(
+ ComponentDependencyModelEntity dependency) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
+
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return new ArrayList<>();
+ }
- private static ComponentDependencyModelEntity mapElementInfoToComponentDependencyModel(
- String vspId, Version version,
- ElementInfo elementInfo) {
- ComponentDependencyModelEntity componentDependencyModelEntity =
- new ComponentDependencyModelEntity(vspId, version, elementInfo.getId().getValue());
- componentDependencyModelEntity.setSourceComponentId(elementInfo.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name()));
- componentDependencyModelEntity.setTargetComponentId(elementInfo.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name()));
- componentDependencyModelEntity.setRelation(elementInfo.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.relation.name()));
-
- return componentDependencyModelEntity;
+ ElementToComponentDependencyModelConvertor convertor =
+ new ElementToComponentDependencyModelConvertor();
+ return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(),
+ ElementType.ComponentDependencies.name()).stream()
+ .map(elementInfo -> {
+ ComponentDependencyModelEntity entity = convertor.convert(elementInfo);
+ entity.setVspId(dependency.getVspId());
+ entity.setVersion(dependency.getVersion());
+ entity.setId(elementInfo.getId().getValue());
+ return entity;
+ })
+ .collect(Collectors.toList());
}
-
- private ZusammenElement buildComponentDependencyElement(ComponentDependencyModelEntity entity) {
- ZusammenElement componentDependencyElement = new ZusammenElement();
-
- if (entity.getId() != null) {
- componentDependencyElement.setElementId(new Id(entity.getId()));
- }
+ private ZusammenElement buildComponentDependencyElement(ComponentDependencyModelEntity compDep,
+ Action action) {
+ ZusammenElement componentDependencyElement =
+ buildElement(compDep.getId() == null ? null : new Id(compDep.getId()), action);
Info info = new Info();
- info.addProperty(ComponentDependencyModelPropertyName.id.name(), entity.getId());
- info.addProperty(ComponentDependencyModelPropertyName.relation.name(), entity.getRelation());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.ComponentDependency);
+ //info.addProperty(ComponentDependencyModelPropertyName.id.name(), entity.getId());
+ info.addProperty(ComponentDependencyModelPropertyName.relation.name(), compDep.getRelation());
info.addProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name(),
- entity.getSourceComponentId());
+ compDep.getSourceComponentId());
info.addProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name(),
- entity.getTargetComponentId());
+ compDep.getTargetComponentId());
componentDependencyElement.setInfo(info);
return componentDependencyElement;
}
- private void addComponentDependencyData(ComponentDependencyModelEntity componentDependency,
- ElementInfo componentDependencyElement) {
- componentDependency.setId(componentDependencyElement.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.id.name()));
- componentDependency.setRelation(componentDependencyElement.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.id.name()));
- componentDependency.setSourceComponentId(componentDependencyElement.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name()));
- componentDependency.setTargetComponentId(componentDependencyElement.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name()));
- }
-
-
private enum ComponentDependencyModelPropertyName {
id,
relation,
sourcecomponent_id,
targetcomponent_id,
}
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java
index aa4bab67df..0f92c95294 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java
@@ -2,7 +2,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
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;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -11,11 +10,13 @@ import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComputeConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
import java.util.Collection;
@@ -23,6 +24,10 @@ import java.util.Collections;
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;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class ComputeDaoZusammenImpl implements ComputeDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -37,83 +42,78 @@ public class ComputeDaoZusammenImpl implements ComputeDao {
@Override
public Collection<ComputeEntity> list(ComputeEntity compute) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(compute.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
return listComputes(context, elementContext, compute);
}
private Collection<ComputeEntity> listComputes(SessionContext context,
- ElementContext elementContext, ComputeEntity compute) {
+ ElementContext elementContext,
+ ComputeEntity compute) {
+ ElementToComputeConvertor convertor = new ElementToComputeConvertor();
return zusammenAdaptor
.listElementsByName(context, elementContext, new Id(compute.getComponentId()),
- StructureElement.Computes.name())
- .stream().map(elementInfo -> mapElementInfoToCompute(
- compute.getVspId(), compute.getVersion(), compute.getComponentId(), elementInfo))
+ ElementType.Computes.name())
+ .stream().map(elementInfo -> convertor.convert(elementInfo))
+ .map(computeEntity -> {
+ computeEntity.setComponentId(compute.getComponentId());
+ computeEntity.setVspId(compute.getVspId());
+ computeEntity.setVersion(compute.getVersion());
+ return computeEntity;
+ })
.collect(Collectors.toList());
}
- private static ComputeEntity mapElementInfoToCompute(String vspId, Version version,
- String componentId, ElementInfo elementInfo) {
- ComputeEntity componentEntity =
- new ComputeEntity(vspId, version, componentId, elementInfo.getId().getValue());
- componentEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return componentEntity;
- }
-
@Override
public void create(ComputeEntity compute) {
ZusammenElement computeElement = computeToZusammen(compute, Action.CREATE);
- ZusammenElement computesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Computes, null);
+ ZusammenElement computesElement = buildStructuralElement(ElementType.Computes, Action.IGNORE);
computesElement.setSubElements(Collections.singletonList(computeElement));
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(compute.getComponentId()));
- componentElement.setAction(Action.IGNORE);
+ ZusammenElement componentElement =
+ buildElement(new Id(compute.getComponentId()), Action.IGNORE);
componentElement.setSubElements(Collections.singletonList(computesElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create compute");
- savedElement.ifPresent(element ->
- compute.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ compute.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(ComputeEntity compute) {
ZusammenElement computeElement = computeToZusammen(compute, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, computeElement,
String.format("Update compute with id %s", compute.getId()));
}
@Override
public ComputeEntity get(ComputeEntity compute) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(compute.getVersion()));
- Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, compute.getId());
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
+ Optional<Element> element =
+ zusammenAdaptor.getElement(context, elementContext, compute.getId());
if (element.isPresent()) {
- compute.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return compute;
+
+ ElementToComputeConvertor convertor = new ElementToComputeConvertor();
+ ComputeEntity entity = convertor.convert(element.get());
+ entity.setVspId(compute.getVspId());
+ entity.setVersion(compute.getVersion());
+ entity.setComponentId(compute.getComponentId());
+ return entity;
} else {
return null;
}
@@ -121,36 +121,30 @@ public class ComputeDaoZusammenImpl implements ComputeDao {
@Override
public void delete(ComputeEntity compute) {
- ZusammenElement computeElement = new ZusammenElement();
- computeElement.setElementId(new Id(compute.getId()));
- computeElement.setAction(Action.DELETE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ZusammenElement computeElement = buildElement(new Id(compute.getId()), Action.DELETE);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, computeElement,
String.format("Delete compute with id %s", compute.getId()));
}
@Override
public ComputeEntity getQuestionnaireData(String vspId, Version version, String componentId,
- String computeId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ String computeId) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
return getQuestionnaire(context, elementContext,
new ComputeEntity(vspId, version, componentId, computeId));
}
private ComputeEntity getQuestionnaire(SessionContext context, ElementContext elementContext,
- ComputeEntity compute) {
+ ComputeEntity compute) {
Optional<Element> questionnaireElement = zusammenAdaptor
.getElementByName(context, elementContext, new Id(compute.getId()),
- StructureElement.Questionnaire.name());
+ ElementType.ComputeQuestionnaire.name());
return questionnaireElement.map(
element -> element.getData() == null
? null
@@ -168,29 +162,22 @@ public class ComputeDaoZusammenImpl implements ComputeDao {
ZusammenElement questionnaireElement =
computeQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
- ZusammenElement computeElement = new ZusammenElement();
- computeElement.setAction(Action.IGNORE);
- computeElement.setElementId(new Id(computeId));
+ ZusammenElement computeElement = buildElement(new Id(computeId), Action.IGNORE);
computeElement.setSubElements(Collections.singletonList(questionnaireElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, computeElement, "Update compute "
+ "questionnaire");
}
@Override
public Collection<ComputeEntity> listByVsp(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
Collection<ComponentEntity> components = ComponentDaoZusammenImpl
- .listComponents(zusammenAdaptor, context, elementContext, vspId, version);
+ .listComponents(zusammenAdaptor, context, vspId, version);
return components.stream()
.map(component ->
@@ -204,15 +191,23 @@ public class ComputeDaoZusammenImpl implements ComputeDao {
@Override
public void deleteAll(String vspId, Version version) {
- ZusammenElement computesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Computes, Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- computesElement, "Delete all computes");
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, null, ElementType.Computes.name());
+
+ if (optionalElement.isPresent()) {
+ Element computesElement = optionalElement.get();
+ Collection<Element> computes = computesElement.getSubElements();
+
+ computes.forEach(compute -> {
+ ZusammenElement computeElement = buildElement(compute.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, computeElement,
+ "Delete compute with id " + compute.getElementId());
+ });
+ }
}
private ZusammenElement computeToZusammen(ComputeEntity compute, Action action) {
@@ -225,27 +220,21 @@ public class ComputeDaoZusammenImpl implements ComputeDao {
}
private ZusammenElement computeQuestionnaireToZusammen(String questionnaireData,
- Action action) {
+ Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ buildStructuralElement(ElementType.ComputeQuestionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
private ZusammenElement buildComputeElement(ComputeEntity compute, Action action) {
- ZusammenElement computeElement = new ZusammenElement();
- computeElement.setAction(action);
- if (compute.getId() != null) {
- computeElement.setElementId(new Id(compute.getId()));
- }
+ ZusammenElement computeElement =
+ buildElement(compute.getId() == null ? null : new Id(compute.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Compute);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Compute);
info.addProperty(ElementPropertyName.compositionData.name(), compute.getCompositionData());
computeElement.setInfo(info);
computeElement.setData(new ByteArrayInputStream(compute.getCompositionData().getBytes()));
return computeElement;
}
-
-
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java
index 947bcc27e5..17580b293b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java
@@ -1,7 +1,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
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;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -10,16 +9,22 @@ import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToDeploymentFlavorConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
import java.util.Collection;
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;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class DeploymentFlavorDaoZusammenImpl implements DeploymentFlavorDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -34,52 +39,49 @@ public class DeploymentFlavorDaoZusammenImpl implements DeploymentFlavorDao {
@Override
public Collection<DeploymentFlavorEntity> list(DeploymentFlavorEntity deploymentFlavor) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(deploymentFlavor.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId());
- return listDeploymentFlavor(zusammenAdaptor, context, elementContext, deploymentFlavor.getVspId(),
+ return listDeploymentFlavor(zusammenAdaptor, context, elementContext,
+ deploymentFlavor.getVspId(),
deploymentFlavor.getVersion());
}
- static Collection<DeploymentFlavorEntity> listDeploymentFlavor(ZusammenAdaptor zusammenAdaptor,
- SessionContext context,
- ElementContext elementContext,
- String vspId, Version version) {
+ private static Collection<DeploymentFlavorEntity> listDeploymentFlavor(
+ ZusammenAdaptor zusammenAdaptor,
+ SessionContext context,
+ ElementContext elementContext,
+ String vspId, Version version) {
+ ElementToDeploymentFlavorConvertor convertor = new ElementToDeploymentFlavorConvertor();
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.DeploymentFlavors.name())
- .stream().map(elementInfo -> mapElementInfoToComponent(vspId, version, elementInfo))
+ .listElementsByName(context, elementContext, null,
+ ElementType.DeploymentFlavors.name())
+ .stream().map(elementInfo -> {
+ DeploymentFlavorEntity entity = convertor.convert(
+ elementInfo);
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ return entity;
+ })
.collect(Collectors.toList());
}
- private static DeploymentFlavorEntity mapElementInfoToComponent(String vspId, Version version,
- ElementInfo elementInfo) {
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vspId, version, elementInfo.getId().getValue());
- deploymentFlavorEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return deploymentFlavorEntity;
- }
@Override
public void create(DeploymentFlavorEntity deploymentFlavor) {
ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor,
Action.CREATE);
ZusammenElement deploymentFlavorElements =
- VspZusammenUtil.buildStructuralElement(StructureElement.DeploymentFlavors, null);
+ buildStructuralElement(ElementType.DeploymentFlavors, Action.IGNORE);
deploymentFlavorElements.getSubElements().add(deploymentFlavorElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ SessionContext context = createSessionContext();
+ Element savedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()),
deploymentFlavorElements, "Create deloymentFlavor");
- savedElement.ifPresent(element ->
- deploymentFlavor.setId(element.getSubElements().iterator().next().getElementId()
- .getValue()));
+ deploymentFlavor.setId(savedElement.getSubElements().iterator().next().getElementId()
+ .getValue());
}
@Override
@@ -87,87 +89,83 @@ public class DeploymentFlavorDaoZusammenImpl implements DeploymentFlavorDao {
ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor,
Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
+ SessionContext context = createSessionContext();
zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()),
deploymentFlavorElement, String.format("Update deloymentFlavor with id %s",
deploymentFlavor.getId()));
}
@Override
public DeploymentFlavorEntity get(DeploymentFlavorEntity deploymentFlavor) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(deploymentFlavor.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId());
Optional<Element> element =
zusammenAdaptor.getElement(context, elementContext, deploymentFlavor.getId());
if (element.isPresent()) {
+ ElementToDeploymentFlavorConvertor convertor = new ElementToDeploymentFlavorConvertor();
+ DeploymentFlavorEntity entity = convertor.convert(element.get());
deploymentFlavor.setCompositionData(new String(FileUtils.toByteArray(element.get()
.getData())));
- return deploymentFlavor;
+ entity.setVspId(deploymentFlavor.getVspId());
+ entity.setVersion(deploymentFlavor.getVersion());
+ return entity;
}
return null;
}
@Override
public void delete(DeploymentFlavorEntity deploymentFlavor) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(deploymentFlavor.getId()));
- componentElement.setAction(Action.DELETE);
+ ZusammenElement componentElement =
+ buildElement(new Id(deploymentFlavor.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
+ SessionContext context = createSessionContext();
zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()),
componentElement, String.format("Delete deloymentFlavor with id %s",
deploymentFlavor.getId()));
}
@Override
public void deleteAll(String vspId, Version version) {
- ZusammenElement deploymentFlavorsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.DeploymentFlavors, Action.DELETE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- deploymentFlavorsElement, "Delete all deploymentFlavors");
- }
-
- private ZusammenElement deploymentFlavorToZusammen(DeploymentFlavorEntity deploymentFlavor,
- Action action) {
- ZusammenElement deploymentFlavorElement = buildDeploymentFlavorElement
- (deploymentFlavor, action);
-
- return deploymentFlavorElement;
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, null, ElementType.DeploymentFlavors.name());
+
+ if (optionalElement.isPresent()) {
+ Element deploymentFlavorsElement = optionalElement.get();
+ Collection<Element> deploymentFlavors = deploymentFlavorsElement.getSubElements();
+
+ deploymentFlavors.forEach(deplymentFlavor -> {
+ ZusammenElement deplymentFlavorZusammenElement =
+ buildElement(deplymentFlavor.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context,
+ elementContext, deplymentFlavorZusammenElement, " Delete Deplyment Flavor with id "
+ + deplymentFlavor.getElementId());
+ });
+ }
}
/*private ZusammenElement deplymentFlavorQuestionnaireToZusammen(String questionnaireData,
Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ VspbuildStructuralElement(ElementType.Questionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}*/
- private ZusammenElement buildDeploymentFlavorElement(DeploymentFlavorEntity deploymentFlavor,
- Action action) {
- ZusammenElement deploymentFlavorElement = new ZusammenElement();
- deploymentFlavorElement.setAction(action);
- if (deploymentFlavor.getId() != null) {
- deploymentFlavorElement.setElementId(new Id(deploymentFlavor.getId()));
- }
+ private ZusammenElement deploymentFlavorToZusammen(DeploymentFlavorEntity deploymentFlavor,
+ Action action) {
+ ZusammenElement deploymentFlavorElement =
+ buildElement(deploymentFlavor.getId() == null ? null : new Id(deploymentFlavor.getId()),
+ action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.DeploymentFlavor);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.DeploymentFlavor);
info.addProperty(ElementPropertyName.compositionData.name(), deploymentFlavor
.getCompositionData());
deploymentFlavorElement.setInfo(info);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java
deleted file mode 100644
index 9ca0bf721a..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
-
-public enum ElementPropertyName {
- type,
- compositionData
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java
deleted file mode 100644
index 9da0780f73..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
-
-public enum ElementType {
- Network,
- Component,
- Nic,
- Process,
- Mib,
- LKG,
- Compute,
- DeploymentFlavor,
- Image
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java
index d913b18956..24ca072b23 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java
@@ -2,7 +2,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
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;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -11,11 +10,13 @@ import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToImageConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
import java.util.Collection;
@@ -23,6 +24,10 @@ import java.util.Collections;
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;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class ImageDaoZusammenImpl implements ImageDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -37,83 +42,76 @@ public class ImageDaoZusammenImpl implements ImageDao {
@Override
public Collection<ImageEntity> list(ImageEntity image) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(image.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
return listImages(context, elementContext, image);
}
private Collection<ImageEntity> listImages(SessionContext context,
- ElementContext elementContext, ImageEntity image) {
+ ElementContext elementContext, ImageEntity image) {
+ ElementToImageConvertor convertor = new ElementToImageConvertor();
return zusammenAdaptor
.listElementsByName(context, elementContext, new Id(image.getComponentId()),
- StructureElement.Images.name())
- .stream().map(elementInfo -> mapElementInfoToImage(
- image.getVspId(), image.getVersion(), image.getComponentId(), elementInfo))
+ ElementType.Images.name())
+ .stream().map(convertor::convert)
+ .map(imageEntity -> {
+ imageEntity.setComponentId(image.getComponentId());
+ imageEntity.setVspId(image.getVspId());
+ imageEntity.setVersion(image.getVersion());
+ return imageEntity;
+ })
.collect(Collectors.toList());
}
- private static ImageEntity mapElementInfoToImage(String vspId, Version version,
- String componentId, ElementInfo elementInfo) {
- ImageEntity imageEntity =
- new ImageEntity(vspId, version, componentId, elementInfo.getId().getValue());
- imageEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return imageEntity;
- }
-
@Override
public void create(ImageEntity image) {
ZusammenElement imageElement = imageToZusammen(image, Action.CREATE);
ZusammenElement imagesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Images, null);
+ buildStructuralElement(ElementType.Images, Action.IGNORE);
imagesElement.setSubElements(Collections.singletonList(imageElement));
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(image.getComponentId()));
- componentElement.setAction(Action.IGNORE);
+ ZusammenElement componentElement = buildElement(new Id(image.getComponentId()), Action.IGNORE);
componentElement.setSubElements(Collections.singletonList(imagesElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create image");
- savedElement.ifPresent(element ->
- image.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ image.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(ImageEntity image) {
ZusammenElement imageElement = imageToZusammen(image, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, imageElement,
String.format("Update image with id %s", image.getId()));
}
@Override
public ImageEntity get(ImageEntity image) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(image.getVersion()));
+ SessionContext context = createSessionContext();
+
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, image.getId());
if (element.isPresent()) {
- image.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return image;
+ ElementToImageConvertor convertor = new ElementToImageConvertor();
+ ImageEntity entity = convertor.convert(element.get());
+ entity.setComponentId(image.getComponentId());
+ entity.setVspId(image.getVspId());
+ entity.setVersion(image.getVersion());
+ return entity;
} else {
return null;
}
@@ -121,41 +119,41 @@ public class ImageDaoZusammenImpl implements ImageDao {
@Override
public void delete(ImageEntity image) {
- ZusammenElement imageElement = new ZusammenElement();
- imageElement.setElementId(new Id(image.getId()));
- imageElement.setAction(Action.DELETE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ZusammenElement imageElement = buildElement(new Id(image.getId()), Action.DELETE);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, imageElement,
String.format("Delete image with id %s", image.getId()));
}
@Override
public void deleteByVspId(String vspId, Version version) {
- ZusammenElement imagesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Images, Action.DELETE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- imagesElement, String.format("Delete all images with vsp id %s", vspId));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<Element> elementOptional = zusammenAdaptor.getElementByName(context, elementContext,
+ null, ElementType.Images.name());
+
+ if (elementOptional.isPresent()) {
+ Element ImagesElement = elementOptional.get();
+ Collection<Element> Images = ImagesElement.getSubElements();
+ Images.forEach(image -> {
+ ZusammenElement imageZusammenElement = buildElement(image.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, imageZusammenElement, "Delete image " +
+ "with id " + image.getElementId());
+ });
+ }
}
@Override
public Collection<ImageEntity> listByVsp(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
Collection<ComponentEntity> components = ComponentDaoZusammenImpl
- .listComponents(zusammenAdaptor, context, elementContext, vspId, version);
+ .listComponents(zusammenAdaptor, context, vspId, version);
return components.stream()
.map(component ->
@@ -169,12 +167,9 @@ public class ImageDaoZusammenImpl implements ImageDao {
@Override
public ImageEntity getQuestionnaireData(String vspId, Version version, String componentId,
- String imageId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ String imageId) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
return getQuestionnaire(context, elementContext,
new ImageEntity(vspId, version, componentId, imageId));
@@ -184,7 +179,7 @@ public class ImageDaoZusammenImpl implements ImageDao {
ImageEntity image) {
Optional<Element> questionnaireElement = zusammenAdaptor
.getElementByName(context, elementContext, new Id(image.getId()),
- StructureElement.Questionnaire.name());
+ ElementType.ImageQuestionnaire.name());
return questionnaireElement.map(
element -> element.getData() == null
? null
@@ -202,21 +197,16 @@ public class ImageDaoZusammenImpl implements ImageDao {
ZusammenElement questionnaireElement =
imageQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
- ZusammenElement imageElement = new ZusammenElement();
- imageElement.setAction(Action.IGNORE);
- imageElement.setElementId(new Id(imageId));
+ ZusammenElement imageElement = buildElement(new Id(imageId), Action.IGNORE);
imageElement.setSubElements(Collections.singletonList(questionnaireElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, imageElement, "Update image "
+ "questionnaire");
}
-
private ZusammenElement imageToZusammen(ImageEntity image, Action action) {
ZusammenElement imageElement = buildImageElement(image, action);
if (action == Action.CREATE) {
@@ -227,21 +217,18 @@ public class ImageDaoZusammenImpl implements ImageDao {
}
private ZusammenElement imageQuestionnaireToZusammen(String questionnaireData,
- Action action) {
+ Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ buildStructuralElement(ElementType.ImageQuestionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
private ZusammenElement buildImageElement(ImageEntity image, Action action) {
- ZusammenElement imageElement = new ZusammenElement();
- imageElement.setAction(action);
- if (image.getId() != null) {
- imageElement.setElementId(new Id(image.getId()));
- }
+ ZusammenElement imageElement =
+ buildElement(image.getId() == null ? null : new Id(image.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Image);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Image);
info.addProperty(ElementPropertyName.compositionData.name(), image.getCompositionData());
imageElement.setInfo(info);
imageElement.setData(new ByteArrayInputStream(image.getCompositionData().getBytes()));
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java
index b22c9f32ed..bccea3a85c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java
@@ -8,19 +8,25 @@ import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNetworkConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
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;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class NetworkDaoZusammenImpl implements NetworkDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -36,71 +42,70 @@ public class NetworkDaoZusammenImpl implements NetworkDao {
@Override
public Collection<NetworkEntity> list(NetworkEntity network) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(network.getVersion()));
-
- return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.Networks.name())
- .stream().map(elementInfo ->
- mapElementInfoToNetwork(network.getVspId(), network.getVersion(), elementInfo))
- .collect(Collectors.toList());
- }
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(network.getVspId(), network.getVersion().getId());
+
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return new ArrayList<>();
+ }
- private NetworkEntity mapElementInfoToNetwork(String vspId, Version version,
- ElementInfo elementInfo) {
- NetworkEntity networkEntity =
- new NetworkEntity(vspId, version, elementInfo.getId().getValue());
- networkEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return networkEntity;
+ ElementToNetworkConvertor convertor = new ElementToNetworkConvertor();
+ return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(),
+ ElementType.Networks.name()).stream()
+ .map(convertor::convert)
+ .map(entity -> {
+ entity.setVspId(network.getVspId());
+ entity.setVersion(network.getVersion());
+ return entity;
+ })
+ .collect(Collectors.toList());
}
@Override
public void create(NetworkEntity network) {
ZusammenElement networkElement = buildNetworkElement(network, Action.CREATE);
- ZusammenElement networksElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Networks, null);
+
+ ZusammenElement networksElement = buildStructuralElement(ElementType.Networks, Action.IGNORE);
networksElement.setSubElements(Collections.singletonList(networkElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- Optional<Element> savedElement =
- zusammenAdaptor.saveElement(context, elementContext, networksElement, "Create network");
- savedElement.ifPresent(element ->
- network.setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(networksElement);
+
+ SessionContext context = createSessionContext();
+ Element savedElement = zusammenAdaptor
+ .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()),
+ vspModel, "Create network");
+ network.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(NetworkEntity network) {
ZusammenElement networkElement = buildNetworkElement(network, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, networkElement,
- String.format("Update network with id %s", network.getId()));
+ SessionContext context = createSessionContext();
+ zusammenAdaptor
+ .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()),
+ networkElement, String.format("Update network with id %s", network.getId()));
}
@Override
public NetworkEntity get(NetworkEntity network) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(network.getVersion()));
+ SessionContext context = createSessionContext();
Optional<Element> element =
- zusammenAdaptor.getElement(context, elementContext, network.getId());
+ zusammenAdaptor.getElement(context,
+ new ElementContext(network.getVspId(), network.getVersion().getId()), network.getId());
if (element.isPresent()) {
- network.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return network;
+ ElementToNetworkConvertor convertor = new ElementToNetworkConvertor();
+ NetworkEntity entity = convertor.convert(element.get());
+ entity.setVspId(network.getVspId());
+ entity.setVersion(network.getVersion());
+ return entity;
} else {
return null;
}
@@ -108,39 +113,44 @@ public class NetworkDaoZusammenImpl implements NetworkDao {
@Override
public void delete(NetworkEntity network) {
- ZusammenElement networkElement = new ZusammenElement();
- networkElement.setElementId(new Id(network.getId()));
- networkElement.setAction(Action.DELETE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext,
- networkElement, String.format("Delete network with id %s", network.getId()));
+ ZusammenElement networkElement = buildElement(new Id(network.getId()), Action.DELETE);
+
+ SessionContext context = createSessionContext();
+ zusammenAdaptor
+ .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()),
+ networkElement, String.format("Delete network with id %s", network.getId()));
}
@Override
public void deleteAll(String vspId, Version version) {
- ZusammenElement networksElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Networks, Action.DELETE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, networksElement, "Delete all networks");
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Collection<ElementInfo> vspModelSubs = zusammenAdaptor
+ .listElementsByName(context, elementContext, null, ElementType.VspModel.name());
+
+ Optional<ElementInfo> networksElement = vspModelSubs.stream()
+ .filter(elementInfo -> elementInfo.getInfo() != null
+ && ElementType.Networks.name().equals(elementInfo.getInfo().getName()))
+ .findFirst();
+ if (!networksElement.isPresent()) {
+ return;
+ }
+
+ ZusammenElement networks = buildElement(networksElement.get().getId(), Action.IGNORE);
+ networks.setSubElements(networksElement.get().getSubElements().stream()
+ .map(network -> buildElement(network.getId(), Action.DELETE))
+ .collect(Collectors.toList()));
+
+ zusammenAdaptor.saveElement(context, elementContext, networks, "Delete all networks");
}
private ZusammenElement buildNetworkElement(NetworkEntity network, Action action) {
- ZusammenElement networkElement = new ZusammenElement();
- networkElement.setAction(action);
- if (network.getId() != null) {
- networkElement.setElementId(new Id(network.getId()));
- }
+ ZusammenElement networkElement =
+ buildElement(network.getId() == null ? null : new Id(network.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Network);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Network);
info.addProperty(ElementPropertyName.compositionData.name(), network.getCompositionData());
networkElement.setInfo(info);
networkElement.setData(new ByteArrayInputStream(network.getCompositionData().getBytes()));
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java
index e597068d87..268e2546ed 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java
@@ -1,20 +1,21 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
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;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNicConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNicQuestionnaireConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
import java.util.Collection;
@@ -22,6 +23,10 @@ import java.util.Collections;
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;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class NicDaoZusammenImpl implements NicDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -37,82 +42,70 @@ public class NicDaoZusammenImpl implements NicDao {
@Override
public Collection<NicEntity> list(NicEntity nic) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(nic.getVersion()));
-
- return listNics(context, elementContext, nic);
+ SessionContext context = createSessionContext();
+ return listNics(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), nic);
}
private Collection<NicEntity> listNics(SessionContext context, ElementContext elementContext,
NicEntity nic) {
- return zusammenAdaptor
- .listElementsByName(context, elementContext, new Id(nic.getComponentId()),
- StructureElement.Nics.name())
- .stream().map(elementInfo -> mapElementInfoToNic(
- nic.getVspId(), nic.getVersion(), nic.getComponentId(), elementInfo))
+ ElementToNicConvertor convertor = new ElementToNicConvertor();
+ return zusammenAdaptor.listElementsByName(context, elementContext, new Id(nic.getComponentId()),
+ ElementType.Nics.name())
+ .stream().map(convertor::convert)
+ .map(nicEntity -> {
+ nicEntity.setComponentId(nicEntity.getComponentId());
+ nicEntity.setVspId(nic.getVspId());
+ nicEntity.setVersion(nic.getVersion());
+ return nicEntity;
+ })
.collect(Collectors.toList());
}
- private NicEntity mapElementInfoToNic(String vspId, Version version,
- String componentId, ElementInfo elementInfo) {
- NicEntity nicEntity =
- new NicEntity(vspId, version, componentId, elementInfo.getId().getValue());
- nicEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return nicEntity;
- }
@Override
public void create(NicEntity nic) {
ZusammenElement nicElement = nicToZusammen(nic, Action.CREATE);
- ZusammenElement nicsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Nics, null);
+ ZusammenElement nicsElement = buildStructuralElement(ElementType.Nics, Action.IGNORE);
nicsElement.setSubElements(Collections.singletonList(nicElement));
- ZusammenElement componentElement =
- buildZusammenElement(new Id(nic.getComponentId()), Action.IGNORE);
+ ZusammenElement componentElement = buildElement(new Id(nic.getComponentId()), Action.IGNORE);
componentElement.setSubElements(Collections.singletonList(nicsElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(nic.getVspId(), nic.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create nic");
- savedElement.ifPresent(element ->
- nic.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ nic.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(NicEntity nic) {
ZusammenElement nicElement = nicToZusammen(nic, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, nicElement,
- String.format("Update nic with id %s", nic.getId()));
+ SessionContext context = createSessionContext();
+ zusammenAdaptor
+ .saveElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()),
+ nicElement, String.format("Update nic with id %s", nic.getId()));
}
@Override
public NicEntity get(NicEntity nic) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(nic.getVersion()));
- Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, nic.getId());
+ SessionContext context = createSessionContext();
+ ElementToNicConvertor convertor = new ElementToNicConvertor();
+ Optional<Element> element = zusammenAdaptor
+ .getElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()),
+ nic.getId());
if (element.isPresent()) {
- nic.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return nic;
+ NicEntity entity = convertor.convert(element.get());
+ entity.setVspId(nic.getVspId());
+ entity.setVersion(nic.getVersion());
+ entity.setComponentId(nic.getComponentId());
+
+ return entity;
} else {
return null;
}
@@ -120,26 +113,20 @@ public class NicDaoZusammenImpl implements NicDao {
@Override
public void delete(NicEntity nic) {
- ZusammenElement nicElement = buildZusammenElement(new Id(nic.getId()), Action.DELETE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, nicElement,
- String.format("Delete nic with id %s", nic.getId()));
+ ZusammenElement nicElement = buildElement(new Id(nic.getId()), Action.DELETE);
+
+ SessionContext context = createSessionContext();
+ zusammenAdaptor
+ .saveElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()),
+ nicElement, String.format("Delete nic with id %s", nic.getId()));
}
@Override
public NicEntity getQuestionnaireData(String vspId, Version version, String componentId,
String nicId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
- return getQuestionnaire(context, elementContext,
+ return getQuestionnaire(context, new ElementContext(vspId, version.getId()),
new NicEntity(vspId, version, componentId, nicId));
}
@@ -147,14 +134,13 @@ public class NicDaoZusammenImpl implements NicDao {
NicEntity nic) {
Optional<Element> questionnaireElement = zusammenAdaptor
.getElementByName(context, elementContext, new Id(nic.getId()),
- StructureElement.Questionnaire.name());
- return questionnaireElement.map(
- element -> element.getData() == null
- ? null
- : new String(FileUtils.toByteArray(element.getData())))
- .map(questionnaireData -> {
- nic.setQuestionnaireData(questionnaireData);
- return nic;
+ ElementType.NicQuestionnaire.name());
+ return questionnaireElement.map(new ElementToNicQuestionnaireConvertor()::convert)
+ .map(entity -> {
+ entity.setVspId(nic.getVspId());
+ entity.setVersion(nic.getVersion());
+ entity.setComponentId(nic.getComponentId());
+ return entity;
})
.orElse(null);
}
@@ -165,29 +151,22 @@ public class NicDaoZusammenImpl implements NicDao {
ZusammenElement questionnaireElement =
nicQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
- ZusammenElement nicElement = new ZusammenElement();
- nicElement.setAction(Action.IGNORE);
- nicElement.setElementId(new Id(nicId));
+ ZusammenElement nicElement = buildElement(new Id(nicId), Action.IGNORE);
nicElement.setSubElements(Collections.singletonList(questionnaireElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, nicElement, "Update nic questionnaire");
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), nicElement,
+ "Update nic questionnaire");
}
@Override
public Collection<NicEntity> listByVsp(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
Collection<ComponentEntity> components = ComponentDaoZusammenImpl
- .listComponents(zusammenAdaptor, context, elementContext, vspId, version);
+ .listComponents(zusammenAdaptor, context, vspId, version);
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
return components.stream()
.map(component ->
listNics(context, elementContext,
@@ -200,16 +179,22 @@ public class NicDaoZusammenImpl implements NicDao {
@Override
public void deleteByComponentId(String vspId, Version version, String componentId) {
- ZusammenElement componentElement = buildZusammenElement(new Id(componentId), Action.IGNORE);
- componentElement.setSubElements(Collections.singletonList(
- VspZusammenUtil.buildStructuralElement(StructureElement.Nics, Action.DELETE)));
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, componentElement,
- String.format("Delete all nics of component %s", componentId));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, new Id(componentId), ElementType.Nics.name());
+
+ if (optionalElement.isPresent()) {
+ Element nicsElement = optionalElement.get();
+ Collection<Element> nics = nicsElement.getSubElements();
+
+ nics.forEach(nic -> {
+ ZusammenElement nicZusammenElement = buildElement(nic.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, nicZusammenElement,
+ "Delete nic with id " + nic.getElementId());
+ });
+ }
}
@Override
@@ -229,26 +214,16 @@ public class NicDaoZusammenImpl implements NicDao {
private ZusammenElement nicQuestionnaireToZusammen(String questionnaireData,
Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ buildStructuralElement(ElementType.NicQuestionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
- private ZusammenElement buildZusammenElement(Id elementId, Action action) {
- ZusammenElement element = new ZusammenElement();
- element.setElementId(elementId);
- element.setAction(action);
- return element;
- }
-
private ZusammenElement buildNicElement(NicEntity nic, Action action) {
- ZusammenElement nicElement = new ZusammenElement();
- nicElement.setAction(action);
- if (nic.getId() != null) {
- nicElement.setElementId(new Id(nic.getId()));
- }
+ ZusammenElement nicElement =
+ buildElement(nic.getId() == null ? null : new Id(nic.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Nic);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Nic);
info.addProperty(ElementPropertyName.compositionData.name(), nic.getCompositionData());
nicElement.setInfo(info);
nicElement.setData(new ByteArrayInputStream(nic.getCompositionData().getBytes()));
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java
index ea51b770bf..5d1ef125fd 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java
@@ -1,15 +1,16 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
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;
-import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.utils.fileutils.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
@@ -18,11 +19,18 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStru
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.Optional;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class OrchestrationTemplateCandidateDaoZusammenImpl
implements OrchestrationTemplateCandidateDao {
+
private static final Logger logger =
LoggerFactory.getLogger(OrchestrationTemplateCandidateDaoZusammenImpl.class);
@@ -39,95 +47,163 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
@Override
public OrchestrationTemplateCandidateData get(String vspId, Version version) {
- logger.info("Getting orchestration template for vsp id -> " + vspId);
+ logger.info("Getting orchestration template for VendorSoftwareProduct id -> " + vspId);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, versionId,
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
Optional<Element> candidateElement =
zusammenAdaptor.getElementByName(context, elementContext, null,
- StructureElement.OrchestrationTemplateCandidate.name());
+ ElementType.OrchestrationTemplateCandidate.name());
if (candidateElement.isPresent()) {
+ if (hasEmptyData(candidateElement.get().getData())) {
+ return null;
+ }
OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
candidateData.setFilesDataStructure(
new String(FileUtils.toByteArray(candidateElement.get().getData())));
- zusammenAdaptor
+ Optional<Element> candidateContentElement = zusammenAdaptor
.getElementByName(context, elementContext, candidateElement.get().getElementId(),
- StructureElement.OrchestrationTemplateCandidateContent.name())
- .ifPresent(candidateContentElement -> candidateData.setContentData(
- ByteBuffer.wrap(FileUtils.toByteArray(candidateContentElement.getData()))));
- logger.info("Finished getting orchestration template for vsp id -> " + vspId);
+ ElementType.OrchestrationTemplateCandidateContent.name());
+
+ if (candidateContentElement.isPresent()) {
+ candidateData.setContentData(
+ ByteBuffer.wrap(FileUtils.toByteArray(candidateContentElement.get().getData())));
+ candidateData.setFileSuffix(candidateContentElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileSuffix.name()));
+ candidateData.setFileName(candidateContentElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileName.name()));
+ }
+ logger
+ .info("Finished getting orchestration template for VendorSoftwareProduct id -> " + vspId);
return candidateData;
}
- logger.info(String.format("Orchestration template for vsp id %s does not exist", vspId));
+ logger.info(String
+ .format("Orchestration template for VendorSoftwareProduct id %s does not exist", vspId));
return null;
}
@Override
- public void update(String vspId, OrchestrationTemplateCandidateData candidateData) {
- logger.info("Uploading candidate data entity for vsp id -> " + vspId);
+ public OrchestrationTemplateCandidateData getInfo(String vspId, Version version) {
+ logger.info("Getting orchestration template info for VendorSoftwareProduct id -> " + vspId);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, versionId);
+ Optional<ElementInfo> candidateElement =
+ zusammenAdaptor.getElementInfoByName(context, elementContext, null,
+ ElementType.OrchestrationTemplateCandidate.name());
+ if (candidateElement.isPresent()) {
+ OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
- ZusammenElement candidateElement = VspZusammenUtil
- .buildStructuralElement(StructureElement.OrchestrationTemplateCandidate, Action.UPDATE);
+ Optional<Element> candidateContentElement = zusammenAdaptor
+ .getElementByName(context, elementContext, candidateElement.get().getId(),
+ ElementType.OrchestrationTemplateCandidateContent.name());
+
+ if (candidateContentElement.isPresent()) {
+ candidateData.setFileSuffix(candidateContentElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileSuffix.name()));
+ candidateData.setFileName(candidateContentElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileName.name()));
+ }
+ logger.info(
+ "Finished getting orchestration template info for VendorSoftwareProduct id -> " + vspId);
+ return candidateData;
+ }
+ logger.info(String
+ .format("Orchestration template info for VendorSoftwareProduct id %s does not exist",
+ vspId));
+ return null;
+ }
+
+ @Override
+ public void update(String vspId, Version version,
+ OrchestrationTemplateCandidateData candidateData) {
+ logger.info("Uploading candidate data entity for VendorSoftwareProduct id -> " + vspId);
+
+ ZusammenElement candidateElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
candidateElement
.setData(new ByteArrayInputStream(candidateData.getFilesDataStructure().getBytes()));
- ZusammenElement candidateContentElement = VspZusammenUtil
- .buildStructuralElement(StructureElement.OrchestrationTemplateCandidateContent, Action.UPDATE);
+
+ ZusammenElement candidateContentElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE);
candidateContentElement
.setData(new ByteArrayInputStream(candidateData.getContentData().array()));
+ candidateContentElement.getInfo()
+ .addProperty(InfoPropertyName.fileSuffix.name(), candidateData.getFileSuffix());
+ candidateContentElement.getInfo()
+ .addProperty(InfoPropertyName.fileName.name(), candidateData.getFileName());
candidateElement.addSubElement(candidateContentElement);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, candidateElement,
"Update Orchestration Template Candidate");
- logger.info("Finished uploading candidate data entity for vsp id -> " + vspId);
+ logger
+ .info("Finished uploading candidate data entity for VendorSoftwareProduct id -> " + vspId);
}
+
@Override
public void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure) {
logger.info("Updating orchestration template for VSP id -> " + vspId);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, versionId);
-
- ZusammenElement candidateElement = VspZusammenUtil
- .buildStructuralElement(StructureElement.OrchestrationTemplateCandidate, Action.UPDATE);
+ ZusammenElement candidateElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
candidateElement
.setData(new ByteArrayInputStream(JsonUtil.object2Json(fileDataStructure).getBytes()));
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, candidateElement,
"Update Orchestration Template Candidate structure");
- logger.info("Finished uploading candidate data entity for vsp id -> " + vspId);
+ logger
+ .info("Finished uploading candidate data entity for VendorSoftwareProduct id -> " + vspId);
}
@Override
public Optional<String> getStructure(String vspId, Version version) {
- logger.info("Getting orchestration template structure for vsp id -> " + vspId);
+ logger
+ .info("Getting orchestration template structure for VendorSoftwareProduct id -> " + vspId);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, versionId,
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- logger.info("Finished getting orchestration template structure for vsp id -> " + vspId);
+ logger.info(
+ "Finished getting orchestration template structure for VendorSoftwareProduct id -> " +
+ vspId);
Optional<Element> element = zusammenAdaptor.getElementByName(context, elementContext, null,
- StructureElement.OrchestrationTemplateCandidate.name());
+ ElementType.OrchestrationTemplateCandidate.name());
if (element.isPresent()) {
+ if (hasEmptyData(element.get().getData())) {
+ return Optional.empty();
+ }
return Optional.of(new String(FileUtils.toByteArray(element.get().getData())));
} else {
return Optional.empty();
}
+ }
+
+ private boolean hasEmptyData(InputStream elementData) {
+ String emptyData = "{}";
+ byte[] byteElementData;
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+ if (Arrays.equals(emptyData.getBytes(), byteElementData)) {
+ return true;
+ }
+ return false;
+ }
+ public enum InfoPropertyName {
+ fileSuffix,
+ fileName
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
index 2b6d52a38a..d02e8541f4 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
@@ -3,22 +3,27 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
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;
-import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.utils.fileutils.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.Optional;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTemplateDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -33,79 +38,128 @@ public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTempla
}
@Override
- public String getValidationData(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ public OrchestrationTemplateEntity getInfo(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return null;
+ }
Optional<ElementInfo> elementInfo = zusammenAdaptor
- .getElementInfoByName(context, elementContext, null,
- StructureElement.OrchestrationTemplate.name());
- if (elementInfo.isPresent()) {
- Optional<Element> element =
- zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(),
- StructureElement.OrchestrationTemplateValidationData.name());
- if (element.isPresent()) {
- return new String(FileUtils.toByteArray(element.get().getData()));
- }
+ .getElementInfoByName(context, elementContext, vspModel.get().getId(),
+ ElementType.OrchestrationTemplate.name());
+ if (!elementInfo.isPresent()) {
+ return null;
}
- return null;
+ Optional<Element> element =
+ zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(),
+ ElementType.OrchestrationTemplateValidationData.name());
+
+ OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity();
+ if (!element.isPresent()) {
+ return orchestrationTemplate;
+ }
+ orchestrationTemplate
+ .setFileSuffix(element.get().getInfo().getProperty(InfoPropertyName.fileSuffix.name()));
+ orchestrationTemplate
+ .setFileName(element.get().getInfo().getProperty(InfoPropertyName.fileName.name()));
+ if (!hasEmptyData(element.get().getData())) {
+ orchestrationTemplate
+ .setValidationData(new String(FileUtils.toByteArray(element.get().getData())));
+ }
+ return orchestrationTemplate;
}
@Override
- public UploadDataEntity getOrchestrationTemplate(String vspId, Version version) {
+ public OrchestrationTemplateEntity get(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- UploadDataEntity uploadData = new UploadDataEntity();
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity();
- Optional<ElementInfo> elementInfo = zusammenAdaptor
- .getElementInfoByName(context, elementContext, null,
- StructureElement.OrchestrationTemplate.name());
- if (elementInfo.isPresent()) {
- Optional<Element> element =
- zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(),
- StructureElement.OrchestrationTemplateValidationData.name());
- element.ifPresent(element1 -> uploadData
- .setValidationData(new String(FileUtils.toByteArray(element1.getData()))));
- element =
- zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(),
- StructureElement.OrchestrationTemplateContent.name());
- element.ifPresent(element1 -> uploadData
- .setContentData(ByteBuffer.wrap(FileUtils.toByteArray(element1.getData()))));
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return orchestrationTemplate;
+ }
+
+ Optional<Element> orchestrationTemplateElement = zusammenAdaptor
+ .getElementByName(context, elementContext, vspModel.get().getId(),
+ ElementType.OrchestrationTemplate.name());
+ if (!orchestrationTemplateElement.isPresent()) {
+ return orchestrationTemplate;
+ }
+
+ if (!hasEmptyData(orchestrationTemplateElement.get().getData())) {
+ orchestrationTemplate.setContentData(
+ ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.get().getData())));
}
- return uploadData;
+
+ Optional<Element> validationDataElement =
+ zusammenAdaptor.getElementByName(context, elementContext,
+ orchestrationTemplateElement.get().getElementId(),
+ ElementType.OrchestrationTemplateValidationData.name());
+ if (validationDataElement.isPresent()) {
+ orchestrationTemplate.setFileSuffix(validationDataElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileSuffix.name()));
+ orchestrationTemplate.setFileName(validationDataElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileName.name()));
+ if (!hasEmptyData(validationDataElement.get().getData())) {
+ orchestrationTemplate.setValidationData(
+ new String(FileUtils.toByteArray(validationDataElement.get().getData())));
+ }
+ }
+ return orchestrationTemplate;
}
@Override
- public void updateOrchestrationTemplateData(String vspId, UploadData uploadData) {
+ public void update(String vspId, Version version,
+ OrchestrationTemplateEntity orchestrationTemplate) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ ZusammenElement validationData =
+ buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.UPDATE);
+ validationData
+ .setData(new ByteArrayInputStream(orchestrationTemplate.getValidationData().getBytes()));
+ validationData.getInfo()
+ .addProperty(InfoPropertyName.fileSuffix.name(), orchestrationTemplate.getFileSuffix());
+ validationData.getInfo()
+ .addProperty(InfoPropertyName.fileName.name(), orchestrationTemplate.getFileName());
+
ZusammenElement orchestrationTemplateElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.OrchestrationTemplate, null);
- ZusammenElement orchestrationTemplateValidationDataElement =
- VspZusammenUtil
- .buildStructuralElement(StructureElement.OrchestrationTemplateValidationData, Action.UPDATE);
- orchestrationTemplateValidationDataElement.setData(new ByteArrayInputStream(uploadData
- .getValidationData().getBytes()));
- ZusammenElement orchestrationTemplateContent =
- VspZusammenUtil.buildStructuralElement(StructureElement.OrchestrationTemplateContent, Action.UPDATE);
- orchestrationTemplateContent
- .setData(new ByteArrayInputStream(uploadData.getContentData().array()));
- orchestrationTemplateElement.addSubElement(orchestrationTemplateValidationDataElement);
- orchestrationTemplateElement.addSubElement(orchestrationTemplateContent);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
-
- zusammenAdaptor.saveElement(context, elementContext, orchestrationTemplateElement, "Update " +
- "Orchestration Template");
+ buildStructuralElement(ElementType.OrchestrationTemplate, Action.UPDATE);
+ orchestrationTemplateElement
+ .setData(new ByteArrayInputStream(orchestrationTemplate.getContentData().array()));
+ orchestrationTemplateElement.addSubElement(validationData);
+
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(orchestrationTemplateElement);
+
+ zusammenAdaptor.saveElement(context, elementContext, vspModel, "Update Orchestration Template");
}
+ private boolean hasEmptyData(InputStream elementData) {
+ String emptyData = "{}";
+ byte[] byteElementData;
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+ if (Arrays.equals(emptyData.getBytes(), byteElementData)) {
+ return true;
+ }
+ return false;
+ }
+
+ private enum InfoPropertyName {
+ fileSuffix,
+ fileName
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java
index b0cff4371e..d74900bdf6 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java
@@ -8,34 +8,35 @@ import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
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;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.DESCRIPTION;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.NAME;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.PROCESS_TYPE;
+
/**
* @author Avrahamg.
* @since March 23, 2017
*/
public class ProcessDaoZusammenImpl implements ProcessDao {
- private static final String NAME = "name";
- private static final String ELEMENT_TYPE = "type";
- private static final String ARTIFACT_NAME = "artifactName";
- private static final String DESCRIPTION = "description";
- private static final String PROCESS_TYPE = "processType";
-
private ZusammenAdaptor zusammenAdaptor;
public ProcessDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
@@ -52,85 +53,59 @@ public class ProcessDaoZusammenImpl implements ProcessDao {
ZusammenElement processElement = buildProcessElement(processEntity, Action.CREATE);
ZusammenElement processesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Processes, null);
+ buildStructuralElement(ElementType.Processes, Action.IGNORE);
ZusammenElement aggregatedElement = VspZusammenUtil.aggregateElements(processesElement,
processElement);
ZusammenElement componentElement;
if (processEntity.getComponentId() != null) {
- componentElement = createParentElement(processEntity);
+ componentElement = buildElement(new Id(processEntity.getComponentId()), Action.IGNORE);
aggregatedElement =
VspZusammenUtil.aggregateElements(componentElement, aggregatedElement);
}
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(processEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Create process");
- savedElement.ifPresent(element -> {
- if (processEntity.getComponentId() == null) {
- processEntity.setId(element.getSubElements().iterator().next()
- .getElementId().getValue());
- } else {
- processEntity.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue());
- }
- });
+ processEntity
+ .setId(processEntity.getComponentId() == null
+ ? savedElement.getSubElements().iterator().next().getElementId().getValue()
+ : savedElement.getSubElements().iterator().next().getSubElements()
+ .iterator().next().getElementId().getValue());
}
@Override
- public ProcessEntity get(ProcessEntity process) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(process.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(process.getVersion()));
-
- Optional<Element> elementOptional =
- zusammenAdaptor.getElement(context, elementContext, process.getId());
-
- if (elementOptional.isPresent()) {
- Element element = elementOptional.get();
- process.setName(element.getInfo().getProperty(NAME));
- process.setArtifactName(element.getInfo().getProperty(ARTIFACT_NAME));
- process.setDescription(element.getInfo().getProperty(DESCRIPTION));
- process.setType(element.getInfo().getProperty
- (PROCESS_TYPE) != null ? ProcessType.valueOf(element.getInfo().getProperty
- (PROCESS_TYPE)) : null);
-
- process.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
- return process;
- } else {
- return null;
- }
+ public ProcessEntity get(ProcessEntity processEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
+
+ return zusammenAdaptor.getElementInfo(context, elementContext, new Id(processEntity.getId()))
+ .map(elementInfo -> convertToProcessEntity(elementInfo, new ElementToProcessConvertor(),
+ processEntity))
+ .orElse(null);
}
@Override
public void update(ProcessEntity processEntity) {
- ZusammenElement processElement = buildProcessElement(processEntity, Action.UPDATE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(processEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ProcessEntity retrieved = getArtifact(processEntity);
+ if (retrieved != null && retrieved.getArtifact() != null) {
+ processEntity.setArtifactName(retrieved.getArtifactName());
+ processEntity.setArtifact(retrieved.getArtifact());
+ }
- Optional<Element> element =
- zusammenAdaptor.saveElement(context, elementContext, processElement, "Create process");
- System.out.println(element.get().getElementId());
+ update(processEntity, "Update process");
}
@Override
public void delete(ProcessEntity processEntity) {
- ZusammenElement processElement = new ZusammenElement();
- processElement.setElementId(new Id(processEntity.getId()));
- processElement.setAction(Action.DELETE);
+ ZusammenElement processElement = buildElement(new Id(processEntity.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(processEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, processElement,
String.format("Delete process with id %s", processEntity.getId()));
@@ -138,69 +113,145 @@ public class ProcessDaoZusammenImpl implements ProcessDao {
@Override
public void deleteAll(ProcessEntity processEntity) {
- ZusammenElement aggregatedElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Processes, Action.DELETE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, new Id(processEntity.getComponentId()), ElementType.Processes.name());
+
+ /* ZusammenElement aggregatedElement =
+ buildStructuralElement(ElementType.Processes, Action.DELETE);
if (processEntity.getComponentId() != null) {
ZusammenElement componentElement = createParentElement(processEntity);
- aggregatedElement = VspZusammenUtil.aggregateElements(componentElement,
+ aggregatedElement = VspaggregateElements(componentElement,
aggregatedElement);
}
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(processEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Delete All processes");
+ zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Delete All
+ processes");*/
+
+ if (optionalElement.isPresent()) {
+ Element processesElement = optionalElement.get();
+ Collection<Element> processes = processesElement.getSubElements();
+
+ processes.forEach(process -> {
+ ZusammenElement processZusammenElement =
+ buildElement(process.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, processZusammenElement,
+ "Delete Process with id " + process.getElementId());
+ });
+ }
}
@Override
public void deleteVspAll(String vspId, Version version) {
- ProcessEntity processEntity = new ProcessEntity();
+ /* ProcessEntity processEntity = new ProcessEntity();
processEntity.setVersion(version);
processEntity.setVspId(vspId);
- deleteAll(processEntity);
+ deleteAll(processEntity); */
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(vspId, version.getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, null, ElementType.Processes.name());
+
+ if (optionalElement.isPresent()) {
+ Element processesElement = optionalElement.get();
+ Collection<Element> processes = processesElement.getSubElements();
+
+ processes.forEach(process -> {
+ ZusammenElement processZusammenElement =
+ buildElement(process.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, processZusammenElement,
+ "Delete Process with id " + process.getElementId());
+ });
+ }
}
@Override
- public Collection<ProcessEntity> list(ProcessEntity process) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(process.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(process.getVersion()));
+ public ProcessEntity getArtifact(ProcessEntity processEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
+
+ return zusammenAdaptor.getElement(context, elementContext, processEntity.getId())
+ .map(element -> {
+ ProcessEntity process = new ElementToProcessConvertor().convert(element);
+ process.setVspId(processEntity.getVspId());
+ process.setVersion(processEntity.getVersion());
+ process.setComponentId(processEntity.getComponentId());
+ return process;
+ })
+ .orElse(null);
+ }
+
+ @Override
+ public void uploadArtifact(ProcessEntity processEntity) {
+ ProcessEntity retrieved = get(processEntity);
+ if (retrieved != null) {
+ retrieved.setArtifactName(processEntity.getArtifactName());
+ retrieved.setArtifact(processEntity.getArtifact());
+
+ update(retrieved, "Upload process artifact");
+ }
+ }
+
+ @Override
+ public void deleteArtifact(ProcessEntity processEntity) {
+ ProcessEntity retrieved = get(processEntity);
+ if (retrieved != null) {
+ retrieved.setArtifactName(null);
+ retrieved.setArtifact(null);
+
+ update(retrieved, "Delete process artifact");
+ }
+ }
+
+ @Override
+ public Collection<ProcessEntity> list(ProcessEntity processEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
Optional<ElementInfo> processesOptional =
zusammenAdaptor.getElementInfoByName(context, elementContext,
- extractParentElementId(process), StructureElement.Processes.name());
+ extractParentElementId(processEntity), ElementType.Processes.name());
if (!processesOptional.isPresent()) {
return new ArrayList<>();
}
+ ElementToProcessConvertor convertor = new ElementToProcessConvertor();
return zusammenAdaptor.listElements(context, elementContext, processesOptional.get().getId())
.stream()
- .map(elementInfo -> mapElementInfoToProcess(
- process.getVspId(), process.getVersion(), process.getComponentId(),
- elementInfo))
+ .map(elementInfo -> convertToProcessEntity(elementInfo, convertor, processEntity))
.collect(Collectors.toList());
}
- private Id extractParentElementId(ProcessEntity processEntity) {
- return processEntity.getComponentId() == null ? null : new Id(processEntity.getComponentId());
+ private ProcessEntity convertToProcessEntity(ElementInfo elementInfo,
+ ElementToProcessConvertor convertor,
+ ProcessEntity inputProcess) {
+ ProcessEntity process = convertor.convert(elementInfo);
+ process.setVspId(inputProcess.getVspId());
+ process.setVersion(inputProcess.getVersion());
+ process.setComponentId(inputProcess.getComponentId());
+ return process;
}
- private ProcessEntity mapElementInfoToProcess(String vspId, Version version,
- String componentId,
- ElementInfo elementInfo) {
- ProcessEntity processEntity = new ProcessEntity(vspId, version, componentId, elementInfo
- .getId().getValue());
- processEntity.setName((String) elementInfo.getInfo().getProperties().get(NAME));
- processEntity
- .setArtifactName((String) elementInfo.getInfo().getProperties().get(ARTIFACT_NAME));
- processEntity.setDescription((String) elementInfo.getInfo().getProperties().get(DESCRIPTION));
- processEntity.setType( elementInfo.getInfo().getProperties().get(PROCESS_TYPE) != null ?
- ProcessType.valueOf((String) elementInfo.getInfo().getProperties().get(PROCESS_TYPE)) :
- null);
- return processEntity;
+ private void update(ProcessEntity processEntity, String message) {
+ ZusammenElement processElement = buildProcessElement(processEntity, Action.UPDATE);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
+
+ zusammenAdaptor.saveElement(context, elementContext, processElement, message);
+ }
+
+ private Id extractParentElementId(ProcessEntity processEntity) {
+ return processEntity.getComponentId() == null ? null : new Id(processEntity.getComponentId());
}
private ZusammenElement buildProcessElement(ProcessEntity process, Action action) {
@@ -208,14 +259,12 @@ public class ProcessDaoZusammenImpl implements ProcessDao {
Info info = new Info();
info.setName(process.getName());
info.addProperty(NAME, process.getName());
- info.addProperty(ELEMENT_TYPE, ElementType.Process);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Process);
info.addProperty(ARTIFACT_NAME, process.getArtifactName());
info.addProperty(DESCRIPTION, process.getDescription());
info.addProperty(PROCESS_TYPE, process.getType() != null ? process.getType().name() : null);
- ZusammenElement processElement = new ZusammenElement();
- processElement.setElementId(new Id(process.getId()));
- processElement.setAction(action);
+ ZusammenElement processElement = buildElement(new Id(process.getId()), action);
processElement.setInfo(info);
if (Objects.nonNull(process.getArtifact())) {
processElement.setData(new ByteArrayInputStream(process.getArtifact().array()));
@@ -223,10 +272,4 @@ public class ProcessDaoZusammenImpl implements ProcessDao {
return processElement;
}
- private ZusammenElement createParentElement(ProcessEntity entity) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(entity.getComponentId()));
- componentElement.setAction(Action.IGNORE);
- return componentElement;
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java
deleted file mode 100644
index 6f15f5cdee..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
-
-public enum StructureElement {
- General,
- OrchestrationTemplateCandidate,
- OrchestrationTemplate,
- OrchestrationTemplateValidationData,
- OrchestrationTemplateContent,
- OrchestrationTemplateCandidateValidationData,
- OrchestrationTemplateCandidateContent,
- Networks,
- Components,
- Nics,
- Processes,
- Mibs,
- SNMP_TRAP,
- SNMP_POLL,
- VES_EVENTS,
- Questionnaire,
- ComponentDependencies,
- Computes,
- Images,
- DeploymentFlavors
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
index 517a01e58d..aa192ede17 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
@@ -1,16 +1,15 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.ItemVersion;
-import com.amdocs.zusammen.utils.fileutils.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToVSPGeneralConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToVSPQuestionnaireConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
@@ -20,10 +19,14 @@ import org.openecomp.sdc.versioning.types.VersionableEntityStoreType;
import java.io.ByteArrayInputStream;
import java.util.Collection;
-import java.util.Date;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareProductInfoDao {
+ private static final String EMPTY_DATA = "{}";
+
private ZusammenAdaptor zusammenAdaptor;
public VendorSoftwareProductInfoDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
@@ -33,7 +36,8 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
@Override
public void registerVersioning(String versionableEntityType) {
VersionableEntityMetadata metadata =
- new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "vsp", null, null);
+ new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "VendorSoftwareProduct",
+ null, null);
VersioningManagerFactory.getInstance().createInterface()
.register(versionableEntityType, metadata);
@@ -41,114 +45,174 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
@Override
public Collection<VspDetails> list(VspDetails entity) {
- return zusammenAdaptor.listItems(ZusammenUtil.createSessionContext()).stream().filter
- (vspEntity-> "vsp".equals(vspEntity.getInfo().getProperty("type")))
- .map(item -> mapInfoToVspDetails(
- item.getId().getValue(), null, item.getInfo(),
- item.getModificationTime(), item.getCreationTime()))
+ ElementToVSPGeneralConvertor convertor = new ElementToVSPGeneralConvertor();
+
+
+ return zusammenAdaptor.listItems(createSessionContext()).stream()
+ .filter(item -> "VendorSoftwareProduct".equals(item.getInfo().getProperty("item_type")))
+ .map(item -> convertor.convert(item))
.collect(Collectors.toList());
}
+
@Override
public void create(VspDetails vspDetails) {
- SessionContext context = ZusammenUtil.createSessionContext();
+ ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.CREATE);
- Id itemId = zusammenAdaptor.createItem(context, mapVspDetailsToZusammenItemInfo(vspDetails));
- Id versionId =
- zusammenAdaptor.createVersion(context, itemId, null, ZusammenUtil.createFirstVersionData());
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
+ zusammenAdaptor.saveElement(context, elementContext, generalElement,
+ "Create VSP General Info Element");
- ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.CREATE);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
- generalElement, "Create VSP General Info Element");
+ createVspStructure(context, elementContext);
+ }
+
+ private void createVspStructure(SessionContext context, ElementContext elementContext) {
+ createOrchestrationTemplateCandidateStructure(context, elementContext);
+ createVspModelStructure(context, elementContext);
- vspDetails.setId(itemId.getValue());//set id for caller
+ zusammenAdaptor.saveElement(context, elementContext,
+ buildStructuralElement(ElementType.DeploymentFlavors, Action.CREATE),
+ "Create VSP Deployment Flavors Element");
+
+ zusammenAdaptor.saveElement(context, elementContext,
+ buildStructuralElement(ElementType.Processes, Action.CREATE),
+ "Create VSP Processes Element");
}
- @Override
- public void update(VspDetails vspDetails) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspDetails.getId());
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
+ private void createOrchestrationTemplateCandidateStructure(SessionContext context,
+ ElementContext elementContext) {
+ ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
- zusammenAdaptor.updateItem(context, itemId, mapVspDetailsToZusammenItemInfo(vspDetails));
+ ZusammenElement candidateContentElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.CREATE);
+ candidateContentElement.setData(emptyData);
- ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.UPDATE);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
- generalElement, "Update VSP General Info Element");
+ ZusammenElement candidateElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.CREATE);
+ candidateElement.setData(emptyData);
+ candidateElement.addSubElement(candidateContentElement);
+
+ zusammenAdaptor.saveElement(context, elementContext, candidateElement,
+ "Create Orchestration Template Candidate Elements");
}
- @Override
- public VspDetails get(VspDetails vspDetails) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspDetails.getId());
- ItemVersion itemVersion = VspZusammenUtil.getFirstVersion(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, itemVersion.getId(),
- VspZusammenUtil.getVersionTag(vspDetails.getVersion()));
+ private void createVspModelStructure(SessionContext context, ElementContext elementContext) {
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.CREATE);
+ vspModel.addSubElement(buildOrchestrationTemplateStructure());
+ vspModel.addSubElement(buildStructuralElement(ElementType.Networks, Action.CREATE));
+ vspModel.addSubElement(buildStructuralElement(ElementType.Components, Action.CREATE));
+ vspModel
+ .addSubElement(buildStructuralElement(ElementType.ComponentDependencies, Action.CREATE));
+
+ ZusammenElement templates = buildStructuralElement(ElementType.Templates, Action.CREATE);
+ ZusammenElement artifacts = buildStructuralElement(ElementType.Artifacts, Action.CREATE);
+ vspModel.addSubElement(
+ buildServiceModelStructure(ElementType.ServiceModel, templates, artifacts));
+ vspModel.addSubElement(
+ buildServiceModelStructure(ElementType.EnrichedServiceModel, templates, artifacts));
+
+ zusammenAdaptor.saveElement(context, elementContext, vspModel, "Create VSP Model Elements");
+ }
- return zusammenAdaptor
- .getElementInfoByName(context, elementContext, null, StructureElement.General.name())
- .map(generalElementInfo -> mapInfoToVspDetails(
- vspDetails.getId(), vspDetails.getVersion(), generalElementInfo.getInfo(),
- itemVersion.getModificationTime(), itemVersion.getCreationTime()))
- .orElse(null);
+ private ZusammenElement buildOrchestrationTemplateStructure() {
+ ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
+
+ ZusammenElement validationData =
+ buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.CREATE);
+ validationData.setData(emptyData);
+
+ ZusammenElement orchestrationTemplate =
+ buildStructuralElement(ElementType.OrchestrationTemplate, Action.CREATE);
+ orchestrationTemplate.setData(emptyData);
+ orchestrationTemplate.addSubElement(validationData);
+
+ return orchestrationTemplate;
}
+ private ZusammenElement buildServiceModelStructure(ElementType serviceModelElementType,
+ ZusammenElement templates,
+ ZusammenElement artifacts) {
+ ZusammenElement serviceModel = buildStructuralElement(serviceModelElementType, Action.CREATE);
+ serviceModel.addSubElement(templates);
+ serviceModel.addSubElement(artifacts);
+ return serviceModel;
+ }
@Override
- public void delete(VspDetails entity) {
+ public void update(VspDetails vspDetails) {
+ ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.UPDATE);
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context,
+ new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()), generalElement,
+ "Update VSP General Info Element");
}
@Override
- public void updateOldVersionIndication(VspDetails vspDetails) {
- VspDetails retrieved = get(vspDetails);
- if (retrieved != null) {
- retrieved.setOldVersion(vspDetails.getOldVersion());
- update(retrieved);
- }
+ public VspDetails get(VspDetails vspDetails) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
+ VspDetails vsp = zusammenAdaptor.getElementInfoByName(context, elementContext, null,
+ ElementType.VendorSoftwareProduct.name())
+ .map(new ElementToVSPGeneralConvertor()::convert)
+ .orElse(null);
+ vsp.setId(vspDetails.getId());
+ vsp.setVersion(vspDetails.getVersion());
+ return vsp;
+ }
+
+ @Override
+ public void delete(VspDetails vspDetails) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
+
+ zusammenAdaptor.saveElement(context, elementContext,
+ buildStructuralElement(ElementType.VspModel, Action.DELETE),
+ "Delete VSP Model Elements");
+
+ createVspModelStructure(context, elementContext);
}
@Override
public void updateQuestionnaireData(String vspId, Version version, String questionnaireData) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
+ SessionContext context = createSessionContext();
ZusammenElement questionnaireElement = mapQuestionnaireToZusammenElement(questionnaireData);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
+ zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()),
questionnaireElement, "Update VSP Questionnaire");
}
- @Override
+ /* @Override
public String getQuestionnaireData(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
+ SessionContext context = createSessionContext();
- return zusammenAdaptor.getElementByName(context,
- new ElementContext(itemId, versionId, VspZusammenUtil.getVersionTag(version)), null,
- StructureElement.Questionnaire.name())
+ return zusammenAdaptor
+ .getElementByName(context, new ElementContext(vspId, version.getId()), null,
+ ElementType.Questionnaire.name())
.map(questionnaireElement ->
new String(FileUtils.toByteArray(questionnaireElement.getData())))
.orElse(null);
- }
+ }*/
@Override
public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) {
- VspQuestionnaireEntity entity = new VspQuestionnaireEntity();
+
+ SessionContext context = createSessionContext();
+ ElementToVSPQuestionnaireConvertor convertor = new ElementToVSPQuestionnaireConvertor();
+ VspQuestionnaireEntity entity = convertor.convert(zusammenAdaptor
+ .getElementByName(context, new ElementContext(vspId, version.getId()), null,
+ ElementType.VSPQuestionnaire.name()).map(element -> element).orElse(null));
entity.setId(vspId);
entity.setVersion(version);
- entity.setQuestionnaireData(getQuestionnaireData(vspId, version));
return entity;
}
@Override
- public void deleteAll(String vspId, Version version) {
-
- }
-
- @Override
public boolean isManual(String vspId, Version version) {
final VspDetails vspDetails = get(new VspDetails(vspId, version));
if (vspDetails != null) {
@@ -159,29 +223,27 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
return false;
}
- private Info mapVspDetailsToZusammenItemInfo(VspDetails vspDetails) {
- Info info = new Info();
- info.setName(vspDetails.getName());
- info.setDescription(vspDetails.getDescription());
- info.addProperty("type", "vsp");
- addVspDetailsToInfo(info, vspDetails);
- return info;
- }
-
private ZusammenElement mapVspDetailsToZusammenElement(VspDetails vspDetails, Action action) {
ZusammenElement generalElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.General, action);
+ buildStructuralElement(ElementType.VendorSoftwareProduct, action);
addVspDetailsToInfo(generalElement.getInfo(), vspDetails);
return generalElement;
}
private ZusammenElement mapQuestionnaireToZusammenElement(String questionnaireData) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, Action.UPDATE);
+ buildStructuralElement(ElementType.VSPQuestionnaire, Action.UPDATE);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
+ private ZusammenElement mapTestElementToZusammenElement(String elementData) {
+ ZusammenElement testElement =
+ buildStructuralElement(ElementType.test, Action.UPDATE);
+ testElement.setData(new ByteArrayInputStream(elementData.getBytes()));
+ return testElement;
+ }
+
private void addVspDetailsToInfo(Info info, VspDetails vspDetails) {
info.addProperty(InfoPropertyName.name.name(), vspDetails.getName());
info.addProperty(InfoPropertyName.description.name(), vspDetails.getDescription());
@@ -191,45 +253,14 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
info.addProperty(InfoPropertyName.vendorId.name(), vspDetails.getVendorId());
info.addProperty(InfoPropertyName.vendorName.name(), vspDetails.getVendorName());
if (vspDetails.getVlmVersion() != null) {
- info.addProperty(
- InfoPropertyName.vendorVersion.name(), vspDetails.getVlmVersion().toString());
+ info.addProperty(InfoPropertyName.vendorVersion.name(), vspDetails.getVlmVersion().getId());
}
info.addProperty(InfoPropertyName.licenseAgreement.name(), vspDetails.getLicenseAgreement());
info.addProperty(InfoPropertyName.featureGroups.name(), vspDetails.getFeatureGroups());
- info.addProperty(InfoPropertyName.oldVersion.name(), vspDetails.getOldVersion());
info.addProperty(InfoPropertyName.onboardingMethod.name(), vspDetails.getOnboardingMethod());
- info.addProperty(InfoPropertyName.obBoardingOrigin.name(), vspDetails.getOnboardingOrigin());
- info.addProperty(InfoPropertyName.networkPackageName.name(), vspDetails.getNetworkPackageName());
- }
-
- private VspDetails mapInfoToVspDetails(String vspId, Version version, Info info,
- Date modificationTime, Date creationTime) {
- VspDetails vspDetails = new VspDetails(vspId, version);
- vspDetails.setName(info.getProperty(InfoPropertyName.name.name()));
- vspDetails.setDescription(info.getProperty(InfoPropertyName.description.name()));
- vspDetails.setCategory(info.getProperty(InfoPropertyName.category.name()));
- vspDetails.setSubCategory(info.getProperty(InfoPropertyName.subCategory.name()));
- vspDetails.setVendorId(info.getProperty(InfoPropertyName.vendorId.name()));
- vspDetails.setVendorName(info.getProperty(InfoPropertyName.vendorName.name()));
- vspDetails.setVlmVersion(
- Version.valueOf(info.getProperty(InfoPropertyName.vendorVersion.name())));
- vspDetails.setLicenseAgreement(info.getProperty(InfoPropertyName.licenseAgreement.name()));
- vspDetails.setFeatureGroups(info.getProperty(InfoPropertyName.featureGroups.name()));
-
- vspDetails.setWritetimeMicroSeconds(
- modificationTime == null ? creationTime.getTime() : modificationTime.getTime());
- vspDetails.setVersion(version);
- String oldVersion = info.getProperty(InfoPropertyName.oldVersion.name());
-
- //Boolean oldVersion = ind == null || "true".equals( ind.toLowerCase());
- vspDetails.setOldVersion(oldVersion);
- vspDetails.setOnboardingMethod(info.getProperty(InfoPropertyName.onboardingMethod.name()));
- vspDetails.setOnboardingOrigin(info.getProperty(InfoPropertyName.obBoardingOrigin.name()));
- vspDetails.setNetworkPackageName(info.getProperty(InfoPropertyName.networkPackageName.name()));
- return vspDetails;
- }
-
- private enum InfoPropertyName {
+ }
+
+ public enum InfoPropertyName {
name,
description,
icon,
@@ -240,10 +271,7 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
vendorVersion,
licenseAgreement,
featureGroups,
- oldVersion,
- onboardingMethod,
- obBoardingOrigin,
- networkPackageName
+ onboardingMethod
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java
index 5e80d4c355..d4dc7e0c4b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java
@@ -1,49 +1,11 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Action;
-import com.amdocs.zusammen.datatypes.item.ItemVersion;
-import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import java.util.Objects;
-import java.util.Optional;
class VspZusammenUtil {
- static ItemVersion getFirstVersion(SessionContext context, Id itemId, ZusammenAdaptor
- zusammenAdaptor) {
-
- Optional<ItemVersion> itemVersion = zusammenAdaptor.getFirstVersion(context, itemId);
-
- if (!itemVersion.isPresent()) {
- throw new CoreException(
- new VendorSoftwareProductNotFoundErrorBuilder(itemId.getValue()).build());
- }
- return itemVersion.get();
- }
-
- static Id getFirstVersionId(SessionContext context, Id itemId, ZusammenAdaptor zusammenAdaptor) {
- return getFirstVersion(context, itemId, zusammenAdaptor).getId();
- }
-
- // TODO: 4/25/2017 remove upon working with more than one single version
- static String getVersionTag(Version version) {
- return version.getStatus() == VersionStatus.Locked
- ? null
- : version.toString();
- }
-
- static ZusammenElement buildStructuralElement(StructureElement structureElement, Action action) {
- return ZusammenUtil.buildStructuralElement(structureElement.name(), action);
- }
-
static ZusammenElement aggregateElements(ZusammenElement... elements) {
ZusammenElement head = null;
ZusammenElement father = null;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java
new file mode 100644
index 0000000000..ae88a7e6b0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java
@@ -0,0 +1,38 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToComponentConvertor extends ElementConvertor<ComponentEntity> {
+
+ @Override
+ public ComponentEntity convert(Element element) {
+ ComponentEntity componentEntity = new ComponentEntity();
+ componentEntity.setId(element.getElementId().getValue());
+ componentEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToComponentEntity(componentEntity,element.getInfo());
+ return componentEntity;
+ }
+
+ @Override
+ public ComponentEntity convert( ElementInfo elementInfo) {
+ ComponentEntity componentEntity = new ComponentEntity();
+ componentEntity.setId(elementInfo.getId().getValue());
+ mapInfoToComponentEntity(componentEntity,elementInfo.getInfo());
+ return componentEntity;
+ }
+
+
+ public void mapInfoToComponentEntity(ComponentEntity componentEntity,Info info){
+
+
+ componentEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java
new file mode 100644
index 0000000000..0864ad3482
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java
@@ -0,0 +1,41 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentDependencyModelPropertyName;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+
+public class ElementToComponentDependencyModelConvertor extends ElementConvertor <ComponentDependencyModelEntity>{
+
+ @Override
+ public ComponentDependencyModelEntity convert( Element element) {
+ ComponentDependencyModelEntity componentDependencyModelEntity = new ComponentDependencyModelEntity();
+ componentDependencyModelEntity.setId(element.getElementId().getValue());
+ mapInfoToComponentDependencyModelEntity(componentDependencyModelEntity,element.getInfo());
+ return componentDependencyModelEntity;
+ }
+
+ @Override
+ public ComponentDependencyModelEntity convert(ElementInfo elementInfo) {
+ ComponentDependencyModelEntity componentDependencyModelEntity = new ComponentDependencyModelEntity();
+
+ componentDependencyModelEntity.setId(elementInfo.getId().getValue());
+ mapInfoToComponentDependencyModelEntity(componentDependencyModelEntity,elementInfo.getInfo());
+ return componentDependencyModelEntity;
+ }
+
+
+ public void mapInfoToComponentDependencyModelEntity(ComponentDependencyModelEntity componentDependencyModelEntity,Info info){
+
+ componentDependencyModelEntity.setSourceComponentId(info
+ .getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name()));
+ componentDependencyModelEntity.setTargetComponentId(info
+ .getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name()));
+ componentDependencyModelEntity.setRelation(info
+ .getProperty(ComponentDependencyModelPropertyName.relation.name()));
+
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java
new file mode 100644
index 0000000000..dd3d122560
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java
@@ -0,0 +1,45 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.enrichment.types.MonitoringUploadType;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+
+import java.nio.ByteBuffer;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME;
+
+public class ElementToComponentMonitoringUploadConvertor extends ElementConvertor<ComponentMonitoringUploadEntity> {
+
+ @Override
+ public ComponentMonitoringUploadEntity convert(Element element) {
+ ComponentMonitoringUploadEntity mibEntity = new ComponentMonitoringUploadEntity();
+
+ mibEntity.setId(element.getElementId().getValue());
+ mibEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
+ mapInfoToComponentMonitoringUploadEntity(mibEntity, element.getInfo());
+ return mibEntity;
+ }
+
+ @Override
+ public ComponentMonitoringUploadEntity convert(ElementInfo elementInfo) {
+ ComponentMonitoringUploadEntity mibEntity = new ComponentMonitoringUploadEntity();
+
+ mibEntity.setId(elementInfo.getId().getValue());
+ mapInfoToComponentMonitoringUploadEntity(mibEntity, elementInfo.getInfo());
+ return mibEntity;
+ }
+
+
+ public void mapInfoToComponentMonitoringUploadEntity(ComponentMonitoringUploadEntity mibEntity,
+ Info info) {
+
+ mibEntity.setArtifactName((String) info.getProperties().get(ARTIFACT_NAME));
+ mibEntity.setType(MonitoringUploadType.valueOf(info.getName()));
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java
new file mode 100644
index 0000000000..1554a1cc10
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+
+
+/**
+ * Created by ayalaben on 9/27/2017
+ */
+public class ElementToComponentQuestionnnaireConvertor extends ElementConvertor<ComponentEntity> {
+ @Override
+ public ComponentEntity convert( Element element) {
+ ComponentEntity componentEntity = new ComponentEntity();
+
+ componentEntity.setId(element.getElementId().getValue());
+ componentEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData())));
+ return componentEntity;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java
new file mode 100644
index 0000000000..f73da6af01
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java
@@ -0,0 +1,45 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
+
+public class ElementToCompositionEntityConvertor extends ElementConvertor <CompositionEntity>{
+
+ @Override
+ public CompositionEntity convert(Element element) {
+
+ CompositionEntity compositionEntity = null;
+ switch (getElementType(element)) {
+ case ComponentQuestionnaire:
+ compositionEntity = new ComponentEntity();
+ break;
+ case VSPQuestionnaire:
+ compositionEntity = new VspQuestionnaireEntity();
+ break;
+ case ImageQuestionnaire:
+ compositionEntity = new ImageEntity();
+ break;
+ case ComputeQuestionnaire:
+ compositionEntity = new ComponentEntity();
+ break;
+ case NicQuestionnaire:
+ compositionEntity = new NicEntity();
+ }
+ if (compositionEntity != null) {
+ compositionEntity.setId(element.getElementId().getValue());
+ compositionEntity.setQuestionnaireData(element.getData() == null
+ ? null
+ : new String(FileUtils.toByteArray(element.getData())));
+ return compositionEntity;
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java
new file mode 100644
index 0000000000..0412e03690
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java
@@ -0,0 +1,40 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToComputeConvertor extends ElementConvertor <ComputeEntity>{
+
+ @Override
+ public ComputeEntity convert( Element element) {
+ ComputeEntity computeEntity = new ComputeEntity();
+
+ computeEntity.setId(element.getElementId().getValue());
+ computeEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToComputeEntity(computeEntity,element.getInfo());
+ return computeEntity;
+ }
+
+ @Override
+ public ComputeEntity convert( ElementInfo elementInfo) {
+ ComputeEntity computeEntity = new ComputeEntity();
+
+ computeEntity.setId(elementInfo.getId().getValue());
+ mapInfoToComputeEntity(computeEntity,elementInfo.getInfo());
+ return computeEntity;
+ }
+
+
+ public void mapInfoToComputeEntity(ComputeEntity computeEntity,Info info){
+
+
+ computeEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java
new file mode 100644
index 0000000000..7ac25762b0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+
+public class ElementToComputeQuestionnaireConvertor extends ElementConvertor <ComputeEntity>{
+
+ @Override
+ public ComputeEntity convert( Element element) {
+ ComputeEntity computeEntity = new ComputeEntity();
+
+ computeEntity.setId(element.getElementId().getValue());
+ computeEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData())));
+ return computeEntity;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java
new file mode 100644
index 0000000000..48265bf765
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java
@@ -0,0 +1,40 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToDeploymentFlavorConvertor extends ElementConvertor <DeploymentFlavorEntity>{
+
+ @Override
+ public DeploymentFlavorEntity convert( Element element) {
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity();
+
+ deploymentFlavorEntity.setId(element.getElementId().getValue());
+ deploymentFlavorEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToDeploymentFlavorEntity(deploymentFlavorEntity,element.getInfo());
+ return deploymentFlavorEntity;
+ }
+
+ @Override
+ public DeploymentFlavorEntity convert( ElementInfo elementInfo) {
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity();
+
+ deploymentFlavorEntity.setId(elementInfo.getId().getValue());
+ mapInfoToDeploymentFlavorEntity(deploymentFlavorEntity,elementInfo.getInfo());
+ return deploymentFlavorEntity;
+ }
+
+
+ public void mapInfoToDeploymentFlavorEntity(DeploymentFlavorEntity deploymentFlavorEntity,Info info){
+
+
+ deploymentFlavorEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java
new file mode 100644
index 0000000000..8aa59c52f5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java
@@ -0,0 +1,40 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToImageConvertor extends ElementConvertor <ImageEntity>{
+
+ @Override
+ public ImageEntity convert( Element element) {
+ ImageEntity imageEntity = new ImageEntity();
+
+ imageEntity.setId(element.getElementId().getValue());
+ imageEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToImageEntity(imageEntity,element.getInfo());
+ return imageEntity;
+ }
+
+ @Override
+ public ImageEntity convert( ElementInfo elementInfo) {
+ ImageEntity imageEntity = new ImageEntity();
+
+ imageEntity.setId(elementInfo.getId().getValue());
+ mapInfoToImageEntity(imageEntity,elementInfo.getInfo());
+ return imageEntity;
+ }
+
+
+ public void mapInfoToImageEntity(ImageEntity imageEntity,Info info){
+
+
+ imageEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java
new file mode 100644
index 0000000000..2e9cfa0396
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+
+public class ElementToImageQuestionnaireConvertor extends ElementConvertor <ImageEntity>{
+
+ @Override
+ public ImageEntity convert( Element element) {
+ ImageEntity imageEntity = new ImageEntity();
+
+ imageEntity.setId(element.getElementId().getValue());
+ imageEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData())));
+ return imageEntity;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java
new file mode 100644
index 0000000000..5da9dc4271
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java
@@ -0,0 +1,23 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME;
+
+/**
+ * Created by ayalaben on 9/5/2017.
+ */
+
+public class ElementToMonitoringUploadMapConvertor extends ElementConvertor<Map<String ,String>> {
+
+ @Override
+ public Map<String ,String> convert(Element element) {
+ HashMap<String,String> map = new HashMap<>();
+ map.put("File Name",element.getInfo().getProperty(ARTIFACT_NAME));
+ return map;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java
new file mode 100644
index 0000000000..6ce24163e6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java
@@ -0,0 +1,38 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToNetworkConvertor extends ElementConvertor <NetworkEntity>{
+
+ @Override
+ public NetworkEntity convert( Element element) {
+ NetworkEntity networkEntity = new NetworkEntity();
+
+ networkEntity.setId(element.getElementId().getValue());
+ networkEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToNetworkEntity(networkEntity,element.getInfo());
+ return networkEntity;
+ }
+
+ @Override
+ public NetworkEntity convert( ElementInfo elementInfo) {
+ NetworkEntity networkEntity = new NetworkEntity();
+
+ networkEntity.setId(elementInfo.getId().getValue());
+ mapInfoToNetworkEntity(networkEntity,elementInfo.getInfo());
+ return networkEntity;
+ }
+
+
+ public void mapInfoToNetworkEntity(NetworkEntity networkEntity,Info info){
+ networkEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java
new file mode 100644
index 0000000000..33788af4e1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java
@@ -0,0 +1,39 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToNicConvertor extends ElementConvertor <NicEntity>{
+
+ @Override
+ public NicEntity convert( Element element) {
+ NicEntity nicEntity = new NicEntity();
+
+ nicEntity.setId(element.getElementId().getValue());
+ nicEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToNicEntity(nicEntity,element.getInfo());
+ return nicEntity;
+ }
+
+ @Override
+ public NicEntity convert( ElementInfo elementInfo) {
+ NicEntity nicEntity = new NicEntity();
+
+ nicEntity.setId(elementInfo.getId().getValue());
+ mapInfoToNicEntity(nicEntity,elementInfo.getInfo());
+ return nicEntity;
+ }
+
+
+ public void mapInfoToNicEntity(NicEntity nicEntity,Info info){
+
+ nicEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java
new file mode 100644
index 0000000000..ff53153269
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+
+public class ElementToNicQuestionnaireConvertor extends ElementConvertor <NicEntity>{
+
+ @Override
+ public NicEntity convert( Element element) {
+ NicEntity nicEntity = new NicEntity();
+
+ nicEntity.setId(element.getElementId().getValue());
+ nicEntity.setQuestionnaireData( element.getData() == null
+ ? null
+ : new String(FileUtils.toByteArray(element.getData())));
+ return nicEntity;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java
new file mode 100644
index 0000000000..b07df95ecc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
+
+/**
+ * Created by ayalaben on 9/6/2017
+ */
+public class ElementToOrchestrationTemplateCandidateMapConvertor
+ extends ElementConvertor<FilesDataStructure> {
+
+ @Override
+ public FilesDataStructure convert(Element element) {
+ return JsonUtil.json2Object(new String(FileUtils.toByteArray(element.getData())),
+ FilesDataStructure.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java
new file mode 100644
index 0000000000..5d3ebc32ad
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java
@@ -0,0 +1,53 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
+
+import java.nio.ByteBuffer;
+
+public class ElementToProcessConvertor extends ElementConvertor<ProcessEntity> {
+
+ @Override
+ public ProcessEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ ProcessEntity processEntity = new ProcessEntity();
+ processEntity.setId(element.getElementId().getValue());
+ processEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
+ mapInfoToProcessEntity(processEntity, element.getInfo());
+ return processEntity;
+ }
+
+ @Override
+ public ProcessEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ ProcessEntity processEntity = new ProcessEntity();
+ processEntity.setId(elementInfo.getId().getValue());
+ mapInfoToProcessEntity(processEntity, elementInfo.getInfo());
+ return processEntity;
+ }
+
+
+ public void mapInfoToProcessEntity(ProcessEntity processEntity, Info info) {
+ processEntity.setName(info.getProperty(NAME));
+ processEntity.setArtifactName(info.getProperty(ARTIFACT_NAME));
+ processEntity.setDescription(info.getProperty(DESCRIPTION));
+ processEntity.setType(info.getProperty
+ (PROCESS_TYPE) != null ? ProcessType.valueOf(info.getProperty
+ (PROCESS_TYPE)) : null);
+ }
+
+
+ public static final String NAME = "name";
+ public static final String ARTIFACT_NAME = "artifactName";
+ public static final String DESCRIPTION = "description";
+ public static final String PROCESS_TYPE = "processType";
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java
new file mode 100644
index 0000000000..bb7e8bb3e8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by ayalaben on 9/11/2017
+ */
+public class ElementToServiceModelMapConvertor extends ElementConvertor<Map<String ,String>> {
+ @Override
+ public Map<String ,String> convert(Element element) {
+ //TODO : after merge with 1802 change to heat fle name/TOSCA file name
+ HashMap<String,String> map = new HashMap<>();
+ map.put("Service Model Definition Entry", element.getInfo().getProperty("base"));
+ return map;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java
new file mode 100644
index 0000000000..c5c2f91595
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java
@@ -0,0 +1,78 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Item;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.VendorSoftwareProductInfoDaoZusammenImpl;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+
+public class ElementToVSPGeneralConvertor extends ElementConvertor {
+ @Override
+ public VspDetails convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapInfoToVspDetails(element.getInfo());
+
+ }
+
+ @Override
+ public VspDetails convert(Item item) {
+ if (item == null) {
+ return null;
+ }
+ VspDetails vspDetails = mapInfoToVspDetails(item.getInfo());
+ vspDetails.setId(item.getId().getValue());
+ return vspDetails;
+ }
+
+ @Override
+ public VspDetails convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapInfoToVspDetails(elementInfo.getInfo());
+
+ }
+
+
+ private VspDetails mapInfoToVspDetails(Info info) {
+
+ VspDetails vspDetails = new VspDetails();
+
+ vspDetails.setName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl
+ .InfoPropertyName.name.name()));
+ vspDetails.setDescription(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.description.name()));
+ vspDetails.setIcon(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.icon.name()));
+ vspDetails.setCategory(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.category.name()));
+ vspDetails.setSubCategory(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.subCategory.name()));
+ vspDetails.setVendorId(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.vendorId.name()));
+ vspDetails.setVendorName(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.vendorName.name()));
+ if (info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.vendorVersion.name()) != null) {
+ vspDetails.setVlmVersion(new Version(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.vendorVersion.name())));
+ }
+
+ vspDetails.setLicenseAgreement(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.licenseAgreement.name()));
+ vspDetails.setFeatureGroups(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.featureGroups.name()));
+ vspDetails.setOnboardingMethod(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.onboardingMethod.name()));
+
+ return vspDetails;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java
new file mode 100644
index 0000000000..d51b8b23b3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.utils.fileutils.FileUtils;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
+
+public class ElementToVSPQuestionnaireConvertor extends ElementConvertor {
+ @Override
+ public VspQuestionnaireEntity convert( Element element) {
+ if(element == null) return null;
+ VspQuestionnaireEntity entity = new VspQuestionnaireEntity();
+ entity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData())));
+ return entity;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
index d3c2a22fff..b4c0d29f74 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
@@ -60,9 +60,6 @@ public class VendorSoftwareProductErrorCodes {
public static final String SAME_SOURCE_TARGET_COMPONENT = "SAME_SOURCE_TARGET_COMPONENT";
- public static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED =
- "VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED";
-
public static final String DUPLICATE_NIC_NAME_NOT_ALLOWED = "DUPLICATE_NIC_NAME_NOT_ALLOWED";
public static final String NIC_NAME_FORMAT_NOT_ALLOWED = "NIC_NAME_FORMAT_NOT_ALLOWED";
@@ -129,4 +126,7 @@ public class VendorSoftwareProductErrorCodes {
public static final String INVALID_EXTENSION = "INVALID_EXTENSION";
+ public static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED =
+ "VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED";
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java
index a7e55bd290..08d911b686 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java
@@ -26,7 +26,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
@@ -42,9 +41,8 @@ public class CompositionEntityDataManagerFactoryImpl extends CompositionEntityDa
ComponentDaoFactory.getInstance().createInterface(),
NicDaoFactory.getInstance().createInterface(),
NetworkDaoFactory.getInstance().createInterface(),
- ImageDaoFactory.getInstance().createInterface() ,
+ ImageDaoFactory.getInstance().createInterface(),
ComputeDaoFactory.getInstance().createInterface(),
- DeploymentFlavorDaoFactory.getInstance().createInterface(),
- VendorSoftwareProductDaoFactory.getInstance().createInterface());
+ DeploymentFlavorDaoFactory.getInstance().createInterface());
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java
index de29d5b8f0..78914aa0e5 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java
@@ -23,8 +23,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.quiestionnaire;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
@@ -47,8 +49,9 @@ import java.util.List;
* Created by TALIO on 11/22/2016
*/
public class QuestionnaireDataServiceImpl implements QuestionnaireDataService {
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
+ private static final ComponentDao componentDao =
+ ComponentDaoFactory.getInstance().createInterface();
+ private static final NicDao nicDao = NicDaoFactory.getInstance().createInterface();
private static final VendorSoftwareProductInfoDao vspInfoDao =
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@@ -56,15 +59,11 @@ public class QuestionnaireDataServiceImpl implements QuestionnaireDataService {
public InformationArtifactData generateQuestionnaireDataForInformationArtifact(String vspId,
Version version) {
-
-
mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
- VspDetails vspDetails =
- vspInfoDao.get(new VspDetails(vspId, version));
- Collection<ComponentEntity> componentEntities =
- vendorSoftwareProductDao.listComponentsQuestionnaire(vspId, version);
- Collection<NicEntity> nicEntities = vendorSoftwareProductDao.listNicsByVsp(vspId, version);
+ VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
+ Collection<ComponentEntity> componentEntities = componentDao.listQuestionnaires(vspId, version);
+ Collection<NicEntity> nicEntities = nicDao.listByVsp(vspId, version);
VspQuestionnaire vspQuestionnaire = getVspQuestionnaireFromJson(vspId, version);
List<ComponentQuestionnaire> componentQuestionnaireList =
@@ -100,7 +99,6 @@ public class QuestionnaireDataServiceImpl implements QuestionnaireDataService {
return componentQuestionnaireList;
}
-
private List<NicQuestionnaire> getListOfNicQuestionnaireFromJson(Collection<NicEntity> entities) {
List<NicQuestionnaire> nicQuestionnaireList = new ArrayList<>();
@@ -112,5 +110,4 @@ public class QuestionnaireDataServiceImpl implements QuestionnaireDataService {
return nicQuestionnaireList;
}
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java
index 100425858f..73b9491e73 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java
@@ -23,12 +23,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
@@ -57,10 +57,10 @@ import java.util.Optional;
public class ManualVspDataCollectionService {
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
private static final VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao =
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
+ private static final DeploymentFlavorDao deploymentFlavorDao =
+ DeploymentFlavorDaoFactory.getInstance().createInterface();
private static final ComputeDao computeDao =
ComputeDaoFactory.getInstance().createInterface();
private static final ImageDao imageDao =
@@ -75,16 +75,14 @@ public class ManualVspDataCollectionService {
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
/**
* Gets vendor name for the vsp.
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the release vendor name
*/
- public Optional<String> getReleaseVendor(String vspId, Version version, String user) {
+ public Optional<String> getReleaseVendor(String vspId, Version version) {
String vendorName = null;
VspDetails vspDetails = vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version));
if (Objects.nonNull(vspDetails)) {
@@ -98,14 +96,12 @@ public class ManualVspDataCollectionService {
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the allowed flavors
*/
- public Map<String, DeploymentFlavorModel> getAllowedFlavors(String vspId, Version version,
- String user) {
+ public Map<String, DeploymentFlavorModel> getAllowedFlavors(String vspId, Version version) {
Map<String, DeploymentFlavorModel> allowedFlavors = new HashMap<>();
Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) {
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
DeploymentFlavor deploymentFlavorCompositionData =
@@ -129,13 +125,12 @@ public class ManualVspDataCollectionService {
LicenseFlavor licenseFlavor = getLicenseFlavor(featureGroupId);
deploymentFlavorModel.setLicense_flavor(licenseFlavor);
//Get sp_part_number
- Optional<String> partNumber = getPartNumber(vspVlmId, vlmVersion, featureGroupId,
- user);
+ Optional<String> partNumber = getPartNumber(vspVlmId, vlmVersion, featureGroupId);
partNumber.ifPresent(deploymentFlavorModel::setSp_part_number);
//Gather and set Vendor Info
String vendorModel = deploymentFlavorCompositionData.getModel();
Optional<VendorInfo> vendorInfo = getVendorInfo(vspVlmId, vendorModel, vlmVersion,
- featureGroupId, user);
+ featureGroupId);
vendorInfo.ifPresent(deploymentFlavorModel::setVendor_info);
//Gather and set Compute info
List<ComponentComputeAssociation> componentComputeAssociations =
@@ -146,7 +141,7 @@ public class ManualVspDataCollectionService {
String componentId = componentComputeAssociation.getComponentId();
String computeFlavorId = componentComputeAssociation.getComputeFlavorId();
Optional<ComputeFlavor> computeFlavor =
- getComputeFlavor(vspId, version, componentId, computeFlavorId, user);
+ getComputeFlavor(vspId, version, componentId, computeFlavorId);
computeFlavor.ifPresent(deploymentFlavorModel::setCompute_flavor);
}
}
@@ -164,15 +159,13 @@ public class ManualVspDataCollectionService {
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the vsp component images
*/
public Map<String, List<MultiFlavorVfcImage>> getVspComponentImages(String vspId,
- Version version,
- String user) {
+ Version version) {
Map<String, List<MultiFlavorVfcImage>> vspComponentImages = new HashMap<>();
Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
DeploymentFlavor deploymentFlavorCompositionData =
deploymentFlavorEntity.getDeploymentFlavorCompositionData();
@@ -184,7 +177,7 @@ public class ManualVspDataCollectionService {
componentComputeAssociations) {
String componentId = componentComputeAssociation.getComponentId();
List<MultiFlavorVfcImage> componentImages =
- getComponentImages(vspId, version, componentId, user);
+ getComponentImages(vspId, version, componentId);
if (CollectionUtils.isNotEmpty(componentImages)) {
vspComponentImages.put(componentId, componentImages);
}
@@ -199,13 +192,12 @@ public class ManualVspDataCollectionService {
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the vsp components
*/
- public Map<String, String> getVspComponents(String vspId, Version version, String user) {
+ public Map<String, String> getVspComponents(String vspId, Version version) {
Map<String, String> componentIdNameMap = new HashMap<>();
Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
DeploymentFlavor deploymentFlavorCompositionData =
deploymentFlavorEntity.getDeploymentFlavorCompositionData();
@@ -216,7 +208,7 @@ public class ManualVspDataCollectionService {
for (ComponentComputeAssociation componentComputeAssociation :
componentComputeAssociations) {
String componentId = componentComputeAssociation.getComponentId();
- Optional<String> componentName = getComponentName(vspId, version, componentId, user);
+ Optional<String> componentName = getComponentName(vspId, version, componentId);
componentName.ifPresent(name -> componentIdNameMap.put(componentId, name));
}
}
@@ -229,13 +221,12 @@ public class ManualVspDataCollectionService {
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the vsp component nics
*/
- public Map<String, List<Nic>> getVspComponentNics(String vspId, Version version, String user) {
+ public Map<String, List<Nic>> getVspComponentNics(String vspId, Version version) {
Map<String, List<Nic>> vspComponentNics = new HashMap<>();
Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) {
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
DeploymentFlavor deploymentFlavorCompositionData =
@@ -247,7 +238,7 @@ public class ManualVspDataCollectionService {
for (ComponentComputeAssociation componentComputeAssociation :
componentComputeAssociations) {
String componentId = componentComputeAssociation.getComponentId();
- List<Nic> componentNics = getComponentNics(vspId, version, componentId, user);
+ List<Nic> componentNics = getComponentNics(vspId, version, componentId);
if (CollectionUtils.isNotEmpty(componentNics)) {
vspComponentNics.put(componentId, componentNics);
}
@@ -259,8 +250,7 @@ public class ManualVspDataCollectionService {
return vspComponentNics;
}
- private List<Nic> getComponentNics(String vspId, Version version, String componentId,
- String user) {
+ private List<Nic> getComponentNics(String vspId, Version version, String componentId) {
List<Nic> componentNics = new ArrayList<>();
Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentId, null));
if (Objects.nonNull(nics)) {
@@ -283,8 +273,8 @@ public class ManualVspDataCollectionService {
}
private Optional<String> getPartNumber(String vlmId, Version version,
- String featureGroupId, String user) {
- FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user);
+ String featureGroupId) {
+ FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId);
if (Objects.nonNull(featureGroup)) {
return Optional.ofNullable(featureGroup.getFeatureGroup().getPartNumber());
}
@@ -292,9 +282,9 @@ public class ManualVspDataCollectionService {
}
private Optional<VendorInfo> getVendorInfo(String vlmId, String vendorModel, Version version,
- String featureGroupId, String user) {
+ String featureGroupId) {
VendorInfo vendorInfo = null;
- FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user);
+ FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId);
if (Objects.nonNull(featureGroup)) {
//Process Feature group to get Manufacturer ref no.
String manufacturerReferenceNumber = featureGroup.getEntityManufacturerReferenceNumber();
@@ -308,29 +298,28 @@ public class ManualVspDataCollectionService {
}
private Optional<ComputeFlavor> getComputeFlavor(String vspId, Version version,
- String componentId, String computeFlavorId,
- String user) {
+ String componentId, String computeFlavorId) {
ComputeFlavor computeFlavor = null;
ComputeEntity computeQuestionnaire = null;
try {
computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId,
computeFlavorId);
} catch (Exception ex) {
- log.debug("",ex);
+ log.debug("", ex);
computeQuestionnaire = null;
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Failed to get compute questionnaire : "
+ ex.getMessage());
}
- if (computeQuestionnaire != null && Objects.nonNull(computeQuestionnaire)) {
+ if (Objects.nonNull(computeQuestionnaire)) {
String computeQuestionnaireData = computeQuestionnaire.getQuestionnaireData();
if (Objects.nonNull(computeQuestionnaireData)) {
Compute compute;
try {
compute = JsonUtil.json2Object(computeQuestionnaireData, Compute.class);
} catch (Exception ex) {
- log.debug("",ex);
+ log.debug("", ex);
compute = null;
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
@@ -354,17 +343,15 @@ public class ManualVspDataCollectionService {
return Optional.ofNullable(computeFlavor);
}
- private FeatureGroupModel getFeatureGroup(String vlmId, Version version, String featureGroupId,
- String user) {
+ private FeatureGroupModel getFeatureGroup(String vlmId, Version version, String featureGroupId) {
FeatureGroupEntity fgInput = new FeatureGroupEntity();
fgInput.setVendorLicenseModelId(vlmId);
fgInput.setVersion(version);
fgInput.setId(featureGroupId);
- return vendorLicenseFacade.getFeatureGroupModel(fgInput, user);
+ return vendorLicenseFacade.getFeatureGroupModel(fgInput);
}
- private Optional<String> getComponentName(String vspId, Version version, String componentId,
- String user) {
+ private Optional<String> getComponentName(String vspId, Version version, String componentId) {
ComponentEntity componentEntity =
componentDao.get(new ComponentEntity(vspId, version, componentId));
@@ -377,18 +364,16 @@ public class ManualVspDataCollectionService {
}
private List<MultiFlavorVfcImage> getComponentImages(String vspId, Version version,
- String componentId, String user) {
+ String componentId) {
List<MultiFlavorVfcImage> multiFlavorVfcImages = new ArrayList<>();
- MultiFlavorVfcImage multiFlavorVfcImage = null;
+ MultiFlavorVfcImage multiFlavorVfcImage;
Collection<ImageEntity> componentImages =
- vendorSoftwareProductDao.listImages(vspId, version, componentId);
+ imageDao.list(new ImageEntity(vspId, version, componentId, null));
if (Objects.nonNull(componentImages)) {
for (ImageEntity componentImage : componentImages) {
- String imageId = componentImage.getId();
- ImageEntity imageEntity = vendorSoftwareProductDao.getImage(vspId, version, componentId,
- imageId);
+ ImageEntity imageEntity = imageDao.get(componentImage);
ImageEntity imageQuestionnaireDataEntity = imageDao.getQuestionnaireData(vspId, version,
- componentId, imageId);
+ componentId, componentImage.getId());
Image imageCompositionData = imageEntity.getImageCompositionData();
if (Objects.nonNull(imageEntity)
&& Objects.nonNull(imageQuestionnaireDataEntity)
@@ -398,14 +383,14 @@ public class ManualVspDataCollectionService {
imageDetails = JsonUtil.json2Object(imageQuestionnaireDataEntity
.getQuestionnaireData(), ImageDetails.class);
} catch (Exception ex) {
- log.debug("",ex);
+ log.debug("", ex);
imageDetails = null;
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to parse image questionnaire : "
+ ex.getMessage());
}
- if (imageDetails != null && Objects.nonNull(imageDetails)
+ if (Objects.nonNull(imageDetails)
&& Objects.nonNull(imageDetails.getVersion())) {
//Image version is used as a key for the image block
//So excluding the population if questionnaire data is absent or invalid
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java
index 19e48eceaa..6b57649308 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java
@@ -47,8 +47,8 @@ import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstituteNodeTemplateErrorBui
import org.openecomp.sdc.tosca.errors.ToscaMissingSubstitutionMappingForReqCapErrorBuilder;
import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java
index 39534cf9b7..ab5ee6c64c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java
@@ -37,7 +37,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
@@ -78,14 +77,14 @@ import java.util.Set;
public class CompositionEntityDataManagerImpl implements CompositionEntityDataManager {
private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR =
- "COMPOSITION_ENTITY_DATA_MANAGER_ERR";
+ "COMPOSITION_ENTITY_DATA_MANAGER_ERR";
private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG =
- "Invalid input: %s may not be null";
+ "Invalid input: %s may not be null";
private static final String MISSING_OR_INVALID_QUESTIONNAIRE_MSG =
"Data is missing/invalid for this %s. Please refill and resubmit.";
private static final Logger logger =
- LoggerFactory.getLogger(CompositionEntityDataManagerImpl.class);
+ LoggerFactory.getLogger(CompositionEntityDataManagerImpl.class);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private Map<CompositionEntityId, CompositionEntityData> entities = new HashMap<>();
@@ -99,14 +98,12 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
private ImageDao imageDao;
private ComputeDao computeDao;
private DeploymentFlavorDao deploymentFlavorDao;
- private VendorSoftwareProductDao vendorSoftwareProductDao;
public CompositionEntityDataManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
ComponentDao componentDao,
NicDao nicDao, NetworkDao networkDao,
ImageDao imageDao, ComputeDao computeDao,
- DeploymentFlavorDao deploymentFlavorDao,
- VendorSoftwareProductDao vendorSoftwareProductDao) {
+ DeploymentFlavorDao deploymentFlavorDao) {
this.vspInfoDao = vspInfoDao;
this.componentDao = componentDao;
this.nicDao = nicDao;
@@ -114,7 +111,6 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
this.imageDao = imageDao;
this.computeDao = computeDao;
this.deploymentFlavorDao = deploymentFlavorDao;
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
}
/**
@@ -133,27 +129,27 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
if (entity == null) {
throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
- .build());
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
+ String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
+ .build());
}
if (schemaTemplateContext == null) {
throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "schema template context"))
- .build());
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
+ String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "schema template context"))
+ .build());
}
CompositionEntityValidationData validationData =
- new CompositionEntityValidationData(entity.getType(), entity.getId());
+ new CompositionEntityValidationData(entity.getType(), entity.getId());
String json =
- schemaTemplateContext == SchemaTemplateContext.composition ? entity.getCompositionData()
- : entity.getQuestionnaireData();
+ schemaTemplateContext == SchemaTemplateContext.composition ? entity.getCompositionData()
+ : entity.getQuestionnaireData();
validationData.setErrors(JsonUtil.validate(
- json == null ? JsonUtil.object2Json(new Object()) : json,
- generateSchema(schemaTemplateContext, entity.getType(), schemaTemplateInput)));
+ json == null ? JsonUtil.object2Json(new Object()) : json,
+ generateSchema(schemaTemplateContext, entity.getType(), schemaTemplateInput)));
mdcDataDebugMessage.debugExitMessage(null);
return validationData;
@@ -169,13 +165,13 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
public void addEntity(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput) {
if (entity == null) {
throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
- .build());
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
+ String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
+ .build());
}
entities.put(entity.getCompositionEntityId(),
- new CompositionEntityData(entity, schemaTemplateInput));
+ new CompositionEntityData(entity, schemaTemplateInput));
}
/**
@@ -205,10 +201,10 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
@Override
public void buildTrees() {
Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData =
- new HashMap<>();
+ new HashMap<>();
entities.entrySet().forEach(
- entry -> addValidationDataEntity(entitiesValidationData, entry.getKey(),
- entry.getValue().entity));
+ entry -> addValidationDataEntity(entitiesValidationData, entry.getKey(),
+ entry.getValue().entity));
}
public Collection<CompositionEntityValidationData> getTrees() {
@@ -259,14 +255,14 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
}
Collection<CompositionEntityValidationData> subEntitiesValidationData =
- entity.getSubEntitiesValidationData();
+ entity.getSubEntitiesValidationData();
return !CollectionUtils.isEmpty(subEntitiesValidationData) &&
- checkForErrorsInChildren(subEntitiesValidationData);
+ checkForErrorsInChildren(subEntitiesValidationData);
}
private boolean checkForErrorsInChildren(
- Collection<CompositionEntityValidationData> subEntitiesValidationData) {
+ Collection<CompositionEntityValidationData> subEntitiesValidationData) {
boolean result = false;
for (CompositionEntityValidationData subEntity : subEntitiesValidationData) {
if (CollectionUtils.isNotEmpty(subEntity.getErrors())) {
@@ -360,10 +356,10 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
//component.setId(CommonMethods.nextUuId()); will be set by the dao
component.setQuestionnaireData(
- new JsonSchemaDataGenerator(
- generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.component,
- null))
- .generateData());
+ new JsonSchemaDataGenerator(
+ generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.component,
+ null))
+ .generateData());
componentDao.create(component);
@@ -377,9 +373,9 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
//nic.setId(CommonMethods.nextUuId()); will be set by the dao
nic.setQuestionnaireData(
- new JsonSchemaDataGenerator(
- generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, null))
- .generateData());
+ new JsonSchemaDataGenerator(
+ generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, null))
+ .generateData());
nicDao.create(nic);
@@ -412,28 +408,26 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
return treeAsList;
}
- public void getEntityListWithErrors(CompositionEntityValidationData entity,
+ private void getEntityListWithErrors(CompositionEntityValidationData entity,
Set<CompositionEntityValidationData> compositionSet) {
- Collection<CompositionEntityValidationData> childNodes =
- entity.getSubEntitiesValidationData();
+ if(CollectionUtils.isNotEmpty(entity.getErrors())){
+ addNodeWithErrors(entity, compositionSet);
+ }
- if (CollectionUtils.isEmpty(childNodes)) {
+ if (CollectionUtils.isEmpty(entity.getSubEntitiesValidationData())) {
return;
}
- for (CompositionEntityValidationData child : childNodes) {
- if (CollectionUtils.isNotEmpty(child.getErrors())) {
- addNodeWithErrors(child, compositionSet);
- }
+ for (CompositionEntityValidationData child : entity.getSubEntitiesValidationData()) {
getEntityListWithErrors(child, compositionSet);
}
}
- public void addNodeWithErrors(CompositionEntityValidationData node,
+ private void addNodeWithErrors(CompositionEntityValidationData node,
Set<CompositionEntityValidationData> entitiesWithErrors) {
CompositionEntityValidationData compositionNodeToAdd = new CompositionEntityValidationData(node
- .getEntityType(), node.getEntityId());
+ .getEntityType(), node.getEntityId());
compositionNodeToAdd.setErrors(node.getErrors());
compositionNodeToAdd.setSubEntitiesValidationData(null);
@@ -446,9 +440,9 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
private CompositionEntityData getCompositionEntityDataById(CompositionEntityValidationData
- entity) {
+ entity) {
for (Map.Entry<CompositionEntityId, CompositionEntityData> entityEntry : entities
- .entrySet()) {
+ .entrySet()) {
if (entityEntry.getKey().getId().equals(entity.getEntityId())) {
return entityEntry.getValue();
}
@@ -458,11 +452,11 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
private void updateValidationCompositionEntityName(Set<CompositionEntityValidationData>
- compositionSet) {
+ compositionSet) {
for (CompositionEntityValidationData entity : compositionSet) {
String compositionData = getCompositionDataAsString(entity);
if (entity.getEntityType().equals(CompositionEntityType.vsp) ||
- Objects.nonNull(compositionData)) {
+ Objects.nonNull(compositionData)) {
entity.setEntityName(getEntityNameByEntityType(compositionData, entity));
}
}
@@ -497,8 +491,8 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
CompositionEntityData vspEntity = getCompositionEntityDataById(entity);
VspQuestionnaireEntity vspQuestionnaireEntity = (VspQuestionnaireEntity) vspEntity.entity;
VspDetails vspDetails =
- vspInfoDao.get(new VspDetails(vspQuestionnaireEntity.getId(),
- vspQuestionnaireEntity.getVersion()));
+ vspInfoDao.get(new VspDetails(vspQuestionnaireEntity.getId(),
+ vspQuestionnaireEntity.getVersion()));
return vspDetails.getName();
}
@@ -514,7 +508,7 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
if (hasChildren(node)) {
Collection<CompositionEntityValidationData> subNodes =
- new ArrayList<>(node.getSubEntitiesValidationData());
+ new ArrayList<>(node.getSubEntitiesValidationData());
subNodes.forEach(subNode -> removeNodesWithoutErrors(subNode, node));
node.setSubEntitiesValidationData(subNodes);
@@ -543,14 +537,14 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
private void addValidationDataEntity(
- Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData,
- CompositionEntityId entityId, CompositionEntity entity) {
+ Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData,
+ CompositionEntityId entityId, CompositionEntity entity) {
if (entitiesValidationData.containsKey(entityId)) {
return;
}
CompositionEntityValidationData validationData =
- new CompositionEntityValidationData(entity.getType(), entity.getId());
+ new CompositionEntityValidationData(entity.getType(), entity.getId());
entitiesValidationData.put(entityId, validationData);
CompositionEntityId parentEntityId = entityId.getParentId();
@@ -578,16 +572,16 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
if (node.getSubEntitiesValidationData() != null) {
node.getSubEntitiesValidationData()
- .forEach(subNode -> addErrorsToTree(subNode, nodeId, errors));
+ .forEach(subNode -> addErrorsToTree(subNode, nodeId, errors));
}
}
private Collection<String> validateQuestionnaire(CompositionEntityData compositionEntityData) {
logger.debug(String.format("validateQuestionnaire start: " +
- "[entity.type]=%s, [entity.id]=%s, [entity.questionnaireString]=%s",
- compositionEntityData.entity.getType().name(),
- compositionEntityData.entity.getCompositionEntityId().toString(),
- compositionEntityData.entity.getQuestionnaireData()));
+ "[entity.type]=%s, [entity.id]=%s, [entity.questionnaireString]=%s",
+ compositionEntityData.entity.getType().name(),
+ compositionEntityData.entity.getCompositionEntityId().toString(),
+ compositionEntityData.entity.getQuestionnaireData()));
if (Objects.isNull(compositionEntityData.entity.getQuestionnaireData()) ||
!JsonUtil.isValidJson(compositionEntityData.entity.getQuestionnaireData())) {
@@ -596,20 +590,20 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
}
return JsonUtil.validate(
- compositionEntityData.entity.getQuestionnaireData() == null
- ? JsonUtil.object2Json(new Object())
- : compositionEntityData.entity.getQuestionnaireData(),
- getSchema(compositionEntityData.entity.getType(), SchemaTemplateContext.questionnaire,
- compositionEntityData.schemaTemplateInput));
+ compositionEntityData.entity.getQuestionnaireData() == null
+ ? JsonUtil.object2Json(new Object())
+ : compositionEntityData.entity.getQuestionnaireData(),
+ getSchema(compositionEntityData.entity.getType(), SchemaTemplateContext.questionnaire,
+ compositionEntityData.schemaTemplateInput));
}
private String getSchema(CompositionEntityType compositionEntityType,
SchemaTemplateContext schemaTemplateContext,
SchemaTemplateInput schemaTemplateInput) {
return schemaTemplateInput == null
- ? nonDynamicSchemas.computeIfAbsent(compositionEntityType,
- k -> generateSchema(schemaTemplateContext, compositionEntityType, null))
- : generateSchema(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
+ ? nonDynamicSchemas.computeIfAbsent(compositionEntityType,
+ k -> generateSchema(schemaTemplateContext, compositionEntityType, null))
+ : generateSchema(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
}
private static class CompositionEntityData {
@@ -630,7 +624,7 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
CompositionEntityType compositionEntityType,
SchemaTemplateInput schemaTemplateInput) {
return SchemaGenerator
- .generate(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
+ .generate(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
}
@Override
@@ -649,46 +643,33 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
image.setId(CommonMethods.nextUuId());
image.setQuestionnaireData(
- new JsonSchemaDataGenerator(SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image, null))
- .generateData());
+ new JsonSchemaDataGenerator(SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image, null))
+ .generateData());
imageDao.create(image);
mdcDataDebugMessage.debugExitMessage(null, null);
return image;
}
- @Override
- public ComputeEntity createCompute(ComputeEntity compute) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", compute.getVspId(),
- compute.getComponentId());
-
- compute.setId(CommonMethods.nextUuId());
- compute.setQuestionnaireData(
- new JsonSchemaDataGenerator(SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute,
- null)).generateData());
-
- computeDao.create(compute);
-
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", compute.getVspId(),
- compute.getComponentId());
- return compute;
- }
-
public void saveComputesFlavorByComponent(String vspId, Version version, Component component,
String componentId) {
if (CollectionUtils.isNotEmpty(component.getCompute())) {
for (ComputeData flavor : component.getCompute()) {
ComputeEntity computeEntity = new ComputeEntity(vspId, version, componentId, null);
computeEntity.setComputeCompositionData(flavor);
- createCompute(computeEntity);
+ computeEntity.setQuestionnaireData(
+ new JsonSchemaDataGenerator(SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute,
+ null)).generateData());
+
+ computeDao.create(computeEntity);
}
}
}
public void saveImagesByComponent(String vspId, Version version, Component component, String
- componentId) {
+ componentId) {
if (CollectionUtils.isNotEmpty(component.getImages())) {
for (Image img : component.getImages()) {
ImageEntity imageEntity = new ImageEntity(vspId, version, componentId, null);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
index 640777e993..45746ed84e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
@@ -72,577 +72,591 @@ import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class CandidateServiceImpl implements CandidateService {
- protected static final Logger logger = LoggerFactory.getLogger(CandidateServiceImpl.class);
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ protected static final Logger logger = LoggerFactory.getLogger(CandidateServiceImpl.class);
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private CandidateServiceValidator candidateServiceValidator = new CandidateServiceValidator();
- private ManifestCreator manifestCreator;
- private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao;
+ private CandidateServiceValidator candidateServiceValidator = new CandidateServiceValidator();
+ private ManifestCreator manifestCreator;
+ private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao;
- public CandidateServiceImpl(ManifestCreator manifestCreator,
- OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao) {
- this.manifestCreator = manifestCreator;
- this.orchestrationTemplateCandidateDataDao = orchestrationTemplateCandidateDataDao;
+ public CandidateServiceImpl(ManifestCreator manifestCreator,
+ OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao) {
+ this.manifestCreator = manifestCreator;
+ this.orchestrationTemplateCandidateDao = orchestrationTemplateCandidateDao;
- }
+ }
- public CandidateServiceImpl() {
- }
+ public CandidateServiceImpl() {
+ }
- @Override
- public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream fileToUpload) {
+ @Override
+ public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream fileToUpload) {
- mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugEntryMessage(null);
- if (Objects.isNull(fileToUpload)) {
- return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- } else {
- try {
- int available = fileToUpload.available();
- if (available == 0) {
- mdcDataDebugMessage.debugExitMessage(null);
- return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- }
- } catch (IOException e) {
- logger.debug(e.getMessage(), e);
- mdcDataDebugMessage.debugExitMessage(null);
- return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- }
+ if (Objects.isNull(fileToUpload)) {
+ return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ } else {
+ try {
+ int available = fileToUpload.available();
+ if (available == 0) {
+ mdcDataDebugMessage.debugExitMessage(null);
+ return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
}
-
+ } catch (IOException e) {
+ logger.debug(e.getMessage(), e);
mdcDataDebugMessage.debugExitMessage(null);
- return Optional.empty();
+ return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ }
}
- @Override
- public Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData) {
- if (Objects.isNull(uploadedFileData)) {
- return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- }
- return Optional.empty();
- }
-
- private String heatStructureTreeToFileDataStructure(HeatStructureTree tree,
- FileContentHandler zipContentMap,
- Map<String, List<ErrorMessage>> uploadErrors,
- AnalyzedZipHeatFiles analyzedZipHeatFiles)
- throws Exception {
- FilesDataStructure structure = new FilesDataStructure();
- Set<String> usedEnvFiles = new HashSet<>();
- addHeatsToFileDataStructure(tree, usedEnvFiles, structure, uploadErrors,
- analyzedZipHeatFiles);
- handleOtherResources(tree, usedEnvFiles, structure);
- FilesDataStructure fileDataStructureFromManifest =
- createFileDataStructureFromManifest(zipContentMap.getFileContent
- (SdcCommon.MANIFEST_NAME));
- List<String> structureArtifacts = structure.getArtifacts();
- structureArtifacts.addAll(fileDataStructureFromManifest.getArtifacts().stream().filter
- (artifact -> isNotStrctureArtifact(structureArtifacts, artifact)).collect((Collectors.toList())));
- handleArtifactsFromTree(tree, structure);
-
- return JsonUtil.object2Json(structure);
- }
-
- private boolean isNotStrctureArtifact(List<String> structureArtifacts, String artifact) {
- return !structureArtifacts.contains(artifact);
- }
-
- @Override
- public OrchestrationTemplateCandidateData createCandidateDataEntity(
- CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception {
-
-
- mdcDataDebugMessage.debugEntryMessage(null);
-
- FileContentHandler zipContentMap = candidateDataEntityTo.getContentMap();
- FilesDataStructure filesDataStructure;
- String dataStructureJson;
-
- if (zipFileManifest != null) {
- // create data structure from manifest
- filesDataStructure = createFileDataStructureFromManifest(zipFileManifest);
- Set<String> zipFileList = zipContentMap.getFileList();
- balanceManifestFilesWithZipFiles(filesDataStructure,
- zipContentMap, analyzedZipHeatFiles);
- Set<String> filesDataStructureFiles = getFlatFileNames(filesDataStructure);
- filesDataStructure.getUnassigned().addAll(zipFileList.stream()
- .filter(fileName -> (!filesDataStructureFiles.contains(fileName) &&
- !filesDataStructure.getNested().contains(fileName) &&
- !fileName.equals(SdcCommon.MANIFEST_NAME)))
- .collect(Collectors.toList()));
- dataStructureJson = JsonUtil.object2Json(filesDataStructure);
- } else {
- // create data structure from based on naming convention
- dataStructureJson =
- heatStructureTreeToFileDataStructure(candidateDataEntityTo.getTree(), zipContentMap,
- candidateDataEntityTo.getErrors(), analyzedZipHeatFiles);
- }
+ mdcDataDebugMessage.debugExitMessage(null);
+ return Optional.empty();
+ }
- mdcDataDebugMessage.debugExitMessage(null);
- return new OrchestrationTemplateCandidateData(
- ByteBuffer.wrap(candidateDataEntityTo.getUploadedFileData()), dataStructureJson);
- }
-
- private void balanceManifestFilesWithZipFiles(
- FilesDataStructure filesDataStructure,
- FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles)
- throws Exception {
- Set<String> zipFileList = fileContentHandler.getFileList();
- filesDataStructure.getNested().addAll(analyzedZipHeatFiles.getNestedFiles());
- List<Module> modules = filesDataStructure.getModules();
- if (CollectionUtils.isEmpty(modules)) {
- return;
- }
+ @Override
+ public Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData) {
+ if (Objects.isNull(uploadedFileData)) {
+ return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ }
+ return Optional.empty();
+ }
+
+ private String heatStructureTreeToFileDataStructure(HeatStructureTree tree,
+ FileContentHandler zipContentMap,
+ Map<String, List<ErrorMessage>> uploadErrors,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws Exception {
+ FilesDataStructure structure = new FilesDataStructure();
+ Set<String> usedEnvFiles = new HashSet<>();
+ addHeatsToFileDataStructure(tree, usedEnvFiles, structure, uploadErrors,
+ analyzedZipHeatFiles);
+ handleOtherResources(tree, usedEnvFiles, structure);
+ FilesDataStructure fileDataStructureFromManifest =
+ createFileDataStructureFromManifest(zipContentMap.getFileContent
+ (SdcCommon.MANIFEST_NAME));
+ List<String> structureArtifacts = structure.getArtifacts();
+ structureArtifacts.addAll(fileDataStructureFromManifest.getArtifacts().stream().filter
+ (artifact -> isNotStrctureArtifact(structureArtifacts, artifact))
+ .collect((Collectors.toList())));
+ handleArtifactsFromTree(tree, structure);
+
+ return JsonUtil.object2Json(structure);
+ }
+
+ private boolean isNotStrctureArtifact(List<String> structureArtifacts, String artifact) {
+ return !structureArtifacts.contains(artifact);
+ }
- for (int i = 0; i < modules.size(); i++) {
- Module module = modules.get(i);
- if (!isFileExistInZipContains(zipFileList, module.getYaml())) {
- addFileToUnassigned(filesDataStructure, zipFileList, module.getEnv());
- addFileToUnassigned(filesDataStructure, zipFileList, module.getVol());
- addFileToUnassigned(filesDataStructure, zipFileList, module.getVolEnv());
- modules.remove(i--);
- } else if (Objects.nonNull(module.getVol()) && !zipFileList.contains(module.getVol())) {
- module.setVol(null);
- CollectionUtils
- .addIgnoreNull(filesDataStructure.getUnassigned(), module.getVolEnv());
- } else {
- if (filesDataStructure.getNested().contains(module.getYaml())) {
- moveModuleFileToNested(filesDataStructure, i--, module);
- }
- }
- }
- }
+ @Override
+ public OrchestrationTemplateCandidateData createCandidateDataEntity(
+ CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ FileContentHandler zipContentMap = candidateDataEntityTo.getContentMap();
+ FilesDataStructure filesDataStructure;
+ String dataStructureJson;
+
+ if (zipFileManifest != null) {
+ // create data structure from manifest
+ filesDataStructure = createFileDataStructureFromManifest(zipFileManifest);
+ Set<String> zipFileList = zipContentMap.getFileList();
+ balanceManifestFilesWithZipFiles(filesDataStructure,
+ zipContentMap, analyzedZipHeatFiles);
+ Set<String> filesDataStructureFiles = getFlatFileNames(filesDataStructure);
+ filesDataStructure.getUnassigned().addAll(zipFileList.stream()
+ .filter(fileName -> (!filesDataStructureFiles.contains(fileName) &&
+ !filesDataStructure.getNested().contains(fileName) &&
+ !fileName.equals(SdcCommon.MANIFEST_NAME)))
+ .collect(Collectors.toList()));
+ dataStructureJson = JsonUtil.object2Json(filesDataStructure);
+ } else {
+ // create data structure from based on naming convention
+ dataStructureJson =
+ heatStructureTreeToFileDataStructure(candidateDataEntityTo.getTree(), zipContentMap,
+ candidateDataEntityTo.getErrors(), analyzedZipHeatFiles);
+ }
+
+ OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
+ candidateData.setContentData(ByteBuffer.wrap(candidateDataEntityTo.getUploadedFileData()));
+ candidateData.setFilesDataStructure(dataStructureJson);
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return candidateData;
+ }
+
+ private void balanceManifestFilesWithZipFiles(
+ FilesDataStructure filesDataStructure,
+ FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws Exception {
+ Set<String> zipFileList = fileContentHandler.getFileList();
+ filesDataStructure.getNested().addAll(analyzedZipHeatFiles.getNestedFiles());
+ List<Module> modules = filesDataStructure.getModules();
+ if (CollectionUtils.isEmpty(modules)) {
+ return;
+ }
+
+ for (int i = 0; i < modules.size(); i++) {
+ Module module = modules.get(i);
+ if (!isFileExistInZipContains(zipFileList, module.getYaml())) {
+ addFileToUnassigned(filesDataStructure, zipFileList, module.getEnv());
+ addFileToUnassigned(filesDataStructure, zipFileList, module.getVol());
+ addFileToUnassigned(filesDataStructure, zipFileList, module.getVolEnv());
+ modules.remove(i--);
+ } else if (Objects.nonNull(module.getVol()) && !zipFileList.contains(module.getVol())) {
+ module.setVol(null);
+ CollectionUtils
+ .addIgnoreNull(filesDataStructure.getUnassigned(), module.getVolEnv());
+ } else {
+ if (filesDataStructure.getNested().contains(module.getYaml())) {
+ moveModuleFileToNested(filesDataStructure, i--, module);
+ }
+ }
+ }
+ }
+
+ private void addFileToUnassigned(FilesDataStructure filesDataStructure, Set<String> zipFileList,
+ String fileName) {
+ if (isFileExistInZipContains(zipFileList, fileName)) {
+ filesDataStructure.getUnassigned().add(fileName);
+ }
+ }
+
+ private boolean isFileExistInZipContains(Set<String> zipFileList, String fileName) {
+ return Objects.nonNull(fileName) && zipFileList.contains(fileName);
+ }
+
+ private void moveModuleFileToNested(FilesDataStructure filesDataStructure, int i,
+ Module module) {
+ if (!filesDataStructure.getNested().contains(module.getYaml())) {
+ filesDataStructure.getNested().add(module.getYaml());
+ }
+ if (Objects.nonNull(module.getEnv())) {
+ filesDataStructure.getNested().add(module.getEnv());
+ }
+ if (Objects.nonNull(module.getVol())) {
+ filesDataStructure.getNested().add(module.getVol());
+ }
+ if (Objects.nonNull(module.getVolEnv())) {
+ filesDataStructure.getNested().add(module.getVolEnv());
+ }
+ filesDataStructure.getModules().remove(i);
+ }
+
+ private Set<String> getFlatFileNames(FilesDataStructure filesDataStructure) {
+ Set<String> fileNames = new HashSet<>();
+ if (!CollectionUtils.isEmpty(filesDataStructure.getModules())) {
+ for (Module module : filesDataStructure.getModules()) {
+ CollectionUtils.addIgnoreNull(fileNames, module.getEnv());
+ CollectionUtils.addIgnoreNull(fileNames, module.getVol());
+ CollectionUtils.addIgnoreNull(fileNames, module.getVolEnv());
+ CollectionUtils.addIgnoreNull(fileNames, module.getYaml());
+ }
+ }
+ fileNames.addAll(filesDataStructure.getArtifacts().stream().collect(Collectors.toSet()));
+ fileNames.addAll(filesDataStructure.getNested().stream().collect(Collectors.toSet()));
+ fileNames.addAll(filesDataStructure.getUnassigned().stream().collect(Collectors.toSet()));
+
+ return fileNames;
+ }
+
+ private FilesDataStructure createFileDataStructureFromManifest(InputStream isManifestContent) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ ManifestContent manifestContent =
+ JsonUtil.json2Object(isManifestContent, ManifestContent.class);
+ FilesDataStructure structure = new FilesDataStructure();
+ for (FileData fileData : manifestContent.getData()) {
+ if (Objects.nonNull(fileData.getType()) &&
+ fileData.getType().equals(FileData.Type.HEAT)) {
+ Module module = new Module();
+ module.setYaml(fileData.getFile());
+ module.setIsBase(fileData.getBase());
+ addHeatDependenciesToModule(module, fileData.getData());
+ structure.getModules().add(module);
+ } else if (HeatFileAnalyzer.isYamlOrEnvFile(fileData.getFile()) &&
+ !FileData.Type.isArtifact(fileData.getType())) {
+ structure.getUnassigned().add(fileData.getFile());
+ } else {
+ structure.getArtifacts().add(fileData.getFile());
+ }
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return structure;
+ }
+
+ private void addHeatDependenciesToModule(Module module, List<FileData> data) {
+ if (CollectionUtils.isEmpty(data)) {
+ return;
+ }
+
+ for (FileData fileData : data) {
+ if (fileData.getType().equals(FileData.Type.HEAT_ENV)) {
+ module.setEnv(fileData.getFile());
+ } else if (fileData.getType().equals(FileData.Type.HEAT_VOL))// must be volume
+ {
+ module.setVol(fileData.getFile());
+ if (!CollectionUtils.isEmpty(fileData.getData())) {
+ FileData volEnv = fileData.getData().get(0);
+ if (volEnv.getType().equals(FileData.Type.HEAT_ENV)) {
+ module.setVolEnv(volEnv.getFile());
+ } else {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder())
+ .withMessage(Messages.ILLEGAL_MANIFEST.getErrorMessage())
+ .withId(Messages.ILLEGAL_MANIFEST.getErrorMessage())
+ .withCategory(ErrorCategory.APPLICATION).build());
+ }
+ }
+ } else {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder())
+ .withMessage(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage())
+ .withId(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage())
+ .withCategory(ErrorCategory.APPLICATION).build());
+ }
+ }
+ }
- private void addFileToUnassigned(FilesDataStructure filesDataStructure, Set<String> zipFileList,
- String fileName) {
- if (isFileExistInZipContains(zipFileList, fileName)) {
- filesDataStructure.getUnassigned().add(fileName);
- }
- }
+ @Override
+ public void updateCandidateUploadData(String vspId, Version version,
+ OrchestrationTemplateCandidateData uploadData) {
+ mdcDataDebugMessage.debugEntryMessage(null);
- private boolean isFileExistInZipContains(Set<String> zipFileList, String fileName) {
- return Objects.nonNull(fileName) && zipFileList.contains(fileName);
- }
+ orchestrationTemplateCandidateDao.update(vspId, version, uploadData);
- private void moveModuleFileToNested(FilesDataStructure filesDataStructure, int i,
- Module module) {
- if (!filesDataStructure.getNested().contains(module.getYaml())) {
- filesDataStructure.getNested().add(module.getYaml());
- }
- if (Objects.nonNull(module.getEnv())) {
- filesDataStructure.getNested().add(module.getEnv());
- }
- if (Objects.nonNull(module.getVol())) {
- filesDataStructure.getNested().add(module.getVol());
- }
- if (Objects.nonNull(module.getVolEnv())) {
- filesDataStructure.getNested().add(module.getVolEnv());
- }
- filesDataStructure.getModules().remove(i);
- }
-
- private Set<String> getFlatFileNames(FilesDataStructure filesDataStructure) {
- Set<String> fileNames = new HashSet<>();
- if (!CollectionUtils.isEmpty(filesDataStructure.getModules())) {
- for (Module module : filesDataStructure.getModules()) {
- CollectionUtils.addIgnoreNull(fileNames, module.getEnv());
- CollectionUtils.addIgnoreNull(fileNames, module.getVol());
- CollectionUtils.addIgnoreNull(fileNames, module.getVolEnv());
- CollectionUtils.addIgnoreNull(fileNames, module.getYaml());
- }
- }
- fileNames.addAll(filesDataStructure.getArtifacts().stream().collect(Collectors.toSet()));
- fileNames.addAll(filesDataStructure.getNested().stream().collect(Collectors.toSet()));
- fileNames.addAll(filesDataStructure.getUnassigned().stream().collect(Collectors.toSet()));
-
- return fileNames;
- }
-
- private FilesDataStructure createFileDataStructureFromManifest(InputStream isManifestContent) {
-
-
- mdcDataDebugMessage.debugEntryMessage(null);
-
- ManifestContent manifestContent =
- JsonUtil.json2Object(isManifestContent, ManifestContent.class);
- FilesDataStructure structure = new FilesDataStructure();
- for (FileData fileData : manifestContent.getData()) {
- if (Objects.nonNull(fileData.getType()) &&
- fileData.getType().equals(FileData.Type.HEAT)) {
- Module module = new Module();
- module.setYaml(fileData.getFile());
- module.setIsBase(fileData.getBase());
- addHeatDependenciesToModule(module, fileData.getData());
- structure.getModules().add(module);
- } else if (HeatFileAnalyzer.isYamlOrEnvFile(fileData.getFile()) &&
- !FileData.Type.isArtifact(fileData.getType())) {
- structure.getUnassigned().add(fileData.getFile());
- } else {
- structure.getArtifacts().add(fileData.getFile());
- }
- }
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
- mdcDataDebugMessage.debugExitMessage(null);
- return structure;
- }
+ @Override
+ public Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(
+ String vspId, Version version) {
- private void addHeatDependenciesToModule(Module module, List<FileData> data) {
- if (CollectionUtils.isEmpty(data)) {
- return;
- }
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
- for (FileData fileData : data) {
- if (fileData.getType().equals(FileData.Type.HEAT_ENV)) {
- module.setEnv(fileData.getFile());
- } else if (fileData.getType().equals(FileData.Type.HEAT_VOL))// must be volume
- {
- module.setVol(fileData.getFile());
- if (!CollectionUtils.isEmpty(fileData.getData())) {
- FileData volEnv = fileData.getData().get(0);
- if (volEnv.getType().equals(FileData.Type.HEAT_ENV)) {
- module.setVolEnv(volEnv.getFile());
- } else {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(Messages.ILLEGAL_MANIFEST.getErrorMessage())
- .withId(Messages.ILLEGAL_MANIFEST.getErrorMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
- }
- }
- } else {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage())
- .withId(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
- }
- }
- }
+ Optional<String> jsonFileDataStructure =
+ orchestrationTemplateCandidateDao.getStructure(vspId, version);
- @Override
- public void updateCandidateUploadData(OrchestrationTemplateCandidateData uploadData,
- String itemId) {
- mdcDataDebugMessage.debugEntryMessage(null);
- orchestrationTemplateCandidateDataDao.update(itemId, uploadData);
- mdcDataDebugMessage.debugExitMessage(null);
+ if (jsonFileDataStructure.isPresent() && JsonUtil.isValidJson(jsonFileDataStructure.get())) {
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
+ return Optional
+ .of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class));
+ } else {
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
+ return Optional.empty();
}
+ }
- @Override
- public Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(
- String vspId, Version version) {
-
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
-
- Optional<String> jsonFileDataStructure =
- orchestrationTemplateCandidateDataDao.getStructure(vspId, version);
+ @Override
+ public void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version,
+ FilesDataStructure fileDataStructure) {
+ OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface()
+ .updateStructure(vspId, version, fileDataStructure);
+ }
- if (jsonFileDataStructure.isPresent()
- && JsonUtil.isValidJson(jsonFileDataStructure.get())) {
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
- return Optional
- .of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class));
- } else {
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
- return Optional.empty();
- }
- }
+ @Override
+ public OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId,
+ Version version) {
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
- @Override
- public void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version,
- FilesDataStructure fileDataStructure) {
- OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface()
- .updateStructure(vspId, version, fileDataStructure);
- }
+ return orchestrationTemplateCandidateDao.get(vspId, version);
+ }
- @Override
- public OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId,
- Version version) {
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
+ @Override
+ public OrchestrationTemplateCandidateData getOrchestrationTemplateCandidateInfo(String vspId,
+ Version version) {
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
- return orchestrationTemplateCandidateDataDao.get(vspId, version);
- }
+ return orchestrationTemplateCandidateDao.getInfo(vspId, version);
+ }
@Override
public String createManifest(VspDetails vspDetails, FilesDataStructure structure) {
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
-
- Optional<ManifestContent> manifest = manifestCreator.createManifest(vspDetails, structure);
- if (!manifest.isPresent()) {
- throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
- }
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
- return JsonUtil.object2Json(manifest.get());
- }
-
- @Override
- public Optional<ManifestContent> createManifest(VspDetails vspDetails,
- FileContentHandler fileContentHandler,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) {
-
-
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
-
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
- return manifestCreator.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
- }
-
- @Override
- public Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
- OrchestrationTemplateCandidateData candidateDataEntity,
- String manifest,
- OnboardingTypesEnum type,
- Map<String, List<ErrorMessage>> uploadErrors) {
- byte[] file;
- ByteArrayInputStream byteArrayInputStream = null;
- try {
- file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, vspId, type);
- byteArrayInputStream = new ByteArrayInputStream(
- Objects.isNull(file) ? candidateDataEntity.getContentData().array()
- : file);
- } catch (IOException e) {
- ErrorMessage errorMessage =
- new ErrorMessage(ErrorLevel.ERROR,
- Messages.CANDIDATE_PROCESS_FAILED.getErrorMessage());
- logger.error(errorMessage.getMessage(), e);
- ErrorsUtil
- .addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, errorMessage, uploadErrors);
- }
- return Optional.ofNullable(byteArrayInputStream);
- }
-
- @Override
- public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId,
- OnboardingTypesEnum type)
- throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- try (final ZipOutputStream zos = new ZipOutputStream(baos);
- ZipInputStream zipStream = new ZipInputStream(
- new ByteArrayInputStream(contentData.array()))) {
- ZipEntry zipEntry;
- boolean manifestWritten = false;
- while ((zipEntry = zipStream.getNextEntry()) != null) {
- if (!zipEntry.getName().equalsIgnoreCase(SdcCommon.MANIFEST_NAME)) {
- ZipEntry loc_ze = new ZipEntry(zipEntry.getName());
- zos.putNextEntry(loc_ze);
- byte[] buf = new byte[1024];
- int len;
- while ((len = zipStream.read(buf)) > 0) {
- zos.write(buf, 0, (len < buf.length) ? len : buf.length);
- }
- } else {
- manifestWritten = true;
- writeManifest(manifest, type, zos);
- }
- zos.closeEntry();
- }
- if (!manifestWritten) {
- writeManifest(manifest, type, zos);
- zos.closeEntry();
- }
- }
- return baos.toByteArray();
+ Optional<ManifestContent> manifest = manifestCreator.createManifest(vspDetails, structure);
+ if (!manifest.isPresent()) {
+ throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
}
- @Override
- public Optional<List<ErrorMessage>> validateFileDataStructure(
- FilesDataStructure filesDataStructure) {
- return candidateServiceValidator.validateFileDataStructure(filesDataStructure);
- }
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
+ return JsonUtil.object2Json(manifest.get());
+ }
- private void writeManifest(String manifest,
- OnboardingTypesEnum type,
- ZipOutputStream zos) throws IOException {
-
- if(isManifestNeedsToGetWritten(type)){
- return;
- }
-
- zos.putNextEntry(new ZipEntry(SdcCommon.MANIFEST_NAME));
- try (InputStream manifestStream = new ByteArrayInputStream(
- manifest.getBytes(StandardCharsets.UTF_8))) {
- byte[] buf = new byte[1024];
- int len;
- while ((len = (manifestStream.read(buf))) > 0) {
- zos.write(buf, 0, (len < buf.length) ? len : buf.length);
- }
- }
- }
+ @Override
+ public Optional<ManifestContent> createManifest(VspDetails vspDetails,
+ FileContentHandler fileContentHandler,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) {
- private boolean isManifestNeedsToGetWritten(OnboardingTypesEnum type) {
- return type.equals(OnboardingTypesEnum.CSAR);
- }
- private void handleArtifactsFromTree(HeatStructureTree tree, FilesDataStructure structure) {
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
- if (Objects.isNull(tree) || Objects.isNull(tree.getArtifacts())) {
- return;
- }
-
- if (CollectionUtils.isNotEmpty(tree.getArtifacts())) {
- structure.getArtifacts().addAll(
- tree.getArtifacts()
- .stream()
- .map(Artifact::getFileName)
- .filter(fileName -> !structure.getArtifacts().contains(fileName))
- .collect(Collectors.toList()));
- }
- }
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
+ return manifestCreator.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
+ }
- private void handleOtherResources(HeatStructureTree tree, Set<String> usedEnvFiles,
- FilesDataStructure structure) {
- Set<HeatStructureTree> others = tree.getOther();
- if (Objects.isNull(others)) {
- return;
- }
+ @Override
+ public Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
+ OrchestrationTemplateCandidateData candidateDataEntity,
+ String manifest,
+ OnboardingTypesEnum type,
+ Map<String, List<ErrorMessage>> uploadErrors) {
+ byte[] file;
+ ByteArrayInputStream byteArrayInputStream = null;
+ try {
+ file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, vspId, type);
+ byteArrayInputStream = new ByteArrayInputStream(
+ Objects.isNull(file) ? candidateDataEntity.getContentData().array()
+ : file);
+ } catch (IOException e) {
+ ErrorMessage errorMessage =
+ new ErrorMessage(ErrorLevel.ERROR,
+ Messages.CANDIDATE_PROCESS_FAILED.getErrorMessage());
+ logger.error(errorMessage.getMessage(), e);
+ ErrorsUtil
+ .addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, errorMessage, uploadErrors);
+ }
+ return Optional.ofNullable(byteArrayInputStream);
+ }
- List<String> artifacts = new ArrayList<>();
- List<String> unassigned = new ArrayList<>();
- for (HeatStructureTree other : others) {
- if (HeatFileAnalyzer.isYamlOrEnvFile(other.getFileName())) {
- if (isEnvFileUsedByHeatFile(usedEnvFiles, other)) {
- continue;
- }
- unassigned.add(other.getFileName());
- } else {
- artifacts.add(other.getFileName());
- }
- handleArtifactsFromTree(other, structure);
+ @Override
+ public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId,
+ OnboardingTypesEnum type)
+ throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ try (final ZipOutputStream zos = new ZipOutputStream(baos);
+ ZipInputStream zipStream = new ZipInputStream(
+ new ByteArrayInputStream(contentData.array()))) {
+ ZipEntry zipEntry;
+ boolean manifestWritten = false;
+ while ((zipEntry = zipStream.getNextEntry()) != null) {
+ if (!zipEntry.getName().equalsIgnoreCase(SdcCommon.MANIFEST_NAME)) {
+ ZipEntry loc_ze = new ZipEntry(zipEntry.getName());
+ zos.putNextEntry(loc_ze);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = zipStream.read(buf)) > 0) {
+ zos.write(buf, 0, (len < buf.length) ? len : buf.length);
+ }
+ } else {
+ manifestWritten = true;
+ writeManifest(manifest, type, zos);
}
- structure.getArtifacts().addAll(artifacts);
- structure.getUnassigned().addAll(unassigned);
+ zos.closeEntry();
+ }
+ if (!manifestWritten) {
+ writeManifest(manifest, type, zos);
+ zos.closeEntry();
+ }
}
+ return baos.toByteArray();
+ }
- private boolean isEnvFileUsedByHeatFile(Set<String> usedEnvFiles, HeatStructureTree other) {
- if (HeatFileAnalyzer.isEnvFile(other.getFileName())) {
- if (usedEnvFiles.contains(other.getFileName())) {
- return true;
- }
- }
- return false;
- }
-
- private void addHeatsToFileDataStructure(HeatStructureTree tree, Set<String> usedEnvFiles,
- FilesDataStructure structure,
- Map<String, List<ErrorMessage>> uploadErrors,
- AnalyzedZipHeatFiles analyzedZipHeatFiles)
- throws Exception {
- List<Module> modules = new ArrayList<>();
- Set<HeatStructureTree> heatsSet = tree.getHeat();
- if (Objects.isNull(heatsSet)) {
- return;
- }
- for (HeatStructureTree heat : heatsSet) {
- if (isFileBaseFile(heat.getFileName())) {
- handleSingleHeat(structure, modules, heat, uploadErrors);
- } else if (isFileModuleFile(heat.getFileName(),
- analyzedZipHeatFiles.getModuleFiles())) {
- handleSingleHeat(structure, modules, heat, uploadErrors);
- } else {
- structure.getUnassigned().add(heat.getFileName());
- addNestedToFileDataStructure(heat, structure);
- }
- if (!Objects.isNull(heat.getEnv())) {
- usedEnvFiles.add(heat.getEnv() == null ? null : heat.getEnv().getFileName());
- }
- }
- structure.setModules(modules);
-
+ @Override
+ public Optional<List<ErrorMessage>> validateFileDataStructure(
+ FilesDataStructure filesDataStructure) {
+ return candidateServiceValidator.validateFileDataStructure(filesDataStructure);
+ }
+
+ private void writeManifest(String manifest,
+ OnboardingTypesEnum type,
+ ZipOutputStream zos) throws IOException {
+
+ if (isManifestNeedsToGetWritten(type)) {
+ return;
+ }
+
+ zos.putNextEntry(new ZipEntry(SdcCommon.MANIFEST_NAME));
+ try (InputStream manifestStream = new ByteArrayInputStream(
+ manifest.getBytes(StandardCharsets.UTF_8))) {
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = (manifestStream.read(buf))) > 0) {
+ zos.write(buf, 0, (len < buf.length) ? len : buf.length);
+ }
+ }
+ }
+
+ private boolean isManifestNeedsToGetWritten(OnboardingTypesEnum type) {
+ return type.equals(OnboardingTypesEnum.CSAR);
+ }
+
+ private void handleArtifactsFromTree(HeatStructureTree tree, FilesDataStructure structure) {
+
+ if (Objects.isNull(tree) || Objects.isNull(tree.getArtifacts())) {
+ return;
+ }
+
+ if (CollectionUtils.isNotEmpty(tree.getArtifacts())) {
+ structure.getArtifacts().addAll(
+ tree.getArtifacts()
+ .stream()
+ .map(Artifact::getFileName)
+ .filter(fileName -> !structure.getArtifacts().contains(fileName))
+ .collect(Collectors.toList()));
+ }
+ }
+
+ private void handleOtherResources(HeatStructureTree tree, Set<String> usedEnvFiles,
+ FilesDataStructure structure) {
+ Set<HeatStructureTree> others = tree.getOther();
+ if (Objects.isNull(others)) {
+ return;
+ }
+
+ List<String> artifacts = new ArrayList<>();
+ List<String> unassigned = new ArrayList<>();
+ for (HeatStructureTree other : others) {
+ if (HeatFileAnalyzer.isYamlOrEnvFile(other.getFileName())) {
+ if (isEnvFileUsedByHeatFile(usedEnvFiles, other)) {
+ continue;
+ }
+ unassigned.add(other.getFileName());
+ } else {
+ artifacts.add(other.getFileName());
+ }
+ handleArtifactsFromTree(other, structure);
+ }
+ structure.getArtifacts().addAll(artifacts);
+ structure.getUnassigned().addAll(unassigned);
+ }
+
+ private boolean isEnvFileUsedByHeatFile(Set<String> usedEnvFiles, HeatStructureTree other) {
+ if (HeatFileAnalyzer.isEnvFile(other.getFileName())) {
+ if (usedEnvFiles.contains(other.getFileName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void addHeatsToFileDataStructure(HeatStructureTree tree, Set<String> usedEnvFiles,
+ FilesDataStructure structure,
+ Map<String, List<ErrorMessage>> uploadErrors,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws Exception {
+ List<Module> modules = new ArrayList<>();
+ Set<HeatStructureTree> heatsSet = tree.getHeat();
+ if (Objects.isNull(heatsSet)) {
+ return;
+ }
+ for (HeatStructureTree heat : heatsSet) {
+ if (isFileBaseFile(heat.getFileName())) {
+ handleSingleHeat(structure, modules, heat, uploadErrors);
+ } else if (isFileModuleFile(heat.getFileName(),
+ analyzedZipHeatFiles.getModuleFiles())) {
+ handleSingleHeat(structure, modules, heat, uploadErrors);
+ } else {
+ structure.getUnassigned().add(heat.getFileName());
+ addNestedToFileDataStructure(heat, structure);
+ }
+ if (!Objects.isNull(heat.getEnv())) {
+ usedEnvFiles.add(heat.getEnv() == null ? null : heat.getEnv().getFileName());
+ }
}
+ structure.setModules(modules);
- private boolean isFileModuleFile(String fileName, Set<String> modulesFileNames) {
- return modulesFileNames.contains(fileName);
- }
+ }
- private boolean isFileBaseFile(String fileName) {
- return manifestCreator.isFileBaseFile(fileName);
- }
+ private boolean isFileModuleFile(String fileName, Set<String> modulesFileNames) {
+ return modulesFileNames.contains(fileName);
+ }
- private void handleSingleHeat(FilesDataStructure structure, List<Module> modules,
- HeatStructureTree heat,
- Map<String, List<ErrorMessage>> uploadErrors) {
+ private boolean isFileBaseFile(String fileName) {
+ return manifestCreator.isFileBaseFile(fileName);
+ }
+ private void handleSingleHeat(FilesDataStructure structure, List<Module> modules,
+ HeatStructureTree heat,
+ Map<String, List<ErrorMessage>> uploadErrors) {
- mdcDataDebugMessage.debugEntryMessage(null);
- Module module = new Module();
- module.setYaml(heat.getFileName());
- module.setIsBase(heat.getBase());
- addNestedToFileDataStructure(heat, structure);
- Set<HeatStructureTree> volumeSet = heat.getVolume();
- int inx = 0;
- if (Objects.nonNull(volumeSet)) {
- handleVolumes(module, volumeSet, structure, inx, uploadErrors);
- }
- handleEnv(module, heat, false, structure);
- modules.add(module);
+ mdcDataDebugMessage.debugEntryMessage(null);
- mdcDataDebugMessage.debugExitMessage(null);
+ Module module = new Module();
+ module.setYaml(heat.getFileName());
+ module.setIsBase(heat.getBase());
+ addNestedToFileDataStructure(heat, structure);
+ Set<HeatStructureTree> volumeSet = heat.getVolume();
+ int inx = 0;
+ if (Objects.nonNull(volumeSet)) {
+ handleVolumes(module, volumeSet, structure, inx, uploadErrors);
}
+ handleEnv(module, heat, false, structure);
+ modules.add(module);
- private void handleVolumes(Module module, Set<HeatStructureTree> volumeSet,
- FilesDataStructure structure, int inx,
- Map<String, List<ErrorMessage>> uploadErrors) {
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
+ private void handleVolumes(Module module, Set<HeatStructureTree> volumeSet,
+ FilesDataStructure structure, int inx,
+ Map<String, List<ErrorMessage>> uploadErrors) {
- mdcDataDebugMessage.debugEntryMessage(null);
- for (HeatStructureTree volume : volumeSet) {
- if (inx++ > 0) {
- ErrorsUtil.addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.WARNING,
- Messages.MORE_THEN_ONE_VOL_FOR_HEAT.getErrorMessage()), uploadErrors);
- break;
- }
- handleArtifactsFromTree(volume, structure);
- module.setVol(volume.getFileName());
- handleEnv(module, volume, true, structure);
- addNestedToFileDataStructure(volume, structure);
- }
+ mdcDataDebugMessage.debugEntryMessage(null);
- mdcDataDebugMessage.debugExitMessage(null);
+ for (HeatStructureTree volume : volumeSet) {
+ if (inx++ > 0) {
+ ErrorsUtil.addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.WARNING,
+ Messages.MORE_THEN_ONE_VOL_FOR_HEAT.getErrorMessage()), uploadErrors);
+ break;
+ }
+ handleArtifactsFromTree(volume, structure);
+ module.setVol(volume.getFileName());
+ handleEnv(module, volume, true, structure);
+ addNestedToFileDataStructure(volume, structure);
}
- private void handleEnv(Module module, HeatStructureTree tree, boolean isVolEnv,
- FilesDataStructure structure) {
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
+ private void handleEnv(Module module, HeatStructureTree tree, boolean isVolEnv,
+ FilesDataStructure structure) {
- mdcDataDebugMessage.debugEntryMessage(null);
- if (Objects.nonNull(tree.getEnv())) {
- if (isVolEnv) {
- module.setVolEnv(tree.getEnv().getFileName());
- } else {
- module.setEnv(tree.getEnv().getFileName());
- }
- handleArtifactsFromTree(tree.getEnv(), structure);
- }
+ mdcDataDebugMessage.debugEntryMessage(null);
- mdcDataDebugMessage.debugExitMessage(null);
+ if (Objects.nonNull(tree.getEnv())) {
+ if (isVolEnv) {
+ module.setVolEnv(tree.getEnv().getFileName());
+ } else {
+ module.setEnv(tree.getEnv().getFileName());
+ }
+ handleArtifactsFromTree(tree.getEnv(), structure);
}
- private void addNestedToFileDataStructure(HeatStructureTree heat,
- FilesDataStructure structure) {
- Set<HeatStructureTree> nestedSet = heat.getNested();
- if (Objects.isNull(nestedSet)) {
- return;
- }
- for (HeatStructureTree nested : nestedSet) {
- if (structure.getNested().contains(nested.getFileName())) {
- continue;
- }
- structure.getNested().add(nested.getFileName());
- if (CollectionUtils.isNotEmpty(nested.getArtifacts())) {
- handleArtifactsFromTree(nested, structure);
- }
- addNestedToFileDataStructure(nested, structure);
- }
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
+
+ private void addNestedToFileDataStructure(HeatStructureTree heat,
+ FilesDataStructure structure) {
+ Set<HeatStructureTree> nestedSet = heat.getNested();
+ if (Objects.isNull(nestedSet)) {
+ return;
+ }
+ for (HeatStructureTree nested : nestedSet) {
+ if (structure.getNested().contains(nested.getFileName())) {
+ continue;
+ }
+ structure.getNested().add(nested.getFileName());
+ if (CollectionUtils.isNotEmpty(nested.getArtifacts())) {
+ handleArtifactsFromTree(nested, structure);
+ }
+ addNestedToFileDataStructure(nested, structure);
}
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
index eed575ff02..ce18097701 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
@@ -68,7 +68,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
addArtifactsToManifestFileDataList(filesDataStructure, fileDataList);
ManifestContent manifestContent = createManifest(vspDetails, fileDataList);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return Optional.of(manifestContent);
}
@@ -76,7 +76,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (CollectionUtils.isNotEmpty(filesDataStructure.getNested())) {
for (String nested : filesDataStructure.getNested()) {
@@ -84,7 +84,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
}
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
@Override
@@ -168,7 +168,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Collection<String> forArtifacts = CollectionUtils
.union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned());
@@ -178,14 +178,14 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
}
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
private void addModulesToManifestFileDataList(
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (CollectionUtils.isNotEmpty(filesDataStructure.getModules())) {
for (Module module : filesDataStructure.getModules()) {
@@ -197,7 +197,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
}
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
private void addEnv(Module module, FileData fileData) {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..982277dbaf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VspMergeDaoFactoryImpl"
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
index 39c14e64fd..4690d75a68 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
@@ -21,7 +21,9 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.commons.health.data.HealthInfo;
import com.amdocs.zusammen.datatypes.Id;
@@ -32,15 +34,19 @@ import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.Item;
import com.amdocs.zusammen.datatypes.item.ItemVersion;
import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionStatus;
+import com.amdocs.zusammen.datatypes.item.Resolution;
import com.amdocs.zusammen.datatypes.itemversion.Tag;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.model.impl.zusammen.ServiceModelDaoZusammenImpl;
-import org.openecomp.sdc.model.impl.zusammen.StructureElement;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.versioning.dao.types.Revision;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -49,6 +55,7 @@ import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -59,6 +66,10 @@ public class ServiceModelDaoFactoryTest {
private static final String baseServiceTemplateName = "baseYaml.yaml";
private static String artifact001;
+ static {
+ SessionContextProviderFactory.getInstance().createInterface().create("test");
+ }
+
@Test
public void storeServiceModelTest() {
@@ -91,14 +102,19 @@ public class ServiceModelDaoFactoryTest {
ElementInfo elementInfo = new ElementInfo();
Info info = new Info();
- info.addProperty("base","baseElement");
+ info.addProperty("base", "baseElement");
elementInfo.setInfo(info);
ElementInfo artifactElementInfo = new ElementInfo();
- artifactElementInfo.setInfo(info);
+ artifactElementInfo.setInfo(new Info());
+ artifactElementInfo.getInfo().setName(ElementType.Artifacts.name());
ElementInfo templateElementInfo = new ElementInfo();
- artifactElementInfo.setInfo(info);
+ templateElementInfo.setInfo(new Info());
+ templateElementInfo.getInfo().setName(ElementType.Templates.name());
+ ElementInfo serviceModelElementInfo = new ElementInfo();
+ serviceModelElementInfo.setInfo(new Info());
+ serviceModelElementInfo.getInfo().setName(ElementType.ServiceModel.name());
ZusammenElement element = new ZusammenElement();
ServiceTemplate serviceTemplate = new ServiceTemplate();
YamlUtil yamlUtil = new YamlUtil();
@@ -111,9 +127,11 @@ public class ServiceModelDaoFactoryTest {
zusammenAdaptor);
zusammenAdaptor.setItemVersion(itemVersionmock);
- zusammenAdaptor.addElementInfo("null"+StructureElement.ServiceModel.name(),elementInfo);
- zusammenAdaptor.addElementInfo("null"+StructureElement.Artifacts.name(),artifactElementInfo);
- zusammenAdaptor.addElementInfo("null"+StructureElement.Templates.name(),templateElementInfo);
+ zusammenAdaptor.addElementInfo("null" + ElementType.ServiceModel.name(), elementInfo);
+ zusammenAdaptor.addElementInfo("null" + ElementType.Artifacts.name(), artifactElementInfo);
+ zusammenAdaptor.addElementInfo("null" + ElementType.Templates.name(), templateElementInfo);
+ zusammenAdaptor.addElementInfo("null" + ElementType.ServiceModel.name(),
+ serviceModelElementInfo);
zusammenAdaptor.addElement(element);
Object model =
@@ -126,11 +144,11 @@ public class ServiceModelDaoFactoryTest {
}
}
- private static void setArtifact(ToscaServiceModel model)
- {
+ private static void setArtifact(ToscaServiceModel model) {
artifact001 =
- (String) (model).getArtifactFiles().getFileList().toArray()[0];
+ (String) (model).getArtifactFiles().getFileList().toArray()[0];
}
+
private ToscaServiceModel getToscaServiceModel() {
Map<String, ServiceTemplate> serviceTemplates = getServiceTemplates(baseServiceTemplateName);
@@ -171,128 +189,225 @@ public class ServiceModelDaoFactoryTest {
return serviceTemplate;
}
- private class ZusammenAdaptorMock implements ZusammenAdaptor
- {
+ private class ZusammenAdaptorMock implements ZusammenAdaptor {
private ItemVersion itemVersion;
- private Map<String,ElementInfo> elementInfoMap = new HashMap();
- private Collection<Element> elements = new ArrayList<>();
+ private Map<String, ElementInfo> elementInfoMap = new HashMap();
+ private Collection<Element> elements = new ArrayList<>();
- public void setItemVersion(ItemVersion itemVersion){
+ public void setItemVersion(ItemVersion itemVersion) {
this.itemVersion = itemVersion;
}
- public void addElementInfo(String key,ElementInfo elementInfo){
- elementInfoMap.put(key,elementInfo);
+ public void addElementInfo(String key, ElementInfo elementInfo) {
+ elementInfoMap.put(key, elementInfo);
}
- public void addElement(Element element){
- elements.add(element);
+
+ public void addElement(Element element) {
+ elements.add(element);
}
+
@Override
public Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId) {
return Optional.ofNullable(itemVersion);
}
- @Override
- public Optional<Element> getElement(SessionContext context, ElementContext elementContext,
- String elementId) {
- return null;
- }
+ @Override
+ public Collection<ItemVersion> listPublicVersions(SessionContext context, Id itemId) {
+ return null;
+ }
- @Override
- public Optional<Element> getElementByName(SessionContext context,
+ @Override
+ public ItemVersion getPublicVersion(SessionContext context, Id itemId, Id versionId) {
+ return null;
+ }
+
+ @Override
+ public Optional<Element> getElement(SessionContext context, ElementContext elementContext,
+ String elementId) {
+ return null;
+ }
+
+ @Override
+ public Optional<Element> getElementByName(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId, String elementName) {
+ return null;
+ }
+
+ @Override
+ public Collection<ElementInfo> listElements(SessionContext context,
ElementContext elementContext,
- Id parentElementId, String elementName) {
- return null;
- }
+ Id parentElementId) {
+ return null;
+ }
- @Override
- public Collection<ElementInfo> listElements(SessionContext context,
- ElementContext elementContext,
- Id parentElementId) {
- return null;
- }
+ @Override
+ public Collection<Element> listElementData(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId) {
+ return elements;
+ }
- @Override
- public Collection<Element> listElementData(SessionContext context,
- ElementContext elementContext,
- Id parentElementId) {
- return elements;
- }
+ @Override
+ public Collection<ElementInfo> listElementsByName(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId, String elementName) {
- @Override
- public Collection<ElementInfo> listElementsByName(SessionContext context,
- ElementContext elementContext,
- Id parentElementId, String elementName) {
- return null;
+ if(elementName.equals(ElementType.VspModel.name())){
+ return elementInfoMap.values();
}
- @Override
- public Optional<ElementInfo> getElementInfoByName(SessionContext context,
- ElementContext elementContext,
- Id parentElementId, String elementName) {
- return Optional.ofNullable(elementInfoMap.get(parentElementId+elementName));
- }
+ return null;
+ }
- @Override
- public Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
- ZusammenElement element, String message) {
- return null;
- }
+ @Override
+ public Optional<ElementInfo> getElementInfoByName(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId, String elementName) {
- @Override
- public Collection<HealthInfo> checkHealth(SessionContext context) {
- return null;
- }
+ if(elementName.equals(ElementType.Templates.name())){
+ return Optional.ofNullable(elementInfoMap.get("null" + elementName));
+ }else if(elementName.equals(ElementType.Artifacts.name())) {
+ return Optional.ofNullable(elementInfoMap.get("null" + elementName));
+ }
- @Override
- public Id createItem(SessionContext context, Info info) {
- return null;
- }
+ return Optional.empty();
+ }
+
+ @Override
+ public Element saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message) {
+ return null;
+ }
- @Override
- public void updateItem(SessionContext context, Id itemId, Info info) {
+ @Override
+ public void resolveElementConflict(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, Resolution resolution) {
- }
+ }
+
+ @Override
+ public Collection<HealthInfo> checkHealth(SessionContext context) {
+ return null;
+ }
- @Override
- public Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
+ @Override
+ public Id createItem(SessionContext context, Info info) {
+ return null;
+ }
+
+ @Override
+ public void updateItem(SessionContext context, Id itemId, Info info) {
+
+ }
+
+ @Override
+ public Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
+ ItemVersionData itemVersionData) {
+ return null;
+ }
+
+ @Override
+ public void updateVersion(SessionContext context, Id itemId, Id versionId,
ItemVersionData itemVersionData) {
- return null;
- }
- @Override
- public void updateVersion(SessionContext context, Id itemId, Id versionId,
- ItemVersionData itemVersionData) {
+ }
- }
+ @Override
+ public ItemVersion getVersion(SessionContext context, Id itemId, Id versionId) {
+ return null;
+ }
- @Override
- public void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag) {
+ @Override
+ public ItemVersionStatus getVersionStatus(SessionContext context, Id itemId, Id versionId) {
+ return null;
+ }
- }
+ @Override
+ public ItemVersionConflict getVersionConflict(SessionContext context, Id itemId, Id versionId) {
+ return null;
+ }
- @Override
- public void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef) {
+ @Override
+ public void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag) {
- }
+ }
- @Override
- public Optional<ElementInfo> getElementInfo(SessionContext context,
- ElementContext elementContext,
- Id elementId) {
- return null;
- }
+ @Override
+ public void resetVersionHistory(SessionContext context, Id itemId, Id versionId,
+ String changeRef) {
- @Override
- public String getVersion(SessionContext sessionContext) {
- return null;
- }
- @Override
- public Collection<Item> listItems(SessionContext context) {
- return null;
- }
}
+
+ /*@Override
+ public void revertVersionToRevision(SessionContext context, Id itemId, Id versionId,
+ Id revisionId) {
+
+ }
+
+ @Override
+ public ItemVersionRevisions listVersionRevisions(SessionContext context, Id itemId,
+ Id versionId) {
+ return null;
+ }*/
+
+ @Override
+ public void publishVersion(SessionContext context, Id itemId, Id versionId, String message) {
+
+ }
+
+ @Override
+ public void syncVersion(SessionContext sessionContext, Id itemId, Id versionId) {
+
+ }
+
+ @Override
+ public void forceSyncVersion(SessionContext context, Id itemId, Id versionId) {
+
+ }
+
+ @Override
+ public Optional<ElementInfo> getElementInfo(SessionContext context,
+ ElementContext elementContext,
+ Id elementId) {
+ return null;
+ }
+
+ @Override
+ public String getVersion(SessionContext sessionContext) {
+ return null;
+ }
+
+ @Override
+ public void revert(SessionContext sessionContext, String itemId, String versionId,
+ String revisionId) {
+
+ }
+
+ @Override
+ public List<Revision> listRevisions(SessionContext sessionContext, String itemId,
+ String versionId) {
+ return null;
+ }
+
+ @Override
+ public Optional<ElementConflict> getElementConflict(SessionContext context,
+ ElementContext elementContext,
+ Id id) {
+ return null;
+ }
+
+ @Override
+ public Collection<Item> listItems(SessionContext context) {
+ return null;
+ }
+
+ @Override
+ public Item getItem(SessionContext context, Id itemId) {
+ return null;
+ }
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java
index 9f2f733a64..dde8d83dea 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java
@@ -21,41 +21,9 @@
package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.HEADER;
-import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_COMPUTE_CPU_OVER_SUBSCRIPTION;
-
-import org.junit.Assert;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData;
import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ComponentQuestionnaire;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.GuestOS;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.NumOfVMs;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.Hypervisor;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.Recovery;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network.NetworkCapacity;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.IpConfiguration;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.Network;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.NicQuestionnaire;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.Protocols;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.VspQuestionnaire;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.Availability;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.General;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.StorageDataReplication;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
public class TxtInformationArtifactGeneratorImplTest {