summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao')
-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/errors/OrchestrationTemplateFileExtensionErrorBuilder.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/errors/VendorSoftwareProductCreationFailedBuilder.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/errors/VendorSoftwareProductNotFoundErrorBuilder.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/ComponentDaoFactoryImpl.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/ComponentDependencyModelDaoFactoryImpl.java18
-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/ComputeDaoFactoryImpl.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/DeploymentFlavorDaoFactoryImpl.java10
-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/ImageDaoFactoryImpl.java16
-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/MonitoringUploadDaoFactoryImpl.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/NetworkDaoFactoryImpl.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/NicDaoFactoryImpl.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/OrchestrationTemplateCandidateDaoFactoryImpl.java22
-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/OrchestrationTemplateDaoFactoryImpl.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/PackageInfoDaoFactoryImpl.java16
-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.java89
-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.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/VendorSoftwareProductInfoDaoFactoryImpl.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/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.java257
-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.java310
-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.java364
-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.java221
-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/ComponentDependencyModelPropertyName.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/ComputeDaoZusammenImpl.java341
-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.java235
-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.java339
-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.java223
-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.java376
-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.java377
-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.java309
-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.java365
-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.java403
-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.java62
-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.java50
-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.java59
-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.java61
-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.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/ElementToCompositionEntityConvertor.java69
-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.java56
-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.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/ElementToDeploymentFlavorConvertor.java56
-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.java56
-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.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/ElementToMonitoringUploadMapConvertor.java27
-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.java54
-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.java55
-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.java25
-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.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/zusammen/convertor/ElementToProcessConvertor.java68
-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.java25
-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.java104
-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.java14
52 files changed, 2344 insertions, 3147 deletions
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/errors/OrchestrationTemplateFileExtensionErrorBuilder.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/errors/OrchestrationTemplateFileExtensionErrorBuilder.java
index 58faa41872..caf4f0486d 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/errors/OrchestrationTemplateFileExtensionErrorBuilder.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/errors/OrchestrationTemplateFileExtensionErrorBuilder.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.
@@ -17,26 +17,25 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_EXTENSION;
+
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_EXTENSION;
-
public class OrchestrationTemplateFileExtensionErrorBuilder {
- private static final String INVALID_EXTENSION_MSG = "Invalid file extension. Valid extensions " +
- "are : zip, csar.";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- public OrchestrationTemplateFileExtensionErrorBuilder(){
- builder.withId(INVALID_EXTENSION);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(INVALID_EXTENSION_MSG));
- }
+ private static final String INVALID_EXTENSION_MSG = "Invalid file extension. Valid extensions " + "are : zip, csar.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public OrchestrationTemplateFileExtensionErrorBuilder() {
+ builder.withId(INVALID_EXTENSION);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_EXTENSION_MSG));
+ }
- public ErrorCode build() {
- return builder.build();
- }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
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/errors/VendorSoftwareProductCreationFailedBuilder.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/errors/VendorSoftwareProductCreationFailedBuilder.java
index a7abbe0dd9..1dc1c40ca9 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/errors/VendorSoftwareProductCreationFailedBuilder.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/errors/VendorSoftwareProductCreationFailedBuilder.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
@@ -25,21 +24,20 @@ import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
public class VendorSoftwareProductCreationFailedBuilder {
- private static final String VSP_CREATION_FAILED = "Failed to create VSP; %s";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- /**
- * Instantiates a new Vendor software product creation failed error builder.
- *
- */
- public VendorSoftwareProductCreationFailedBuilder(String reason) {
- builder.withId(VendorSoftwareProductErrorCodes.FAILED_TO_CREATE_VSP);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder
- .withMessage(String.format(VSP_CREATION_FAILED, reason));
- }
+ private static final String VSP_CREATION_FAILED = "Failed to create VSP; %s";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Vendor software product creation failed error builder.
+ */
+ public VendorSoftwareProductCreationFailedBuilder(String reason) {
+ builder.withId(VendorSoftwareProductErrorCodes.FAILED_TO_CREATE_VSP);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VSP_CREATION_FAILED, reason));
+ }
- public ErrorCode build() {
- return builder.build();
- }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
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/errors/VendorSoftwareProductNotFoundErrorBuilder.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/errors/VendorSoftwareProductNotFoundErrorBuilder.java
index ef5b43fad4..8cb2d72d25 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/errors/VendorSoftwareProductNotFoundErrorBuilder.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/errors/VendorSoftwareProductNotFoundErrorBuilder.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.
@@ -17,31 +17,30 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_NOT_FOUND;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_NOT_FOUND;
-
public class VendorSoftwareProductNotFoundErrorBuilder {
- private static final String VSP_FOUND_MSG = "Vendor software product with Id %s not found.";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- /**
- * Instantiates a new Vendor software product not found error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- */
- public VendorSoftwareProductNotFoundErrorBuilder(String vendorSoftwareProductId) {
- builder.withId(VSP_NOT_FOUND);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(VSP_FOUND_MSG, vendorSoftwareProductId));
- }
+ private static final String VSP_FOUND_MSG = "Vendor software product with Id %s not found.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Vendor software product not found error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ */
+ public VendorSoftwareProductNotFoundErrorBuilder(String vendorSoftwareProductId) {
+ builder.withId(VSP_NOT_FOUND);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VSP_FOUND_MSG, vendorSoftwareProductId));
+ }
- public ErrorCode build() {
- return builder.build();
- }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
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/ComponentDaoFactoryImpl.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/ComponentDaoFactoryImpl.java
index 1ef0caac0c..bcf4cf1dcd 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/ComponentDaoFactoryImpl.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/ComponentDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentDaoZusammenImpl;
public class ComponentDaoFactoryImpl extends ComponentDaoFactory {
- private static final ComponentDao INSTANCE = new ComponentDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public ComponentDao createInterface() {
- return INSTANCE;
- }
+ private static final ComponentDao INSTANCE = new ComponentDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public ComponentDao 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/ComponentDependencyModelDaoFactoryImpl.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/ComponentDependencyModelDaoFactoryImpl.java
index f4f36c3355..180f11917a 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/ComponentDependencyModelDaoFactoryImpl.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/ComponentDependencyModelDaoFactoryImpl.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.
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
-
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
@@ -28,11 +26,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentDepend
public class ComponentDependencyModelDaoFactoryImpl extends ComponentDependencyModelDaoFactory {
- private static final ComponentDependencyModelDao INSTANCE = new
- ComponentDependencyModelDaoZusammenImpl( ZusammenAdaptorFactory.getInstance().createInterface());
+ private static final ComponentDependencyModelDao INSTANCE = new ComponentDependencyModelDaoZusammenImpl(
+ ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public ComponentDependencyModelDao createInterface() {
- return INSTANCE;
- }
+ @Override
+ public ComponentDependencyModelDao 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/ComputeDaoFactoryImpl.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/ComputeDaoFactoryImpl.java
index 3032d523c4..1a9127c95a 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/ComputeDaoFactoryImpl.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/ComputeDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComputeDaoZusammenImpl;
public class ComputeDaoFactoryImpl extends ComputeDaoFactory {
- private static final ComputeDao INSTANCE = new ComputeDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public ComputeDao createInterface() {
- return INSTANCE;
- }
+ private static final ComputeDao INSTANCE = new ComputeDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public ComputeDao 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/DeploymentFlavorDaoFactoryImpl.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/DeploymentFlavorDaoFactoryImpl.java
index 93ce6b122c..b4ad183539 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/DeploymentFlavorDaoFactoryImpl.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/DeploymentFlavorDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -25,10 +24,9 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.DeploymentFlavorDaoZusammenImpl;
+public class DeploymentFlavorDaoFactoryImpl extends DeploymentFlavorDaoFactory {
-public class DeploymentFlavorDaoFactoryImpl extends DeploymentFlavorDaoFactory{
- private static final DeploymentFlavorDao INSTANCE = new DeploymentFlavorDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
+ private static final DeploymentFlavorDao INSTANCE = new DeploymentFlavorDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
@Override
public DeploymentFlavorDao 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/dao/impl/ImageDaoFactoryImpl.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/ImageDaoFactoryImpl.java
index 21abcae517..2d01ecf96a 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/ImageDaoFactoryImpl.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/ImageDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -27,11 +26,10 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ImageDaoZusamme
public class ImageDaoFactoryImpl extends ImageDaoFactory {
- private static final ImageDao INSTANCE = new ImageDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
+ private static final ImageDao INSTANCE = new ImageDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public ImageDao createInterface() {
- return INSTANCE;
- }
+ @Override
+ public ImageDao 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/MonitoringUploadDaoFactoryImpl.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/MonitoringUploadDaoFactoryImpl.java
index fa6a0cbfc2..bcee3a2789 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/MonitoringUploadDaoFactoryImpl.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/MonitoringUploadDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentArtifactDaoZusammenImpl;
public class MonitoringUploadDaoFactoryImpl extends MonitoringUploadDaoFactory {
- private static final ComponentArtifactDao INSTANCE = new ComponentArtifactDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public ComponentArtifactDao createInterface() {
- return INSTANCE;
- }
+ private static final ComponentArtifactDao INSTANCE = new ComponentArtifactDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public ComponentArtifactDao 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/NetworkDaoFactoryImpl.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/NetworkDaoFactoryImpl.java
index 5bccc5ced2..cc555b4a6c 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/NetworkDaoFactoryImpl.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/NetworkDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.NetworkDaoZusammenImpl;
public class NetworkDaoFactoryImpl extends NetworkDaoFactory {
- private static final NetworkDao INSTANCE = new NetworkDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public NetworkDao createInterface() {
- return INSTANCE;
- }
+ private static final NetworkDao INSTANCE = new NetworkDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public NetworkDao 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/NicDaoFactoryImpl.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/NicDaoFactoryImpl.java
index 76e5d443f2..956d84e2d4 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/NicDaoFactoryImpl.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/NicDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.NicDaoZusammenImpl;
public class NicDaoFactoryImpl extends NicDaoFactory {
- private static final NicDao INSTANCE = new NicDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public NicDao createInterface() {
- return INSTANCE;
- }
+ private static final NicDao INSTANCE = new NicDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public NicDao 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/OrchestrationTemplateCandidateDaoFactoryImpl.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/OrchestrationTemplateCandidateDaoFactoryImpl.java
index 8cc2c6f61f..d0e838ff19 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/OrchestrationTemplateCandidateDaoFactoryImpl.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/OrchestrationTemplateCandidateDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -25,14 +24,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidat
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.OrchestrationTemplateCandidateDaoZusammenImpl;
-public class OrchestrationTemplateCandidateDaoFactoryImpl
- extends OrchestrationTemplateCandidateDaoFactory {
- private static final OrchestrationTemplateCandidateDao INSTANCE =
- new OrchestrationTemplateCandidateDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
+public class OrchestrationTemplateCandidateDaoFactoryImpl extends OrchestrationTemplateCandidateDaoFactory {
+
+ private static final OrchestrationTemplateCandidateDao INSTANCE = new OrchestrationTemplateCandidateDaoZusammenImpl(
+ ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public OrchestrationTemplateCandidateDao createInterface() {
- return INSTANCE;
- }
+ @Override
+ public OrchestrationTemplateCandidateDao 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/OrchestrationTemplateDaoFactoryImpl.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/OrchestrationTemplateDaoFactoryImpl.java
index 8b90462131..57f37beb24 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/OrchestrationTemplateDaoFactoryImpl.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/OrchestrationTemplateDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -25,15 +24,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.OrchestrationTemplateDaoZusammenImpl;
+public class OrchestrationTemplateDaoFactoryImpl extends OrchestrationTemplateDaoFactory {
-public class OrchestrationTemplateDaoFactoryImpl
- extends OrchestrationTemplateDaoFactory {
- private static final OrchestrationTemplateDao INSTANCE =
- new OrchestrationTemplateDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
+ private static final OrchestrationTemplateDao INSTANCE = new OrchestrationTemplateDaoZusammenImpl(
+ ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public OrchestrationTemplateDao createInterface() {
- return INSTANCE;
- }
+ @Override
+ public OrchestrationTemplateDao 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/PackageInfoDaoFactoryImpl.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/PackageInfoDaoFactoryImpl.java
index 8b9bedcd3a..2982e07d2f 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/PackageInfoDaoFactoryImpl.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/PackageInfoDaoFactoryImpl.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.
@@ -17,17 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
public class PackageInfoDaoFactoryImpl extends PackageInfoDaoFactory {
- private static final PackageInfoDao INSTANCE = new PackageInfoDaoImpl();
- @Override
- public PackageInfoDao createInterface() {
- return INSTANCE;
- }
+ private static final PackageInfoDao INSTANCE = new PackageInfoDaoImpl();
+
+ @Override
+ public PackageInfoDao 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/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 ff4fd45420..591af3c8b9 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
@@ -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.
@@ -17,72 +17,67 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.Result;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import org.openecomp.core.dao.impl.CassandraBaseDao;
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements PackageInfoDao {
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final Mapper<PackageInfo> mapper =
- noSqlDb.getMappingManager().mapper(PackageInfo.class);
- private static final PackageInfoAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(PackageInfoAccessor.class);
- @Override
- protected Mapper<PackageInfo> getMapper() {
- return mapper;
- }
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<PackageInfo> mapper = noSqlDb.getMappingManager().mapper(PackageInfo.class);
+ private static final PackageInfoAccessor accessor = noSqlDb.getMappingManager().createAccessor(PackageInfoAccessor.class);
- @Override
- protected Object[] getKeys(PackageInfo entity) {
- return new Object[]{entity.getVspId(), entity.getVersion()};
- }
+ @Override
+ protected Mapper<PackageInfo> getMapper() {
+ return mapper;
+ }
- @Override
- public Collection<PackageInfo> list(PackageInfo entity) {
- return accessor.listInfo().all();
- }
+ @Override
+ protected Object[] getKeys(PackageInfo entity) {
+ return new Object[]{entity.getVspId(), entity.getVersion()};
+ }
- @Override
- public List<PackageInfo> listByCategory(String category, String subCategory) {
- Result<PackageInfo> packages = accessor.listInfo();
+ @Override
+ public Collection<PackageInfo> list(PackageInfo entity) {
+ return accessor.listInfo().all();
+ }
- List<PackageInfo> filteredPackages = new ArrayList<>();
- for (PackageInfo packageInfo : packages) {
- if (category != null) {
- if (category.equals(packageInfo.getCategory())) {
- filteredPackages.add(packageInfo);
- }
- } else if (subCategory != null) {
- if (subCategory.equals(packageInfo.getSubCategory())) {
- filteredPackages.add(packageInfo);
+ @Override
+ public List<PackageInfo> listByCategory(String category, String subCategory) {
+ Result<PackageInfo> packages = accessor.listInfo();
+ List<PackageInfo> filteredPackages = new ArrayList<>();
+ for (PackageInfo packageInfo : packages) {
+ if (category != null) {
+ if (category.equals(packageInfo.getCategory())) {
+ filteredPackages.add(packageInfo);
+ }
+ } else if (subCategory != null) {
+ if (subCategory.equals(packageInfo.getSubCategory())) {
+ filteredPackages.add(packageInfo);
+ }
+ } else {
+ filteredPackages.add(packageInfo);
+ }
}
- } else {
- filteredPackages.add(packageInfo);
- }
+ return filteredPackages;
}
- return filteredPackages;
- }
- @Accessor
- interface PackageInfoAccessor {
+ @Accessor
+ interface PackageInfoAccessor {
- @Query(
- "SELECT vsp_id,version,display_name,vsp_name,vsp_description,vendor_name,category"
+ @Query("SELECT vsp_id,version,display_name,vsp_name,vsp_description,vendor_name,category"
+ " ,sub_category, vendor_release,package_checksum,package_type, resource_type FROM package_details")
- Result<PackageInfo> listInfo();
- }
+ Result<PackageInfo> listInfo();
+ }
}
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 0205446ae8..72b9c76615 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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -26,11 +25,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ProcessDaoZusammenImpl;
public class ProcessDaoFactoryImpl extends ProcessDaoFactory {
- private static final ProcessDao INSTANCE = new ProcessDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public ProcessDao createInterface() {
- return INSTANCE;
- }
+ private static final ProcessDao INSTANCE = new ProcessDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public ProcessDao 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/VendorSoftwareProductInfoDaoFactoryImpl.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/VendorSoftwareProductInfoDaoFactoryImpl.java
index a5f9d17431..978d11cd3b 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/VendorSoftwareProductInfoDaoFactoryImpl.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/VendorSoftwareProductInfoDaoFactoryImpl.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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -26,12 +25,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoF
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.VendorSoftwareProductInfoDaoZusammenImpl;
public class VendorSoftwareProductInfoDaoFactoryImpl extends VendorSoftwareProductInfoDaoFactory {
- private static final VendorSoftwareProductInfoDao INSTANCE =
- new VendorSoftwareProductInfoDaoZusammenImpl(
- ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public VendorSoftwareProductInfoDao createInterface() {
- return INSTANCE;
- }
+ private static final VendorSoftwareProductInfoDao INSTANCE = new VendorSoftwareProductInfoDaoZusammenImpl(
+ ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public VendorSoftwareProductInfoDao 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/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
index f6f3c84303..0c7c552489 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/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
@@ -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.
@@ -17,21 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
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());
+ private static final VspMergeDao INSTANCE = new VspMergeDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface());
- @Override
- public VspMergeDao createInterface() {
- return INSTANCE;
- }
+ @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
index 86045ab20a..e7579c6ce6 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/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
@@ -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.
@@ -17,9 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -32,6 +34,8 @@ import com.datastax.driver.extras.codecs.enums.EnumNameCodec;
import com.datastax.driver.mapping.MappingManager;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
+import java.util.List;
+import java.util.stream.Collectors;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
@@ -39,155 +43,120 @@ 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;
+public class VspMergeDaoImpl implements VspMergeDao {
-import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
-import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+ private static final String VSP_MODEL_NOT_EXIST = "Vsp model does not exist for Vsp %s, version %s.";
+ private static final VspMergeHintAccessor accessor;
-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 final VspMergeHintAccessor accessor;
-
- static {
- MappingManager mappingManager = NoSqlDbFactory.getInstance().createInterface().getMappingManager();
- mappingManager.getSession().getCluster().getConfiguration().getCodecRegistry()
- .register(new EnumNameCodec<>(Resolution.class));
- accessor = mappingManager.createAccessor(VspMergeHintAccessor.class);
- }
-
- private ZusammenAdaptor zusammenAdaptor;
-
- public VspMergeDaoImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public boolean isConflicted(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 updateHint(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 deleteHint(String vspId, Version version) {
- accessor.delete(getUser(),vspId,version.getId());
- }
-
- @Override
- public void updateConflictResolution(String vspId, Version version,
- Resolution resolution) {
- accessor.updateModelResolution(resolution, getUser(), vspId, version.getId());
- }
-
- @Override
- public void applyConflictResolution(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;
+ static {
+ MappingManager mappingManager = NoSqlDbFactory.getInstance().createInterface().getMappingManager();
+ mappingManager.getSession().getCluster().getConfiguration().getCodecRegistry().register(new EnumNameCodec<>(Resolution.class));
+ accessor = mappingManager.createAccessor(VspMergeHintAccessor.class);
+ }
+
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public VspMergeDaoImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public boolean isConflicted(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId()));
+ return listVspModels(context, elementContext).size() > 1;
}
- if (vspModels.size() != 2) {
- return;
+ @Override
+ public void updateHint(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);
}
- String user = getUser();
- Row row = accessor.get(user, vspId, version.getId()).one();
- if (row == null) {
- throw new IllegalStateException(
- "Vsp model id must exists if its conflict is being resolved");
+ @Override
+ public void deleteHint(String vspId, Version version) {
+ accessor.delete(getUser(), vspId, version.getId());
}
- String resolutionValue = row.getString("model_resolution");
- if (resolutionValue == null) {
- return; // model conflict is not resolved yet
+
+ @Override
+ public void updateConflictResolution(String vspId, Version version, Resolution resolution) {
+ accessor.updateModelResolution(resolution, getUser(), vspId, version.getId());
+ }
+
+ @Override
+ public void applyConflictResolution(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.get(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.update(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());
}
- Resolution resolution = Resolution.valueOf(resolutionValue);
- String localModelId = row.getString("model_id");
-
- String chosenModelId =
- keepOnlyChosenVspModel(context, elementContext, vspModels, resolution, localModelId);
-
- accessor.update(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();
- }
+ private void updateVspModelId(String vspId, Version version, String vspModelId) {
+ accessor.update(vspModelId, null, getUser(), vspId, version.getId());
+ }
+
+ private String getUser() {
+ return SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId();
+ }
+
+ @Accessor
+ interface VspMergeHintAccessor {
+
+ @Query("SELECT model_id, model_resolution FROM vsp_merge_hint " + "WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet get(String space, String itemId, String versionId);
+
+ @Query("UPDATE vsp_merge_hint SET model_id=?, model_resolution=? " + "WHERE space=? AND item_id=? AND version_id=?")
+ void update(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("DELETE from vsp_merge_hint WHERE space=? AND item_id=? AND version_id=?")
+ void delete(String space, String itemId, String versionId);
}
- 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.update(vspModelId, null, getUser(), vspId, version.getId());
- }
-
- private String getUser() {
- return SessionContextProviderFactory.getInstance().createInterface()
- .get().getUser().getUserId();
- }
-
- @Accessor
- interface VspMergeHintAccessor {
-
- @Query("SELECT model_id, model_resolution FROM vsp_merge_hint " +
- "WHERE space=? AND item_id=? AND version_id=?")
- ResultSet get(String space, String itemId, String versionId);
-
- @Query("UPDATE vsp_merge_hint SET model_id=?, model_resolution=? " +
- "WHERE space=? AND item_id=? AND version_id=?")
- void update(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("DELETE from vsp_merge_hint WHERE space=? AND item_id=? AND version_id=?")
- void delete(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 e80e7d5d66..dbfee03219 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
@@ -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.
@@ -17,15 +17,24 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+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 com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
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 java.io.ByteArrayInputStream;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.stream.Collectors;
import org.openecomp.core.enrichment.types.MonitoringUploadType;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
@@ -34,202 +43,145 @@ 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 java.io.ByteArrayInputStream;
-import java.nio.ByteBuffer;
-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.*;
-
/**
* @author Avrahamg.
* @since March 21, 2017
*/
public class ComponentArtifactDaoZusammenImpl implements ComponentArtifactDao {
- private static final String ARTIFACT_NAME = "artifactName";
+ private static final String ARTIFACT_NAME = "artifactName";
+ private ZusammenAdaptor zusammenAdaptor;
- private ZusammenAdaptor zusammenAdaptor;
-
- public ComponentArtifactDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
+ public ComponentArtifactDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning is not implemented for ComponentArtifactDaoZusammenImpl
- }
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ // registerVersioning is not implemented for ComponentArtifactDaoZusammenImpl
+ }
- @Override
- public Optional<ComponentMonitoringUploadEntity> getByType(
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ @Override
+ public Optional<ComponentMonitoringUploadEntity> getByType(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(componentMonitoringUploadEntity.getVspId(),
componentMonitoringUploadEntity.getVersion().getId());
-
- Optional<Element> mibsElement =
- 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());
- if (monitoringElement.isPresent()) {
- ComponentMonitoringUploadEntity entity =
- new ElementToComponentMonitoringUploadConvertor().convert(monitoringElement.get());
- entity.setVspId(componentMonitoringUploadEntity.getVspId());
- entity.setVersion(componentMonitoringUploadEntity.getVersion());
- entity.setComponentId(componentMonitoringUploadEntity.getComponentId());
- return Optional.of(entity);
- }
+ Optional<Element> mibsElement = 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());
+ if (monitoringElement.isPresent()) {
+ ComponentMonitoringUploadEntity entity = new ElementToComponentMonitoringUploadConvertor().convert(monitoringElement.get());
+ entity.setVspId(componentMonitoringUploadEntity.getVspId());
+ entity.setVersion(componentMonitoringUploadEntity.getVersion());
+ entity.setComponentId(componentMonitoringUploadEntity.getComponentId());
+ return Optional.of(entity);
+ }
+ }
+ return Optional.empty();
}
- return Optional.empty();
- }
-
- @Override
- public void create(ComponentMonitoringUploadEntity entity) {
- ZusammenElement mibElement = buildMibElement(entity);
-
- ZusammenElement mibsElement = buildStructuralElement(ElementType.Mibs, null);
-
- ZusammenElement componentElement = buildElement(new Id(entity.getComponentId()), Action.IGNORE);
-
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(entity.getVspId(), entity.getVersion().getId());
-
- Element savedElement = zusammenAdaptor.saveElement(context, elementContext,
- VspZusammenUtil.aggregateElements(componentElement, mibsElement, mibElement),
- "Create monitoring upload");
- entity.setId(savedElement.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue());
- }
-
- @Override
- public void delete(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ @Override
+ public void create(ComponentMonitoringUploadEntity entity) {
+ ZusammenElement mibElement = buildMibElement(entity);
+ ZusammenElement mibsElement = buildStructuralElement(ElementType.Mibs, null);
+ ZusammenElement componentElement = buildElement(new Id(entity.getComponentId()), Action.IGNORE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(entity.getVspId(), entity.getVersion().getId());
+ Element savedElement = zusammenAdaptor
+ .saveElement(context, elementContext, VspZusammenUtil.aggregateElements(componentElement, mibsElement, mibElement),
+ "Create monitoring upload");
+ entity.setId(savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue());
+ }
- ZusammenElement mibElement = buildMibElementStructure(componentMonitoringUploadEntity);
- mibElement.setElementId(new Id(componentMonitoringUploadEntity.getId()));
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ @Override
+ public void delete(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ 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 mibEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(mibEntity.getVspId(), mibEntity.getVersion().getId());
+ return zusammenAdaptor.listElementsByName(context, elementContext, new Id(mibEntity.getComponentId()), ElementType.Mibs.toString()).stream()
+ .map(new ElementToComponentMonitoringUploadConvertor()::convert).map(mib -> {
+ mib.setVspId(mibEntity.getVspId());
+ mib.setVersion(mibEntity.getVersion());
+ mib.setComponentId(mibEntity.getComponentId());
+ return mib;
+ }).collect(Collectors.toList());
+ }
- zusammenAdaptor.saveElement(context, elementContext, mibElement,
- String.format("Delete mib with id %s", componentMonitoringUploadEntity.getId()));
- }
-
-
-
- @Override
- public Collection<ComponentMonitoringUploadEntity> list(
- ComponentMonitoringUploadEntity mibEntity) {
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(mibEntity.getVspId(), mibEntity.getVersion().getId());
- return zusammenAdaptor
- .listElementsByName(context, elementContext, new Id(mibEntity.getComponentId()),
- ElementType.Mibs.toString())
- .stream()
- .map(new ElementToComponentMonitoringUploadConvertor()::convert)
- .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) {
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ @Override
+ public void deleteAll(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ 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());
+ });
+ }
+ }
- Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
- elementContext, new Id(componentMonitoringUploadEntity.getComponentId()), ElementType.Mibs
- .name());
+ @Override
+ public Collection<ComponentMonitoringUploadEntity> listArtifacts(ComponentMonitoringUploadEntity monitoringUploadEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(monitoringUploadEntity.getVspId(), monitoringUploadEntity.getVersion().getId());
+ final Optional<Element> elementByName = zusammenAdaptor
+ .getElementByName(context, elementContext, new Id(monitoringUploadEntity.getComponentId()), ElementType.Mibs.name());
+ if (!elementByName.isPresent()) {
+ return Collections.emptyList();
+ } else {
+ final Id elementId = elementByName.get().getElementId();
+ return zusammenAdaptor.listElementData(context, elementContext, elementId).stream()
+ .map(element -> buildMibEntity(element, monitoringUploadEntity)).collect(Collectors.toList());
+ }
+ }
- if (optionalElement.isPresent()) {
- Element mibsElement = optionalElement.get();
- Collection<Element> mibs = mibsElement.getSubElements();
+ private ComponentMonitoringUploadEntity buildMibEntity(Element element, ComponentMonitoringUploadEntity monitoringUploadEntity) {
+ final String componentId = monitoringUploadEntity.getComponentId();
+ ComponentMonitoringUploadEntity createdMib = new ComponentMonitoringUploadEntity(monitoringUploadEntity.getVspId(),
+ monitoringUploadEntity.getVersion(), componentId, null);
+ createdMib.setArtifactName((String) element.getInfo().getProperties().get(ARTIFACT_NAME));
+ createdMib.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
+ createdMib.setType(MonitoringUploadType.valueOf(element.getInfo().getName()));
+ return createdMib;
+ }
- mibs.forEach(mib -> {
- ZusammenElement mibZusammenElement = buildElement(mib.getElementId(), Action.DELETE);
- zusammenAdaptor.saveElement(context, elementContext, mibZusammenElement,
- "Delete mib with id " + mib.getElementId());
- });
+ private ZusammenElement buildMibElement(ComponentMonitoringUploadEntity monitoringUploadEntity) {
+ ZusammenElement monitoringElement = buildMibElementStructure(monitoringUploadEntity);
+ monitoringElement.getInfo().getProperties().put(ARTIFACT_NAME, monitoringUploadEntity.getArtifactName());
+ monitoringElement.setData(new ByteArrayInputStream(monitoringUploadEntity.getArtifact().array()));
+ return monitoringElement;
}
- }
-
- @Override
- public Collection<ComponentMonitoringUploadEntity> listArtifacts(
- ComponentMonitoringUploadEntity monitoringUploadEntity) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(monitoringUploadEntity.getVspId(),
- monitoringUploadEntity.getVersion().getId());
-
- final Optional<Element> elementByName =
- zusammenAdaptor.getElementByName(context, elementContext,
- new Id(monitoringUploadEntity.getComponentId()), ElementType.Mibs.name());
-
- if (!elementByName.isPresent()) {
- return Collections.emptyList();
- } else {
- final Id elementId = elementByName.get().getElementId();
- return zusammenAdaptor.listElementData(context, elementContext, elementId).stream()
- .map(element -> buildMibEntity(element, monitoringUploadEntity))
- .collect(Collectors.toList());
+
+ private ZusammenElement buildMibElementStructure(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ return buildStructuralElement(getMonitoringStructuralElement(componentMonitoringUploadEntity.getType()), Action.UPDATE);
}
- }
-
- private ComponentMonitoringUploadEntity buildMibEntity(Element element,
- ComponentMonitoringUploadEntity monitoringUploadEntity) {
- final String componentId = monitoringUploadEntity.getComponentId();
- ComponentMonitoringUploadEntity
- createdMib = new ComponentMonitoringUploadEntity(monitoringUploadEntity.getVspId(),
- monitoringUploadEntity.getVersion(),
- componentId,
- null);
- createdMib.setArtifactName((String) element.getInfo().getProperties().get(ARTIFACT_NAME));
- createdMib.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
- createdMib.setType(MonitoringUploadType.valueOf(element.getInfo().getName()));
- return createdMib;
- }
-
- private ZusammenElement buildMibElement(
- ComponentMonitoringUploadEntity monitoringUploadEntity) {
-
- ZusammenElement monitoringElement = buildMibElementStructure(monitoringUploadEntity);
- monitoringElement.getInfo().getProperties()
- .put(ARTIFACT_NAME, monitoringUploadEntity.getArtifactName());
- monitoringElement
- .setData(new ByteArrayInputStream(monitoringUploadEntity.getArtifact().array()));
- return monitoringElement;
- }
-
- private ZusammenElement buildMibElementStructure(
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- return buildStructuralElement(getMonitoringStructuralElement(componentMonitoringUploadEntity
- .getType()), Action.UPDATE);
- }
-
- private ElementType getMonitoringStructuralElement(MonitoringUploadType type){
- switch (type) {
- case SNMP_POLL:
- return ElementType.SNMP_POLL;
- case SNMP_TRAP:
- return ElementType.SNMP_TRAP;
- case VES_EVENTS:
- return ElementType.VES_EVENTS;
- default:
- throw new IllegalArgumentException();
+
+ private ElementType getMonitoringStructuralElement(MonitoringUploadType type) {
+ switch (type) {
+ case SNMP_POLL:
+ return ElementType.SNMP_POLL;
+ case SNMP_TRAP:
+ return ElementType.SNMP_TRAP;
+ case 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 d38db0b0da..8c2fb92f17 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
@@ -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.
@@ -17,9 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+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 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;
@@ -28,6 +31,12 @@ 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 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 org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
@@ -37,233 +46,170 @@ 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.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.*;
-
public class ComponentDaoZusammenImpl implements ComponentDao {
- private ZusammenAdaptor zusammenAdaptor;
-
- public ComponentDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning is not implemented for ComponentDaoZusammenImpl
- }
-
- @Override
- public Collection<ComponentEntity> list(ComponentEntity component) {
- SessionContext context = createSessionContext();
-
- return listComponents(zusammenAdaptor, context, component.getVspId(), component.getVersion());
- }
-
- static Collection<ComponentEntity> listComponents(ZusammenAdaptor zusammenAdaptor,
- SessionContext context,
- String vspId, Version version) {
- ElementContext elementContext = new ElementContext(vspId, version.getId());
+ private ZusammenAdaptor zusammenAdaptor;
- Optional<ElementInfo> vspModel = zusammenAdaptor
- .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
- if (!vspModel.isPresent()) {
- return new ArrayList<>();
+ public ComponentDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
}
- 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());
- }
-
-
- @Override
- public void create(ComponentEntity component) {
- ZusammenElement componentElement = componentToZusammen(component, Action.CREATE);
-
- ZusammenElement componentsElement =
- buildStructuralElement(ElementType.Components, Action.IGNORE);
- componentsElement.getSubElements().add(componentElement);
-
- 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 = createSessionContext();
- zusammenAdaptor.saveElement(context,
- 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 = createSessionContext();
-
- Optional<Element> element =
- zusammenAdaptor.getElement(context,
- new ElementContext(component.getVspId(), component.getVersion().getId()),
- component.getId());
-
- if (element.isPresent()) {
- ComponentEntity entity = new ElementToComponentConvertor().convert(element.get());
- entity.setVspId(component.getVspId());
- entity.setVersion(component.getVersion());
- return entity;
+ static Collection<ComponentEntity> listComponents(ZusammenAdaptor zusammenAdaptor, SessionContext context, String vspId, Version version) {
+ 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());
}
- return null;
- }
-
- @Override
- public void delete(ComponentEntity component) {
- ZusammenElement componentElement = buildElement(new Id(component.getId()), Action.DELETE);
-
- SessionContext context = createSessionContext();
- zusammenAdaptor.saveElement(context,
- 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 = createSessionContext();
-
- return getQuestionnaire(context, new ElementContext(vspId, version.getId()),
- new ComponentEntity(vspId, version, componentId));
- }
-
- private ComponentEntity getQuestionnaire(SessionContext context, ElementContext elementContext,
- ComponentEntity component) {
- Optional<Element> questionnaireElement = zusammenAdaptor
- .getElementByName(context, elementContext, new Id(component.getId()),
- ElementType.ComponentQuestionnaire.name());
- return questionnaireElement.map(new ElementToComponentQuestionnnaireConvertor()::convert)
- .map(entity -> {
- entity.setVspId(component.getVspId());
- entity.setVersion(component.getVersion());
- return entity;
- })
- .orElse(null);
- }
-
- @Override
- public void updateQuestionnaireData(String vspId, Version version, String componentId,
- String questionnaireData) {
- ZusammenElement questionnaireElement =
- componentQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
-
- ZusammenElement componentElement = buildElement(new Id(componentId), Action.IGNORE);
- componentElement.setSubElements(Collections.singletonList(questionnaireElement));
-
- SessionContext context = createSessionContext();
- zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()),
- componentElement, "Update component questionnaire");
- }
-
- @Override
- public Collection<ComponentEntity> listQuestionnaires(String vspId, Version version) {
- return listCompositionAndQuestionnaire(vspId, version);
- }
- @Override
- public Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId,
- Version version) {
- SessionContext context = createSessionContext();
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ // registerVersioning is not implemented for ComponentDaoZusammenImpl
+ }
- Collection<ComponentEntity> components =
- listComponents(zusammenAdaptor, context, vspId, version);
+ @Override
+ public Collection<ComponentEntity> list(ComponentEntity component) {
+ SessionContext context = createSessionContext();
+ return listComponents(zusammenAdaptor, context, component.getVspId(), component.getVersion());
+ }
- ElementContext elementContext = new ElementContext(vspId, version.getId());
- components.forEach(component -> component.setQuestionnaireData(
- getQuestionnaire(context, elementContext, component).getQuestionnaireData()));
- return components;
- }
+ @Override
+ public void create(ComponentEntity component) {
+ ZusammenElement componentElement = componentToZusammen(component, Action.CREATE);
+ ZusammenElement componentsElement = buildStructuralElement(ElementType.Components, Action.IGNORE);
+ componentsElement.getSubElements().add(componentElement);
+ 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 deleteAll(String vspId, Version version) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
+ @Override
+ public void update(ComponentEntity component) {
+ ZusammenElement componentElement = componentToZusammen(component, Action.UPDATE);
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(component.getVspId(), component.getVersion().getId()), componentElement,
+ String.format("Update component with id %s", component.getId()));
+ }
- Collection<ElementInfo> vspModelSubs = zusammenAdaptor
- .listElementsByName(context, elementContext, null, ElementType.VspModel.name());
+ @Override
+ public ComponentEntity get(ComponentEntity component) {
+ SessionContext context = createSessionContext();
+ Optional<Element> element = zusammenAdaptor
+ .getElement(context, new ElementContext(component.getVspId(), component.getVersion().getId()), component.getId());
+ if (element.isPresent()) {
+ ComponentEntity entity = new ElementToComponentConvertor().convert(element.get());
+ entity.setVspId(component.getVspId());
+ entity.setVersion(component.getVersion());
+ return entity;
+ }
+ return null;
+ }
- Optional<ElementInfo> componentsElement = vspModelSubs.stream()
- .filter(elementInfo -> elementInfo.getInfo() != null
- && ElementType.Components.name().equals(elementInfo.getInfo().getName()))
- .findFirst();
- if (!componentsElement.isPresent()) {
- return;
+ @Override
+ public void delete(ComponentEntity component) {
+ ZusammenElement componentElement = buildElement(new Id(component.getId()), Action.DELETE);
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(component.getVspId(), component.getVersion().getId()), componentElement,
+ String.format("Delete component with id %s", component.getId()));
}
- ZusammenElement components = buildElement(componentsElement.get().getId(), Action.IGNORE);
- components.setSubElements(componentsElement.get().getSubElements().stream()
- .map(component -> buildElement(component.getId(), Action.DELETE))
- .collect(Collectors.toList()));
+ @Override
+ public ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId) {
+ SessionContext context = createSessionContext();
+ return getQuestionnaire(context, new ElementContext(vspId, version.getId()), new ComponentEntity(vspId, version, componentId));
+ }
- zusammenAdaptor.saveElement(context, elementContext, components, "Delete all components");
- }
+ private ComponentEntity getQuestionnaire(SessionContext context, ElementContext elementContext, ComponentEntity component) {
+ Optional<Element> questionnaireElement = zusammenAdaptor
+ .getElementByName(context, elementContext, new Id(component.getId()), ElementType.ComponentQuestionnaire.name());
+ return questionnaireElement.map(new ElementToComponentQuestionnnaireConvertor()::convert).map(entity -> {
+ entity.setVspId(component.getVspId());
+ entity.setVersion(component.getVersion());
+ return entity;
+ }).orElse(null);
+ }
- private ZusammenElement componentToZusammen(ComponentEntity component, Action action) {
- ZusammenElement componentElement = buildComponentElement(component, action);
+ @Override
+ public void updateQuestionnaireData(String vspId, Version version, String componentId, String questionnaireData) {
+ ZusammenElement questionnaireElement = componentQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
+ ZusammenElement componentElement = buildElement(new Id(componentId), Action.IGNORE);
+ componentElement.setSubElements(Collections.singletonList(questionnaireElement));
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), componentElement, "Update component questionnaire");
+ }
- 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));
+ @Override
+ public Collection<ComponentEntity> listQuestionnaires(String vspId, Version version) {
+ return listCompositionAndQuestionnaire(vspId, version);
+ }
- 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));
+ @Override
+ public Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ Collection<ComponentEntity> components = listComponents(zusammenAdaptor, context, vspId, version);
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ components.forEach(component -> component.setQuestionnaireData(getQuestionnaire(context, elementContext, component).getQuestionnaireData()));
+ return components;
}
- return componentElement;
- }
- private ZusammenElement componentQuestionnaireToZusammen(String questionnaireData,
- Action action) {
- ZusammenElement questionnaireElement =
- buildStructuralElement(ElementType.ComponentQuestionnaire, action);
- questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
- return questionnaireElement;
- }
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ 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;
+ }
+ 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 buildComponentElement(ComponentEntity component, Action action) {
- ZusammenElement componentElement =
- buildElement(component.getId() == null ? null : new Id(component.getId()), action);
- Info info = new Info();
- 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;
- }
+ private ZusammenElement componentToZusammen(ComponentEntity component, Action action) {
+ ZusammenElement componentElement = buildComponentElement(component, action);
+ 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;
+ }
+ private ZusammenElement componentQuestionnaireToZusammen(String questionnaireData, Action action) {
+ ZusammenElement questionnaireElement = buildStructuralElement(ElementType.ComponentQuestionnaire, action);
+ questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
+ return questionnaireElement;
+ }
+ private ZusammenElement buildComponentElement(ComponentEntity component, Action action) {
+ ZusammenElement componentElement = buildElement(component.getId() == null ? null : new Id(component.getId()), action);
+ Info info = new Info();
+ 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 bb80a95aab..5662da2769 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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -34,7 +33,6 @@ 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.types.ElementPropertyName;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
@@ -47,148 +45,103 @@ import static org.openecomp.core.zusammen.api.ZusammenUtil.*;
*/
public class ComponentDependencyModelDaoZusammenImpl implements ComponentDependencyModelDao {
- private ZusammenAdaptor zusammenAdaptor;
-
- public ComponentDependencyModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public ComponentDependencyModelEntity get(ComponentDependencyModelEntity dependency) {
+ private ZusammenAdaptor zusammenAdaptor;
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
-
- Optional<ElementInfo> componentDependencyElement =
- zusammenAdaptor.getElementInfo(context, elementContext, new Id(dependency.getId()));
-
- if (componentDependencyElement.isPresent()) {
- ElementToComponentDependencyModelConvertor convertor = new
- ElementToComponentDependencyModelConvertor();
-
- ComponentDependencyModelEntity entity = convertor.convert(componentDependencyElement.get());
- entity.setVspId(dependency.getVspId());
- entity.setVersion(dependency.getVersion());
- return entity;
+ public ComponentDependencyModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
}
- return null;
- }
-
- @Override
- public void create(ComponentDependencyModelEntity dependency) {
- ZusammenElement componentDependency =
- buildComponentDependencyElement(dependency, Action.CREATE);
-
- ZusammenElement componentDependencies =
- buildStructuralElement(ElementType.ComponentDependencies, Action.IGNORE);
- componentDependencies.addSubElement(componentDependency);
-
- ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
- vspModel.addSubElement(componentDependencies);
-
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
-
- Element compDepsSavedElement = zusammenAdaptor
- .saveElement(context, elementContext, vspModel, "Create component dependency model");
-
- dependency.setId(compDepsSavedElement.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue());
- }
-
- @Override
- public void update(ComponentDependencyModelEntity dependency) {
- ZusammenElement componentDependencyElement =
- buildComponentDependencyElement(dependency, Action.UPDATE);
-
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
-
- zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement,
- String.format("Update component dependency model with id %s", dependency.getId()));
- }
-
- @Override
- 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
- public void registerVersioning(String versionableEntityType) {
- //not implemented?
- }
-
- @Override
- 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<>();
+ @Override
+ public ComponentDependencyModelEntity get(ComponentDependencyModelEntity dependency) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
+ Optional<ElementInfo> componentDependencyElement = zusammenAdaptor.getElementInfo(context, elementContext, new Id(dependency.getId()));
+ if (componentDependencyElement.isPresent()) {
+ ElementToComponentDependencyModelConvertor convertor = new ElementToComponentDependencyModelConvertor();
+ ComponentDependencyModelEntity entity = convertor.convert(componentDependencyElement.get());
+ entity.setVspId(dependency.getVspId());
+ entity.setVersion(dependency.getVersion());
+ return entity;
+ }
+ return null;
}
- 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());
- }
+ @Override
+ public void create(ComponentDependencyModelEntity dependency) {
+ ZusammenElement componentDependency = buildComponentDependencyElement(dependency, Action.CREATE);
+ ZusammenElement componentDependencies = buildStructuralElement(ElementType.ComponentDependencies, Action.IGNORE);
+ componentDependencies.addSubElement(componentDependency);
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(componentDependencies);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
+ Element compDepsSavedElement = zusammenAdaptor.saveElement(context, elementContext, vspModel, "Create component dependency model");
+ dependency.setId(compDepsSavedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue());
+ }
- private ZusammenElement buildComponentDependencyElement(ComponentDependencyModelEntity compDep,
- Action action) {
- ZusammenElement componentDependencyElement =
- buildElement(compDep.getId() == null ? null : new Id(compDep.getId()), action);
+ @Override
+ public void update(ComponentDependencyModelEntity dependency) {
+ ZusammenElement componentDependencyElement = buildComponentDependencyElement(dependency, Action.UPDATE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
+ zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement,
+ String.format("Update component dependency model with id %s", dependency.getId()));
+ }
- Info info = new Info();
- info.addProperty(ElementPropertyName.elementType.name(), ElementType.ComponentDependency);
- info.addProperty(ComponentDependencyModelPropertyName.RELATION.getVal(), compDep.getRelation());
- info.addProperty(ComponentDependencyModelPropertyName.SOURCE_COMPONENT_ID.getVal(),
- compDep.getSourceComponentId());
- info.addProperty(ComponentDependencyModelPropertyName.TARGET_COMPONENT_ID.getVal(),
- compDep.getTargetComponentId());
+ @Override
+ 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()));
+ }
- componentDependencyElement.setInfo(info);
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ //not implemented?
+ }
- return componentDependencyElement;
- }
+ @Override
+ 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<>();
+ }
+ 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 enum ComponentDependencyModelPropertyName {
- ID("id"),
- RELATION("relation"),
- SOURCE_COMPONENT_ID("sourcecomponent_id"),
- TARGET_COMPONENT_ID("targetcomponent_id");
+ 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(ElementPropertyName.elementType.name(), ElementType.ComponentDependency);
+ info.addProperty(ComponentDependencyModelPropertyName.RELATION.getVal(), compDep.getRelation());
+ info.addProperty(ComponentDependencyModelPropertyName.SOURCE_COMPONENT_ID.getVal(), compDep.getSourceComponentId());
+ info.addProperty(ComponentDependencyModelPropertyName.TARGET_COMPONENT_ID.getVal(), compDep.getTargetComponentId());
+ componentDependencyElement.setInfo(info);
+ return componentDependencyElement;
+ }
- private String val;
+ private enum ComponentDependencyModelPropertyName {
+ ID("id"), RELATION("relation"), SOURCE_COMPONENT_ID("sourcecomponent_id"), TARGET_COMPONENT_ID("targetcomponent_id");
+ private String val;
- ComponentDependencyModelPropertyName(String val){
- this.val=val;
- }
+ ComponentDependencyModelPropertyName(String val) {
+ this.val = val;
+ }
- public String getVal() {
- return val;
+ public String getVal() {
+ return val;
+ }
}
- }
}
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/ComponentDependencyModelPropertyName.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/ComponentDependencyModelPropertyName.java
index 534c253811..7624886b9c 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/ComponentDependencyModelPropertyName.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/ComponentDependencyModelPropertyName.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.
@@ -17,16 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
/**
* Created by ayalaben on 5/16/2017
*/
-public enum ComponentDependencyModelPropertyName {
- id,
- relation,
- sourcecomponent_id,
- targetcomponent_id,
-
-}
+public 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 d1b540b312..48111ad041 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
@@ -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.
@@ -17,9 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+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 com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
@@ -28,6 +30,11 @@ 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 java.io.ByteArrayInputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.stream.Collectors;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
@@ -38,222 +45,156 @@ 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;
-import java.util.Collections;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import static org.openecomp.core.zusammen.api.ZusammenUtil.*;
-
public class ComputeDaoZusammenImpl implements ComputeDao {
- private ZusammenAdaptor zusammenAdaptor;
-
- public ComputeDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning not implemented for ComputeDaoZusammenImpl
- }
-
- @Override
- public Collection<ComputeEntity> list(ComputeEntity compute) {
- 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) {
- return zusammenAdaptor
- .listElementsByName(context, elementContext, new Id(compute.getComponentId()),
- ElementType.Computes.name())
- .stream()
- .map(new ElementToComputeConvertor()::convert)
- .map(computeEntity -> {
- computeEntity.setComponentId(compute.getComponentId());
- computeEntity.setVspId(compute.getVspId());
- computeEntity.setVersion(compute.getVersion());
- return computeEntity;
- })
- .collect(Collectors.toList());
- }
-
- @Override
- public void create(ComputeEntity compute) {
- ZusammenElement computeElement = computeToZusammen(compute, Action.CREATE);
-
- ZusammenElement computesElement = buildStructuralElement(ElementType.Computes, Action.IGNORE);
- computesElement.setSubElements(Collections.singletonList(computeElement));
-
- ZusammenElement componentElement =
- buildElement(new Id(compute.getComponentId()), Action.IGNORE);
- componentElement.setSubElements(Collections.singletonList(computesElement));
-
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(compute.getVspId(), compute.getVersion().getId());
+ private ZusammenAdaptor zusammenAdaptor;
- Element savedElement =
- zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create compute");
- 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 = 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 = createSessionContext();
- ElementContext elementContext =
- new ElementContext(compute.getVspId(), compute.getVersion().getId());
- Optional<Element> element =
- zusammenAdaptor.getElement(context, elementContext, compute.getId());
-
- if (element.isPresent()) {
-
- 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;
+ public ComputeDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
}
- }
-
- @Override
- public void delete(ComputeEntity compute) {
- 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 = 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) {
- Optional<Element> questionnaireElement = zusammenAdaptor
- .getElementByName(context, elementContext, new Id(compute.getId()),
- ElementType.ComputeQuestionnaire.name());
- return questionnaireElement.map(
- element -> element.getData() == null
- ? null
- : new String(FileUtils.toByteArray(element.getData())))
- .map(questionnaireData -> {
- compute.setQuestionnaireData(questionnaireData);
- return compute;
- })
- .orElse(null);
- }
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ // registerVersioning not implemented for ComputeDaoZusammenImpl
+ }
- @Override
- public void updateQuestionnaireData(String vspId, Version version, String componentId,
- String computeId, String questionnaireData) {
- ZusammenElement questionnaireElement =
- computeQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
+ @Override
+ public Collection<ComputeEntity> list(ComputeEntity compute) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(compute.getVspId(), compute.getVersion().getId());
+ return listComputes(context, elementContext, compute);
+ }
- ZusammenElement computeElement = buildElement(new Id(computeId), Action.IGNORE);
- computeElement.setSubElements(Collections.singletonList(questionnaireElement));
+ private Collection<ComputeEntity> listComputes(SessionContext context, ElementContext elementContext, ComputeEntity compute) {
+ return zusammenAdaptor.listElementsByName(context, elementContext, new Id(compute.getComponentId()), ElementType.Computes.name()).stream()
+ .map(new ElementToComputeConvertor()::convert).map(computeEntity -> {
+ computeEntity.setComponentId(compute.getComponentId());
+ computeEntity.setVspId(compute.getVspId());
+ computeEntity.setVersion(compute.getVersion());
+ return computeEntity;
+ }).collect(Collectors.toList());
+ }
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
- zusammenAdaptor.saveElement(context, elementContext, computeElement, "Update compute "
- + "questionnaire");
- }
+ @Override
+ public void create(ComputeEntity compute) {
+ ZusammenElement computeElement = computeToZusammen(compute, Action.CREATE);
+ ZusammenElement computesElement = buildStructuralElement(ElementType.Computes, Action.IGNORE);
+ computesElement.setSubElements(Collections.singletonList(computeElement));
+ ZusammenElement componentElement = buildElement(new Id(compute.getComponentId()), Action.IGNORE);
+ componentElement.setSubElements(Collections.singletonList(computesElement));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(compute.getVspId(), compute.getVersion().getId());
+ Element savedElement = zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create compute");
+ compute.setId(savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue());
+ }
- @Override
- public Collection<ComputeEntity> listByVsp(String vspId, Version version) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
+ @Override
+ public void update(ComputeEntity compute) {
+ ZusammenElement computeElement = computeToZusammen(compute, Action.UPDATE);
+ 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()));
+ }
- Collection<ComponentEntity> components = ComponentDaoZusammenImpl
- .listComponents(zusammenAdaptor, context, vspId, version);
+ @Override
+ public ComputeEntity get(ComputeEntity compute) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(compute.getVspId(), compute.getVersion().getId());
+ Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, compute.getId());
+ if (element.isPresent()) {
+ 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;
+ }
+ }
- return components.stream()
- .map(component ->
- listComputes(context, elementContext,
- new ComputeEntity(vspId, version, component.getId(), null)).stream()
- .map(compute -> getQuestionnaire(context, elementContext, compute))
- .collect(Collectors.toList()))
- .flatMap(Collection::stream)
- .collect(Collectors.toList());
- }
+ @Override
+ public void delete(ComputeEntity compute) {
+ 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 void deleteAll(String vspId, Version version) {
+ @Override
+ public ComputeEntity getQuestionnaireData(String vspId, Version version, String componentId, String computeId) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ return getQuestionnaire(context, elementContext, new ComputeEntity(vspId, version, componentId, computeId));
+ }
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
+ private ComputeEntity getQuestionnaire(SessionContext context, ElementContext elementContext, ComputeEntity compute) {
+ Optional<Element> questionnaireElement = zusammenAdaptor
+ .getElementByName(context, elementContext, new Id(compute.getId()), ElementType.ComputeQuestionnaire.name());
+ return questionnaireElement.map(element -> element.getData() == null ? null : new String(FileUtils.toByteArray(element.getData())))
+ .map(questionnaireData -> {
+ compute.setQuestionnaireData(questionnaireData);
+ return compute;
+ }).orElse(null);
+ }
- Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
- elementContext, null, ElementType.Computes.name());
+ @Override
+ public void updateQuestionnaireData(String vspId, Version version, String componentId, String computeId, String questionnaireData) {
+ ZusammenElement questionnaireElement = computeQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
+ ZusammenElement computeElement = buildElement(new Id(computeId), Action.IGNORE);
+ computeElement.setSubElements(Collections.singletonList(questionnaireElement));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ zusammenAdaptor.saveElement(context, elementContext, computeElement, "Update compute " + "questionnaire");
+ }
- if (optionalElement.isPresent()) {
- Element computesElement = optionalElement.get();
- Collection<Element> computes = computesElement.getSubElements();
+ @Override
+ public Collection<ComputeEntity> listByVsp(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ Collection<ComponentEntity> components = ComponentDaoZusammenImpl.listComponents(zusammenAdaptor, context, vspId, version);
+ return components.stream().map(
+ component -> listComputes(context, elementContext, new ComputeEntity(vspId, version, component.getId(), null)).stream()
+ .map(compute -> getQuestionnaire(context, elementContext, compute)).collect(Collectors.toList())).flatMap(Collection::stream)
+ .collect(Collectors.toList());
+ }
- computes.forEach(compute -> {
- ZusammenElement computeElement = buildElement(compute.getElementId(), Action.DELETE);
- zusammenAdaptor.saveElement(context, elementContext, computeElement,
- "Delete compute with id " + compute.getElementId());
- });
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ 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) {
- ZusammenElement computeElement = buildComputeElement(compute, action);
- if (action == Action.CREATE) {
- computeElement.setSubElements(Collections.singletonList(
- computeQuestionnaireToZusammen(compute.getQuestionnaireData(), Action.CREATE)));
+ private ZusammenElement computeToZusammen(ComputeEntity compute, Action action) {
+ ZusammenElement computeElement = buildComputeElement(compute, action);
+ if (action == Action.CREATE) {
+ computeElement.setSubElements(Collections.singletonList(computeQuestionnaireToZusammen(compute.getQuestionnaireData(), Action.CREATE)));
+ }
+ return computeElement;
}
- return computeElement;
- }
- private ZusammenElement computeQuestionnaireToZusammen(String questionnaireData,
- Action action) {
- ZusammenElement questionnaireElement =
- buildStructuralElement(ElementType.ComputeQuestionnaire, action);
- questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
- return questionnaireElement;
- }
+ private ZusammenElement computeQuestionnaireToZusammen(String questionnaireData, Action action) {
+ ZusammenElement questionnaireElement = buildStructuralElement(ElementType.ComputeQuestionnaire, action);
+ questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
+ return questionnaireElement;
+ }
- private ZusammenElement buildComputeElement(ComputeEntity compute, Action action) {
- ZusammenElement computeElement =
- buildElement(compute.getId() == null ? null : new Id(compute.getId()), action);
- Info info = new Info();
- 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;
- }
+ private ZusammenElement buildComputeElement(ComputeEntity compute, Action action) {
+ ZusammenElement computeElement = buildElement(compute.getId() == null ? null : new Id(compute.getId()), action);
+ Info info = new Info();
+ 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 8ccaf083d1..d72bd6b9b9 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
@@ -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.
@@ -17,9 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+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 com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.Id;
@@ -27,6 +30,10 @@ 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 java.io.ByteArrayInputStream;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.stream.Collectors;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
@@ -36,153 +43,105 @@ 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.*;
-
public class DeploymentFlavorDaoZusammenImpl implements DeploymentFlavorDao {
- private ZusammenAdaptor zusammenAdaptor;
-
- public DeploymentFlavorDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning not implemented for DeploymentFlavorDaoZusammenImpl
- }
-
- @Override
- public Collection<DeploymentFlavorEntity> list(DeploymentFlavorEntity deploymentFlavor) {
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId());
-
- return listDeploymentFlavor(zusammenAdaptor, context, elementContext,
- deploymentFlavor.getVspId(),
- deploymentFlavor.getVersion());
- }
+ private ZusammenAdaptor zusammenAdaptor;
- 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,
- ElementType.DeploymentFlavors.name())
- .stream().map(elementInfo -> {
- DeploymentFlavorEntity entity = convertor.convert(
- elementInfo);
- entity.setVspId(vspId);
- entity.setVersion(version);
- return entity;
- })
- .collect(Collectors.toList());
- }
-
-
- @Override
- public void create(DeploymentFlavorEntity deploymentFlavor) {
- ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor,
- Action.CREATE);
- ZusammenElement deploymentFlavorElements =
- buildStructuralElement(ElementType.DeploymentFlavors, Action.IGNORE);
- deploymentFlavorElements.getSubElements().add(deploymentFlavorElement);
-
- SessionContext context = createSessionContext();
- Element savedElement = zusammenAdaptor.saveElement(context,
- new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()),
- deploymentFlavorElements, "Create deloymentFlavor");
- deploymentFlavor.setId(savedElement.getSubElements().iterator().next().getElementId()
- .getValue());
- }
-
- @Override
- public void update(DeploymentFlavorEntity deploymentFlavor) {
- ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor,
- Action.UPDATE);
-
- SessionContext context = createSessionContext();
- zusammenAdaptor.saveElement(context,
- 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 = createSessionContext();
- ElementContext elementContext =
- new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId());
-
- Optional<Element> element =
- zusammenAdaptor.getElement(context, elementContext, deploymentFlavor.getId());
+ public DeploymentFlavorDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
- if (element.isPresent()) {
- ElementToDeploymentFlavorConvertor convertor = new ElementToDeploymentFlavorConvertor();
- DeploymentFlavorEntity entity = convertor.convert(element.get());
- deploymentFlavor.setCompositionData(new String(FileUtils.toByteArray(element.get()
- .getData())));
- entity.setVspId(deploymentFlavor.getVspId());
- entity.setVersion(deploymentFlavor.getVersion());
- return entity;
+ 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, ElementType.DeploymentFlavors.name()).stream().map(elementInfo -> {
+ DeploymentFlavorEntity entity = convertor.convert(elementInfo);
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ return entity;
+ }).collect(Collectors.toList());
}
- return null;
- }
- @Override
- public void delete(DeploymentFlavorEntity deploymentFlavor) {
- ZusammenElement componentElement =
- buildElement(new Id(deploymentFlavor.getId()), Action.DELETE);
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ // registerVersioning not implemented for DeploymentFlavorDaoZusammenImpl
+ }
- SessionContext context = createSessionContext();
- zusammenAdaptor.saveElement(context,
- new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()),
- componentElement, String.format("Delete deloymentFlavor with id %s",
- deploymentFlavor.getId()));
- }
+ @Override
+ public Collection<DeploymentFlavorEntity> list(DeploymentFlavorEntity deploymentFlavor) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId());
+ return listDeploymentFlavor(zusammenAdaptor, context, elementContext, deploymentFlavor.getVspId(), deploymentFlavor.getVersion());
+ }
- @Override
- public void deleteAll(String vspId, Version version) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
+ @Override
+ public void create(DeploymentFlavorEntity deploymentFlavor) {
+ ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor, Action.CREATE);
+ ZusammenElement deploymentFlavorElements = buildStructuralElement(ElementType.DeploymentFlavors, Action.IGNORE);
+ deploymentFlavorElements.getSubElements().add(deploymentFlavorElement);
+ SessionContext context = createSessionContext();
+ Element savedElement = zusammenAdaptor
+ .saveElement(context, new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()), deploymentFlavorElements,
+ "Create deloymentFlavor");
+ deploymentFlavor.setId(savedElement.getSubElements().iterator().next().getElementId().getValue());
+ }
- Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
- elementContext, null, ElementType.DeploymentFlavors.name());
+ @Override
+ public void update(DeploymentFlavorEntity deploymentFlavor) {
+ ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor, Action.UPDATE);
+ SessionContext context = createSessionContext();
+ zusammenAdaptor
+ .saveElement(context, new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()), deploymentFlavorElement,
+ String.format("Update deloymentFlavor with id %s", deploymentFlavor.getId()));
+ }
- if (optionalElement.isPresent()) {
- Element deploymentFlavorsElement = optionalElement.get();
- Collection<Element> deploymentFlavors = deploymentFlavorsElement.getSubElements();
+ @Override
+ public DeploymentFlavorEntity get(DeploymentFlavorEntity deploymentFlavor) {
+ 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())));
+ entity.setVspId(deploymentFlavor.getVspId());
+ entity.setVersion(deploymentFlavor.getVersion());
+ return entity;
+ }
+ return null;
+ }
- deploymentFlavors.forEach(deplymentFlavor -> {
- ZusammenElement deplymentFlavorZusammenElement =
- buildElement(deplymentFlavor.getElementId(), Action.DELETE);
- zusammenAdaptor.saveElement(context,
- elementContext, deplymentFlavorZusammenElement, " Delete Deplyment Flavor with id "
- + deplymentFlavor.getElementId());
- });
+ @Override
+ public void delete(DeploymentFlavorEntity deploymentFlavor) {
+ ZusammenElement componentElement = buildElement(new Id(deploymentFlavor.getId()), Action.DELETE);
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()), componentElement,
+ String.format("Delete deloymentFlavor with id %s", 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.elementType.name(), ElementType.DeploymentFlavor);
- info.addProperty(ElementPropertyName.compositionData.name(), deploymentFlavor
- .getCompositionData());
- deploymentFlavorElement.setInfo(info);
- deploymentFlavorElement.setData(new ByteArrayInputStream(deploymentFlavor.getCompositionData()
- .getBytes()));
- return deploymentFlavorElement;
- }
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ 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 deploymentFlavorToZusammen(DeploymentFlavorEntity deploymentFlavor, Action action) {
+ ZusammenElement deploymentFlavorElement = buildElement(deploymentFlavor.getId() == null ? null : new Id(deploymentFlavor.getId()), action);
+ Info info = new Info();
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.DeploymentFlavor);
+ info.addProperty(ElementPropertyName.compositionData.name(), deploymentFlavor.getCompositionData());
+ deploymentFlavorElement.setInfo(info);
+ deploymentFlavorElement.setData(new ByteArrayInputStream(deploymentFlavor.getCompositionData().getBytes()));
+ return deploymentFlavorElement;
+ }
}
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 f82827d02b..5227a4cff4 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
@@ -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.
@@ -17,9 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+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 com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
@@ -28,6 +30,11 @@ 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 java.io.ByteArrayInputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.stream.Collectors;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
@@ -38,220 +45,156 @@ 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;
-import java.util.Collections;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import static org.openecomp.core.zusammen.api.ZusammenUtil.*;
-
public class ImageDaoZusammenImpl implements ImageDao {
- private ZusammenAdaptor zusammenAdaptor;
-
- public ImageDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning not implemented for ImageDaoZusammenImpl
- }
-
- @Override
- public Collection<ImageEntity> list(ImageEntity image) {
- 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) {
- return zusammenAdaptor
- .listElementsByName(context, elementContext, new Id(image.getComponentId()),
- ElementType.Images.name())
- .stream().map(new ElementToImageConvertor()::convert)
- .map(imageEntity -> {
- imageEntity.setComponentId(image.getComponentId());
- imageEntity.setVspId(image.getVspId());
- imageEntity.setVersion(image.getVersion());
- return imageEntity;
- })
- .collect(Collectors.toList());
- }
-
- @Override
- public void create(ImageEntity image) {
- ZusammenElement imageElement = imageToZusammen(image, Action.CREATE);
-
- ZusammenElement imagesElement =
- buildStructuralElement(ElementType.Images, Action.IGNORE);
- imagesElement.setSubElements(Collections.singletonList(imageElement));
-
- ZusammenElement componentElement = buildElement(new Id(image.getComponentId()), Action.IGNORE);
- componentElement.setSubElements(Collections.singletonList(imagesElement));
-
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(image.getVspId(), image.getVersion().getId());
-
- Element savedElement =
- zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create image");
- image.setId(savedElement.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue());
- }
+ private ZusammenAdaptor zusammenAdaptor;
- @Override
- public void update(ImageEntity image) {
- ZusammenElement imageElement = imageToZusammen(image, Action.UPDATE);
-
- 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 = createSessionContext();
-
- ElementContext elementContext =
- new ElementContext(image.getVspId(), image.getVersion().getId());
- Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, image.getId());
-
- if (element.isPresent()) {
- 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;
+ public ImageDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
}
- }
-
- @Override
- public void delete(ImageEntity image) {
- 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) {
- 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 void registerVersioning(String versionableEntityType) {
+ // registerVersioning not implemented for ImageDaoZusammenImpl
}
- }
-
- @Override
- public Collection<ImageEntity> listByVsp(String vspId, Version version) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
- Collection<ComponentEntity> components = ComponentDaoZusammenImpl
- .listComponents(zusammenAdaptor, context, vspId, version);
+ @Override
+ public Collection<ImageEntity> list(ImageEntity image) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(image.getVspId(), image.getVersion().getId());
+ return listImages(context, elementContext, image);
+ }
- return components.stream()
- .map(component ->
- listImages(context, elementContext,
- new ImageEntity(vspId, version, component.getId(), null)).stream()
- .map(image -> getQuestionnaire(context, elementContext, image))
- .collect(Collectors.toList()))
- .flatMap(Collection::stream)
- .collect(Collectors.toList());
- }
+ private Collection<ImageEntity> listImages(SessionContext context, ElementContext elementContext, ImageEntity image) {
+ return zusammenAdaptor.listElementsByName(context, elementContext, new Id(image.getComponentId()), ElementType.Images.name()).stream()
+ .map(new ElementToImageConvertor()::convert).map(imageEntity -> {
+ imageEntity.setComponentId(image.getComponentId());
+ imageEntity.setVspId(image.getVspId());
+ imageEntity.setVersion(image.getVersion());
+ return imageEntity;
+ }).collect(Collectors.toList());
+ }
- @Override
- public ImageEntity getQuestionnaireData(String vspId, Version version, String componentId,
- String imageId) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
+ @Override
+ public void create(ImageEntity image) {
+ ZusammenElement imageElement = imageToZusammen(image, Action.CREATE);
+ ZusammenElement imagesElement = buildStructuralElement(ElementType.Images, Action.IGNORE);
+ imagesElement.setSubElements(Collections.singletonList(imageElement));
+ ZusammenElement componentElement = buildElement(new Id(image.getComponentId()), Action.IGNORE);
+ componentElement.setSubElements(Collections.singletonList(imagesElement));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(image.getVspId(), image.getVersion().getId());
+ Element savedElement = zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create image");
+ image.setId(savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue());
+ }
- return getQuestionnaire(context, elementContext,
- new ImageEntity(vspId, version, componentId, imageId));
- }
+ @Override
+ public void update(ImageEntity image) {
+ ZusammenElement imageElement = imageToZusammen(image, Action.UPDATE);
+ 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()));
+ }
- private ImageEntity getQuestionnaire(SessionContext context, ElementContext elementContext,
- ImageEntity image) {
- Optional<Element> questionnaireElement = zusammenAdaptor
- .getElementByName(context, elementContext, new Id(image.getId()),
- ElementType.ImageQuestionnaire.name());
- return questionnaireElement.map(
- element -> element.getData() == null
- ? null
- : new String(FileUtils.toByteArray(element.getData())))
- .map(questionnaireData -> {
- image.setQuestionnaireData(questionnaireData);
- return image;
- })
- .orElse(null);
- }
+ @Override
+ public ImageEntity get(ImageEntity image) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(image.getVspId(), image.getVersion().getId());
+ Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, image.getId());
+ if (element.isPresent()) {
+ 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;
+ }
+ }
- @Override
- public void updateQuestionnaireData(String vspId, Version version, String componentId,
- String imageId, String questionnaireData) {
- ZusammenElement questionnaireElement =
- imageQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
+ @Override
+ public void delete(ImageEntity image) {
+ 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()));
+ }
- ZusammenElement imageElement = buildElement(new Id(imageId), Action.IGNORE);
- imageElement.setSubElements(Collections.singletonList(questionnaireElement));
+ @Override
+ public void deleteByVspId(String vspId, Version version) {
+ 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());
+ });
+ }
+ }
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
- zusammenAdaptor.saveElement(context, elementContext, imageElement, "Update image "
- + "questionnaire");
- }
+ @Override
+ public Collection<ImageEntity> listByVsp(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ Collection<ComponentEntity> components = ComponentDaoZusammenImpl.listComponents(zusammenAdaptor, context, vspId, version);
+ return components.stream().map(
+ component -> listImages(context, elementContext, new ImageEntity(vspId, version, component.getId(), null)).stream()
+ .map(image -> getQuestionnaire(context, elementContext, image)).collect(Collectors.toList())).flatMap(Collection::stream)
+ .collect(Collectors.toList());
+ }
+ @Override
+ public ImageEntity getQuestionnaireData(String vspId, Version version, String componentId, String imageId) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ return getQuestionnaire(context, elementContext, new ImageEntity(vspId, version, componentId, imageId));
+ }
- private ZusammenElement imageToZusammen(ImageEntity image, Action action) {
- ZusammenElement imageElement = buildImageElement(image, action);
- if (action == Action.CREATE) {
- imageElement.setSubElements(Collections.singletonList(
- imageQuestionnaireToZusammen(image.getQuestionnaireData(), Action.CREATE)));
+ private ImageEntity getQuestionnaire(SessionContext context, ElementContext elementContext, ImageEntity image) {
+ Optional<Element> questionnaireElement = zusammenAdaptor
+ .getElementByName(context, elementContext, new Id(image.getId()), ElementType.ImageQuestionnaire.name());
+ return questionnaireElement.map(element -> element.getData() == null ? null : new String(FileUtils.toByteArray(element.getData())))
+ .map(questionnaireData -> {
+ image.setQuestionnaireData(questionnaireData);
+ return image;
+ }).orElse(null);
}
- return imageElement;
- }
- private ZusammenElement imageQuestionnaireToZusammen(String questionnaireData,
- Action action) {
- ZusammenElement questionnaireElement =
- buildStructuralElement(ElementType.ImageQuestionnaire, action);
- questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
- return questionnaireElement;
- }
+ @Override
+ public void updateQuestionnaireData(String vspId, Version version, String componentId, String imageId, String questionnaireData) {
+ ZusammenElement questionnaireElement = imageQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
+ ZusammenElement imageElement = buildElement(new Id(imageId), Action.IGNORE);
+ imageElement.setSubElements(Collections.singletonList(questionnaireElement));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ zusammenAdaptor.saveElement(context, elementContext, imageElement, "Update image " + "questionnaire");
+ }
- private ZusammenElement buildImageElement(ImageEntity image, Action action) {
- ZusammenElement imageElement =
- buildElement(image.getId() == null ? null : new Id(image.getId()), action);
- Info info = new Info();
- info.addProperty(ElementPropertyName.elementType.name(), ElementType.Image);
- info.addProperty(ElementPropertyName.compositionData.name(), image.getCompositionData());
- imageElement.setInfo(info);
- imageElement.setData(new ByteArrayInputStream(image.getCompositionData().getBytes()));
- return imageElement;
- }
+ private ZusammenElement imageToZusammen(ImageEntity image, Action action) {
+ ZusammenElement imageElement = buildImageElement(image, action);
+ if (action == Action.CREATE) {
+ imageElement.setSubElements(Collections.singletonList(imageQuestionnaireToZusammen(image.getQuestionnaireData(), Action.CREATE)));
+ }
+ return imageElement;
+ }
+ private ZusammenElement imageQuestionnaireToZusammen(String questionnaireData, Action action) {
+ ZusammenElement questionnaireElement = buildStructuralElement(ElementType.ImageQuestionnaire, action);
+ questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
+ return questionnaireElement;
+ }
+ private ZusammenElement buildImageElement(ImageEntity image, Action action) {
+ ZusammenElement imageElement = buildElement(image.getId() == null ? null : new Id(image.getId()), action);
+ Info info = new Info();
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Image);
+ info.addProperty(ElementPropertyName.compositionData.name(), image.getCompositionData());
+ imageElement.setInfo(info);
+ imageElement.setData(new ByteArrayInputStream(image.getCompositionData().getBytes()));
+ return imageElement;
+ }
}
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 4099e1264b..0230f3e486 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
@@ -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.
@@ -17,9 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+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 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;
@@ -28,6 +31,12 @@ 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 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 org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
@@ -36,141 +45,103 @@ 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.*;
-
public class NetworkDaoZusammenImpl implements NetworkDao {
- private ZusammenAdaptor zusammenAdaptor;
-
- public NetworkDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning not implemented for NetworkDaoZusammenImpl
- }
+ private ZusammenAdaptor zusammenAdaptor;
- @Override
- public Collection<NetworkEntity> list(NetworkEntity network) {
- 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<>();
+ public NetworkDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
}
- return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(),
- ElementType.Networks.name()).stream()
- .map(new ElementToNetworkConvertor()::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 = buildStructuralElement(ElementType.Networks, Action.IGNORE);
- networksElement.setSubElements(Collections.singletonList(networkElement));
-
- 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 = 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 = createSessionContext();
-
- Optional<Element> element =
- zusammenAdaptor.getElement(context,
- new ElementContext(network.getVspId(), network.getVersion().getId()), network.getId());
-
- if (element.isPresent()) {
- ElementToNetworkConvertor convertor = new ElementToNetworkConvertor();
- NetworkEntity entity = convertor.convert(element.get());
- entity.setVspId(network.getVspId());
- entity.setVersion(network.getVersion());
- return entity;
- } else {
- return null;
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ // registerVersioning not implemented for NetworkDaoZusammenImpl
}
- }
-
- @Override
- public void delete(NetworkEntity network) {
- 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 Collection<NetworkEntity> list(NetworkEntity network) {
+ 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<>();
+ }
+ return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(), ElementType.Networks.name()).stream()
+ .map(new ElementToNetworkConvertor()::convert).map(entity -> {
+ entity.setVspId(network.getVspId());
+ entity.setVersion(network.getVersion());
+ return entity;
+ }).collect(Collectors.toList());
+ }
- @Override
- public void deleteAll(String vspId, Version version) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
+ @Override
+ public void create(NetworkEntity network) {
+ ZusammenElement networkElement = buildNetworkElement(network, Action.CREATE);
+ ZusammenElement networksElement = buildStructuralElement(ElementType.Networks, Action.IGNORE);
+ networksElement.setSubElements(Collections.singletonList(networkElement));
+ 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());
+ }
- Collection<ElementInfo> vspModelSubs = zusammenAdaptor
- .listElementsByName(context, elementContext, null, ElementType.VspModel.name());
+ @Override
+ public void update(NetworkEntity network) {
+ ZusammenElement networkElement = buildNetworkElement(network, Action.UPDATE);
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()), networkElement,
+ String.format("Update network with id %s", network.getId()));
+ }
- Optional<ElementInfo> networksElement = vspModelSubs.stream()
- .filter(elementInfo -> elementInfo.getInfo() != null
- && ElementType.Networks.name().equals(elementInfo.getInfo().getName()))
- .findFirst();
- if (!networksElement.isPresent()) {
- return;
+ @Override
+ public NetworkEntity get(NetworkEntity network) {
+ SessionContext context = createSessionContext();
+ Optional<Element> element = zusammenAdaptor
+ .getElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()), network.getId());
+ if (element.isPresent()) {
+ ElementToNetworkConvertor convertor = new ElementToNetworkConvertor();
+ NetworkEntity entity = convertor.convert(element.get());
+ entity.setVspId(network.getVspId());
+ entity.setVersion(network.getVersion());
+ return entity;
+ } else {
+ return null;
+ }
}
- ZusammenElement networks = buildElement(networksElement.get().getId(), Action.IGNORE);
- networks.setSubElements(networksElement.get().getSubElements().stream()
- .map(network -> buildElement(network.getId(), Action.DELETE))
- .collect(Collectors.toList()));
+ @Override
+ public void delete(NetworkEntity network) {
+ 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()));
+ }
- zusammenAdaptor.saveElement(context, elementContext, networks, "Delete all networks");
- }
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ 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 =
- buildElement(network.getId() == null ? null : new Id(network.getId()), action);
- Info info = new Info();
- info.addProperty(ElementPropertyName.elementType.name(), ElementType.Network);
- info.addProperty(ElementPropertyName.compositionData.name(), network.getCompositionData());
- networkElement.setInfo(info);
- networkElement.setData(new ByteArrayInputStream(network.getCompositionData().getBytes()));
- return networkElement;
- }
+ private ZusammenElement buildNetworkElement(NetworkEntity network, Action action) {
+ ZusammenElement networkElement = buildElement(network.getId() == null ? null : new Id(network.getId()), action);
+ Info info = new Info();
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Network);
+ info.addProperty(ElementPropertyName.compositionData.name(), network.getCompositionData());
+ networkElement.setInfo(info);
+ networkElement.setData(new ByteArrayInputStream(network.getCompositionData().getBytes()));
+ return networkElement;
+ }
}
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 05f8d9dcfc..baad1d7c89 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
@@ -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.
@@ -17,9 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+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 com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.Id;
@@ -27,6 +30,11 @@ 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 java.io.ByteArrayInputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.stream.Collectors;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
@@ -37,217 +45,159 @@ 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;
-import java.util.Collections;
-import java.util.Optional;
-import java.util.stream.Collectors;
+public class NicDaoZusammenImpl implements NicDao {
-import static org.openecomp.core.zusammen.api.ZusammenUtil.*;
+ private ZusammenAdaptor zusammenAdaptor;
-public class NicDaoZusammenImpl implements NicDao {
+ public NicDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ // registerVersioning is not implemented for NicDaoZusammenImpl
+ }
+
+ @Override
+ public Collection<NicEntity> list(NicEntity 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()), ElementType.Nics.name()).stream()
+ .map(new ElementToNicConvertor()::convert).map(nicEntity -> {
+ nicEntity.setComponentId(nic.getComponentId());
+ nicEntity.setVspId(nic.getVspId());
+ nicEntity.setVersion(nic.getVersion());
+ return nicEntity;
+ }).collect(Collectors.toList());
+ }
+
+ @Override
+ public void create(NicEntity nic) {
+ ZusammenElement nicElement = nicToZusammen(nic, Action.CREATE);
+ ZusammenElement nicsElement = buildStructuralElement(ElementType.Nics, Action.IGNORE);
+ nicsElement.setSubElements(Collections.singletonList(nicElement));
+ ZusammenElement componentElement = buildElement(new Id(nic.getComponentId()), Action.IGNORE);
+ componentElement.setSubElements(Collections.singletonList(nicsElement));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(nic.getVspId(), nic.getVersion().getId());
+ Element savedElement = zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create nic");
+ nic.setId(savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue());
+ }
- private ZusammenAdaptor zusammenAdaptor;
-
- public NicDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning is not implemented for NicDaoZusammenImpl
- }
-
- @Override
- public Collection<NicEntity> list(NicEntity 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()),
- ElementType.Nics.name())
- .stream()
- .map(new ElementToNicConvertor()::convert)
- .map(nicEntity -> {
- nicEntity.setComponentId(nic.getComponentId());
- nicEntity.setVspId(nic.getVspId());
- nicEntity.setVersion(nic.getVersion());
- return nicEntity;
- })
- .collect(Collectors.toList());
- }
-
-
- @Override
- public void create(NicEntity nic) {
- ZusammenElement nicElement = nicToZusammen(nic, Action.CREATE);
-
- ZusammenElement nicsElement = buildStructuralElement(ElementType.Nics, Action.IGNORE);
- nicsElement.setSubElements(Collections.singletonList(nicElement));
-
- ZusammenElement componentElement = buildElement(new Id(nic.getComponentId()), Action.IGNORE);
- componentElement.setSubElements(Collections.singletonList(nicsElement));
-
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(nic.getVspId(), nic.getVersion().getId());
-
- Element savedElement =
- zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create nic");
- 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 = 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 = createSessionContext();
- ElementToNicConvertor convertor = new ElementToNicConvertor();
- Optional<Element> element = zusammenAdaptor
- .getElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()),
- nic.getId());
-
- if (element.isPresent()) {
- NicEntity entity = convertor.convert(element.get());
- entity.setVspId(nic.getVspId());
- entity.setVersion(nic.getVersion());
- entity.setComponentId(nic.getComponentId());
-
- return entity;
- } else {
- return null;
- }
- }
-
- @Override
- public void delete(NicEntity nic) {
- 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 = createSessionContext();
-
- return getQuestionnaire(context, new ElementContext(vspId, version.getId()),
- new NicEntity(vspId, version, componentId, nicId));
- }
-
- private NicEntity getQuestionnaire(SessionContext context, ElementContext elementContext,
- NicEntity nic) {
- Optional<Element> questionnaireElement = zusammenAdaptor
- .getElementByName(context, elementContext, new Id(nic.getId()),
- 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);
- }
-
- @Override
- public void updateQuestionnaireData(String vspId, Version version, String componentId,
- String nicId, String questionnaireData) {
- ZusammenElement questionnaireElement =
- nicQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
-
- ZusammenElement nicElement = buildElement(new Id(nicId), Action.IGNORE);
- nicElement.setSubElements(Collections.singletonList(questionnaireElement));
-
- 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 = createSessionContext();
-
- Collection<ComponentEntity> components = ComponentDaoZusammenImpl
- .listComponents(zusammenAdaptor, context, vspId, version);
-
- ElementContext elementContext = new ElementContext(vspId, version.getId());
- return components.stream()
- .map(component ->
- listNics(context, elementContext,
- new NicEntity(vspId, version, component.getId(), null)).stream()
- .map(nic -> {
- nic.setQuestionnaireData(getQuestionnaire(context, elementContext, nic).getQuestionnaireData());
- return nic;
- })
- .collect(Collectors.toList()))
- .flatMap(Collection::stream)
- .collect(Collectors.toList());
- }
-
- @Override
- public void deleteByComponentId(String vspId, Version version, String 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
- public void deleteByVspId(String vspId, Version version) {
- // deleteByVspId not implemented for NicDaoZusammenImpl
- }
-
- private ZusammenElement nicToZusammen(NicEntity nic, Action action) {
- ZusammenElement nicElement = buildNicElement(nic, action);
- if (action == Action.CREATE) {
- nicElement.setSubElements(Collections.singletonList(
- nicQuestionnaireToZusammen(nic.getQuestionnaireData(), Action.CREATE)));
- }
- return nicElement;
- }
-
- private ZusammenElement nicQuestionnaireToZusammen(String questionnaireData,
- Action action) {
- ZusammenElement questionnaireElement =
- buildStructuralElement(ElementType.NicQuestionnaire, action);
- questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
- return questionnaireElement;
- }
-
- private ZusammenElement buildNicElement(NicEntity nic, Action action) {
- ZusammenElement nicElement =
- buildElement(nic.getId() == null ? null : new Id(nic.getId()), action);
- Info info = new Info();
- info.addProperty(ElementPropertyName.elementType.name(), ElementType.Nic);
- info.addProperty(ElementPropertyName.compositionData.name(), nic.getCompositionData());
- nicElement.setInfo(info);
- nicElement.setData(new ByteArrayInputStream(nic.getCompositionData().getBytes()));
- return nicElement;
- }
+ @Override
+ public void update(NicEntity nic) {
+ ZusammenElement nicElement = nicToZusammen(nic, Action.UPDATE);
+ 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 = createSessionContext();
+ ElementToNicConvertor convertor = new ElementToNicConvertor();
+ Optional<Element> element = zusammenAdaptor.getElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), nic.getId());
+ if (element.isPresent()) {
+ NicEntity entity = convertor.convert(element.get());
+ entity.setVspId(nic.getVspId());
+ entity.setVersion(nic.getVersion());
+ entity.setComponentId(nic.getComponentId());
+ return entity;
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void delete(NicEntity nic) {
+ 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 = createSessionContext();
+ return getQuestionnaire(context, new ElementContext(vspId, version.getId()), new NicEntity(vspId, version, componentId, nicId));
+ }
+
+ private NicEntity getQuestionnaire(SessionContext context, ElementContext elementContext, NicEntity nic) {
+ Optional<Element> questionnaireElement = zusammenAdaptor
+ .getElementByName(context, elementContext, new Id(nic.getId()), 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);
+ }
+
+ @Override
+ public void updateQuestionnaireData(String vspId, Version version, String componentId, String nicId, String questionnaireData) {
+ ZusammenElement questionnaireElement = nicQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
+ ZusammenElement nicElement = buildElement(new Id(nicId), Action.IGNORE);
+ nicElement.setSubElements(Collections.singletonList(questionnaireElement));
+ 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 = createSessionContext();
+ Collection<ComponentEntity> components = ComponentDaoZusammenImpl.listComponents(zusammenAdaptor, context, vspId, version);
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ return components.stream()
+ .map(component -> listNics(context, elementContext, new NicEntity(vspId, version, component.getId(), null)).stream().map(nic -> {
+ nic.setQuestionnaireData(getQuestionnaire(context, elementContext, nic).getQuestionnaireData());
+ return nic;
+ }).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList());
+ }
+
+ @Override
+ public void deleteByComponentId(String vspId, Version version, String 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
+ public void deleteByVspId(String vspId, Version version) {
+ // deleteByVspId not implemented for NicDaoZusammenImpl
+ }
+
+ private ZusammenElement nicToZusammen(NicEntity nic, Action action) {
+ ZusammenElement nicElement = buildNicElement(nic, action);
+ if (action == Action.CREATE) {
+ nicElement.setSubElements(Collections.singletonList(nicQuestionnaireToZusammen(nic.getQuestionnaireData(), Action.CREATE)));
+ }
+ return nicElement;
+ }
+
+ private ZusammenElement nicQuestionnaireToZusammen(String questionnaireData, Action action) {
+ ZusammenElement questionnaireElement = buildStructuralElement(ElementType.NicQuestionnaire, action);
+ questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
+ return questionnaireElement;
+ }
+
+ private ZusammenElement buildNicElement(NicEntity nic, Action action) {
+ ZusammenElement nicElement = buildElement(nic.getId() == null ? null : new Id(nic.getId()), action);
+ Info info = new Info();
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Nic);
+ info.addProperty(ElementPropertyName.compositionData.name(), nic.getCompositionData());
+ nicElement.setInfo(info);
+ nicElement.setData(new ByteArrayInputStream(nic.getCompositionData().getBytes()));
+ return nicElement;
+ }
}
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 4c1e2e1ef2..fb26714375 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
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
@@ -41,251 +40,173 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCan
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.versioning.dao.types.Version;
-public class OrchestrationTemplateCandidateDaoZusammenImpl
- implements OrchestrationTemplateCandidateDao {
-
- private static final Logger logger =
- LoggerFactory.getLogger(OrchestrationTemplateCandidateDaoZusammenImpl.class);
-
- private final ZusammenAdaptor zusammenAdaptor;
-
- private static final String EMPTY_DATA = "{}";
-
- public OrchestrationTemplateCandidateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
+public class OrchestrationTemplateCandidateDaoZusammenImpl implements OrchestrationTemplateCandidateDao {
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning not implemented for OrchestrationTemplateCandidateDaoZusammenImpl
- }
+ private static final Logger logger = LoggerFactory.getLogger(OrchestrationTemplateCandidateDaoZusammenImpl.class);
+ private static final String EMPTY_DATA = "{}";
+ private final ZusammenAdaptor zusammenAdaptor;
- @Override
- public Optional<OrchestrationTemplateCandidateData> get(String vspId, Version version) {
- logger.info("Getting orchestration template for vsp id {}", vspId);
-
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
-
- Optional<Element> candidateElement =
- zusammenAdaptor.getElementByName(context, elementContext, null,
- ElementType.OrchestrationTemplateCandidate.name());
-
- if (!candidateElement.isPresent() ||
- VspZusammenUtil.hasEmptyData(candidateElement.get().getData()) ||
- candidateElement.get().getSubElements().isEmpty()) {
- logger.info("Orchestration template for vsp id {} does not exist / has empty data", vspId);
- return Optional.empty();
+ public OrchestrationTemplateCandidateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
}
- OrchestrationTemplateCandidateData candidate = new OrchestrationTemplateCandidateData();
- candidate.setFilesDataStructure(
- new String(FileUtils.toByteArray(candidateElement.get().getData())));
-
- candidateElement.get().getSubElements().stream()
- .map(element -> zusammenAdaptor
- .getElement(context, elementContext, element.getElementId().toString()))
- .forEach(element -> element.ifPresent(
- candidateInfoElement -> populateCandidate(candidate, candidateInfoElement, true)));
-
- logger.info("Finished getting orchestration template for vsp id {}", vspId);
- return candidate.getFileSuffix() == null ? Optional.empty() : Optional.of(candidate);
- }
-
- @Override
- public Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version) {
- logger.info("Getting orchestration template info for vsp id {}", vspId);
-
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
-
- Optional<ElementInfo> candidateElement =
- zusammenAdaptor.getElementInfoByName(context, elementContext, null,
- ElementType.OrchestrationTemplateCandidate.name());
-
- if (!candidateElement.isPresent() || candidateElement.get().getSubElements().isEmpty()) {
- logger.info("Orchestration template info for vsp id {} does not exist", vspId);
- return Optional.empty();
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ // registerVersioning not implemented for OrchestrationTemplateCandidateDaoZusammenImpl
}
- OrchestrationTemplateCandidateData candidate = new OrchestrationTemplateCandidateData();
- candidateElement.get().getSubElements().stream()
- .map(elementInfo -> zusammenAdaptor
- .getElement(context, elementContext, elementInfo.getId().toString()))
- .forEach(element -> element.ifPresent(
- candidateInfoElement -> populateCandidate(candidate, candidateInfoElement, false)));
- logger.info("Finished getting orchestration template info for vsp id {}", vspId);
- return candidate.getFileSuffix() == null ? Optional.empty() : Optional.of(candidate);
- }
-
- private void populateCandidate(final OrchestrationTemplateCandidateData candidate,
- final Element candidateInfoElement,
- final boolean fullData) {
- final String elementName = candidateInfoElement.getInfo().getName();
- if (ElementType.OrchestrationTemplateCandidateContent.name().equals(elementName)) {
- if (fullData) {
- candidate.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData())));
- }
- candidate.setFileSuffix(candidateInfoElement.getInfo()
- .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
- candidate.setFileName(candidateInfoElement.getInfo()
- .getProperty(InfoPropertyName.FILE_NAME.getVal()));
- } else if (ElementType.OrchestrationTemplateCandidateValidationData.name().equals(elementName)) {
- candidate.setValidationData(new String(FileUtils.toByteArray(candidateInfoElement.getData())));
- } else if (ElementType.ORIGINAL_ONBOARDED_PACKAGE.name().equals(elementName)) {
- candidate.setOriginalFileName(candidateInfoElement.getInfo()
- .getProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal()));
- candidate.setOriginalFileSuffix(candidateInfoElement.getInfo()
- .getProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal()));
- if (fullData) {
- candidate.setOriginalFileContentData(
- ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData()))
- );
- }
+ @Override
+ public Optional<OrchestrationTemplateCandidateData> get(String vspId, Version version) {
+ logger.info("Getting orchestration template for vsp id {}", vspId);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ Optional<Element> candidateElement = zusammenAdaptor
+ .getElementByName(context, elementContext, null, ElementType.OrchestrationTemplateCandidate.name());
+ if (!candidateElement.isPresent() || VspZusammenUtil.hasEmptyData(candidateElement.get().getData()) || candidateElement.get().getSubElements()
+ .isEmpty()) {
+ logger.info("Orchestration template for vsp id {} does not exist / has empty data", vspId);
+ return Optional.empty();
+ }
+ OrchestrationTemplateCandidateData candidate = new OrchestrationTemplateCandidateData();
+ candidate.setFilesDataStructure(new String(FileUtils.toByteArray(candidateElement.get().getData())));
+ candidateElement.get().getSubElements().stream()
+ .map(element -> zusammenAdaptor.getElement(context, elementContext, element.getElementId().toString()))
+ .forEach(element -> element.ifPresent(candidateInfoElement -> populateCandidate(candidate, candidateInfoElement, true)));
+ logger.info("Finished getting orchestration template for vsp id {}", vspId);
+ return candidate.getFileSuffix() == null ? Optional.empty() : Optional.of(candidate);
}
- }
-
- @Override
- public void delete(String vspId, Version version) {
- ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
-
- ZusammenElement candidateContentElement =
- buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE);
- candidateContentElement.setData(emptyData);
-
- ZusammenElement validationData = buildStructuralElement(ElementType
- .OrchestrationTemplateCandidateValidationData, Action.UPDATE);
- validationData.setData(emptyData);
-
- ZusammenElement candidateElement =
- buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
- candidateElement.setData(emptyData);
- candidateElement.addSubElement(candidateContentElement);
- candidateElement.addSubElement(validationData);
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
- zusammenAdaptor.saveElement(context, elementContext, candidateElement,
- "Delete Orchestration Template Candidate Elements's content");
- }
-
- @Override
- public void update(final String vspId, final Version version,
- final OrchestrationTemplateCandidateData candidateData) {
- logger.info("Uploading candidate data entity for vsp id {}", vspId);
- final ZusammenElement candidateElement =
- buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
- candidateElement
- .setData(new ByteArrayInputStream(candidateData.getFilesDataStructure().getBytes()));
-
- final ZusammenElement candidateContentElement =
- buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE);
- candidateContentElement
- .setData(new ByteArrayInputStream(candidateData.getContentData().array()));
- candidateContentElement.getInfo()
- .addProperty(InfoPropertyName.FILE_SUFFIX.getVal(), candidateData.getFileSuffix());
- candidateContentElement.getInfo()
- .addProperty(InfoPropertyName.FILE_NAME.getVal(), candidateData.getFileName());
-
- if (OnboardingTypesEnum.CSAR.toString().equalsIgnoreCase(candidateData.getFileSuffix())) {
- final ZusammenElement originalPackageElement =
- buildStructuralElement(ElementType.ORIGINAL_ONBOARDED_PACKAGE, Action.UPDATE);
- originalPackageElement.getInfo()
- .addProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal(), candidateData.getOriginalFileName());
- originalPackageElement.getInfo()
- .addProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal(), candidateData.getOriginalFileSuffix());
- originalPackageElement.setData(new ByteArrayInputStream(candidateData.getOriginalFileContentData().array()));
- candidateElement.addSubElement(originalPackageElement);
+ @Override
+ public Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version) {
+ logger.info("Getting orchestration template info for vsp id {}", vspId);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ Optional<ElementInfo> candidateElement = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.OrchestrationTemplateCandidate.name());
+ if (!candidateElement.isPresent() || candidateElement.get().getSubElements().isEmpty()) {
+ logger.info("Orchestration template info for vsp id {} does not exist", vspId);
+ return Optional.empty();
+ }
+ OrchestrationTemplateCandidateData candidate = new OrchestrationTemplateCandidateData();
+ candidateElement.get().getSubElements().stream()
+ .map(elementInfo -> zusammenAdaptor.getElement(context, elementContext, elementInfo.getId().toString()))
+ .forEach(element -> element.ifPresent(candidateInfoElement -> populateCandidate(candidate, candidateInfoElement, false)));
+ logger.info("Finished getting orchestration template info for vsp id {}", vspId);
+ return candidate.getFileSuffix() == null ? Optional.empty() : Optional.of(candidate);
}
- final ZusammenElement validationData = buildStructuralElement(ElementType
- .OrchestrationTemplateCandidateValidationData, Action.UPDATE);
- if (candidateData.getValidationData() != null) {
- validationData
- .setData(new ByteArrayInputStream(candidateData.getValidationData().getBytes()));
- }
- candidateElement.addSubElement(validationData);
- 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);
- }
-
- @Override
- public void updateValidationData(String vspId, Version version,
- ValidationStructureList validationData) {
- logger
- .info("Updating validation data of orchestration template candidate for VSP id {} ", vspId);
-
- ZusammenElement validationDataElement = buildStructuralElement(ElementType
- .OrchestrationTemplateCandidateValidationData, Action.UPDATE);
- validationDataElement.setData(validationData == null ? new ByteArrayInputStream(EMPTY_DATA
- .getBytes()) : new ByteArrayInputStream(JsonUtil.object2Json(validationData).getBytes()));
-
- ZusammenElement candidateElement =
- buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.IGNORE);
- candidateElement.addSubElement(validationDataElement);
-
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
- zusammenAdaptor.saveElement(context, elementContext, candidateElement,
- "Update Orchestration Template Candidate validation data");
- logger
- .info("Finished updating validation data of orchestration template candidate for VSP id {}",
- vspId);
- }
-
- @Override
- public void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure) {
- logger.info("Updating orchestration template for VSP id {}", vspId);
-
- 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);
- }
-
-
- @Override
- public Optional<String> getStructure(String vspId, Version version) {
- logger.info("Getting orchestration template candidate structure for vsp id {}", vspId);
-
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
+ private void populateCandidate(final OrchestrationTemplateCandidateData candidate, final Element candidateInfoElement, final boolean fullData) {
+ final String elementName = candidateInfoElement.getInfo().getName();
+ if (ElementType.OrchestrationTemplateCandidateContent.name().equals(elementName)) {
+ if (fullData) {
+ candidate.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData())));
+ }
+ candidate.setFileSuffix(candidateInfoElement.getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
+ candidate.setFileName(candidateInfoElement.getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ } else if (ElementType.OrchestrationTemplateCandidateValidationData.name().equals(elementName)) {
+ candidate.setValidationData(new String(FileUtils.toByteArray(candidateInfoElement.getData())));
+ } else if (ElementType.ORIGINAL_ONBOARDED_PACKAGE.name().equals(elementName)) {
+ candidate.setOriginalFileName(candidateInfoElement.getInfo().getProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal()));
+ candidate.setOriginalFileSuffix(candidateInfoElement.getInfo().getProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal()));
+ if (fullData) {
+ candidate.setOriginalFileContentData(ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData())));
+ }
+ }
+ }
- Optional<Element> element = zusammenAdaptor.getElementByName(context, elementContext, null,
- ElementType.OrchestrationTemplateCandidate.name());
+ @Override
+ public void delete(String vspId, Version version) {
+ ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
+ ZusammenElement candidateContentElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE);
+ candidateContentElement.setData(emptyData);
+ ZusammenElement validationData = buildStructuralElement(ElementType.OrchestrationTemplateCandidateValidationData, Action.UPDATE);
+ validationData.setData(emptyData);
+ ZusammenElement candidateElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
+ candidateElement.setData(emptyData);
+ candidateElement.addSubElement(candidateContentElement);
+ candidateElement.addSubElement(validationData);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ zusammenAdaptor.saveElement(context, elementContext, candidateElement, "Delete Orchestration Template Candidate Elements's content");
+ }
- if (element.isPresent() && !VspZusammenUtil.hasEmptyData(element.get().getData())) {
- return Optional.of(new String(FileUtils.toByteArray(element.get().getData())));
+ @Override
+ public void update(final String vspId, final Version version, final OrchestrationTemplateCandidateData candidateData) {
+ logger.info("Uploading candidate data entity for vsp id {}", vspId);
+ final ZusammenElement candidateElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
+ candidateElement.setData(new ByteArrayInputStream(candidateData.getFilesDataStructure().getBytes()));
+ final ZusammenElement candidateContentElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE);
+ candidateContentElement.setData(new ByteArrayInputStream(candidateData.getContentData().array()));
+ candidateContentElement.getInfo().addProperty(InfoPropertyName.FILE_SUFFIX.getVal(), candidateData.getFileSuffix());
+ candidateContentElement.getInfo().addProperty(InfoPropertyName.FILE_NAME.getVal(), candidateData.getFileName());
+ if (OnboardingTypesEnum.CSAR.toString().equalsIgnoreCase(candidateData.getFileSuffix())) {
+ final ZusammenElement originalPackageElement = buildStructuralElement(ElementType.ORIGINAL_ONBOARDED_PACKAGE, Action.UPDATE);
+ originalPackageElement.getInfo().addProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal(), candidateData.getOriginalFileName());
+ originalPackageElement.getInfo().addProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal(), candidateData.getOriginalFileSuffix());
+ originalPackageElement.setData(new ByteArrayInputStream(candidateData.getOriginalFileContentData().array()));
+ candidateElement.addSubElement(originalPackageElement);
+ }
+ final ZusammenElement validationData = buildStructuralElement(ElementType.OrchestrationTemplateCandidateValidationData, Action.UPDATE);
+ if (candidateData.getValidationData() != null) {
+ validationData.setData(new ByteArrayInputStream(candidateData.getValidationData().getBytes()));
+ }
+ candidateElement.addSubElement(validationData);
+ 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 getting orchestration template candidate structure for vsp id {}", vspId);
+ @Override
+ public void updateValidationData(String vspId, Version version, ValidationStructureList validationData) {
+ logger.info("Updating validation data of orchestration template candidate for VSP id {} ", vspId);
+ ZusammenElement validationDataElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidateValidationData, Action.UPDATE);
+ validationDataElement.setData(validationData == null ? new ByteArrayInputStream(EMPTY_DATA.getBytes())
+ : new ByteArrayInputStream(JsonUtil.object2Json(validationData).getBytes()));
+ ZusammenElement candidateElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.IGNORE);
+ candidateElement.addSubElement(validationDataElement);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ zusammenAdaptor.saveElement(context, elementContext, candidateElement, "Update Orchestration Template Candidate validation data");
+ logger.info("Finished updating validation data of orchestration template candidate for VSP id {}", vspId);
+ }
- return Optional.empty();
- }
+ @Override
+ public void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure) {
+ logger.info("Updating orchestration template for VSP id {}", vspId);
+ 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);
+ }
- public enum InfoPropertyName {
- FILE_SUFFIX("fileSuffix"),
- FILE_NAME("fileName"),
- ORIGINAL_FILE_NAME("originalFilename"),
- ORIGINAL_FILE_SUFFIX("originalFileSuffix");
+ @Override
+ public Optional<String> getStructure(String vspId, Version version) {
+ logger.info("Getting orchestration template candidate structure for vsp id {}", vspId);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ Optional<Element> element = zusammenAdaptor
+ .getElementByName(context, elementContext, null, ElementType.OrchestrationTemplateCandidate.name());
+ if (element.isPresent() && !VspZusammenUtil.hasEmptyData(element.get().getData())) {
+ return Optional.of(new String(FileUtils.toByteArray(element.get().getData())));
+ }
+ logger.info("Finished getting orchestration template candidate structure for vsp id {}", vspId);
+ return Optional.empty();
+ }
- private final String val;
+ public enum InfoPropertyName {
+ FILE_SUFFIX("fileSuffix"), FILE_NAME("fileName"), ORIGINAL_FILE_NAME("originalFilename"), ORIGINAL_FILE_SUFFIX("originalFileSuffix");
+ private final String val;
- InfoPropertyName(String val) {
- this.val = val;
- }
+ InfoPropertyName(String val) {
+ this.val = val;
+ }
- private String getVal() {
- return val;
+ private String getVal() {
+ return val;
+ }
}
- }
}
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 bc186e7629..dd78a94eb5 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
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
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;
@@ -23,6 +25,10 @@ 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 java.io.ByteArrayInputStream;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.Optional;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.logging.api.Logger;
@@ -31,205 +37,142 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.ByteArrayInputStream;
-import java.nio.ByteBuffer;
-import java.util.Collection;
-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 static final Logger LOGGER = LoggerFactory.getLogger(
- OrchestrationTemplateDaoZusammenImpl.class);
- private ZusammenAdaptor zusammenAdaptor;
-
- public OrchestrationTemplateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning not implemented for OrchestrationTemplateDaoZusammenImpl
- }
-
- @Override
- 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, vspModel.get().getId(),
- ElementType.OrchestrationTemplate.name());
- if (!elementInfo.isPresent()) {
- return null;
- }
-
- Optional<Element> element =
- zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(),
- ElementType.OrchestrationTemplateValidationData.name());
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateDaoZusammenImpl.class);
+ private ZusammenAdaptor zusammenAdaptor;
- OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity();
- if (!element.isPresent()) {
- return orchestrationTemplate;
+ public OrchestrationTemplateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
}
- orchestrationTemplate
- .setFileSuffix(element.get().getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
- orchestrationTemplate
- .setFileName(element.get().getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal()));
- if (!VspZusammenUtil.hasEmptyData(element.get().getData())) {
- orchestrationTemplate
- .setValidationData(new String(FileUtils.toByteArray(element.get().getData())));
- }
- return orchestrationTemplate;
- }
-
- @Override
- public OrchestrationTemplateEntity get(String vspId, Version version) {
- SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
-
- OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity();
- Optional<ElementInfo> vspModel = zusammenAdaptor
- .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
- if (!vspModel.isPresent()) {
- return orchestrationTemplate;
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ // registerVersioning not implemented for OrchestrationTemplateDaoZusammenImpl
}
- Optional<Element> orchestrationTemplateElementOpt = zusammenAdaptor
- .getElementByName(context, elementContext, vspModel.get().getId(),
- ElementType.OrchestrationTemplate.name());
-
- if (! orchestrationTemplateElementOpt.isPresent()) {
- return orchestrationTemplate;
- } else {
- Element orchestrationTemplateElement = orchestrationTemplateElementOpt.get();
-
- if (VspZusammenUtil.hasEmptyData(orchestrationTemplateElement.getData())) {
- return orchestrationTemplate;
- }
-
- orchestrationTemplate.setContentData(
- ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.getData())));
-
- Collection<Element> subElements = orchestrationTemplateElement.getSubElements();
- if (subElements.isEmpty()) {
+ @Override
+ 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, vspModel.get().getId(), ElementType.OrchestrationTemplate.name());
+ if (!elementInfo.isPresent()) {
+ 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.FILE_SUFFIX.getVal()));
+ orchestrationTemplate.setFileName(element.get().getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ if (!VspZusammenUtil.hasEmptyData(element.get().getData())) {
+ orchestrationTemplate.setValidationData(new String(FileUtils.toByteArray(element.get().getData())));
+ }
return orchestrationTemplate;
- }
-
- for (Element element : subElements) {
- Optional<Element> subElementOpt = zusammenAdaptor.getElement(context,
- elementContext, element.getElementId().toString());
-
- subElementOpt.ifPresent(subElement -> {
- if (subElement.getInfo().getName().equals(ElementType
- .OrchestrationTemplateValidationData.name())) {
-
- orchestrationTemplate.setFileSuffix(subElement.getInfo()
- .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
- orchestrationTemplate.setFileName(subElement.getInfo()
- .getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ }
- if (!VspZusammenUtil.hasEmptyData(subElement.getData())) {
- orchestrationTemplate.setValidationData(
- new String(FileUtils.toByteArray(subElement.getData())));
+ @Override
+ public OrchestrationTemplateEntity get(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity();
+ Optional<ElementInfo> vspModel = zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return orchestrationTemplate;
+ }
+ Optional<Element> orchestrationTemplateElementOpt = zusammenAdaptor
+ .getElementByName(context, elementContext, vspModel.get().getId(), ElementType.OrchestrationTemplate.name());
+ if (!orchestrationTemplateElementOpt.isPresent()) {
+ return orchestrationTemplate;
+ } else {
+ Element orchestrationTemplateElement = orchestrationTemplateElementOpt.get();
+ if (VspZusammenUtil.hasEmptyData(orchestrationTemplateElement.getData())) {
+ return orchestrationTemplate;
}
- } else if (subElement.getInfo().getName().equals(ElementType
- .OrchestrationTemplateStructure.name())) {
- orchestrationTemplate.setFilesDataStructure(new String(FileUtils.toByteArray(subElement
- .getData())));
- }
- });
- }
+ orchestrationTemplate.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.getData())));
+ Collection<Element> subElements = orchestrationTemplateElement.getSubElements();
+ if (subElements.isEmpty()) {
+ return orchestrationTemplate;
+ }
+ for (Element element : subElements) {
+ Optional<Element> subElementOpt = zusammenAdaptor.getElement(context, elementContext, element.getElementId().toString());
+ subElementOpt.ifPresent(subElement -> {
+ if (subElement.getInfo().getName().equals(ElementType.OrchestrationTemplateValidationData.name())) {
+ orchestrationTemplate.setFileSuffix(subElement.getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
+ orchestrationTemplate.setFileName(subElement.getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ if (!VspZusammenUtil.hasEmptyData(subElement.getData())) {
+ orchestrationTemplate.setValidationData(new String(FileUtils.toByteArray(subElement.getData())));
+ }
+ } else if (subElement.getInfo().getName().equals(ElementType.OrchestrationTemplateStructure.name())) {
+ orchestrationTemplate.setFilesDataStructure(new String(FileUtils.toByteArray(subElement.getData())));
+ }
+ });
+ }
+ }
+ return orchestrationTemplate;
}
- return orchestrationTemplate;
- }
-
- @Override
- 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.FILE_SUFFIX.getVal(), orchestrationTemplate.getFileSuffix());
- validationData.getInfo()
- .addProperty(InfoPropertyName.FILE_NAME.getVal(), orchestrationTemplate.getFileName());
- ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType
- .OrchestrationTemplateStructure, Action.UPDATE);
- orchestrationTemplateStructure
- .setData(new ByteArrayInputStream(orchestrationTemplate.getFilesDataStructure()
- .getBytes()));
- ZusammenElement orchestrationTemplateElement =
- buildStructuralElement(ElementType.OrchestrationTemplate, Action.UPDATE);
- orchestrationTemplateElement
- .setData(new ByteArrayInputStream(orchestrationTemplate.getContentData().array()));
- orchestrationTemplateElement.addSubElement(validationData);
- orchestrationTemplateElement.addSubElement(orchestrationTemplateStructure);
- ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
- vspModel.addSubElement(orchestrationTemplateElement);
-
- zusammenAdaptor.saveElement(context, elementContext, vspModel, "Update Orchestration Template");
- }
- @Override
- public Optional<String> getOrchestrationTemplateStructure(String vspId, Version version) {
- LOGGER.info("Getting orchestration template structure for VendorSoftwareProduct id" +
- " " + "-> " + vspId);
-
- 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 Optional.empty();
- }
- Optional<Element> orchestrationTemplateElement = zusammenAdaptor.getElementByName(context,
- elementContext, vspModel.get().getId(), ElementType.OrchestrationTemplate.name());
- if (!orchestrationTemplateElement.isPresent()) {
- return Optional.empty();
+ @Override
+ 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.FILE_SUFFIX.getVal(), orchestrationTemplate.getFileSuffix());
+ validationData.getInfo().addProperty(InfoPropertyName.FILE_NAME.getVal(), orchestrationTemplate.getFileName());
+ ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType.OrchestrationTemplateStructure, Action.UPDATE);
+ orchestrationTemplateStructure.setData(new ByteArrayInputStream(orchestrationTemplate.getFilesDataStructure().getBytes()));
+ ZusammenElement orchestrationTemplateElement = buildStructuralElement(ElementType.OrchestrationTemplate, Action.UPDATE);
+ orchestrationTemplateElement.setData(new ByteArrayInputStream(orchestrationTemplate.getContentData().array()));
+ orchestrationTemplateElement.addSubElement(validationData);
+ orchestrationTemplateElement.addSubElement(orchestrationTemplateStructure);
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(orchestrationTemplateElement);
+ zusammenAdaptor.saveElement(context, elementContext, vspModel, "Update Orchestration Template");
}
- Optional<Element> orchestrationTemplateStructureElement = zusammenAdaptor
- .getElementByName(context, elementContext,
- orchestrationTemplateElement.get().getElementId(),
- ElementType.OrchestrationTemplateStructure.name());
- if (orchestrationTemplateStructureElement.isPresent() &&
- !VspZusammenUtil.hasEmptyData(orchestrationTemplateStructureElement.get().getData())) {
- return Optional.of(new String(
- FileUtils.toByteArray(orchestrationTemplateStructureElement.get().getData())));
+ @Override
+ public Optional<String> getOrchestrationTemplateStructure(String vspId, Version version) {
+ LOGGER.info("Getting orchestration template structure for VendorSoftwareProduct id" + " " + "-> " + vspId);
+ 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 Optional.empty();
+ }
+ Optional<Element> orchestrationTemplateElement = zusammenAdaptor
+ .getElementByName(context, elementContext, vspModel.get().getId(), ElementType.OrchestrationTemplate.name());
+ if (!orchestrationTemplateElement.isPresent()) {
+ return Optional.empty();
+ }
+ Optional<Element> orchestrationTemplateStructureElement = zusammenAdaptor
+ .getElementByName(context, elementContext, orchestrationTemplateElement.get().getElementId(),
+ ElementType.OrchestrationTemplateStructure.name());
+ if (orchestrationTemplateStructureElement.isPresent() && !VspZusammenUtil
+ .hasEmptyData(orchestrationTemplateStructureElement.get().getData())) {
+ return Optional.of(new String(FileUtils.toByteArray(orchestrationTemplateStructureElement.get().getData())));
+ }
+ LOGGER.info("Finished getting orchestration template structure for VendorSoftwareProduct " + "id -> " + vspId);
+ return Optional.empty();
}
- LOGGER.info("Finished getting orchestration template structure for VendorSoftwareProduct " +
- "id -> " + vspId);
- return Optional.empty();
- }
+ private enum InfoPropertyName {
+ FILE_SUFFIX("fileSuffix"), FILE_NAME("fileName");
+ private String val;
- private enum InfoPropertyName {
- FILE_SUFFIX("fileSuffix"),
- FILE_NAME("fileName");
-
- private String val;
-
- InfoPropertyName(String val){
- this.val=val;
- }
+ InfoPropertyName(String val) {
+ this.val = val;
+ }
- public String getVal() {
- return val;
+ public String getVal() {
+ return val;
+ }
}
- }
}
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 76e14d8606..28bf1d8ddb 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
@@ -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.
@@ -17,9 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+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;
+
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;
@@ -28,6 +35,12 @@ 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 java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
@@ -36,238 +49,176 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
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.Objects;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import static org.openecomp.core.zusammen.api.ZusammenUtil.*;
-import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.*;
-
/**
* @author Avrahamg.
* @since March 23, 2017
*/
public class ProcessDaoZusammenImpl implements ProcessDao {
- private ZusammenAdaptor zusammenAdaptor;
-
- public ProcessDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- // registerVersioning not implemented for ProcessDaoZusammenImpl
- }
+ private ZusammenAdaptor zusammenAdaptor;
- @Override
- public void create(ProcessEntity processEntity) {
- ZusammenElement processElement = buildProcessElement(processEntity, Action.CREATE);
-
- ZusammenElement processesElement =
- buildStructuralElement(ElementType.Processes, Action.IGNORE);
- ZusammenElement aggregatedElement = VspZusammenUtil.aggregateElements(processesElement,
- processElement);
- ZusammenElement componentElement;
- if (processEntity.getComponentId() != null) {
- componentElement = buildElement(new Id(processEntity.getComponentId()), Action.IGNORE);
- aggregatedElement =
- VspZusammenUtil.aggregateElements(componentElement, aggregatedElement);
+ public ProcessDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
}
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
-
- Element savedElement =
- zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Create process");
- 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 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) {
- ProcessEntity retrieved = getArtifact(processEntity);
- if (retrieved != null && retrieved.getArtifact() != null) {
- processEntity.setArtifactName(retrieved.getArtifactName());
- processEntity.setArtifact(retrieved.getArtifact());
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ // registerVersioning not implemented for ProcessDaoZusammenImpl
}
- update(processEntity, "Update process");
- }
-
- @Override
- public void delete(ProcessEntity processEntity) {
- ZusammenElement processElement = buildElement(new Id(processEntity.getId()), Action.DELETE);
-
- 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()));
- }
-
- @Override
- public void deleteAll(ProcessEntity processEntity) {
- 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());
-
- 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 create(ProcessEntity processEntity) {
+ ZusammenElement processElement = buildProcessElement(processEntity, Action.CREATE);
+ ZusammenElement processesElement = buildStructuralElement(ElementType.Processes, Action.IGNORE);
+ ZusammenElement aggregatedElement = VspZusammenUtil.aggregateElements(processesElement, processElement);
+ ZusammenElement componentElement;
+ if (processEntity.getComponentId() != null) {
+ componentElement = buildElement(new Id(processEntity.getComponentId()), Action.IGNORE);
+ aggregatedElement = VspZusammenUtil.aggregateElements(componentElement, aggregatedElement);
+ }
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
+ Element savedElement = zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Create process");
+ processEntity.setId(processEntity.getComponentId() == null ? savedElement.getSubElements().iterator().next().getElementId().getValue()
+ : savedElement.getSubElements().iterator().next().getSubElements().iterator().next().getElementId().getValue());
}
- }
-
- @Override
- public void deleteVspAll(String vspId, Version version) {
- 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 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 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 update(ProcessEntity processEntity) {
+ ProcessEntity retrieved = getArtifact(processEntity);
+ if (retrieved != null && retrieved.getArtifact() != null) {
+ processEntity.setArtifactName(retrieved.getArtifactName());
+ processEntity.setArtifact(retrieved.getArtifact());
+ }
+ update(processEntity, "Update process");
}
- }
-
- @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 void delete(ProcessEntity processEntity) {
+ ZusammenElement processElement = buildElement(new Id(processEntity.getId()), Action.DELETE);
+ 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()));
}
- }
-
- @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(processEntity), ElementType.Processes.name());
- if (!processesOptional.isPresent()) {
- return new ArrayList<>();
+ @Override
+ public void deleteAll(ProcessEntity processEntity) {
+ 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());
+ 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());
+ });
+ }
}
- ElementToProcessConvertor convertor = new ElementToProcessConvertor();
- return zusammenAdaptor.listElements(context, elementContext, processesOptional.get().getId())
- .stream()
- .map(elementInfo -> convertToProcessEntity(elementInfo, convertor, processEntity))
- .collect(Collectors.toList());
- }
- 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;
- }
+ @Override
+ public void deleteVspAll(String vspId, Version version) {
+ 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());
+ });
+ }
+ }
- private void update(ProcessEntity processEntity, String message) {
- ZusammenElement processElement = buildProcessElement(processEntity, Action.UPDATE);
+ @Override
+ 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);
+ }
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
+ @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");
+ }
+ }
- zusammenAdaptor.saveElement(context, elementContext, processElement, message);
- }
+ @Override
+ public void deleteArtifact(ProcessEntity processEntity) {
+ ProcessEntity retrieved = get(processEntity);
+ if (retrieved != null) {
+ retrieved.setArtifactName(null);
+ retrieved.setArtifact(null);
+ update(retrieved, "Delete process artifact");
+ }
+ }
- private Id extractParentElementId(ProcessEntity processEntity) {
- return processEntity.getComponentId() == null ? null : new Id(processEntity.getComponentId());
- }
+ @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(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 -> convertToProcessEntity(elementInfo, convertor, processEntity)).collect(Collectors.toList());
+ }
- private ZusammenElement buildProcessElement(ProcessEntity process, Action action) {
+ 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;
+ }
- Info info = new Info();
- info.setName(process.getName());
- info.addProperty(NAME, process.getName());
- 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);
+ 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);
+ }
- ZusammenElement processElement = buildElement(new Id(process.getId()), action);
- processElement.setInfo(info);
- if (Objects.nonNull(process.getArtifact())) {
- processElement.setData(new ByteArrayInputStream(process.getArtifact().array()));
+ private Id extractParentElementId(ProcessEntity processEntity) {
+ return processEntity.getComponentId() == null ? null : new Id(processEntity.getComponentId());
}
- return processElement;
- }
+ private ZusammenElement buildProcessElement(ProcessEntity process, Action action) {
+ Info info = new Info();
+ info.setName(process.getName());
+ info.addProperty(NAME, process.getName());
+ 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 = buildElement(new Id(process.getId()), action);
+ processElement.setInfo(info);
+ if (Objects.nonNull(process.getArtifact())) {
+ processElement.setData(new ByteArrayInputStream(process.getArtifact().array()));
+ }
+ return processElement;
+ }
}
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 de42344788..9655434e74 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
@@ -15,11 +15,17 @@
*/
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
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 java.io.ByteArrayInputStream;
+import java.util.Collection;
+import java.util.stream.Collectors;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
@@ -33,256 +39,197 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
import org.openecomp.sdc.versioning.types.VersionableEntityStoreType;
-import java.io.ByteArrayInputStream;
-import java.util.Collection;
-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) {
- this.zusammenAdaptor = zusammenAdaptor;
- }
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- VersionableEntityMetadata metadata =
- new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "VendorSoftwareProduct",
- null, null);
-
- ActionVersioningManagerFactory.getInstance().createInterface()
- .register(versionableEntityType, metadata);
- }
-
- @Override
- public Collection<VspDetails> list(VspDetails entity) {
- return zusammenAdaptor.listItems(createSessionContext()).stream()
- .filter(item -> "VendorSoftwareProduct".equals(item.getInfo().getProperty("item_type")))
- .map(new ElementToVSPGeneralConvertor()::convert)
- .collect(Collectors.toList());
- }
-
- @Override
- public void create(VspDetails vspDetails) {
- ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.CREATE);
-
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
- zusammenAdaptor.saveElement(context, elementContext, generalElement,
- "Create VSP General Info Element");
-
- createVspStructure(context, elementContext);
- }
-
- private void createVspStructure(SessionContext context, ElementContext elementContext) {
- createOrchestrationTemplateCandidateStructure(context, elementContext);
- createVspModelStructure(context, elementContext);
-
- 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");
- }
-
- private void createOrchestrationTemplateCandidateStructure(SessionContext context,
- ElementContext elementContext) {
- ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
- ZusammenElement candidateContentElement =
- buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.CREATE);
- candidateContentElement.setData(emptyData);
- ZusammenElement validationData = buildStructuralElement(ElementType
- .OrchestrationTemplateCandidateValidationData, Action.CREATE);
- ZusammenElement candidateElement =
- buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.CREATE);
- candidateElement.setData(emptyData);
- candidateElement.addSubElement(candidateContentElement);
- candidateElement.addSubElement(validationData);
- zusammenAdaptor.saveElement(context, elementContext, candidateElement,
- "Create Orchestration Template Candidate Elements");
- }
+ private static final String EMPTY_DATA = "{}";
+ private ZusammenAdaptor zusammenAdaptor;
- 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");
- }
-
- private ZusammenElement buildOrchestrationTemplateStructure() {
- ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
-
- ZusammenElement validationData =
- buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.CREATE);
- validationData.setData(emptyData);
-
- ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType
- .OrchestrationTemplateStructure, Action.CREATE);
- validationData.setData(emptyData);
-
- ZusammenElement orchestrationTemplate =
- buildStructuralElement(ElementType.OrchestrationTemplate, Action.CREATE);
- orchestrationTemplate.setData(emptyData);
- orchestrationTemplate.addSubElement(validationData);
- orchestrationTemplate.addSubElement(orchestrationTemplateStructure);
-
- 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;
- }
+ public VendorSoftwareProductInfoDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
- @Override
- public void update(VspDetails vspDetails) {
- ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.UPDATE);
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ VersionableEntityMetadata metadata = new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "VendorSoftwareProduct", null, null);
+ ActionVersioningManagerFactory.getInstance().createInterface().register(versionableEntityType, metadata);
+ }
- SessionContext context = createSessionContext();
- zusammenAdaptor.saveElement(context,
- new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()), generalElement,
- "Update VSP General Info Element");
- }
+ @Override
+ public Collection<VspDetails> list(VspDetails entity) {
+ return zusammenAdaptor.listItems(createSessionContext()).stream()
+ .filter(item -> "VendorSoftwareProduct".equals(item.getInfo().getProperty("item_type"))).map(new ElementToVSPGeneralConvertor()::convert)
+ .collect(Collectors.toList());
+ }
- @Override
- public VspDetails get(VspDetails vspDetails) {
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
- return zusammenAdaptor.getElementInfoByName(context, elementContext, null,
- ElementType.VendorSoftwareProduct.name())
- .map(new ElementToVSPGeneralConvertor()::convert)
- .map(vsp -> {
- vsp.setId(vspDetails.getId());
- vsp.setVersion(vspDetails.getVersion());
- return vsp;
- })
- .orElse(null);
- }
+ @Override
+ public void create(VspDetails vspDetails) {
+ ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.CREATE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
+ zusammenAdaptor.saveElement(context, elementContext, generalElement, "Create VSP General Info Element");
+ createVspStructure(context, elementContext);
+ }
- @Override
- public void delete(VspDetails vspDetails) {
- SessionContext context = createSessionContext();
- ElementContext elementContext =
- new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
+ private void createVspStructure(SessionContext context, ElementContext elementContext) {
+ createOrchestrationTemplateCandidateStructure(context, elementContext);
+ createVspModelStructure(context, elementContext);
+ 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");
+ }
- zusammenAdaptor.saveElement(context, elementContext,
- buildStructuralElement(ElementType.VspModel, Action.DELETE),
- "Delete VSP Model Elements");
+ private void createOrchestrationTemplateCandidateStructure(SessionContext context, ElementContext elementContext) {
+ ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
+ ZusammenElement candidateContentElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.CREATE);
+ candidateContentElement.setData(emptyData);
+ ZusammenElement validationData = buildStructuralElement(ElementType.OrchestrationTemplateCandidateValidationData, Action.CREATE);
+ ZusammenElement candidateElement = buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.CREATE);
+ candidateElement.setData(emptyData);
+ candidateElement.addSubElement(candidateContentElement);
+ candidateElement.addSubElement(validationData);
+ zusammenAdaptor.saveElement(context, elementContext, candidateElement, "Create Orchestration Template Candidate Elements");
+ }
- createVspModelStructure(context, elementContext);
- }
+ 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");
+ }
- @Override
- public void updateQuestionnaireData(String vspId, Version version, String questionnaireData) {
- SessionContext context = createSessionContext();
+ private ZusammenElement buildOrchestrationTemplateStructure() {
+ ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
+ ZusammenElement validationData = buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.CREATE);
+ validationData.setData(emptyData);
+ ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType.OrchestrationTemplateStructure, Action.CREATE);
+ validationData.setData(emptyData);
+ ZusammenElement orchestrationTemplate = buildStructuralElement(ElementType.OrchestrationTemplate, Action.CREATE);
+ orchestrationTemplate.setData(emptyData);
+ orchestrationTemplate.addSubElement(validationData);
+ orchestrationTemplate.addSubElement(orchestrationTemplateStructure);
+ return orchestrationTemplate;
+ }
- ZusammenElement questionnaireElement = mapQuestionnaireToZusammenElement(questionnaireData);
- zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()),
- questionnaireElement, "Update VSP Questionnaire");
- }
+ 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 VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) {
- SessionContext context = createSessionContext();
- VspQuestionnaireEntity entity = new ElementToVSPQuestionnaireConvertor().convert(zusammenAdaptor
- .getElementByName(context, new ElementContext(vspId, version.getId()), null,
- ElementType.VSPQuestionnaire.name())
- .orElse(null));
- entity.setId(vspId);
- entity.setVersion(version);
- return entity;
- }
+ @Override
+ 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 boolean isManual(String vspId, Version version) {
- final VspDetails vspDetails = get(new VspDetails(vspId, version));
- return vspDetails != null &&
- OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod());
- }
+ @Override
+ public VspDetails get(VspDetails vspDetails) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
+ return zusammenAdaptor.getElementInfoByName(context, elementContext, null, ElementType.VendorSoftwareProduct.name())
+ .map(new ElementToVSPGeneralConvertor()::convert).map(vsp -> {
+ vsp.setId(vspDetails.getId());
+ vsp.setVersion(vspDetails.getVersion());
+ return vsp;
+ }).orElse(null);
+ }
- private ZusammenElement mapVspDetailsToZusammenElement(VspDetails vspDetails, Action action) {
- ZusammenElement generalElement =
- buildStructuralElement(ElementType.VendorSoftwareProduct, action);
- addVspDetailsToInfo(generalElement.getInfo(), vspDetails);
- return generalElement;
- }
+ @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);
+ }
- private ZusammenElement mapQuestionnaireToZusammenElement(String questionnaireData) {
- ZusammenElement questionnaireElement =
- buildStructuralElement(ElementType.VSPQuestionnaire, Action.UPDATE);
- questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
- return questionnaireElement;
- }
+ @Override
+ public void updateQuestionnaireData(String vspId, Version version, String questionnaireData) {
+ SessionContext context = createSessionContext();
+ ZusammenElement questionnaireElement = mapQuestionnaireToZusammenElement(questionnaireData);
+ zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), questionnaireElement, "Update VSP Questionnaire");
+ }
- private void addVspDetailsToInfo(Info info, VspDetails vspDetails) {
- info.addProperty(InfoPropertyName.NAME.getValue(), vspDetails.getName());
- info.addProperty(InfoPropertyName.DESCRIPTION.getValue(), vspDetails.getDescription());
- info.addProperty(InfoPropertyName.ICON.getValue(), vspDetails.getIcon());
- info.addProperty(InfoPropertyName.CATEGORY.getValue(), vspDetails.getCategory());
- info.addProperty(InfoPropertyName.SUB_CATEGORY.getValue(), vspDetails.getSubCategory());
- info.addProperty(InfoPropertyName.VENDOR_ID.getValue(), vspDetails.getVendorId());
- info.addProperty(InfoPropertyName.VENDOR_NAME.getValue(), vspDetails.getVendorName());
- if (vspDetails.getVlmVersion() != null) {
- info.addProperty(InfoPropertyName.VENDOR_VERSION.getValue(),
- vspDetails.getVlmVersion().getId());
+ @Override
+ public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ VspQuestionnaireEntity entity = new ElementToVSPQuestionnaireConvertor().convert(
+ zusammenAdaptor.getElementByName(context, new ElementContext(vspId, version.getId()), null, ElementType.VSPQuestionnaire.name())
+ .orElse(null));
+ entity.setId(vspId);
+ entity.setVersion(version);
+ return entity;
}
- info.addProperty(InfoPropertyName.LICENSE_TYPE.getValue(),
- vspDetails.getLicenseType());
- info.addProperty(InfoPropertyName.LICENSE_AGREEMENT.getValue(),
- vspDetails.getLicenseAgreement());
- info.addProperty(InfoPropertyName.FEATURE_GROUPS.getValue(), vspDetails.getFeatureGroups());
- info.addProperty(InfoPropertyName.ON_BOARDING_METHOD.getValue(),
- vspDetails.getOnboardingMethod());
- }
- public enum InfoPropertyName {
- NAME("name"),
- DESCRIPTION("description"),
- ICON("icon"),
- CATEGORY("category"),
- SUB_CATEGORY("subCategory"),
- VENDOR_ID("vendorId"),
- VENDOR_NAME("vendorName"),
- VENDOR_VERSION("vendorVersion"),
- LICENSE_TYPE("licenseType"),
- LICENSE_AGREEMENT("licenseAgreement"),
- FEATURE_GROUPS("featureGroups"),
- ON_BOARDING_METHOD("onboardingMethod");
+ @Override
+ public boolean isManual(String vspId, Version version) {
+ final VspDetails vspDetails = get(new VspDetails(vspId, version));
+ return vspDetails != null && OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod());
+ }
- private String value;
+ private ZusammenElement mapVspDetailsToZusammenElement(VspDetails vspDetails, Action action) {
+ ZusammenElement generalElement = buildStructuralElement(ElementType.VendorSoftwareProduct, action);
+ addVspDetailsToInfo(generalElement.getInfo(), vspDetails);
+ return generalElement;
+ }
- InfoPropertyName(String value) {
- this.value = value;
+ private ZusammenElement mapQuestionnaireToZusammenElement(String questionnaireData) {
+ ZusammenElement questionnaireElement = buildStructuralElement(ElementType.VSPQuestionnaire, Action.UPDATE);
+ questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
+ return questionnaireElement;
}
- public String getValue() {
- return value;
+ private void addVspDetailsToInfo(Info info, VspDetails vspDetails) {
+ info.addProperty(InfoPropertyName.NAME.getValue(), vspDetails.getName());
+ info.addProperty(InfoPropertyName.DESCRIPTION.getValue(), vspDetails.getDescription());
+ info.addProperty(InfoPropertyName.ICON.getValue(), vspDetails.getIcon());
+ info.addProperty(InfoPropertyName.CATEGORY.getValue(), vspDetails.getCategory());
+ info.addProperty(InfoPropertyName.SUB_CATEGORY.getValue(), vspDetails.getSubCategory());
+ info.addProperty(InfoPropertyName.VENDOR_ID.getValue(), vspDetails.getVendorId());
+ info.addProperty(InfoPropertyName.VENDOR_NAME.getValue(), vspDetails.getVendorName());
+ if (vspDetails.getVlmVersion() != null) {
+ info.addProperty(InfoPropertyName.VENDOR_VERSION.getValue(), vspDetails.getVlmVersion().getId());
+ }
+ info.addProperty(InfoPropertyName.LICENSE_TYPE.getValue(), vspDetails.getLicenseType());
+ info.addProperty(InfoPropertyName.LICENSE_AGREEMENT.getValue(), vspDetails.getLicenseAgreement());
+ info.addProperty(InfoPropertyName.FEATURE_GROUPS.getValue(), vspDetails.getFeatureGroups());
+ info.addProperty(InfoPropertyName.ON_BOARDING_METHOD.getValue(), vspDetails.getOnboardingMethod());
}
- }
+ public enum InfoPropertyName {
+ // @formatter:off
+ NAME("name"),
+ DESCRIPTION("description"),
+ ICON("icon"),
+ CATEGORY("category"),
+ SUB_CATEGORY("subCategory"),
+ VENDOR_ID("vendorId"),
+ VENDOR_NAME("vendorName"),
+ VENDOR_VERSION("vendorVersion"),
+ LICENSE_TYPE("licenseType"),
+ LICENSE_AGREEMENT("licenseAgreement"),
+ FEATURE_GROUPS("featureGroups"),
+ ON_BOARDING_METHOD("onboardingMethod");
+ // @formatter:on
+
+ private String value;
+
+ InfoPropertyName(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
}
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 d78e48bff8..c0b1be61bf 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
@@ -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.
@@ -17,49 +17,47 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import org.apache.commons.io.IOUtils;
-
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Objects;
+import org.apache.commons.io.IOUtils;
class VspZusammenUtil {
- private VspZusammenUtil(){}
+ private VspZusammenUtil() {
+ }
- static ZusammenElement aggregateElements(ZusammenElement... elements) {
- ZusammenElement head = null;
- ZusammenElement father = null;
- for (ZusammenElement element : elements) {
- if (Objects.isNull(head)) {
- head = father = element;
- } else {
- if (father != null) {
- father.getSubElements().add(element);
- father = element;
+ static ZusammenElement aggregateElements(ZusammenElement... elements) {
+ ZusammenElement head = null;
+ ZusammenElement father = null;
+ for (ZusammenElement element : elements) {
+ if (Objects.isNull(head)) {
+ head = father = element;
+ } else {
+ if (father != null) {
+ father.getSubElements().add(element);
+ father = element;
+ }
+ }
}
- }
+ return head;
}
- return head;
- }
-
- static boolean hasEmptyData(InputStream elementData) {
- String EMPTY_DATA = "{}";
- byte[] byteElementData;
- try {
- byteElementData = IOUtils.toByteArray(elementData);
- } catch (IOException ex) {
- return false;
- }
- if (Arrays.equals(EMPTY_DATA.getBytes(), byteElementData)) {
- return true;
+ static boolean hasEmptyData(InputStream elementData) {
+ String EMPTY_DATA = "{}";
+ byte[] byteElementData;
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException ex) {
+ return false;
+ }
+ if (Arrays.equals(EMPTY_DATA.getBytes(), byteElementData)) {
+ return true;
+ }
+ return false;
}
- 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/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
index b7a172ed90..d4c7fd05db 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -30,29 +29,24 @@ 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()));
- }
-
+ @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
index 232ff336aa..b00f4e4846 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -27,35 +26,27 @@ 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()));
-
- }
-
+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
index 2a8b3b9c81..044a862e4d 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/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
@@ -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.
@@ -17,49 +17,40 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME;
+
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 java.nio.ByteBuffer;
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()));
- }
-
-
+ @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
index f8ab803280..febafaae2f 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -25,17 +24,16 @@ 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;
- }
+ @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
index ca0d564ce2..b3271f5db4 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/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
@@ -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.
@@ -17,45 +17,44 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
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.*;
-
-public class ElementToCompositionEntityConvertor extends ElementConvertor <CompositionEntity>{
+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;
- @Override
- public CompositionEntity convert(Element element) {
+public class ElementToCompositionEntityConvertor extends ElementConvertor<CompositionEntity> {
- 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();
+ @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;
+ }
}
- 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
index ee10221862..12fba38009 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -28,33 +27,26 @@ 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()));
- }
-
+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
index bc5b556625..c255dcce24 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -25,15 +24,13 @@ 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;
- }
+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
index 19719c6827..c354da1707 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -28,33 +27,26 @@ 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()));
- }
-
+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
index 66621d6934..5aa164c06b 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -28,33 +27,26 @@ 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()));
- }
-
+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
index 4dfe9d297f..32aa3c4041 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -25,15 +24,13 @@ 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;
- }
+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
index 8c4a284fa4..0f2b208808 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/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
@@ -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.
@@ -17,27 +17,24 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
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 static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import java.util.HashMap;
import java.util.Map;
-
-import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME;
+import org.openecomp.convertor.ElementConvertor;
/**
* Created by ayalaben on 9/5/2017.
*/
+public class ElementToMonitoringUploadMapConvertor extends ElementConvertor<Map<String, String>> {
-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;
- }
+ @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
index a34e650e78..0a64ff54c2 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -28,31 +27,26 @@ 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()));
- }
-
+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
index a41eb382b2..e126586420 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -28,32 +27,26 @@ 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()));
- }
-
+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
index ec84ae9f6d..fe397f772d 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -25,17 +24,13 @@ 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;
- }
+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
index de9cc520b3..653c561ca6 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -29,12 +28,10 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStru
/**
* Created by ayalaben on 9/6/2017
*/
-public class ElementToOrchestrationTemplateCandidateMapConvertor
- extends ElementConvertor<FilesDataStructure> {
+public class ElementToOrchestrationTemplateCandidateMapConvertor extends ElementConvertor<FilesDataStructure> {
- @Override
- public FilesDataStructure convert(Element element) {
- return JsonUtil.json2Object(new String(FileUtils.toByteArray(element.getData())),
- FilesDataStructure.class);
- }
+ @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
index ec8aa172bd..d14f870eac 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/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
@@ -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.
@@ -17,55 +17,51 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
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 java.nio.ByteBuffer;
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> {
- 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";
+ 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";
- @Override
- public ProcessEntity convert(Element element) {
- if (element == null) {
- return null;
+ @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;
}
- 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;
+ @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;
}
- 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 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);
+ }
}
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
index 574d3b30f6..e6a151a6c3 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/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
@@ -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.
@@ -17,24 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
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 org.openecomp.convertor.ElementConvertor;
/**
* 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;
- }
+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
index d8bb1798ff..8234eeeaf1 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/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
@@ -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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -29,72 +28,51 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.VendorSoftwareP
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;
+ @Override
+ public VspDetails convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapInfoToVspDetails(element.getInfo());
}
- VspDetails vspDetails = mapInfoToVspDetails(item.getInfo());
- vspDetails.setId(item.getId().getValue());
- return vspDetails;
- }
- @Override
- public VspDetails convert(ElementInfo elementInfo) {
- if (elementInfo == null) {
- return null;
+ @Override
+ public VspDetails convert(Item item) {
+ if (item == null) {
+ return null;
+ }
+ VspDetails vspDetails = mapInfoToVspDetails(item.getInfo());
+ vspDetails.setId(item.getId().getValue());
+ return vspDetails;
}
- return mapInfoToVspDetails(elementInfo.getInfo());
-
- }
-
- private VspDetails mapInfoToVspDetails(Info info) {
-
- VspDetails vspDetails = new VspDetails();
-
- vspDetails.setName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl
- .InfoPropertyName.NAME.getValue()));
- vspDetails.setDescription(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.DESCRIPTION.getValue()));
- vspDetails.setIcon(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ICON.getValue()));
- vspDetails.setCategory(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.CATEGORY.getValue()));
- vspDetails.setSubCategory(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.SUB_CATEGORY.getValue()));
- vspDetails.setVendorId(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_ID.getValue()));
- vspDetails.setVendorName(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_NAME.getValue()));
- if (info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue()) != null) {
- vspDetails.setVlmVersion(new Version(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue())));
+ @Override
+ public VspDetails convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapInfoToVspDetails(elementInfo.getInfo());
}
- vspDetails.setLicenseType(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_TYPE.getValue()));
- vspDetails.setLicenseAgreement(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_AGREEMENT.getValue()));
- vspDetails.setFeatureGroups(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.FEATURE_GROUPS.getValue()));
- vspDetails.setOnboardingMethod(info.getProperty(
- VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ON_BOARDING_METHOD.getValue()));
-
- return vspDetails;
- }
-
-
+ private VspDetails mapInfoToVspDetails(Info info) {
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.NAME.getValue()));
+ vspDetails.setDescription(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.DESCRIPTION.getValue()));
+ vspDetails.setIcon(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ICON.getValue()));
+ vspDetails.setCategory(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.CATEGORY.getValue()));
+ vspDetails.setSubCategory(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.SUB_CATEGORY.getValue()));
+ vspDetails.setVendorId(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_ID.getValue()));
+ vspDetails.setVendorName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_NAME.getValue()));
+ if (info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue()) != null) {
+ vspDetails
+ .setVlmVersion(new Version(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue())));
+ }
+ vspDetails.setLicenseType(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_TYPE.getValue()));
+ vspDetails.setLicenseAgreement(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_AGREEMENT.getValue()));
+ vspDetails.setFeatureGroups(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.FEATURE_GROUPS.getValue()));
+ vspDetails.setOnboardingMethod(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ON_BOARDING_METHOD.getValue()));
+ 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
index b8797cf8e2..71a2b4782d 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/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
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -23,11 +22,10 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
public class ElementToVSPQuestionnaireConvertor extends ElementConvertor {
- @Override
- public VspQuestionnaireEntity convert(Element element) {
- VspQuestionnaireEntity entity = new VspQuestionnaireEntity();
- entity.setQuestionnaireData(
- element == null ? "{}" : new String(FileUtils.toByteArray(element.getData())));
- return entity;
- }
+ @Override
+ public VspQuestionnaireEntity convert(Element element) {
+ VspQuestionnaireEntity entity = new VspQuestionnaireEntity();
+ entity.setQuestionnaireData(element == null ? "{}" : new String(FileUtils.toByteArray(element.getData())));
+ return entity;
+ }
}