diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib')
161 files changed, 10395 insertions, 1340 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/pom.xml index 4862094291..01f7635d41 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/pom.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -12,26 +12,21 @@ <artifactId>openecomp-sdc-vendor-software-product-api</artifactId> + <dependencies> <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>2.3.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-core-lib</artifactId> <type>pom</type> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-facade-core</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-nosqldb-core</artifactId> <version>${project.version}</version> </dependency> @@ -55,9 +50,17 @@ <artifactId>openecomp-sdc-model-core</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>${freemarker.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-config-lib</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> - - -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/pom.xml.versionsBackup new file mode 100644 index 0000000000..67f6a45c0d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/pom.xml.versionsBackup @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>openecomp-sdc-vendor-software-product-api</artifactId> + <version>1.0-SNAPSHOT</version> + + + <dependencies> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-core-lib</artifactId> + <type>pom</type> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-facade-core</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-nosqldb-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-versioning-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-translator-core</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-enrichment-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-model-core</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>2.3.25-incubating</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-config-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + + +</project>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java index 860ef5fd41..8b2470a525 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java @@ -26,6 +26,10 @@ public final class VendorSoftwareProductConstants { public static final String VSP_PACKAGE_ZIP = "VSPPackage.zip"; public static final String CSAR = "CSAR"; public static final String UPLOAD_RAW_DATA = "UPLOAD_RAW_DATA"; + public static final String INFORMATION_ARTIFACT_NAME = "VSP_%s_Information.txt"; + public static final String UNSUPPORTED_OPERATION_ERROR = + "An error has occurred: Unsupported operation for 1707 release."; + public final class UniqueValues { public static final String VENDOR_SOFTWARE_PRODUCT_NAME = "Vendor Software Product name"; @@ -33,6 +37,8 @@ public final class VendorSoftwareProductConstants { public static final String NETWORK_NAME = "Network name"; public static final String COMPONENT_NAME = "ComponentData name"; public static final String NIC_NAME = "NIC name"; + public static final String ORCHESTRATION_CANDIDATE_NAME = "Orchestration Candidate name"; //public static final String COMPONENT_ARTIFACT_NAME = "ComponentArtifact name"; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDao.java index ca795b4929..ef3f2f131d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDao.java @@ -29,10 +29,14 @@ import java.util.Collection; public interface ComponentDao extends VersionableDao, BaseDao<ComponentEntity> { + ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId); + void updateQuestionnaireData(String vspId, Version version, String componentId, String questionnaireData); Collection<ComponentEntity> listQuestionnaires(String vspId, Version version); + Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId, Version version); + void deleteAll(String vspId, Version version); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java new file mode 100644 index 0000000000..1be4a5cda5 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java @@ -0,0 +1,13 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao; + +import org.openecomp.core.dao.BaseDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; + +public interface ComponentDependencyModelDao extends VersionableDao, + BaseDao<ComponentDependencyModelEntity> { + + public void deleteAll(String vspId, Version version); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDaoFactory.java new file mode 100644 index 0000000000..bd6f2859ad --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDaoFactory.java @@ -0,0 +1,13 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao; + + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class ComponentDependencyModelDaoFactory extends + AbstractComponentFactory<ComponentDependencyModelDao> { + + public static ComponentDependencyModelDaoFactory getInstance() { + return AbstractFactory.getInstance(ComponentDependencyModelDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentArtifactDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/MibDao.java index d43c9687c2..cf980a52ff 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentArtifactDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/MibDao.java @@ -20,21 +20,22 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentArtifactEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; import java.util.Collection; +import java.util.Optional; -public interface ComponentArtifactDao extends VersionableDao { - ComponentArtifactEntity getArtifactByType(ComponentArtifactEntity entity); +public interface MibDao extends VersionableDao { - void update(ComponentArtifactEntity entity); + Optional<MibEntity> getByType(MibEntity entity); - void delete(ComponentArtifactEntity entity); + void create(MibEntity entity); - Collection<ComponentArtifactEntity> getArtifactNamesAndTypesForComponent( - ComponentArtifactEntity entity); + void delete(MibEntity entity); - void deleteAll(ComponentArtifactEntity entity); + Collection<MibEntity> list(MibEntity entity); + + void deleteAll(MibEntity entity); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessArtifactDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/MibDaoFactory.java index 534777c701..52c610caa6 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessArtifactDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/MibDaoFactory.java @@ -23,10 +23,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -public abstract class ProcessArtifactDaoFactory - extends AbstractComponentFactory<ProcessArtifactDao> { +public abstract class MibDaoFactory + extends AbstractComponentFactory<MibDao> { - public static ProcessArtifactDaoFactory getInstance() { - return AbstractFactory.getInstance(ProcessArtifactDaoFactory.class); + public static MibDaoFactory getInstance() { + return AbstractFactory.getInstance(MibDaoFactory.class); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDao.java index 199e65fd83..348b777fe6 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NetworkDao.java @@ -21,13 +21,24 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.dao.BaseDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; +import java.util.Collection; + public interface NetworkDao extends VersionableDao, BaseDao<NetworkEntity> { - void updateQuestionnaireData(String vspId, Version version, String id, String questionnaireData); + void deleteAll(String vspId, Version version); + + + + + + + + } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDao.java index bbfa8bf8c0..3205fcdb1f 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/NicDao.java @@ -29,6 +29,9 @@ import java.util.Collection; public interface NicDao extends VersionableDao, BaseDao<NicEntity> { + NicEntity getQuestionnaireData(String vspId, Version version, String componentId, + String nicId); + void updateQuestionnaireData(String vspId, Version version, String componentId, String nicId, String questionnaireData); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java new file mode 100644 index 0000000000..fceac0ac98 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.dao; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Optional; + +public interface OrchestrationTemplateCandidateDao extends VersionableDao { + + OrchestrationTemplateCandidateData get(String vspId, Version version); + + void update(String vspId, OrchestrationTemplateCandidateData candidateData); + + void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure); + + Optional<String> getStructure(String vspId, Version version); +} + diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessArtifactDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDaoFactory.java index 2a5d9013bd..5624da018a 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/ProcessArtifactDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDaoFactory.java @@ -18,16 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +package org.openecomp.sdc.vendorsoftwareproduct.dao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessArtifactDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessArtifactDaoFactory; +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; -public class ProcessArtifactDaoFactoryImpl extends ProcessArtifactDaoFactory { - private static final ProcessArtifactDao INSTANCE = new ProcessArtifactDaoCassandraImpl(); +public abstract class OrchestrationTemplateCandidateDaoFactory + extends AbstractComponentFactory<OrchestrationTemplateCandidateDao> { - @Override - public ProcessArtifactDao createInterface() { - return INSTANCE; + public static OrchestrationTemplateCandidateDaoFactory getInstance() { + return AbstractFactory.getInstance(OrchestrationTemplateCandidateDaoFactory.class); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java new file mode 100644 index 0000000000..a8c2eb8f7b --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.dao; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity; +import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; + +public interface OrchestrationTemplateDao extends VersionableDao { + + String getValidationData(String vspId, Version version); + + UploadDataEntity getOrchestrationTemplate(String vspId, Version version); + + void updateOrchestrationTemplateData(String vspId, UploadData uploadData); +} + diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentArtifactDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDaoFactory.java index 56a0ec65af..be3c849a20 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentArtifactDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDaoFactory.java @@ -23,10 +23,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -public abstract class ComponentArtifactDaoFactory - extends AbstractComponentFactory<ComponentArtifactDao> { +public abstract class OrchestrationTemplateDaoFactory + extends AbstractComponentFactory<OrchestrationTemplateDao> { - public static ComponentArtifactDaoFactory getInstance() { - return AbstractFactory.getInstance(ComponentArtifactDaoFactory.class); + public static OrchestrationTemplateDaoFactory getInstance() { + return AbstractFactory.getInstance(OrchestrationTemplateDaoFactory.class); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java index a22c725b6f..d12069f480 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java @@ -24,10 +24,15 @@ import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; import org.openecomp.sdc.versioning.dao.types.Version; +import java.nio.ByteBuffer; import java.util.List; public interface PackageInfoDao extends BaseDao<PackageInfo> { List<PackageInfo> listByCategory(String category, String subCategory); - void deleteRowTranslateContent(String vspId, Version version); + public void deleteRowTranslateContent(String vspId, Version version); + + void updateTranslatedContent(String vspId, Version version, ByteBuffer translateContent); + + } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java index 8aa3400d24..c6622ef8e5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java @@ -1,30 +1,17 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; +/** + * @author Avrahamg. + * @since March 23, 2017 + */ public interface ProcessDao extends VersionableDao, BaseDao<ProcessEntity> { - void deleteAll(ProcessEntity entity); + + + void deleteVspAll(String vspId, Version version); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java index d8de3c6bd4..85262db208 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java @@ -20,76 +20,26 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessArtifactEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; -import java.nio.ByteBuffer; import java.util.Collection; import java.util.List; -public interface VendorSoftwareProductDao extends VersionableDao { - - void createVendorSoftwareProductInfo(VspDetails vspDetails); - - Collection<VspDetails> listVendorSoftwareProductsInfo(); - - VspDetails getVendorSoftwareProductInfo(VspDetails vspDetails); - - void updateVendorSoftwareProductInfo(VspDetails vspDetails); - - void deleteVendorSoftwareProductInfo(VspDetails vspDetails); - - - void updateUploadData(UploadDataEntity uploadData); - - UploadDataEntity getUploadData(UploadDataEntity uploadData); - - ByteBuffer getContentData(UploadDataEntity uploadDataEntity); - - - List<PackageInfo> listPackages(String category, String subCategory); - - void insertPackageDetails(PackageInfo packageInfo); - - PackageInfo getPackageInfo(PackageInfo packageInfo); - - void deletePackageInfo(PackageInfo packageInfo); - - - Collection<NetworkEntity> listNetworks(String vspId, Version version); - - void createNetwork(NetworkEntity network); - void updateNetwork(NetworkEntity network); - - NetworkEntity getNetwork(String vspId, Version version, String networkId); - - void deleteNetwork(String vspId, Version version); +public interface VendorSoftwareProductDao extends VersionableDao { Collection<ComponentEntity> listComponents(String vspId, Version version); - void createComponent(ComponentEntity component); - - void updateComponent(ComponentEntity component); - - ComponentEntity getComponent(String vspId, Version version, String componentId); - Collection<ComponentEntity> listComponentsQuestionnaire(String vspId, Version version); - void updateComponentQuestionnaire(String vspId, Version version, String componentId, - String questionnaireData); - - void deleteComponent(String vspId, Version version); + Collection<ComponentEntity> listComponentsCompositionAndQuestionnaire(String vspId, + Version version); Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId); @@ -108,33 +58,23 @@ public interface VendorSoftwareProductDao extends VersionableDao { void uploadProcessArtifact(String vspId, Version version, String componentId, String processId, byte[] artifact, String artifactFileName); - ProcessArtifactEntity getProcessArtifact(String vspId, Version version, String componentId, - String processId); + ProcessEntity getProcessArtifact(String vspId, Version version, String componentId, + String processId); void deleteProcessArtifact(String vspId, Version version, String componentId, String processId); - VspQuestionnaireEntity getQuestionnaire(String vspId, Version version); - - void updateQuestionnaire(String vspId, Version version, String questionnaireData); - - - Collection<NicEntity> listNics(String vspId, Version version, String componentId); - - void createNic(NicEntity nic); - - void updateNic(NicEntity nicEntity); - - NicEntity getNic(String vspId, Version version, String componentId, String nicId); - - void updateNicQuestionnaire(String vspId, Version version, String componentId, String nicId, - String questionnaireData); - Collection<NicEntity> listNicsByVsp(String vspId, Version version); - void deleteNic(String vspId, Version version, String componentId); void deleteUploadData(String vspId, Version version); - void updateVspLatestModificationTime(String vspId, Version version); + //void updateVspLatestModificationTime(String vspId, Version version); + void createComponentDependencyModel( + List<ComponentDependencyModelEntity> componentDependencyModelEntity, String vspId, + Version version); + + Collection<ComponentDependencyModelEntity> listComponentDependencies(String vspId,Version + version); + } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java index 33aaa8e1ad..32070fe06a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java @@ -23,8 +23,9 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; -public abstract class VendorSoftwareProductDaoFactory - extends AbstractComponentFactory<VendorSoftwareProductDao> { + +public abstract class VendorSoftwareProductDaoFactory extends + AbstractComponentFactory<VendorSoftwareProductDao> { public static VendorSoftwareProductDaoFactory getInstance() { diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java index 74a3f69e6c..ffb0d5eca7 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java @@ -22,9 +22,19 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao; import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; public interface VendorSoftwareProductInfoDao extends VersionableDao, BaseDao<VspDetails> { -// void updateLastModificationTime(VspDetails entity); + void updateOldVersionIndication(VspDetails vspDetails); + + void updateQuestionnaireData(String vspId, Version version, String questionnaireData); + + String getQuestionnaireData(String vspId, Version version); + + VspQuestionnaireEntity getQuestionnaire(String vspId, Version version); + + void deleteAll(String vspId, Version version); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/Action.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/Action.java index 3e82053574..be78e78f5a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/Action.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/Action.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.type; + public enum Action { CREATE_PACKAGE, CHECK_IN, diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentDependencyModelEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentDependencyModelEntity.java new file mode 100644 index 0000000000..28a84e0a4f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentDependencyModelEntity.java @@ -0,0 +1,155 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.type; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionableEntity; + +@Table(keyspace = "dox", name = "vsp_component_dependency_model") +public class ComponentDependencyModelEntity implements VersionableEntity { + + public static final String ENTITY_TYPE = "Vendor Software Product Component Dependency Model"; + @PartitionKey + @Column(name = "vsp_id") + private String vspId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "dependency_id") + private String id; + @Column(name = "sourcecomponent_id") + private String sourceComponentId; + @Column(name = "targetcomponent_id") + private String targetComponentId; + @Column(name = "relation") + private String relation; + + public ComponentDependencyModelEntity() { + + } + + /** + * Instantiates a new ComponentDependencyModelEntity entity. + * + * @param vspId the vsp id + * @param version the version + * @param dependencyId the dependencyId + */ + public ComponentDependencyModelEntity(String vspId, Version version, String dependencyId) { + this.vspId = vspId; + this.version = version; + this.id = dependencyId; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getVspId(); + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public String getVspId() { + return vspId; + } + + public void setVspId(String vspId) { + this.vspId = vspId; + } + + public String getTargetComponentId() { + return targetComponentId; + } + + public void setTargetComponentId(String targetComponentId) { + this.targetComponentId = targetComponentId; + } + + public String getSourceComponentId() { + return sourceComponentId; + } + + public void setSourceComponentId(String sourceComponentId) { + this.sourceComponentId = sourceComponentId; + } + + public String getRelation() { + return relation; + } + + public void setRelation(String relation) { + this.relation = relation; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + ComponentDependencyModelEntity that = (ComponentDependencyModelEntity) o; + + if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) { + return false; + } + if (version != null ? !version.equals(that.version) : that.version != null) { + return false; + } + if (id != null ? !id.equals(that.id) : that.id != null) { + return false; + } + if (sourceComponentId != null ? !sourceComponentId.equals(that.sourceComponentId) + : that.sourceComponentId != null) { + return false; + } + if (targetComponentId != null ? !targetComponentId.equals(that.targetComponentId) + : that.targetComponentId != null) { + return false; + } + if (relation != null ? !relation.equals(that.relation) : that.relation != null) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = vspId != null ? vspId.hashCode() : 0; + result = 31 * result + (version != null ? version.hashCode() : 0); + result = 31 * result + (id != null ? id.hashCode() : 0); + result = 31 * result + (sourceComponentId != null ? sourceComponentId.hashCode() : 0); + result = 31 * result + (targetComponentId != null ? targetComponentId.hashCode() : 0); + result = 31 * result + (relation != null ? relation.hashCode() : 0); + return result; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentEntity.java index a74ba04ec4..602fd6d15c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentEntity.java @@ -38,7 +38,7 @@ import java.util.List; @Table(keyspace = "dox", name = "vsp_component") public class ComponentEntity implements CompositionEntity { - private static final String ENTITY_TYPE = "Vendor Software Product ComponentData"; + private static final String ENTITY_TYPE = "Vendor Software Product Component"; @PartitionKey @Column(name = "vsp_id") @@ -83,22 +83,32 @@ public class ComponentEntity implements CompositionEntity { return new CompositionEntityId(getId(), new CompositionEntityId(getVspId(), null)); } - public String getVspId() { - return vspId; + @Override + public String getCompositionData() { + return compositionData; } - public void setVspId(String vspId) { - this.vspId = vspId; + @Override + public void setCompositionData(String compositionData) { + this.compositionData = compositionData; } @Override - public Version getVersion() { - return version; + public String getQuestionnaireData() { + return questionnaireData; } @Override - public void setVersion(Version version) { - this.version = version; + public void setQuestionnaireData(String questionnaireData) { + this.questionnaireData = questionnaireData; + } + + public String getVspId() { + return vspId; + } + + public void setVspId(String vspId) { + this.vspId = vspId; } @Override @@ -122,13 +132,13 @@ public class ComponentEntity implements CompositionEntity { } @Override - public String getCompositionData() { - return compositionData; + public Version getVersion() { + return version; } @Override - public void setCompositionData(String compositionData) { - this.compositionData = compositionData; + public void setVersion(Version version) { + this.version = version; } public ComponentData getComponentCompositionData() { @@ -140,16 +150,6 @@ public class ComponentEntity implements CompositionEntity { this.compositionData = component == null ? null : JsonUtil.object2Json(component); } - @Override - public String getQuestionnaireData() { - return questionnaireData; - } - - @Override - public void setQuestionnaireData(String questionnaireData) { - this.questionnaireData = questionnaireData; - } - public List<NicEntity> getNics() { return nics; } @@ -159,15 +159,25 @@ public class ComponentEntity implements CompositionEntity { } @Override - public boolean equals(Object obj) { - if (this == obj) { + public int hashCode() { + int result = vspId != null ? vspId.hashCode() : 0; + result = 31 * result + (version != null ? version.hashCode() : 0); + result = 31 * result + (id != null ? id.hashCode() : 0); + result = 31 * result + (compositionData != null ? compositionData.hashCode() : 0); + result = 31 * result + (questionnaireData != null ? questionnaireData.hashCode() : 0); + return result; + } + + @Override + public boolean equals(Object object) { + if (this == object) { return true; } - if (obj == null || getClass() != obj.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - ComponentEntity that = (ComponentEntity) obj; + ComponentEntity that = (ComponentEntity) object; if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) { return false; @@ -186,14 +196,4 @@ public class ComponentEntity implements CompositionEntity { : that.questionnaireData == null; } - - @Override - public int hashCode() { - int result = vspId != null ? vspId.hashCode() : 0; - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (compositionData != null ? compositionData.hashCode() : 0); - result = 31 * result + (questionnaireData != null ? questionnaireData.hashCode() : 0); - return result; - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentArtifactEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/MibEntity.java index 3636a591d4..f057c1745a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ComponentArtifactEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/MibEntity.java @@ -25,14 +25,15 @@ import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.Frozen; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; -import org.openecomp.core.enrichment.types.ComponentArtifactType; +import org.openecomp.core.enrichment.types.ArtifactType; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionableEntity; +import java.io.Serializable; import java.nio.ByteBuffer; @Table(keyspace = "dox", name = "vsp_component_artifact") -public class ComponentArtifactEntity implements VersionableEntity { +public class MibEntity implements VersionableEntity, Serializable { public static final String ENTITY_TYPE = "Vendor Software Product Component Artifact"; @PartitionKey @Column(name = "vsp_id") @@ -45,7 +46,7 @@ public class ComponentArtifactEntity implements VersionableEntity { private String componentId; @ClusteringColumn(value = 1) @Column(name = "artifact_type") - private ComponentArtifactType type; + private ArtifactType type; @ClusteringColumn(value = 2) @Column(name = "artifact_id") private String id; @@ -53,7 +54,7 @@ public class ComponentArtifactEntity implements VersionableEntity { private String artifactName; private ByteBuffer artifact; - public ComponentArtifactEntity() { + public MibEntity() { } @@ -65,7 +66,7 @@ public class ComponentArtifactEntity implements VersionableEntity { * @param componentId the component id * @param id the id */ - public ComponentArtifactEntity(String vspId, Version version, String componentId, String id) { + public MibEntity(String vspId, Version version, String componentId, String id) { this.vspId = vspId; this.version = version; this.componentId = componentId; @@ -80,14 +81,6 @@ public class ComponentArtifactEntity implements VersionableEntity { this.vspId = vspId; } - public Version getVersion() { - return version; - } - - public void setVersion(Version version) { - this.version = version; - } - public String getComponentId() { return componentId; } @@ -114,6 +107,14 @@ public class ComponentArtifactEntity implements VersionableEntity { this.id = id; } + public Version getVersion() { + return version; + } + + public void setVersion(Version version) { + this.version = version; + } + public String getArtifactName() { return artifactName; } @@ -130,11 +131,23 @@ public class ComponentArtifactEntity implements VersionableEntity { this.artifact = artifact; } - public ComponentArtifactType getType() { + public ArtifactType getType() { return type; } - public void setType(ComponentArtifactType type) { + public void setType(ArtifactType type) { this.type = type; } + + @Override + public String toString() { + return "MibEntity{" + + "vspId='" + vspId + '\'' + + ", version=" + version + + ", componentId='" + componentId + '\'' + + ", type=" + type + + ", id='" + id + '\'' + + ", artifactName='" + artifactName + '\'' + + '}'; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NetworkEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NetworkEntity.java index 1599e4a88c..4b848a06b3 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NetworkEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NetworkEntity.java @@ -31,6 +31,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEnti import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; import org.openecomp.sdc.versioning.dao.types.Version; + @Table(keyspace = "dox", name = "vsp_network") public class NetworkEntity implements CompositionEntity { private static final String ENTITY_TYPE = "Vendor Software Product Network"; @@ -76,22 +77,32 @@ public class NetworkEntity implements CompositionEntity { return new CompositionEntityId(getId(), new CompositionEntityId(getVspId(), null)); } - public String getVspId() { - return vspId; + @Override + public String getCompositionData() { + return compositionData; } - public void setVspId(String vspId) { - this.vspId = vspId; + @Override + public void setCompositionData(String compositionData) { + this.compositionData = compositionData; } @Override - public Version getVersion() { - return version; + public String getQuestionnaireData() { + return questionnaireData; } @Override - public void setVersion(Version version) { - this.version = version; + public void setQuestionnaireData(String questionnaireData) { + this.questionnaireData = questionnaireData; + } + + public String getVspId() { + return vspId; + } + + public void setVspId(String vspId) { + this.vspId = vspId; } @Override @@ -115,13 +126,13 @@ public class NetworkEntity implements CompositionEntity { } @Override - public String getCompositionData() { - return compositionData; + public Version getVersion() { + return version; } @Override - public void setCompositionData(String compositionData) { - this.compositionData = compositionData; + public void setVersion(Version version) { + this.version = version; } public Network getNetworkCompositionData() { @@ -133,25 +144,25 @@ public class NetworkEntity implements CompositionEntity { } @Override - public String getQuestionnaireData() { - return questionnaireData; - } - - @Override - public void setQuestionnaireData(String questionnaireData) { - this.questionnaireData = questionnaireData; + public int hashCode() { + int result = vspId != null ? vspId.hashCode() : 0; + result = 31 * result + (version != null ? version.hashCode() : 0); + result = 31 * result + (id != null ? id.hashCode() : 0); + result = 31 * result + (compositionData != null ? compositionData.hashCode() : 0); + result = 31 * result + (questionnaireData != null ? questionnaireData.hashCode() : 0); + return result; } @Override - public boolean equals(Object obj) { - if (this == obj) { + public boolean equals(Object object) { + if (this == object) { return true; } - if (obj == null || getClass() != obj.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - NetworkEntity that = (NetworkEntity) obj; + NetworkEntity that = (NetworkEntity) object; if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) { return false; @@ -170,14 +181,4 @@ public class NetworkEntity implements CompositionEntity { : that.questionnaireData == null; } - - @Override - public int hashCode() { - int result = vspId != null ? vspId.hashCode() : 0; - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (compositionData != null ? compositionData.hashCode() : 0); - result = 31 * result + (questionnaireData != null ? questionnaireData.hashCode() : 0); - return result; - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NicEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NicEntity.java index 33042a128a..656693c14d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NicEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/NicEntity.java @@ -34,7 +34,7 @@ import org.openecomp.sdc.versioning.dao.types.Version; @Table(keyspace = "dox", name = "vsp_component_nic") public class NicEntity implements CompositionEntity { - private static final String ENTITY_TYPE = "Vendor Software Product ComponentData NIC"; + private static final String ENTITY_TYPE = "Vendor Software Product NIC"; @PartitionKey @Column(name = "vsp_id") @@ -83,22 +83,32 @@ public class NicEntity implements CompositionEntity { new CompositionEntityId(getComponentId(), new CompositionEntityId(getVspId(), null))); } - public String getVspId() { - return vspId; + @Override + public String getCompositionData() { + return compositionData; } - public void setVspId(String vspId) { - this.vspId = vspId; + @Override + public void setCompositionData(String compositionData) { + this.compositionData = compositionData; } @Override - public Version getVersion() { - return version; + public String getQuestionnaireData() { + return questionnaireData; } @Override - public void setVersion(Version version) { - this.version = version; + public void setQuestionnaireData(String questionnaireData) { + this.questionnaireData = questionnaireData; + } + + public String getVspId() { + return vspId; + } + + public void setVspId(String vspId) { + this.vspId = vspId; } @Override @@ -111,14 +121,6 @@ public class NicEntity implements CompositionEntity { return getVspId(); } - public String getComponentId() { - return componentId; - } - - public void setComponentId(String componentId) { - this.componentId = componentId; - } - @Override public String getId() { return id; @@ -130,13 +132,21 @@ public class NicEntity implements CompositionEntity { } @Override - public String getCompositionData() { - return compositionData; + public Version getVersion() { + return version; } @Override - public void setCompositionData(String compositionData) { - this.compositionData = compositionData; + public void setVersion(Version version) { + this.version = version; + } + + public String getComponentId() { + return componentId; + } + + public void setComponentId(String componentId) { + this.componentId = componentId; } public Nic getNicCompositionData() { @@ -148,25 +158,26 @@ public class NicEntity implements CompositionEntity { } @Override - public String getQuestionnaireData() { - return questionnaireData; - } - - @Override - public void setQuestionnaireData(String questionnaireData) { - this.questionnaireData = questionnaireData; + public int hashCode() { + int result = vspId != null ? vspId.hashCode() : 0; + result = 31 * result + (version != null ? version.hashCode() : 0); + result = 31 * result + (componentId != null ? componentId.hashCode() : 0); + result = 31 * result + (id != null ? id.hashCode() : 0); + result = 31 * result + (compositionData != null ? compositionData.hashCode() : 0); + result = 31 * result + (questionnaireData != null ? questionnaireData.hashCode() : 0); + return result; } @Override - public boolean equals(Object obj) { - if (this == obj) { + public boolean equals(Object object) { + if (this == object) { return true; } - if (obj == null || getClass() != obj.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - NicEntity nicEntity = (NicEntity) obj; + NicEntity nicEntity = (NicEntity) object; if (vspId != null ? !vspId.equals(nicEntity.vspId) : nicEntity.vspId != null) { return false; @@ -189,15 +200,4 @@ public class NicEntity implements CompositionEntity { : nicEntity.questionnaireData == null; } - - @Override - public int hashCode() { - int result = vspId != null ? vspId.hashCode() : 0; - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (componentId != null ? componentId.hashCode() : 0); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (compositionData != null ? compositionData.hashCode() : 0); - result = 31 * result + (questionnaireData != null ? questionnaireData.hashCode() : 0); - return result; - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java new file mode 100644 index 0000000000..de70434d2f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java @@ -0,0 +1,34 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.type; + +import java.nio.ByteBuffer; + +public class OrchestrationTemplateCandidateData { + private ByteBuffer contentData; + private String filesDataStructure; + + + public OrchestrationTemplateCandidateData() { + } + + public OrchestrationTemplateCandidateData(ByteBuffer contentData, + String dataStructureJson) { + this.contentData = contentData; + this.filesDataStructure = dataStructureJson; + } + + public ByteBuffer getContentData() { + return contentData; + } + + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; + } + + public String getFilesDataStructure() { + return filesDataStructure; + } + + public void setFilesDataStructure(String filesDataStructure) { + this.filesDataStructure = filesDataStructure; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessArtifactEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateDataEntity.java index 89e6de1e87..c451a72056 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessArtifactEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateDataEntity.java @@ -20,7 +20,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.Frozen; import com.datastax.driver.mapping.annotations.PartitionKey; @@ -30,66 +29,55 @@ import org.openecomp.sdc.versioning.dao.types.VersionableEntity; import java.nio.ByteBuffer; -@Table(keyspace = "dox", name = "vsp_process") -public class ProcessArtifactEntity implements VersionableEntity { - public static final String ENTITY_TYPE = "Vendor Software Product Process artifact"; +@Table(keyspace = "dox", name = "vsp_orchestration_template_candidate") +public class OrchestrationTemplateCandidateDataEntity implements VersionableEntity { + private static final String ENTITY_TYPE = + "Vendor Software Product Upload Orchestration_candidate data"; + @PartitionKey @Column(name = "vsp_id") - private String vspId; + private String id; + @PartitionKey(value = 1) @Frozen private Version version; - @ClusteringColumn - @Column(name = "component_id") - private String componentId; - @ClusteringColumn(value = 1) - @Column(name = "process_id") - private String id; - @Column(name = "artifact_name") - private String artifactName; - private ByteBuffer artifact; - public ProcessArtifactEntity() { + @Column(name = "content_data") + private ByteBuffer contentData; + + @Column(name = "files_data_structure") + private String filesDataStructure; + public OrchestrationTemplateCandidateDataEntity() { } /** - * Instantiates a new Process artifact entity. + * Instantiates a new OrchestrationTemplateCandidateDataEntity. * - * @param vspId the vsp id - * @param version the version - * @param componentId the component id - * @param id the id + * @param id the id + * @param version the Version + */ - public ProcessArtifactEntity(String vspId, Version version, String componentId, String id) { - this.vspId = vspId; - this.version = version; - this.componentId = componentId; + public OrchestrationTemplateCandidateDataEntity(String id, Version version) { this.id = id; - } - - public String getVspId() { - return vspId; - } - - public void setVspId(String vspId) { - this.vspId = vspId; - } - - public Version getVersion() { - return version; - } - - public void setVersion(Version version) { this.version = version; } - public String getComponentId() { - return componentId; - } - - public void setComponentId(String componentId) { - this.componentId = componentId; + /** + * Instantiates a new OrchestrationTemplateCandidateDataEntity. + * + * @param filesDataStructure the files data Structure + * @param version the version + * @param contentData the contentData + * @param id the id + */ + public OrchestrationTemplateCandidateDataEntity(String id, Version version, + ByteBuffer contentData, + String filesDataStructure) { + this.id = id; + this.contentData = contentData; + this.filesDataStructure = filesDataStructure; + this.version = version; } @Override @@ -99,7 +87,7 @@ public class ProcessArtifactEntity implements VersionableEntity { @Override public String getFirstClassCitizenId() { - return getVspId(); + return null; } public String getId() { @@ -110,19 +98,29 @@ public class ProcessArtifactEntity implements VersionableEntity { this.id = id; } - public String getArtifactName() { - return artifactName; + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public ByteBuffer getContentData() { + return contentData; } - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; } - public ByteBuffer getArtifact() { - return artifact; + public String getFilesDataStructure() { + return filesDataStructure; } - public void setArtifact(ByteBuffer artifact) { - this.artifact = artifact; + public void setFilesDataStructure(String filesDataStructure) { + this.filesDataStructure = filesDataStructure; } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java index 03f26cb57d..ad02883b2e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java @@ -20,7 +20,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.type; - import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.Frozen; import com.datastax.driver.mapping.annotations.PartitionKey; @@ -29,6 +28,7 @@ import org.openecomp.sdc.versioning.dao.types.Version; import java.nio.ByteBuffer; + @Table(keyspace = "dox", name = "package_details") public class PackageInfo { diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessEntity.java index d407540194..eacc3c4bae 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessEntity.java @@ -22,12 +22,15 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.type; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Enumerated; import com.datastax.driver.mapping.annotations.Frozen; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionableEntity; +import java.nio.ByteBuffer; + @Table(keyspace = "dox", name = "vsp_process") public class ProcessEntity implements VersionableEntity { public static final String ENTITY_TYPE = "Vendor Software Product Process"; @@ -45,8 +48,12 @@ public class ProcessEntity implements VersionableEntity { private String id; private String name; private String description; + @Column(name = "type") + @Enumerated + private ProcessType type; @Column(name = "artifact_name") private String artifactName; + private ByteBuffer artifact; public ProcessEntity() { @@ -75,14 +82,6 @@ public class ProcessEntity implements VersionableEntity { this.vspId = vspId; } - public Version getVersion() { - return version; - } - - public void setVersion(Version version) { - this.version = version; - } - public String getComponentId() { return componentId; } @@ -109,8 +108,16 @@ public class ProcessEntity implements VersionableEntity { this.id = id; } + public Version getVersion() { + return version; + } + + public void setVersion(Version version) { + this.version = version; + } + public String getName() { - return name; + return name == null ? "" : name; } public void setName(String name) { @@ -125,6 +132,14 @@ public class ProcessEntity implements VersionableEntity { this.description = description; } + public ProcessType getType() { + return type; + } + + public void setType(ProcessType type) { + this.type = type; + } + public String getArtifactName() { return artifactName; } @@ -133,16 +148,24 @@ public class ProcessEntity implements VersionableEntity { this.artifactName = artifactName; } + public ByteBuffer getArtifact() { + return artifact; + } + + public void setArtifact(ByteBuffer artifact) { + this.artifact = artifact; + } + @Override - public boolean equals(Object obj) { - if (this == obj) { + public boolean equals(Object other) { + if (this == other) { return true; } - if (obj == null || getClass() != obj.getClass()) { + if (other == null || getClass() != other.getClass()) { return false; } - ProcessEntity that = (ProcessEntity) obj; + ProcessEntity that = (ProcessEntity) other; if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) { return false; @@ -159,10 +182,22 @@ public class ProcessEntity implements VersionableEntity { if (name != null ? !name.equals(that.name) : that.name != null) { return false; } - return description != null ? description.equals(that.description) : that.description == null - && - (artifactName != null ? artifactName.equals(that.artifactName) : that.artifactName == null); + if (description != null ? !description.equals(that.description) : that.description != null) { + return false; + } + if (artifactName != null ? !artifactName.equals(that.artifactName) + : that.artifactName != null) { + return false; + } + if (artifact != null ? !artifact.equals(that.artifact) : that.artifact != null) { + return false; + } + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + + return true; } @Override @@ -173,7 +208,23 @@ public class ProcessEntity implements VersionableEntity { result = 31 * result + (id != null ? id.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); result = 31 * result + (artifactName != null ? artifactName.hashCode() : 0); + result = 31 * result + (artifact != null ? artifact.hashCode() : 0); return result; } + + @Override + public String toString() { + return "ProcessEntity{" + + "vspId='" + vspId + '\'' + + ", version=" + version + + ", componentId='" + componentId + '\'' + + ", id='" + id + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", type=" + type + + ", artifactName='" + artifactName + '\'' + + '}'; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessType.java new file mode 100644 index 0000000000..d49386c3bf --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/ProcessType.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.openecomp.sdc.vendorsoftwareproduct.dao.type; + +public enum ProcessType { + Lifecycle_Operations, + Other +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/TranslatedFileData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/TranslatedFileData.java index c6f197a4cf..506d7e51aa 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/TranslatedFileData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/TranslatedFileData.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.type; + public class TranslatedFileData { private String displayName; diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java new file mode 100644 index 0000000000..071af919a4 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.dao.type; + +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; + +import java.nio.ByteBuffer; + + +public class UploadData { + + private String id; + + private String packageName; + + private String packageVersion; + + private String validationData; + + private ByteBuffer contentData; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public String getPackageVersion() { + return packageVersion; + } + + public void setPackageVersion(String packageVersion) { + this.packageVersion = packageVersion; + } + + public String getValidationData() { + return validationData; + } + + public void setValidationData(String validationData) { + this.validationData = validationData; + } + + public ValidationStructureList getValidationDataStructure() { + return validationData == null ? null + : JsonUtil.json2Object(validationData, ValidationStructureList.class); + } + + public void setValidationDataStructure(ValidationStructureList validationData) { + this.validationData = validationData == null ? null + : JsonUtil.object2Json(validationData); + } + + public ByteBuffer getContentData() { + return contentData; + } + + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java index a70b2cd6c8..2ade95b025 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java @@ -20,10 +20,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.Column; -import com.datastax.driver.mapping.annotations.Frozen; -import com.datastax.driver.mapping.annotations.PartitionKey; -import com.datastax.driver.mapping.annotations.Table; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; import org.openecomp.sdc.versioning.dao.types.Version; @@ -31,28 +27,19 @@ import org.openecomp.sdc.versioning.dao.types.VersionableEntity; import java.nio.ByteBuffer; -@Table(keyspace = "dox", name = "vsp_information") public class UploadDataEntity implements VersionableEntity { private static final String ENTITY_TYPE = "Vendor Software Product Upload data"; - @PartitionKey - @Column(name = "vsp_id") private String id; - @PartitionKey(value = 1) - @Frozen private Version version; - @Column(name = "package_name") private String packageName; - @Column(name = "package_version") private String packageVersion; - @Column(name = "validation_data") private String validationData; - @Column(name = "content_data") private ByteBuffer contentData; public UploadDataEntity() { diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java index 3423ba36b3..0019bce477 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java @@ -20,11 +20,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.Column; -import com.datastax.driver.mapping.annotations.Computed; -import com.datastax.driver.mapping.annotations.Frozen; -import com.datastax.driver.mapping.annotations.PartitionKey; -import com.datastax.driver.mapping.annotations.Table; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; import org.openecomp.sdc.versioning.dao.types.Version; @@ -32,16 +27,12 @@ import org.openecomp.sdc.versioning.dao.types.VersionableEntity; import java.util.List; -@Table(keyspace = "dox", name = "vsp_information") + public class VspDetails implements VersionableEntity { public static final String ENTITY_TYPE = "Vendor Software Product"; - @PartitionKey - @Column(name = "vsp_id") private String id; - @PartitionKey(value = 1) - @Frozen private Version version; private String name; @@ -49,37 +40,24 @@ public class VspDetails implements VersionableEntity { private String category; - @Column(name = "sub_category") private String subCategory; private String icon; - @Column(name = "vendor_name") private String vendorName; - @Column(name = "vendor_id") private String vendorId; - @Column(name = "vlm_version") - @Frozen private Version vlmVersion; - @Column(name = "license_agreement") private String licenseAgreement; - @Column(name = "feature_groups") private List<String> featureGroups; - @Column(name = "package_name") - private String packageName; - - @Column(name = "package_version") - private String packageVersion; - - @Column(name = "validation_data") private String validationData; - @Computed("writetime(name)") + private String oldVersion; + private Long writetimeMicroSeconds; public VspDetails() { @@ -198,22 +176,6 @@ public class VspDetails implements VersionableEntity { this.featureGroups = featureGroups; } - public String getPackageName() { - return packageName; - } - - public void setPackageName(String packageName) { - this.packageName = packageName; - } - - public String getPackageVersion() { - return packageVersion; - } - - public void setPackageVersion(String packageVersion) { - this.packageVersion = packageVersion; - } - public String getValidationData() { return validationData; } @@ -239,4 +201,23 @@ public class VspDetails implements VersionableEntity { public void setWritetimeMicroSeconds(Long writetimeMicroSeconds) { this.writetimeMicroSeconds = writetimeMicroSeconds; } + + /*public boolean isOldVersion() { + return this.oldVersion; + }*/ + + public String getOldVersion(){ + return this.oldVersion; + } + + public void setOldVersion(String oldVersion) { + this.oldVersion = oldVersion; + } + + @Override + public String toString() { + return String.format( + "Vsp id = '%s', Version = %s', Name = %s', Category = %s', Description = %s', Vendor = %s'", + this.id, this.version, this.name, this.category, this.description, this.vendorName); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspQuestionnaireEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspQuestionnaireEntity.java index 42fbecfe01..da41ab28ba 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspQuestionnaireEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspQuestionnaireEntity.java @@ -20,25 +20,17 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.type; -import com.datastax.driver.mapping.annotations.Column; -import com.datastax.driver.mapping.annotations.Frozen; -import com.datastax.driver.mapping.annotations.PartitionKey; -import com.datastax.driver.mapping.annotations.Table; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; import org.openecomp.sdc.versioning.dao.types.Version; -@Table(keyspace = "dox", name = "vsp_information") + + public class VspQuestionnaireEntity implements CompositionEntity { private static final String ENTITY_TYPE = "Vendor Software Product"; - @PartitionKey - @Column(name = "vsp_id") private String id; - @PartitionKey(value = 1) - @Frozen private Version version; - @Column(name = "questionnaire_data") private String questionnaireData; public VspQuestionnaireEntity() { @@ -51,6 +43,16 @@ public class VspQuestionnaireEntity implements CompositionEntity { } @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getId(); + } + + @Override public String getId() { return id; } @@ -71,16 +73,6 @@ public class VspQuestionnaireEntity implements CompositionEntity { } @Override - public String getEntityType() { - return ENTITY_TYPE; - } - - @Override - public String getFirstClassCitizenId() { - return getId(); - } - - @Override public CompositionEntityType getType() { return CompositionEntityType.vsp; } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/utils/ErrorsUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/utils/ErrorsUtil.java new file mode 100644 index 0000000000..fc23a77bef --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/utils/ErrorsUtil.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.errors.utils; + +import org.openecomp.sdc.datatypes.error.ErrorMessage; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Created by Talio on 11/30/2016. + */ +public class ErrorsUtil { + + public static void addStructureErrorToErrorMap(String fileName, ErrorMessage errorMessage, Map<String, List<ErrorMessage>> errors) { + List<ErrorMessage> errorList = errors.get(fileName); + if (errorList == null) { + errorList = new ArrayList<>(); + errors.put(fileName, errorList); + } + errorList.add(errorMessage); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CandidateServiceFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CandidateServiceFactory.java new file mode 100644 index 0000000000..f16d8d4ebe --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CandidateServiceFactory.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; + +/** + * Created by Talio on 12/15/2016. + */ +public abstract class CandidateServiceFactory extends AbstractComponentFactory<CandidateService> { + + public static CandidateServiceFactory getInstance(){ + return AbstractFactory.getInstance(CandidateServiceFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionDataExtractorFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionDataExtractorFactory.java new file mode 100644 index 0000000000..d10b8b715d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionDataExtractorFactory.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; +import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor; + +public abstract class CompositionDataExtractorFactory extends + AbstractComponentFactory<CompositionDataExtractor> { + + public static CompositionDataExtractorFactory getInstance() { + return AbstractFactory.getInstance(CompositionDataExtractorFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionEntityDataManagerFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionEntityDataManagerFactory.java new file mode 100644 index 0000000000..bcb6174dce --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/CompositionEntityDataManagerFactory.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; +import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager; + +public abstract class CompositionEntityDataManagerFactory extends + AbstractComponentFactory<CompositionEntityDataManager> { + + public static CompositionEntityDataManagerFactory getInstance() { + return AbstractFactory.getInstance(CompositionEntityDataManagerFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactory.java new file mode 100644 index 0000000000..7e6e7db5dc --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactory.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator; + + +public abstract class InformationArtifactGeneratorFactory extends AbstractComponentFactory<InformationArtifactGenerator> { + + public static InformationArtifactGeneratorFactory getInstance() { + return AbstractFactory.getInstance(InformationArtifactGeneratorFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/ManifestCreatorFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/ManifestCreatorFactory.java new file mode 100644 index 0000000000..9189ffce6d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/ManifestCreatorFactory.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.ManifestCreator; + +/** + * Created by Talio on 12/15/2016. + */ +public abstract class ManifestCreatorFactory extends AbstractComponentFactory<ManifestCreator>{ + + public static ManifestCreatorFactory getInstance(){ + return AbstractFactory.getInstance(ManifestCreatorFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnnaireDataServiceFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnnaireDataServiceFactory.java new file mode 100644 index 0000000000..a1b9430e41 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnnaireDataServiceFactory.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator; +import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService; + + +public abstract class QuestionnnaireDataServiceFactory extends AbstractComponentFactory<QuestionnaireDataService> { + + public static QuestionnnaireDataServiceFactory getInstance() { + return AbstractFactory.getInstance(QuestionnnaireDataServiceFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactData.java new file mode 100644 index 0000000000..2bf11b03d6 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactData.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact; + + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ComponentQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.NicQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.VspQuestionnaire; + +import java.util.List; + +/** + * Created by TALIO on 11/22/2016 + */ +public class InformationArtifactData { + private VspDetails vspDetails; + private VspQuestionnaire vspQuestionnaire; + private List<ComponentQuestionnaire> componentQuestionnaires; + private List<NicQuestionnaire> nicQuestionnaires; + + + public InformationArtifactData(VspDetails vspDetails, VspQuestionnaire vspQuestionnaire, List<ComponentQuestionnaire> componentQuestionnaires, List<NicQuestionnaire> nicQuestionnaires) { + this.vspDetails = vspDetails; + this.vspQuestionnaire = vspQuestionnaire; + this.componentQuestionnaires = componentQuestionnaires; + this.nicQuestionnaires = nicQuestionnaires; + } + + public InformationArtifactData() { + + } + + public VspQuestionnaire getVspQuestionnaire() { + return vspQuestionnaire; + } + + public void setVspQuestionnaire(VspQuestionnaire vspQuestionnaire) { + this.vspQuestionnaire = vspQuestionnaire; + } + + public List<ComponentQuestionnaire> getComponentQuestionnaires() { + return componentQuestionnaires; + } + + public void setComponentQuestionnaires(List<ComponentQuestionnaire> componentQuestionnaires) { + this.componentQuestionnaires = componentQuestionnaires; + } + + public List<NicQuestionnaire> getNicQuestionnaires() { + return nicQuestionnaires; + } + + public void setNicQuestionnaires(List<NicQuestionnaire> nicQuestionnaires) { + this.nicQuestionnaires = nicQuestionnaires; + } + + public VspDetails getVspDetails() { + return vspDetails; + } + + public void setVspDetails(VspDetails vspDetails) { + this.vspDetails = 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/UploadDataDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactGenerator.java index 317bc344c4..11d8e7b501 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/UploadDataDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/InformationArtifactGenerator.java @@ -18,16 +18,18 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact; -import org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDaoFactory; +import org.openecomp.sdc.versioning.dao.types.Version; -public class UploadDataDaoFactoryImpl extends UploadDataDaoFactory { - private static final UploadDataDao INSTANCE = new UploadDataDaoImpl(); +import java.io.IOException; +import java.nio.ByteBuffer; - @Override - public UploadDataDao createInterface() { - return INSTANCE; - } +/** + * @author katyr + * @since November 29, 2016 + */ + +public interface InformationArtifactGenerator { + String generate(String vspId, Version version) throws IOException; } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/questionnaire/QuestionnaireDataService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/questionnaire/QuestionnaireDataService.java new file mode 100644 index 0000000000..0bf10c09e8 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/questionnaire/QuestionnaireDataService.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.questionnaire; + +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData; +import org.openecomp.sdc.versioning.dao.types.Version; + +/** + * @author katyr + * @since November 29, 2016 + */ + +public interface QuestionnaireDataService { + InformationArtifactData generateQuestionnaireDataForInformationArtifact(String vspId, Version version); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java new file mode 100644 index 0000000000..533f041621 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services; + +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; + +import java.io.IOException; +import java.util.Map; + +/** + * @author Avrahamg + * @since December 21, 2016 + */ +public interface HeatFileAnalyzer { + + static boolean isEnvFile(String fileName) { + return fileName.endsWith(".env"); + } + + static boolean isYamlFile(String fileName) { + return fileName.endsWith(".yml") || fileName.endsWith(".yaml"); + } + + static boolean isYamlOrEnvFile(String fileName) { + return isYamlFile(fileName) || isEnvFile(fileName); + } + + AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files) throws IOException; +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java new file mode 100644 index 0000000000..0b82638277 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.composition; + +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData; + +public interface CompositionDataExtractor { + + CompositionData extractServiceCompositionData(ToscaServiceModel toscaServiceModel); + + String getComponentDisplayName(String componentName); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java new file mode 100644 index 0000000000..5bde801188 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.composition; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +public interface CompositionEntityDataManager { + + Map<CompositionEntityId, Collection<String>> validateEntitiesQuestionnaire(); + + void addEntity(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput); + + CompositionEntityValidationData validateEntity(CompositionEntity entity, + SchemaTemplateContext schemaTemplateContext, + SchemaTemplateInput schemaTemplateInput); + + void buildTrees(); + + void addErrorsToTrees(Map<CompositionEntityId, Collection<String>> errors); + + Set<CompositionEntityValidationData> getEntityListWithErrors(); + + Collection<CompositionEntityValidationData> getTrees(); + + void saveCompositionData(String vspId, Version version, CompositionData compositionData); + + Set<CompositionEntityValidationData> getAllErrorsByVsp(String vspId); + + void saveComponents(String vspId, Version version, CompositionData compositionData, + Map<String, String> networkIdByName); + + void saveNicsByComponent(String vspId, Version version, + Map<String, String> networkIdByName, Component component, + String componentId); + + Map<String, String> saveNetworks(String vspId, Version version, + CompositionData compositionData); + + NetworkEntity createNetwork(NetworkEntity network); + + ComponentEntity createComponent(ComponentEntity component); + + NicEntity createNic(NicEntity nic); + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java new file mode 100644 index 0000000000..4ca623e6a3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule; + +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public interface CandidateService { + Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload); + + Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData); + + OrchestrationTemplateCandidateData createCandidateDataEntity( + CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest, AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception; + + void updateCandidateUploadData(OrchestrationTemplateCandidateData uploadData, String + itemId); + + Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId, + Version activeVersion); + + void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version activeVersion, + FilesDataStructure fileDataStructure); + + OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId, + Version activeVersion); + + Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId, + OrchestrationTemplateCandidateData candidateDataEntity, + String manifest, Map<String, List<ErrorMessage>> uploadErrors); + + byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId) + throws IOException; + + Optional<ManifestContent> createManifest(VspDetails vspDetails, + FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles); + + String createManifest(VspDetails vspDetails, FilesDataStructure structure); + + Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java new file mode 100644 index 0000000000..fd70d20c22 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule; + +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; + +import java.util.Optional; + +public interface ManifestCreator { + Optional<ManifestContent> createManifest(VspDetails vspDetails, FilesDataStructure filesDataStructure); + + Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler + fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles); + + boolean isFileBaseFile(String fileName); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java new file mode 100644 index 0000000000..d26942219f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.impl; + +import org.openecomp.sdc.vendorsoftwareproduct.services.HeatFileAnalyzer; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.*; +import java.util.regex.Pattern; + +public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer { + private static final String HEAT_IDENTIFIER_REGEX = "^heat_template_version:.*"; + private static final String HEAT_RESOURCES_REGEX = "^resources:\\s*$"; + private static final String HEAT_PARAMETERS_REGEX = "^parameters:\\s*$"; + private static final String HEAT_CONDITIONS_REGEX = "^conditions:\\s*$"; + private static final String HEAT_OUTPUTS_REGEX = "^outputs:\\s*$"; + private static final String HEAT_PARAMETER_GROUP_REGEX = "^parameter_groups:\\s*$"; + private static final String HEAT_DESCRIPTION_REGEX = "^description:\\s*$"; + //allowing spaces at start followed by 'type:' + spaces + any characters + ('.yml' or '.yaml')+ + // spaces + private static final String HEAT_NESTED_RESOURCE_REGEX = "\\s*type:\\s*\\S*.(yml|yaml)\\s*$"; + + + private static final String IDENTIFIER = "IDENTIFIER"; + private static final String RESOURCES = "RESOURCES"; + private static final String PARAMETERS = "PARAMETERS"; + private static final String CONDITIONS = "CONDITIONS"; + private static final String OUTPUTS = "OUTPUTS"; + private static final String PARAMETER_GROUP = "PARAMETER_GROUP"; + private static final String DESCRIPTION = "DESCRIPTION"; + private static final String NESTED_PATTERN = "NESTED_PATTERN"; + + private Map<String, Pattern> patterns; + + public HeatFileAnalyzerRowDataImpl() { + patterns = new HashMap<>(); + patterns.put(IDENTIFIER, Pattern.compile(HEAT_IDENTIFIER_REGEX)); + patterns.put(RESOURCES, Pattern.compile(HEAT_RESOURCES_REGEX)); + patterns.put(PARAMETERS, Pattern.compile(HEAT_PARAMETERS_REGEX)); + patterns.put(CONDITIONS, Pattern.compile(HEAT_CONDITIONS_REGEX)); + patterns.put(OUTPUTS, Pattern.compile(HEAT_OUTPUTS_REGEX)); + patterns.put(PARAMETER_GROUP, Pattern.compile(HEAT_PARAMETER_GROUP_REGEX)); + patterns.put(DESCRIPTION, Pattern.compile(HEAT_DESCRIPTION_REGEX)); + patterns.put(NESTED_PATTERN, Pattern.compile(HEAT_NESTED_RESOURCE_REGEX)); + } + + @Override + public AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files) + throws IOException { + AnalyzedZipHeatFiles analyzedZipHeatFiles = new AnalyzedZipHeatFiles(); + + BufferedReader bfReader; + for (Map.Entry<String, byte[]> fileData : files.entrySet()) { + String fileName = fileData.getKey(); + if (!HeatFileAnalyzer.isYamlFile(fileName)) { + analyzedZipHeatFiles.addOtherNonModuleFile(fileName); + continue; + } + boolean foundHeatIdentifier = false; + try (InputStream is = new ByteArrayInputStream(fileData.getValue())) { + bfReader = new BufferedReader(new InputStreamReader(is)); + String line; + boolean isResourcesSection = false; + Set<String> nestedFilesNames = new HashSet<>(); + while ((line = bfReader.readLine()) != null) { + if (!foundHeatIdentifier && isMatch(patterns.get(IDENTIFIER), line)) { + foundHeatIdentifier = true; + analyzedZipHeatFiles.addModuleFile(fileName); + if (isResourcesSection) // it means the identifier is located after the resources + // section + { + break; + } + } else if (isMatch(patterns.get(RESOURCES), line)) { + isResourcesSection = true; + } else if (isResourceSectionEnd(line, isResourcesSection)) { + if (foundHeatIdentifier) { + break; + } + } else if (isResourcesSection) { + Optional<String> optionalNestedFileName = fetchNestedFileName(line); + optionalNestedFileName + .ifPresent(nestedFilesNames::add); + } + } + analyzedZipHeatFiles.addNestedFiles(fetchFileNamesToReturn(nestedFilesNames, + foundHeatIdentifier)); + } + } + return analyzedZipHeatFiles; + } + + private Optional<String> fetchNestedFileName(String line) { + if (isMatch(patterns.get(NESTED_PATTERN), line)) { + String trimmedLine = line.trim(); + String nestedFileName = trimmedLine + .substring(trimmedLine.indexOf("type:") + "type:".length(), trimmedLine.length()) + .trim(); + return Optional.of(nestedFileName); + } + return Optional.empty(); + } + + private Set<String> fetchFileNamesToReturn(Set<String> filesNamesToReturn, + boolean foundHeatIdentifier) { + if (!foundHeatIdentifier) { + return new HashSet<>(); + } else { + return filesNamesToReturn; + } + } + + private boolean isResourceSectionEnd(String line, boolean isResourcesSection) { + return isResourcesSection && isStartOfNonResourcesHeatSection(line); + } + + private boolean isStartOfNonResourcesHeatSection(String line) { + return isMatch(patterns.get(PARAMETERS), line) || + isMatch(patterns.get(CONDITIONS), line) || + isMatch(patterns.get(OUTPUTS), line) || + isMatch(patterns.get(PARAMETER_GROUP), line) || + isMatch(patterns.get(DESCRIPTION), line); + } + + private boolean isMatch(Pattern pattern, String line) { + return pattern.matcher(line).matches(); + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java new file mode 100644 index 0000000000..6b1837fa10 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator; + +import freemarker.template.Template; +import freemarker.template.TemplateException; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +public class SchemaGenerator { + public static final String SCHEMA_GENERATION_ERROR = "SCHEMA_GENERATION_ERROR"; + + /** + * Generate string. + * + * @param schemaTemplateContext the schema template context + * @param entityType the entity type + * @param input the input + * @return the string + */ + public static String generate(SchemaTemplateContext schemaTemplateContext, + CompositionEntityType entityType, SchemaTemplateInput input) { + Template schemaTemplate = + SchemaGeneratorConfig.getSchemaTemplate(schemaTemplateContext, entityType); + return processTemplate(input, schemaTemplate); + } + + private static String processTemplate(SchemaTemplateInput input, Template schemaTemplate) { + try (Writer writer = new StringWriter(1024)) { + schemaTemplate.process(input, writer); + return writer.toString(); + } catch (IOException | TemplateException exception) { + throw new CoreException( + new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION) + .withId(SCHEMA_GENERATION_ERROR).withMessage(exception.getMessage()).build()); + } + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java new file mode 100644 index 0000000000..3937ca2f2e --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java @@ -0,0 +1,154 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator; + +import freemarker.cache.StringTemplateLoader; +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateExceptionHandler; +import org.openecomp.core.utilities.applicationconfig.ApplicationConfig; +import org.openecomp.core.utilities.applicationconfig.ApplicationConfigFactory; +import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class SchemaGeneratorConfig { + public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR = + "SCHEMA_GENERATOR_INITIALIZATION_ERROR"; + public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG = + "Error occurred while loading questionnaire schema schemaTemplates"; + private static final String CONFIGURATION_NAMESPACE = "vsp.schemaTemplates"; + private static Map<SchemaTemplateId, SchemaTemplate> schemaTemplates = new HashMap<>(); + private static ApplicationConfig applicationConfig = + ApplicationConfigFactory.getInstance().createInterface(); + + private static Configuration configuration = new Configuration(Configuration.VERSION_2_3_23); + private static StringTemplateLoader stringLoader = new StringTemplateLoader(); + + static { + configuration.setClassLoaderForTemplateLoading(SchemaGenerator.class.getClassLoader(), + File.pathSeparator); + configuration.setDefaultEncoding("UTF-8"); + configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); + configuration.setLogTemplateExceptions(true); + configuration.setTemplateLoader(stringLoader); + } + + public static void insertSchemaTemplate(SchemaTemplateContext schemaTemplateContext, + CompositionEntityType entityType, + String schemaTemplateString) { + applicationConfig.insertValue(CONFIGURATION_NAMESPACE, + new SchemaTemplateId(schemaTemplateContext, entityType).toString(), schemaTemplateString); + } + + /** + * Gets schema template. + * + * @param schemaTemplateContext the schema template context + * @param entityType the entity type + * @return the schema template + */ + public static Template getSchemaTemplate(SchemaTemplateContext schemaTemplateContext, + CompositionEntityType entityType) { + SchemaTemplateId id = new SchemaTemplateId(schemaTemplateContext, entityType); + ConfigurationData configurationData = + applicationConfig.getConfigurationData(CONFIGURATION_NAMESPACE, id.toString()); + + SchemaTemplate schemaTemplate = schemaTemplates.get(id); + if (schemaTemplate == null || schemaTemplate.timestamp != configurationData.getTimeStamp()) { + stringLoader.putTemplate(id.toString(), configurationData.getValue()); + Template template; + try { + template = configuration.getTemplate(id.toString()); + } catch (IOException exception) { + throw new CoreException( + new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION) + .withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR) + .withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception); + } + schemaTemplate = new SchemaTemplate(template, configurationData.getTimeStamp()); + schemaTemplates.put(id, schemaTemplate); + } + return schemaTemplate.template; + } + + private static class SchemaTemplateId { + private SchemaTemplateContext context; + private CompositionEntityType entityType; + + public SchemaTemplateId(SchemaTemplateContext context, CompositionEntityType entityType) { + this.context = context; + this.entityType = entityType; + } + + @Override + public String toString() { + return context + "." + entityType; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + + SchemaTemplateId that = (SchemaTemplateId) obj; + + if (entityType != that.entityType) { + return false; + } + if (context != that.context) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = entityType != null ? entityType.hashCode() : 0; + result = 31 * result + (context != null ? context.hashCode() : 0); + return result; + } + } + + private static class SchemaTemplate { + private Template template; + private long timestamp; + + public SchemaTemplate(Template template, long timestamp) { + this.template = template; + this.timestamp = timestamp; + } + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java new file mode 100644 index 0000000000..9540f3d965 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.utils; + +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.common.utils.SdcCommon; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; +import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree; +import org.openecomp.sdc.heat.services.tree.HeatTreeManager; +import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.services.HeatFileAnalyzer; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; +import org.openecomp.sdc.vendorsoftwareproduct.services.impl.HeatFileAnalyzerRowDataImpl; +import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; + +import java.io.InputStream; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +public class CandidateEntityBuilder { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + private CandidateService candidateService; + + public CandidateEntityBuilder(CandidateService candidateService) { + this.candidateService = candidateService; + } + + public OrchestrationTemplateCandidateData buildCandidateEntityFromZip( + VspDetails vspDetails, byte[] uploadedFileData, FileContentHandler contentMap, + Map<String, List<ErrorMessage>> uploadErrors, String user) throws Exception { + //mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId()); + + InputStream zipFileManifest = contentMap.getFileContent(SdcCommon.MANIFEST_NAME); + HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl(); + AnalyzedZipHeatFiles analyzedZipHeatFiles = + heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles()); + HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles); + + CandidateDataEntityTo candidateDataEntityTo = + new CandidateDataEntityTo(vspDetails.getId(), user, uploadedFileData, tree, contentMap, + vspDetails.getVersion()); + candidateDataEntityTo.setErrors(uploadErrors); + OrchestrationTemplateCandidateData candidateDataEntity = + candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest, + analyzedZipHeatFiles); + + mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId()); + return candidateDataEntity; + } + + private HeatStructureTree getHeatStructureTree(VspDetails vspDetails, + FileContentHandler contentMap, + AnalyzedZipHeatFiles analyzedZipHeatFiles) { + addManifestToFileContentMapIfNotExist(vspDetails, contentMap, analyzedZipHeatFiles); + HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(contentMap); + heatTreeManager.createTree(); + return heatTreeManager.getTree(); + } + + private void addManifestToFileContentMapIfNotExist(VspDetails vspDetails, + FileContentHandler fileContentHandler, + AnalyzedZipHeatFiles analyzedZipHeatFiles) { + mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId()); + + InputStream manifest = fileContentHandler.getFileContent(SdcCommon.MANIFEST_NAME); + if (Objects.isNull(manifest)) { + Optional<ManifestContent> manifestContentOptional = + candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles); + if (!manifestContentOptional.isPresent()) { + throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()); + } + ManifestContent manifestContent = manifestContentOptional.get(); + fileContentHandler.addFile( + SdcCommon.MANIFEST_NAME, + String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes()); + } + + mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId()); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java new file mode 100644 index 0000000000..4ea0a02053 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types; + +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CandidateDataEntityTo { + private final String vspId; + private final String user; +// private final UploadFileResponse uploadFileResponse; + private Map<String, List<ErrorMessage>> errors = new HashMap<>(); + private final byte[] uploadedFileData; + private final HeatStructureTree tree; + private final Version activeVersion; + private final FileContentHandler contentMap; + + /** + * Instantiates a new Candidate data entity to. + * @param vspId the vsp id + * @param user the user + * @param uploadedFileData the uploaded file data + * @param tree the tree + * @param contentMap the content map + * @param activeVersion the active version + */ + public CandidateDataEntityTo(String vspId, String user, + byte[] uploadedFileData, HeatStructureTree tree, + FileContentHandler contentMap, Version activeVersion) { + this.vspId = vspId; + this.user = user; + this.errors = errors; + this.uploadedFileData = uploadedFileData; + this.tree = tree; + this.activeVersion = activeVersion; + this.contentMap = contentMap; + } + + public String getVspId() { + return vspId; + } + + public String getUser() { + return user; + } + + public byte[] getUploadedFileData() { + return uploadedFileData; + } + + public HeatStructureTree getTree() { + return tree; + } + + public Version getActiveVersion() { + return activeVersion; + } + + public FileContentHandler getContentMap() { + return contentMap; + } + + public Map<String, List<ErrorMessage>> getErrors() {return errors;} + + public void setErrors(Map<String, List<ErrorMessage>> errors) {this.errors = errors;} +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/AnalyzedZipHeatFiles.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/AnalyzedZipHeatFiles.java new file mode 100644 index 0000000000..5e04a1683c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/AnalyzedZipHeatFiles.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat; + +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** + * @author Avrahamg + * @since December 25, 2016 + */ +public class AnalyzedZipHeatFiles { + private Set<String> nestedFiles = new HashSet<>(); + private Set<String> otherNonModuleFiles = new HashSet<>(); + private Set<String> moduleFiles = new HashSet<>(); + + public void addNestedFile(String fileName) + { + nestedFiles.add(fileName); + moduleFiles.remove(fileName); + } + + public void addNestedFiles(Collection<String> fileNames) + { + nestedFiles.addAll(fileNames); + moduleFiles.removeAll(fileNames); + } + + public void addOtherNonModuleFile(String fileName) + { + otherNonModuleFiles.add(fileName); + moduleFiles.remove(fileName); + } + + public void addOtherNonModuleFiles(Collection<String> fileNames) + { + otherNonModuleFiles.addAll(fileNames); + moduleFiles.removeAll(fileNames); + } + + public void addModuleFile(String fileName) + { + moduleFiles.add(fileName); + } + + public Collection<String> getFilesNotEligbleForModules() + { + return CollectionUtils.union(this.getNestedFiles(), this.getOtherNonModuleFiles()); + } + + public Set<String> getNestedFiles() { + return nestedFiles; + } + + public Set<String> getOtherNonModuleFiles() { + return otherNonModuleFiles; + } + + public Set<String> getModuleFiles() { + return moduleFiles; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Constants.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Constants.java new file mode 100644 index 0000000000..4e19dd67e9 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Constants.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat; + +public class Constants { + public static final String BASE_HEAT_REGEX = "(^base_.*\\.|.*_base\\.|.*_base_.*\\.|^base\\.)(yaml|yml)$"; + public static final String VOL_FILE_NAME_SUFFIX = "_volume"; + public static final String ENV_FILE_EXTENSION = ".env"; +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/FilesDataStructure.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/FilesDataStructure.java new file mode 100644 index 0000000000..f0d5458082 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/FilesDataStructure.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat; + +import java.util.ArrayList; +import java.util.List; + +public class FilesDataStructure { + private List<Module> modules = new ArrayList<>(); + private List<String> unassigned = new ArrayList<>(); + private List<String> artifacts = new ArrayList<>(); + private List<String> nested = new ArrayList<>(); + + public List<Module> getModules() { + return modules; + } + + public void setModules(List<Module> modules) { + this.modules = modules; + } + + public List<String> getUnassigned() { + return unassigned; + } + + public void setUnassigned(List<String> unassigned) { + this.unassigned = unassigned; + } + + public List<String> getArtifacts() { + return artifacts; + } + + public void setArtifacts(List<String> artifacts) { + this.artifacts = artifacts; + } + + public List<String> getNested() { + return nested; + } + + public void setNested(List<String> nested) { + this.nested = nested; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Module.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Module.java new file mode 100644 index 0000000000..45a29f928f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/candidateheat/Module.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat; + +public class Module { + private String name; + private Boolean isBase; + private String yaml; + private String env; + private String vol; + private String volEnv; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getIsBase() { + return isBase; + } + + public void setIsBase(Boolean isBase) { + this.isBase = isBase; + } + + public String getYaml() { + return yaml; + } + + public void setYaml(String yaml) { + this.yaml = yaml; + } + + public String getEnv() { + return env; + } + + public void setEnv(String env) { + this.env = env; + } + + public String getVol() { + return vol; + } + + public void setVol(String vol) { + this.vol = vol; + } + + public String getVolEnv() { + return volEnv; + } + + public void setVolEnv(String volEnv) { + this.volEnv = volEnv; + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentData.java index 0b3096c686..28d187ec69 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentData.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ComponentData.java @@ -24,6 +24,7 @@ public class ComponentData implements CompositionDataEntity { private String name; private String description; private String displayName; + private String vfcCode; public String getName() { return name; @@ -50,15 +51,23 @@ public class ComponentData implements CompositionDataEntity { } @Override - public boolean equals(Object obj) { - if (this == obj) { + public int hashCode() { + int result = name.hashCode(); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (displayName != null ? displayName.hashCode() : 0); + return result; + } + + @Override + public boolean equals(Object object) { + if (this == object) { return true; } - if (!(obj instanceof ComponentData)) { + if (!(object instanceof ComponentData)) { return false; } - ComponentData that = (ComponentData) obj; + ComponentData that = (ComponentData) object; if (!name.equals(that.name)) { return false; @@ -70,11 +79,11 @@ public class ComponentData implements CompositionDataEntity { } - @Override - public int hashCode() { - int result = name.hashCode(); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (displayName != null ? displayName.hashCode() : 0); - return result; + public String getVfcCode() { + return vfcCode; + } + + public void setVfcCode(String vfcCode) { + this.vfcCode = vfcCode; } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityId.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityId.java index af1123b2e8..71c8e4609a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityId.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityId.java @@ -38,15 +38,22 @@ public class CompositionEntityId { } @Override - public boolean equals(Object obj) { - if (this == obj) { + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (parentId != null ? parentId.hashCode() : 0); + return result; + } + + @Override + public boolean equals(Object object) { + if (this == object) { return true; } - if (obj == null || getClass() != obj.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - CompositionEntityId that = (CompositionEntityId) obj; + CompositionEntityId that = (CompositionEntityId) object; if (id != null ? !id.equals(that.id) : that.id != null) { return false; @@ -54,11 +61,4 @@ public class CompositionEntityId { return parentId != null ? parentId.equals(that.parentId) : that.parentId == null; } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (parentId != null ? parentId.hashCode() : 0); - return result; - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityType.java index f762aeb341..4695210de5 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityType.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityType.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.composition; + public enum CompositionEntityType { vsp, network, diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityValidationData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityValidationData.java new file mode 100644 index 0000000000..d126763409 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/CompositionEntityValidationData.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.composition; + +import java.util.ArrayList; +import java.util.Collection; + +public class CompositionEntityValidationData { + private CompositionEntityType entityType; + private String entityId; + private String entityName; + private Collection<String> errors; + private Collection<CompositionEntityValidationData> subEntitiesValidationData; + + public CompositionEntityValidationData(CompositionEntityType entityType, String entityId) { + this.entityType = entityType; + this.entityId = entityId; + } + + public String getEntityName() { + return entityName; + } + + public void setEntityName(String entityName) { + this.entityName = entityName; + } + + public CompositionEntityType getEntityType() { + return entityType; + } + + public void setEntityType(CompositionEntityType entityType) { + this.entityType = entityType; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public Collection<String> getErrors() { + return errors; + } + + public void setErrors(Collection<String> errors) { + this.errors = errors; + } + + public Collection<CompositionEntityValidationData> getSubEntitiesValidationData() { + return subEntitiesValidationData; + } + + public void setSubEntitiesValidationData(Collection<CompositionEntityValidationData> toSet) { + this.subEntitiesValidationData = toSet; + } + + /** + * Add sub entity validation data. + * + * @param subEntityValidationData the sub entity validation data + */ + public void addSubEntityValidationData(CompositionEntityValidationData subEntityValidationData) { + if (subEntitiesValidationData == null) { + subEntitiesValidationData = new ArrayList<>(); + } + subEntitiesValidationData.add(subEntityValidationData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + CompositionEntityValidationData that = (CompositionEntityValidationData) o; + + if (entityType != that.entityType) { + return false; + } + if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) { + return false; + } + if (entityName != null ? !entityName.equals(that.entityName) : that.entityName != null) { + return false; + } + if (errors != null ? !errors.equals(that.errors) : that.errors != null) { + return false; + } + if (subEntitiesValidationData != null ? !subEntitiesValidationData + .equals(that.subEntitiesValidationData) : that.subEntitiesValidationData != null) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = entityType != null ? entityType.hashCode() : 0; + result = 31 * result + (entityId != null ? entityId.hashCode() : 0); + result = 31 * result + (entityName != null ? entityName.hashCode() : 0); + result = 31 * result + (errors != null ? errors.hashCode() : 0); + result = + 31 * result + + (subEntitiesValidationData != null ? subEntitiesValidationData.hashCode() : 0); + return result; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ExtractCompositionDataContext.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ExtractCompositionDataContext.java new file mode 100644 index 0000000000..6736512cee --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/ExtractCompositionDataContext.java @@ -0,0 +1,134 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.composition; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class ExtractCompositionDataContext { + private List<Network> networks = new ArrayList<>(); + private List<Component> components = new ArrayList<>(); + private Map<String, Nic> nics = new HashMap<>(); + private Set<String> handledServiceTemplates = new HashSet<>(); + private Set<String> createdComponents = new HashSet<>(); + + public Set<String> getCreatedComponents() { + return createdComponents; + } + + public void setCreatedComponents(Set<String> createdComponents) { + this.createdComponents = createdComponents; + } + + public Set<String> getHandledServiceTemplates() { + return handledServiceTemplates; + } + + public void setHandledServiceTemplates(Set<String> handledServiceTemplates) { + this.handledServiceTemplates = handledServiceTemplates; + } + + public void addHandledServiceTemplates(String handledServiceTemplate) { + this.handledServiceTemplates.add(handledServiceTemplate); + } + + public List<Network> getNetworks() { + return networks; + } + + public void setNetworks(List<Network> networks) { + this.networks = networks; + } + + /** + * Add network. + * + * @param network the network + */ + public void addNetwork(Network network) { + if (network != null) { + networks.add(network); + } + } + + /** + * Add networks. + * + * @param network the network + */ + public void addNetworks(List<Network> network) { + if (networks != null) { + networks.addAll(network); + } + } + + public List<Component> getComponents() { + return components; + } + + public void setComponents(List<Component> components) { + this.components = components; + } + + /** + * Add component. + * + * @param component the component + */ + public void addComponent(Component component) { + if (component != null) { + components.add(component); + } + } + + /** + * Add components. + * + * @param components the components + */ + public void addComponents(List<Component> components) { + if (components != null) { + this.components.addAll(components); + } + } + + public Map<String, Nic> getNics() { + return nics; + } + + public void setNics(Map<String, Nic> nics) { + this.nics = nics; + } + + public void addNic(String nicId, Nic nic) { + this.nics.put(nicId, nic); + } + + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Network.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Network.java index 2f9eb4e69c..ba0361b3b4 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Network.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Network.java @@ -41,15 +41,22 @@ public class Network implements CompositionDataEntity { } @Override - public boolean equals(Object obj) { - if (this == obj) { + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + (dhcp ? 1 : 0); + return result; + } + + @Override + public boolean equals(Object object) { + if (this == object) { return true; } - if (obj == null || getClass() != obj.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - Network network = (Network) obj; + Network network = (Network) object; if (dhcp != network.dhcp) { return false; @@ -57,11 +64,4 @@ public class Network implements CompositionDataEntity { return name != null ? name.equals(network.name) : network.name == null; } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (dhcp ? 1 : 0); - return result; - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Nic.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Nic.java index e44a731824..24832951a8 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Nic.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/composition/Nic.java @@ -68,15 +68,24 @@ public class Nic implements CompositionDataEntity { } @Override - public boolean equals(Object obj) { - if (this == obj) { + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (networkId != null ? networkId.hashCode() : 0); + result = 31 * result + (networkType != null ? networkType.hashCode() : 0); + return result; + } + + @Override + public boolean equals(Object object) { + if (this == object) { return true; } - if (obj == null || getClass() != obj.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - Nic nic = (Nic) obj; + Nic nic = (Nic) object; if (name != null ? !name.equals(nic.name) : nic.name != null) { return false; @@ -90,13 +99,4 @@ public class Nic implements CompositionDataEntity { return networkType == nic.networkType; } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (networkId != null ? networkId.hashCode() : 0); - result = 31 * result + (networkType != null ? networkType.hashCode() : 0); - return result; - } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/ComponentQuestionnaire.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/ComponentQuestionnaire.java new file mode 100644 index 0000000000..e451292eaf --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/ComponentQuestionnaire.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component; + + +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.General; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.highAvailability.HighAvailabilityAndLoadBalancing; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network.Network; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage.Storage; + +/** + * Created by TALIO on 11/21/2016 + */ +public class ComponentQuestionnaire { + private General general; + private Compute compute; + private HighAvailabilityAndLoadBalancing highAvailabilityAndLoadBalancing; + private Network network; + private Storage storage; + + public General getGeneral() { + return general; + } + + public void setGeneral(General general) { + this.general = general; + } + + public Compute getCompute() { + return compute; + } + + public void setCompute(Compute compute) { + this.compute = compute; + } + + public HighAvailabilityAndLoadBalancing getHighAvailabilityAndLoadBalancing() { + return highAvailabilityAndLoadBalancing; + } + + public void setHighAvailabilityAndLoadBalancing(HighAvailabilityAndLoadBalancing highAvailabilityAndLoadBalancing) { + this.highAvailabilityAndLoadBalancing = highAvailabilityAndLoadBalancing; + } + + public Network getNetwork() { + return network; + } + + public void setNetwork(Network network) { + this.network = network; + } + + public Storage getStorage() { + return storage; + } + + public void setStorage(Storage storage) { + this.storage = storage; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/Compute.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/Compute.java new file mode 100644 index 0000000000..9295288aca --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/Compute.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute; + +/** + * Created by TALIO on 11/22/2016. + */ +public class Compute { + private GuestOS guestOS; + private NumOfVMs numOfVMs; + private VmSizing vmSizing; + + public GuestOS getGuestOS() { + return guestOS; + } + + public void setGuestOS(GuestOS guestOS) { + this.guestOS = guestOS; + } + + public NumOfVMs getNumOfVMs() { + return numOfVMs; + } + + public void setNumOfVMs(NumOfVMs numOfVMs) { + this.numOfVMs = numOfVMs; + } + + public VmSizing getVmSizing() { + return vmSizing; + } + + public void setVmSizing(VmSizing vmSizing) { + this.vmSizing = vmSizing; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java new file mode 100644 index 0000000000..db22b3a3ee --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute; + +/** + * Created by TALIO on 11/22/2016. + */ +public class GuestOS { + private String name; + private String tools; + private int bitSize; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTools() { + return tools; + } + + public void setTools(String tools) { + this.tools = tools; + } + + public int getBitSize() { + return bitSize; + } + + public void setBitSize(int bitSize) { + this.bitSize = bitSize; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/NumOfVMs.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/NumOfVMs.java new file mode 100644 index 0000000000..3b0b8dbb0c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/NumOfVMs.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute; + +/** + * Created by TALIO on 11/22/2016. + */ +public class NumOfVMs { + private int minimum; + private int maximum; + private String CpuOverSubscriptionRatio; + private String MemoryRAM; + + public int getMinimum() { + return minimum; + } + + public void setMinimum(int minimum) { + this.minimum = minimum; + } + + public int getMaximum() { + return maximum; + } + + public void setMaximum(int maximum) { + this.maximum = maximum; + } + + public String getCpuOverSubscriptionRatio() { + return CpuOverSubscriptionRatio; + } + + public void setCpuOverSubscriptionRatio(String cpuOverSubscriptionRatio) { + CpuOverSubscriptionRatio = cpuOverSubscriptionRatio; + } + + public String getMemoryRAM() { + return MemoryRAM; + } + + public void setMemoryRAM(String memoryRAM) { + MemoryRAM = memoryRAM; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java new file mode 100644 index 0000000000..2ae7f48f33 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute; + +/** + * Created by TALIO on 11/22/2016. + */ +public class VmSizing { + private int numOfCPUs; + private int fileSystemSizeGB; + private int persistentStorageVolumeSize; + private int IOOperationsPerSec; + + public int getNumOfCPUs() { + return numOfCPUs; + } + + public void setNumOfCPUs(int numOfCPUs) { + this.numOfCPUs = numOfCPUs; + } + + public int getFileSystemSizeGB() { + return fileSystemSizeGB; + } + + public void setFileSystemSizeGB(int fileSystemSizeGB) { + this.fileSystemSizeGB = fileSystemSizeGB; + } + + public int getPersistentStorageVolumeSize() { + return persistentStorageVolumeSize; + } + + public void setPersistentStorageVolumeSize(int persistentStorageVolumeSize) { + this.persistentStorageVolumeSize = persistentStorageVolumeSize; + } + + public int getIOOperationsPerSec() { + return IOOperationsPerSec; + } + + public void setIOOperationsPerSec(int IOOperationsPerSec) { + this.IOOperationsPerSec = IOOperationsPerSec; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/General.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/General.java new file mode 100644 index 0000000000..7d64906741 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/General.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general; + +/** + * Created by TALIO on 11/22/2016. + */ +public class General { + private Hypervisor hypervisor; + private Image image; + protected Recovery recovery; + private String dnsConfiguration; + private String vmCloneUsage; + + public Hypervisor getHypervisor() { + return hypervisor; + } + + public void setHypervisor(Hypervisor hypervisor) { + this.hypervisor = hypervisor; + } + + public Image getImage() { + return image; + } + + public void setImage(Image image) { + this.image = image; + } + + public Recovery getRecovery() { + return recovery; + } + + public void setRecovery(Recovery recovery) { + this.recovery = recovery; + } + + public String getDnsConfiguration() { + return dnsConfiguration; + } + + public void setDnsConfiguration(String dnsConfiguration) { + this.dnsConfiguration = dnsConfiguration; + } + + public String getVmCloneUsage() { + return vmCloneUsage; + } + + public void setVmCloneUsage(String vmCloneUsage) { + this.vmCloneUsage = vmCloneUsage; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Hypervisor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Hypervisor.java new file mode 100644 index 0000000000..930a3ce285 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Hypervisor.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general; + +/** + * Created by TALIO on 11/22/2016. + */ +public class Hypervisor { + private String hypervisor; + private String drivers; + private String containerFeaturesDescription; + + public String getHypervisor() { + return hypervisor; + } + + public void setHypervisor(String hypervisor) { + this.hypervisor = hypervisor; + } + + public String getDrivers() { + return drivers; + } + + public void setDrivers(String drivers) { + this.drivers = drivers; + } + + public String getContainerFeaturesDescription() { + return containerFeaturesDescription; + } + + public void setContainerFeaturesDescription(String containerFeaturesDescription) { + this.containerFeaturesDescription = containerFeaturesDescription; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java new file mode 100644 index 0000000000..09e83b875f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general; + +/** + * Created by TALIO on 11/22/2016. + */ +public class Image { + private String format; + private String providedBy; + private int bootDiskSizePerVM; + private int ephemeralDiskSizePerVM; + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getProvidedBy() { + return providedBy; + } + + public void setProvidedBy(String providedBy) { + this.providedBy = providedBy; + } + + public int getBootDiskSizePerVM() { + return bootDiskSizePerVM; + } + + public void setBootDiskSizePerVM(int bootDiskSizePerVM) { + this.bootDiskSizePerVM = bootDiskSizePerVM; + } + + public int getEphemeralDiskSizePerVM() { + return ephemeralDiskSizePerVM; + } + + public void setEphemeralDiskSizePerVM(int ephemeralDiskSizePerVM) { + this.ephemeralDiskSizePerVM = ephemeralDiskSizePerVM; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java new file mode 100644 index 0000000000..4a13829d71 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general; + +/** + * Created by TALIO on 11/22/2016. + */ +public class Recovery { + private int pointObjective; + private int timeObjective; + private String vmProcessFailuresHandling; + + public int getPointObjective() { + return pointObjective; + } + + public void setPointObjective(int pointObjective) { + this.pointObjective = pointObjective; + } + + public int getTimeObjective() { + return timeObjective; + } + + public void setTimeObjective(int timeObjective) { + this.timeObjective = timeObjective; + } + + public String getVmProcessFailuresHandling() { + return vmProcessFailuresHandling; + } + + public void setVmProcessFailuresHandling(String vmProcessFailuresHandling) { + this.vmProcessFailuresHandling = vmProcessFailuresHandling; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/highAvailability/HighAvailabilityAndLoadBalancing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/highAvailability/HighAvailabilityAndLoadBalancing.java new file mode 100644 index 0000000000..b5965887ba --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/highAvailability/HighAvailabilityAndLoadBalancing.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.highAvailability; + +/** + * Created by TALIO on 11/22/2016. + */ +public class HighAvailabilityAndLoadBalancing { + private String failureLoadDistribution; + private String nkModelImplementation; + private String architectureChoice; + private String slaRequirements; + private String horizontalScaling; + private String loadDistributionMechanism; + private String isComponentMandatory; + private String highAvailabilityMode; + + public String getFailureLoadDistribution() { + return failureLoadDistribution; + } + + public void setFailureLoadDistribution(String failureLoadDistribution) { + this.failureLoadDistribution = failureLoadDistribution; + } + + public String getNkModelImplementation() { + return nkModelImplementation; + } + + public void setNkModelImplementation(String nkModelImplementation) { + this.nkModelImplementation = nkModelImplementation; + } + + public String getArchitectureChoice() { + return architectureChoice; + } + + public void setArchitectureChoice(String architectureChoice) { + this.architectureChoice = architectureChoice; + } + + public String getSlaRequirements() { + return slaRequirements; + } + + public void setSlaRequirements(String slaRequirements) { + this.slaRequirements = slaRequirements; + } + + public String getHorizontalScaling() { + return horizontalScaling; + } + + public void setHorizontalScaling(String horizontalScaling) { + this.horizontalScaling = horizontalScaling; + } + + public String getLoadDistributionMechanism() { + return loadDistributionMechanism; + } + + public void setLoadDistributionMechanism(String loadDistributionMechanism) { + this.loadDistributionMechanism = loadDistributionMechanism; + } + + public String getIsComponentMandatory() { + return isComponentMandatory; + } + + public void setIsComponentMandatory(String isComponentMandatory) { + this.isComponentMandatory = isComponentMandatory; + } + + public String getHighAvailabilityMode() { + return highAvailabilityMode; + } + + public void setHighAvailabilityMode(String highAvailabilityMode) { + this.highAvailabilityMode = highAvailabilityMode; + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/Network.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/Network.java new file mode 100644 index 0000000000..3e631c791e --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/Network.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network; + +/** + * Created by TALIO on 11/22/2016. + */ +public class Network { + private NetworkCapacity networkCapacity; + + public NetworkCapacity getNetworkCapacity() { + return networkCapacity; + } + + public void setNetworkCapacity(NetworkCapacity networkCapacity) { + this.networkCapacity = networkCapacity; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/NetworkCapacity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/NetworkCapacity.java new file mode 100644 index 0000000000..cd1e6e67b5 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/network/NetworkCapacity.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network; + +/** + * Created by TALIO on 11/22/2016. + */ +public class NetworkCapacity { + private String protocolWithHighestTrafficProfileAcrossAllNICs; + private int networkTransactionsPerSecond; + + public String getProtocolWithHighestTrafficProfileAcrossAllNICs() { + return protocolWithHighestTrafficProfileAcrossAllNICs; + } + + public void setProtocolWithHighestTrafficProfileAcrossAllNICs(String protocolWithHighestTrafficProfileAcrossAllNICs) { + this.protocolWithHighestTrafficProfileAcrossAllNICs = protocolWithHighestTrafficProfileAcrossAllNICs; + } + + public int getNetworkTransactionsPerSecond() { + return networkTransactionsPerSecond; + } + + public void setNetworkTransactionsPerSecond(int networkTransactionsPerSecond) { + this.networkTransactionsPerSecond = networkTransactionsPerSecond; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java new file mode 100644 index 0000000000..df5bcb0a02 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage; + +/** + * Created by TALIO on 11/22/2016. + */ +public class Backup { + private String backupType; + private String backupSolution; + private String backupNIC; + private int backupStorageSize; + + public String getBackupType() { + return backupType; + } + + public void setBackupType(String backupType) { + this.backupType = backupType; + } + + public String getBackupSolution() { + return backupSolution; + } + + public void setBackupSolution(String backupSolution) { + this.backupSolution = backupSolution; + } + + public String getBackupNIC() { + return backupNIC; + } + + public void setBackupNIC(String backupNIC) { + this.backupNIC = backupNIC; + } + + public int getBackupStorageSize() { + return backupStorageSize; + } + + public void setBackupStorageSize(int backupStorageSize) { + this.backupStorageSize = backupStorageSize; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java new file mode 100644 index 0000000000..cbf1fbeb78 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage; + +/** + * Created by TALIO on 11/22/2016. + */ +public class LogBackup { + private int sizeOfLogFiles; + private int logBackupFrequency; + private int logRetentionPeriod; + private String logFileLocation; + + public int getSizeOfLogFiles() { + return sizeOfLogFiles; + } + + public void setSizeOfLogFiles(int sizeOfLogFiles) { + this.sizeOfLogFiles = sizeOfLogFiles; + } + + public int getLogBackupFrequency() { + return logBackupFrequency; + } + + public void setLogBackupFrequency(int logBackupFrequency) { + this.logBackupFrequency = logBackupFrequency; + } + + public int getLogRetentionPeriod() { + return logRetentionPeriod; + } + + public void setLogRetentionPeriod(int logRetentionPeriod) { + this.logRetentionPeriod = logRetentionPeriod; + } + + public String getLogFileLocation() { + return logFileLocation; + } + + public void setLogFileLocation(String logFileLocation) { + this.logFileLocation = logFileLocation; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/SnapshotBackup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/SnapshotBackup.java new file mode 100644 index 0000000000..6d61c5751a --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/SnapshotBackup.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage; + +/** + * Created by TALIO on 11/22/2016. + */ +public class SnapshotBackup { + private int snapshotFrequency; + + public int getSnapshotFrequency() { + return snapshotFrequency; + } + + public void setSnapshotFrequency(int snapshotFrequency) { + this.snapshotFrequency = snapshotFrequency; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Storage.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Storage.java new file mode 100644 index 0000000000..36d34964ef --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Storage.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage; + +/** + * Created by TALIO on 11/22/2016. + */ +public class Storage { + private Backup backup; + private LogBackup logBackup; + private SnapshotBackup snapshotBackup; + + public Backup getBackup() { + return backup; + } + + public void setBackup(Backup backup) { + this.backup = backup; + } + + public LogBackup getLogBackup() { + return logBackup; + } + + public void setLogBackup(LogBackup logBackup) { + this.logBackup = logBackup; + } + + public SnapshotBackup getSnapshotBackup() { + return snapshotBackup; + } + + public void setSnapshotBackup(SnapshotBackup snapshotBackup) { + this.snapshotBackup = snapshotBackup; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/AcceptableJitter.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/AcceptableJitter.java new file mode 100644 index 0000000000..e81822ef5f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/AcceptableJitter.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; + +/** + * Created by TALIO on 11/22/2016. + */ +public class AcceptableJitter { + private int mean; + private int max; + private int variable; + + public int getMean() { + return mean; + } + + public void setMean(int mean) { + this.mean = mean; + } + + public int getMax() { + return max; + } + + public void setMax(int max) { + this.max = max; + } + + public int getVariable() { + return variable; + } + + public void setVariable(int variable) { + this.variable = variable; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/IpConfiguration.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/IpConfiguration.java new file mode 100644 index 0000000000..06359eb3ef --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/IpConfiguration.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; + +/** + * Created by TALIO on 11/22/2016. + */ +public class IpConfiguration { + private boolean ipv4Required; + private boolean ipv6Required; + + public boolean isIpv4Required() { + return ipv4Required; + } + + public void setIpv4Required(boolean ipv4Required) { + this.ipv4Required = ipv4Required; + } + + public boolean isIpv6Required() { + return ipv6Required; + } + + public void setIpv6Required(boolean ipv6Required) { + this.ipv6Required = ipv6Required; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Network.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Network.java new file mode 100644 index 0000000000..882d309b66 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Network.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; + +/** + * Created by TALIO on 11/22/2016 + */ +public class Network { + private String networkDescription; + + public String getNetworkDescription() { + return networkDescription; + } + + public void setNetworkDescription(String networkDescription) { + this.networkDescription = networkDescription; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Network{"); + sb.append("networkDescription='").append(networkDescription).append('\''); + sb.append('}'); + return sb.toString(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/NicQuestionnaire.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/NicQuestionnaire.java new file mode 100644 index 0000000000..0bc8b5df47 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/NicQuestionnaire.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; + +/** + * Created by TALIO on 11/21/2016. + */ +public class NicQuestionnaire { + private Protocols protocols; + private IpConfiguration ipConfiguration; + private Network network; + private Sizing sizing; + + public Protocols getProtocols() { + return protocols; + } + + public void setProtocols(Protocols protocols) { + this.protocols = protocols; + } + + public IpConfiguration getIpConfiguration() { + return ipConfiguration; + } + + public void setIpConfiguration(IpConfiguration ipConfiguration) { + this.ipConfiguration = ipConfiguration; + } + + public Network getNetwork() { + return network; + } + + public void setNetwork(Network network) { + this.network = network; + } + + public Sizing getSizing() { + return sizing; + } + + public void setSizing(Sizing sizing) { + this.sizing = sizing; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PacketsAndBytes.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PacketsAndBytes.java new file mode 100644 index 0000000000..358620254c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PacketsAndBytes.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; + +/** + * Created by TALIO on 11/22/2016. + */ +public class PacketsAndBytes { + private PeakAndAvg packets; + private PeakAndAvg bytes; + + public PeakAndAvg getPackets() { + return packets; + } + + public void setPackets(PeakAndAvg packets) { + this.packets = packets; + } + + public PeakAndAvg getBytes() { + return bytes; + } + + public void setBytes(PeakAndAvg bytes) { + this.bytes = bytes; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java new file mode 100644 index 0000000000..3d80224698 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; + +/** + * Created by TALIO on 11/22/2016. + */ +public class PeakAndAvg { + private int peak; + private int avg; + + public int getPeak() { + return peak; + } + + public void setPeak(int peak) { + this.peak = peak; + } + + public int getAvg() { + return avg; + } + + public void setAvg(int avg) { + this.avg = avg; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Protocols.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Protocols.java new file mode 100644 index 0000000000..37b76bd451 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Protocols.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by TALIO on 11/22/2016. + */ +public class Protocols { + private List<String> protocols = new ArrayList<>(); + private String protocolWithHighestTrafficProfile; + + public List<String> getProtocols() { + return protocols; + } + + public void setProtocols(List<String> protocols) { + this.protocols = protocols; + } + + public String getProtocolWithHighestTrafficProfile() { + return protocolWithHighestTrafficProfile; + } + + public void setProtocolWithHighestTrafficProfile(String protocolWithHighestTrafficProfile) { + this.protocolWithHighestTrafficProfile = protocolWithHighestTrafficProfile; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Protocols{"); + sb.append("protocols=").append(protocols); + sb.append(", protocolWithHighestTrafficProfile='").append(protocolWithHighestTrafficProfile) + .append('\''); + sb.append('}'); + return sb.toString(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java new file mode 100644 index 0000000000..32a9e5a186 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic; + +/** + * Created by TALIO on 11/22/2016 + */ +public class Sizing { + private String describeQualityOfService; + private int acceptablePacketLoss; + private PacketsAndBytes inflowTrafficPerSecond; + private PacketsAndBytes outflowTrafficPerSecond; + private PacketsAndBytes flowLength; + private AcceptableJitter acceptableJitter; + + public String getDescribeQualityOfService() { + return describeQualityOfService; + } + + public void setDescribeQualityOfService(String describeQualityOfService) { + this.describeQualityOfService = describeQualityOfService; + } + + public int getAcceptablePacketLoss() { + return acceptablePacketLoss; + } + + public void setAcceptablePacketLoss(int acceptablePacketLoss) { + this.acceptablePacketLoss = acceptablePacketLoss; + } + + public PacketsAndBytes getInflowTrafficPerSecond() { + return inflowTrafficPerSecond; + } + + public void setInflowTrafficPerSecond(PacketsAndBytes inflowTrafficPerSecond) { + this.inflowTrafficPerSecond = inflowTrafficPerSecond; + } + + public PacketsAndBytes getOutflowTrafficPerSecond() { + return outflowTrafficPerSecond; + } + + public void setOutflowTrafficPerSecond(PacketsAndBytes outflowTrafficPerSecond) { + this.outflowTrafficPerSecond = outflowTrafficPerSecond; + } + + public PacketsAndBytes getFlowLength() { + return flowLength; + } + + public void setFlowLength(PacketsAndBytes flowLength) { + this.flowLength = flowLength; + } + + public AcceptableJitter getAcceptableJitter() { + return acceptableJitter; + } + + public void setAcceptableJitter(AcceptableJitter acceptableJitter) { + this.acceptableJitter = acceptableJitter; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/VspQuestionnaire.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/VspQuestionnaire.java new file mode 100644 index 0000000000..0b53e04f0c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/VspQuestionnaire.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp; + + +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.General; + +/** + * Created by TALIO on 11/21/2016. + */ +public class VspQuestionnaire { + private General general; + + public General getGeneral() { + return general; + } + + public void setGeneral(General general) { + this.general = general; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/Availability.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/Availability.java new file mode 100644 index 0000000000..4f146466f8 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/Availability.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general; + +/** + * Created by TALIO on 11/21/2016. + */ +public class Availability { + private boolean useAvailabilityZonesForHighAvailability = false; + + public boolean isUseAvailabilityZonesForHighAvailability() { + return useAvailabilityZonesForHighAvailability; + } + + public void setUseAvailabilityZonesForHighAvailability(boolean useAvailabilityZonesForHighAvailability) { + this.useAvailabilityZonesForHighAvailability = useAvailabilityZonesForHighAvailability; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/General.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/General.java new file mode 100644 index 0000000000..566374f1f7 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/General.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general; + +/** + * Created by TALIO on 11/22/2016. + */ +public class General { + + private String affinityData; + private Availability availability; + private RegionsData regionsData; + private StorageDataReplication storageDataReplication; + + public StorageDataReplication getStorageDataReplication() { + return storageDataReplication; + } + + public void setStorageDataReplication(StorageDataReplication storageDataReplication) { + this.storageDataReplication = storageDataReplication; + } + + public String getAffinityData() { + return affinityData; + } + + public void setAffinityData(String affinityData) { + this.affinityData = affinityData; + } + + public Availability getAvailability() { + return availability; + } + + public void setAvailability(Availability availability) { + this.availability = availability; + } + + public RegionsData getRegionsData() { + return regionsData; + } + + public void setRegionsData(RegionsData regionsData) { + this.regionsData = regionsData; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/RegionsData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/RegionsData.java new file mode 100644 index 0000000000..efdcb46e89 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/RegionsData.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by TALIO on 11/21/2016. + */ +public class RegionsData { + private boolean multiRegion; + private List<String> regions = new ArrayList<>(); + + public boolean isMultiRegion() { + return multiRegion; + } + + public void setMultiRegion(boolean multiRegion) { + this.multiRegion = multiRegion; + } + + public List<String> getRegions() { + return regions; + } + + public void setRegions(List<String> regions) { + this.regions = regions; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java new file mode 100644 index 0000000000..7c073af422 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general; + +/** + * Created by TALIO on 11/21/2016. + */ +public class StorageDataReplication { + private boolean storageReplicationAcrossRegion; + private int storageReplicationSize; + private int storageReplicationFrequency; + private String storageReplicationSource; + private String storageReplicationDestination; + + public String getStorageReplicationDestination() { + return storageReplicationDestination; + } + + public void setStorageReplicationDestination(String storageReplicationDestination) { + this.storageReplicationDestination = storageReplicationDestination; + } + + public int getStorageReplicationSize() { + return storageReplicationSize; + } + + public void setStorageReplicationSize(int storageReplicationSize) { + this.storageReplicationSize = storageReplicationSize; + } + + public int getStorageReplicationFrequency() { + return storageReplicationFrequency; + } + + public void setStorageReplicationFrequency(int storageReplicationFrequency) { + this.storageReplicationFrequency = storageReplicationFrequency; + } + + public String getStorageReplicationSource() { + return storageReplicationSource; + } + + public void setStorageReplicationSource(String storageReplicationSource) { + this.storageReplicationSource = storageReplicationSource; + } + + public boolean isStorageReplicationAcrossRegion() { + return storageReplicationAcrossRegion; + } + + public void setStorageReplicationAcrossRegion(boolean storageReplicationAcrossRegion) { + this.storageReplicationAcrossRegion = storageReplicationAcrossRegion; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java new file mode 100644 index 0000000000..46d0c6c40d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; + +public class ComponentCompositionSchemaInput implements SchemaTemplateInput { + private boolean manual; + private ComponentData component; + + public boolean isManual() { + return manual; + } + + public void setManual(boolean manual) { + this.manual = manual; + } + + public ComponentData getComponent() { + return component; + } + + public void setComponent(ComponentData component) { + this.component = component; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java new file mode 100644 index 0000000000..1f92e6d957 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; + +import java.util.List; +import java.util.Map; + +public class ComponentQuestionnaireSchemaInput implements SchemaTemplateInput { + private List<String> nicNames; + private Map componentQuestionnaireData; + + public ComponentQuestionnaireSchemaInput(List<String> nicNames, Map componentQuestionnaireData) { + this.nicNames = nicNames; + this.componentQuestionnaireData = componentQuestionnaireData; + } + + public List<String> getNicNames() { + return nicNames; + } + + public Map getComponentQuestionnaireData() { + return componentQuestionnaireData; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NetworkCompositionSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NetworkCompositionSchemaInput.java new file mode 100644 index 0000000000..67a2f3d5a1 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NetworkCompositionSchemaInput.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; + +public class NetworkCompositionSchemaInput implements SchemaTemplateInput { + private boolean manual; + private Network network; + + public boolean isManual() { + return manual; + } + + public void setManual(boolean manual) { + this.manual = manual; + } + + public Network getNetwork() { + return network; + } + + public void setNetwork(Network network) { + this.network = network; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java new file mode 100644 index 0000000000..87693a492c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; + +import java.util.Collection; + +public class NicCompositionSchemaInput implements SchemaTemplateInput { + private boolean manual; + private Nic nic; + private Collection<String> networkIds; + + public boolean isManual() { + return manual; + } + + public void setManual(boolean manual) { + this.manual = manual; + } + + public Nic getNic() { + return nic; + } + + public void setNic(Nic nic) { + this.nic = nic; + } + + public Collection<String> getNetworkIds() { + return networkIds; + } + + public void setNetworkIds(Collection<String> networkIds) { + this.networkIds = networkIds; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java new file mode 100644 index 0000000000..3ee3e4a5e6 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; + +public enum SchemaTemplateContext { + composition, + questionnaire +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessArtifactDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateInput.java index 5b562368b5..93e614f98b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessArtifactDao.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateInput.java @@ -18,15 +18,8 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.sdc.vendorsoftwareproduct.dao; +package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessArtifactEntity; +public interface SchemaTemplateInput { -public interface ProcessArtifactDao { - - void update(ProcessArtifactEntity entity); - - ProcessArtifactEntity get(ProcessArtifactEntity entity); - - void delete(ProcessArtifactEntity entity); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json index 86b2f857cf..85177c42c1 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json @@ -1,14 +1,23 @@ { "org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VendorSoftwareProductDaoFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.dao.VspDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VspDaoFactoryImpl", "org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VendorSoftwareProductInfoDaoFactoryImpl", "org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.UploadDataDaoFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.OrchestrationTemplateCandidateDaoFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.OrchestrationTemplateDaoFactoryImpl", "org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.PackageInfoDaoFactoryImpl", "org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.NetworkDaoFactoryImpl", "org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.ComponentDaoFactoryImpl", - "org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.ComponentArtifactDaoFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.MibDaoFactoryImpl", "org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.NicDaoFactoryImpl", "org.openecomp.sdc.vendorsoftwareproduct.dao.VspQuestionnaireDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VspQuestionnaireDaoFactoryImpl", "org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.ProcessDaoFactoryImpl", - "org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessArtifactDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.ProcessArtifactDaoFactoryImpl" - + "org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessArtifactDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.ProcessArtifactDaoFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.factory.QuestionnnaireDataServiceFactory": "org.openecomp.sdc.vendorsoftwareproduct.factory.QuestionnaireDataServiceFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory":"org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory": "org.openecomp.sdc.vendorsoftwareproduct.factory.impl.CandidateServiceFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory": "org.openecomp.sdc.vendorsoftwareproduct.factory.impl.CompositionDataExtractorFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.factory.impl.CompositionEntityDataManagerFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.factory.ManifestCreatorFactory": "org.openecomp.sdc.vendorsoftwareproduct.factory.impl.ManifestCreatorFactoryImpl", + "org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.ComponentDependencyModelDaoFactoryImpl" }
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml index ce7f7be7fd..939e1b003a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml @@ -1,49 +1,32 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>openecomp-sdc-vendor-software-product-core</artifactId> + <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-vendor-software-product-lib</artifactId> <version>1.1.0-SNAPSHOT</version> </parent> - <artifactId>openecomp-sdc-vendor-software-product-core</artifactId> - <dependencies> <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>2.3.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.yaml</groupId> - <artifactId>snakeyaml</artifactId> - <version>1.14</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-enrichment-impl</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-vendor-software-product-api</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-nosqldb-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> - <version>2.3.23</version> + <version>${freemarker.version}</version> </dependency> <dependency> <groupId>org.testng</groupId> @@ -52,7 +35,7 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-config-lib</artifactId> <version>${project.version}</version> </dependency> @@ -62,6 +45,87 @@ <version>${project.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.xmlgraphics</groupId> + <artifactId>fop</artifactId> + <version>${fop.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + <version>${jackson.dataformat.version}</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>${commons.io.version}</version> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>${mockito.all.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-core</artifactId> + <version>${openecomp.sdc.common.version}</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-api</artifactId> + <version>${openecomp.sdc.common.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-zusammen-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-zusammen-core</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.4</version> + </dependency> + + + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-tosca-datatype</artifactId> + <version>${openecomp.sdc.common.version}</version> + </dependency> </dependencies> -</project>
\ No newline at end of file + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${mvn.surefire.version}</version> + <configuration> + <skipTests>true</skipTests> + <useSystemClassLoader>false</useSystemClassLoader> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml.versionsBackup new file mode 100644 index 0000000000..634e0874ac --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml.versionsBackup @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>openecomp-sdc-vendor-software-product-core</artifactId> + <version>1.0-SNAPSHOT</version> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-nosqldb-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>2.3.23</version> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>${testng.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-config-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-model-impl</artifactId> + <version>1.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.xmlgraphics</groupId> + <artifactId>fop</artifactId> + <version>2.1</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + <version>2.7.4</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.5</version> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.10.19</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-core</artifactId> + <version>1707.0.0-SNAPSHOT</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-api</artifactId> + <version>1707.0.0-SNAPSHOT</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.19.1</version> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + </plugins> + </build> + +</project>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/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 new file mode 100644 index 0000000000..45989ddbf0 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilder.java @@ -0,0 +1,28 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.text.MessageFormat; + +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)); + } + + 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 new file mode 100644 index 0000000000..ef5b43fad4 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilder.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.dao.errors; + + +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)); + } + + 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/ComponentArtifactDaoCassandraImpl.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/ComponentArtifactDaoCassandraImpl.java deleted file mode 100644 index 2525537cef..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentArtifactDaoCassandraImpl.java +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; - -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.UDTValue; -import com.datastax.driver.mapping.Mapper; -import com.datastax.driver.mapping.Result; -import com.datastax.driver.mapping.UDTMapper; -import com.datastax.driver.mapping.annotations.Accessor; -import com.datastax.driver.mapping.annotations.Query; -import org.openecomp.core.dao.impl.CassandraBaseDao; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentArtifactEntity; -import org.openecomp.sdc.versioning.VersioningManagerFactory; -import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdc.versioning.types.VersionableEntityMetadata; - - -import java.nio.ByteBuffer; -import java.util.Collection; - -public class ComponentArtifactDaoCassandraImpl extends CassandraBaseDao<ComponentArtifactEntity> - implements ComponentArtifactDao { - - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final ComponentArtifactAccessor accessor = - noSqlDb.getMappingManager().createAccessor(ComponentArtifactAccessor.class); - private static final Mapper<ComponentArtifactEntity> mapper = - noSqlDb.getMappingManager().mapper(ComponentArtifactEntity.class); - private static final UDTMapper<Version> versionMapper = - noSqlDb.getMappingManager().udtMapper(Version.class); - - - @Override - public void registerVersioning(String versionableEntityType) { - VersionableEntityMetadata metadata = new VersionableEntityMetadata( - mapper.getTableMetadata().getName(), - mapper.getTableMetadata().getPartitionKey().get(0).getName(), - mapper.getTableMetadata().getPartitionKey().get(1).getName()); - - // metadata.setUniqueValuesMetadata(Collections.singletonList(new UniqueValueMetadata - // (VendorSoftwareProductConstants.UniqueValues.COMPONENT_ARTIFACT_NAME, - // Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(), mapper - // .getTableMetadata().getPartitionKey().get(1).getName(), "name")))); - - VersioningManagerFactory.getInstance().createInterface() - .register(versionableEntityType, metadata); - } - - @Override - public ComponentArtifactEntity getArtifactByType(ComponentArtifactEntity entity) { - return accessor.listByType(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getType().toString()).one(); - } - - @Override - protected Mapper<ComponentArtifactEntity> getMapper() { - return mapper; - } - - @Override - protected Object[] getKeys(ComponentArtifactEntity entity) { - return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getType().toString(), entity.getId()}; - } - - @Override - public Collection<ComponentArtifactEntity> list(ComponentArtifactEntity entity) { - return accessor.listByType(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getType().toString()).all(); - } - - @Override - public void update(ComponentArtifactEntity entity) { - accessor.update(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getId(), entity.getArtifactName(), entity.getArtifact(), - entity.getType().toString()); - - } - - @Override - public void delete(ComponentArtifactEntity entity) { - accessor.delete(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getType().toString()); - } - - @Override - public Collection<ComponentArtifactEntity> getArtifactNamesAndTypesForComponent( - ComponentArtifactEntity entity) { - return accessor.getArtifactNamesAndTypesForComponent(entity.getVspId(), - versionMapper.toUDT(entity.getVersion()), entity.getComponentId()).all(); - } - - @Override - public void deleteAll(ComponentArtifactEntity entity) { - accessor.deleteAll(entity.getVspId(), versionMapper.toUDT(entity.getVersion())); - } - - - @Accessor - interface ComponentArtifactAccessor { - - @Query( - "insert into vsp_component_artifact (vsp_id, version, component_id, artifact_id, name, " - + "artifact, artifact_type) values (?,?,?,?,?,?,?)") - ResultSet update(String vspId, UDTValue version, String componentId, String id, - String artifactName, ByteBuffer artifact, String type); - - @Query( - "select vsp_id, version, component_id, artifact_type, artifact_id, name, artifact from " - + "vsp_component_artifact where vsp_id=? and version=? and component_id=? and " - + "artifact_type =?") - Result<ComponentArtifactEntity> listByType(String vspId, UDTValue version, String componentId, - String type); - - @Query( - "delete name, artifact from vsp_component_artifact where vsp_id=? and version=? and " - + "component_id=? and artifact_type=? and artifact_id=?") - ResultSet delete(String vspId, UDTValue version, String componentId, String type, - String artifactId); - - @Query( - "delete from vsp_component_artifact where vsp_id=? and version=? and component_id=? " - + "and artifact_type=?") - ResultSet delete(String vspId, UDTValue version, String componentId, String artifactType); - - @Query("delete from vsp_component_artifact where vsp_id=? and version=?") - ResultSet deleteAll(String vspId, UDTValue version); - - @Query( - "select name, artifact_type from vsp_component_artifact where vsp_id=? and version=? " - + "and component_id=?") - Result<ComponentArtifactEntity> getArtifactNamesAndTypesForComponent(String vspId, - UDTValue version, - String componentId); - - } -} 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/ComponentDaoCassandraImpl.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/ComponentDaoCassandraImpl.java index 85372380c0..9cdd950a72 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/ComponentDaoCassandraImpl.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/ComponentDaoCassandraImpl.java @@ -61,10 +61,10 @@ public class ComponentDaoCassandraImpl extends CassandraBaseDao<ComponentEntity> mapper.getTableMetadata().getPartitionKey().get(1).getName()); - metadata.setUniqueValuesMetadata(Collections.singletonList( - new UniqueValueMetadata(VendorSoftwareProductConstants.UniqueValues.COMPONENT_NAME, - Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(), - mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name")))); + metadata.setUniqueValuesMetadata(Collections.singletonList(new UniqueValueMetadata( + VendorSoftwareProductConstants.UniqueValues.COMPONENT_NAME, + Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(), + mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name")))); VersioningManagerFactory.getInstance().createInterface() .register(versionableEntityType, metadata); @@ -93,9 +93,14 @@ public class ComponentDaoCassandraImpl extends CassandraBaseDao<ComponentEntity> } @Override - public void updateQuestionnaireData(String vspId, Version version, String id, + public ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId) { + return accessor.getQuestionnaireData(vspId, versionMapper.toUDT(version), componentId); + } + + @Override + public void updateQuestionnaireData(String vspId, Version version, String componentId, String questionnaireData) { - accessor.updateQuestionnaireData(questionnaireData, vspId, versionMapper.toUDT(version), id); + accessor.updateQuestionnaireData(questionnaireData, vspId, versionMapper.toUDT(version), componentId); } @Override @@ -104,6 +109,11 @@ public class ComponentDaoCassandraImpl extends CassandraBaseDao<ComponentEntity> } @Override + public Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId, Version version){ + return accessor.listCompositionAndQuestionnaire(vspId, versionMapper.toUDT(version)).all(); + } + + @Override public void deleteAll(String vspId, Version version) { accessor.deleteAll(vspId, version); } @@ -112,24 +122,34 @@ public class ComponentDaoCassandraImpl extends CassandraBaseDao<ComponentEntity> interface ComponentAccessor { @Query( - "select vsp_id, version, component_id, composition_data from vsp_component " - + "where vsp_id=? and version=?") + "select vsp_id, version, component_id, composition_data from vsp_component" + + " where vsp_id=? and version=?") Result<ComponentEntity> list(String vspId, UDTValue version); @Query( - "select vsp_id, version, component_id, questionnaire_data from vsp_component " - + "where vsp_id=? and version=?") + "select vsp_id, version, component_id, composition_data, questionnaire_data from vsp_component" + + " where vsp_id=? and version=?") + Result<ComponentEntity> listCompositionAndQuestionnaire(String vspId, UDTValue version); + + @Query( + "select vsp_id, version, component_id, questionnaire_data from vsp_component" + + " where vsp_id=? and version=?") Result<ComponentEntity> listQuestionnaires(String vspId, UDTValue version); @Query( - "insert into vsp_component (vsp_id, version, component_id, composition_data) " - + "values (?,?,?,?)") + "select vsp_id, version, component_id, questionnaire_data from vsp_component" + + " where vsp_id=? and version=? and component_id=?") + ComponentEntity getQuestionnaireData(String vspId, UDTValue version, String id); + + @Query( + "insert into vsp_component (vsp_id, version, component_id, composition_data)" + + " values (?,?,?,?)") ResultSet updateCompositionData(String vspId, UDTValue version, String id, String compositionData); @Query( - "update vsp_component set questionnaire_data=? where vsp_id=? and version=? " - + "and component_id=?") + "update vsp_component set questionnaire_data=? where vsp_id=? and version=?" + + " and component_id=?") ResultSet updateQuestionnaireData(String questionnaireData, String vspId, UDTValue version, String 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/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 1e57242ce1..1ef0caac0c 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 @@ -20,11 +20,14 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; 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 ComponentDaoCassandraImpl(); + private static final ComponentDao INSTANCE = new ComponentDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); @Override public ComponentDao 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/ComponentDependencyModelDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java new file mode 100644 index 0000000000..b46486eb32 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java @@ -0,0 +1,87 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; + +import com.datastax.driver.core.ResultSet; +import com.datastax.driver.core.UDTValue; +import com.datastax.driver.mapping.Mapper; +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.UDTMapper; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.dao.impl.CassandraBaseDao; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; +import org.openecomp.sdc.versioning.VersioningManagerFactory; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.UniqueValueMetadata; +import org.openecomp.sdc.versioning.types.VersionableEntityMetadata; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +public class ComponentDependencyModelDaoCassandraImpl extends CassandraBaseDao + <ComponentDependencyModelEntity> implements ComponentDependencyModelDao { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper<ComponentDependencyModelEntity> mapper = + noSqlDb.getMappingManager().mapper(ComponentDependencyModelEntity.class); + private static final ComponentDependencyModelDaoCassandraImpl.ComponentDependencyModelAccessor + accessor = noSqlDb.getMappingManager().createAccessor( + ComponentDependencyModelDaoCassandraImpl.ComponentDependencyModelAccessor.class); + private static final UDTMapper<Version> versionMapper = + noSqlDb.getMappingManager().udtMapper(Version.class); + + @Override + protected Mapper<ComponentDependencyModelEntity> getMapper() { + return mapper; + } + + @Override + protected Object[] getKeys(ComponentDependencyModelEntity entity) { + return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion()), + entity.getId()}; + } + + @Override + public Collection<ComponentDependencyModelEntity> list(ComponentDependencyModelEntity entity) { + return accessor + .list(entity.getVspId(), versionMapper.toUDT(entity.getVersion())).all(); + } + + @Override + public void deleteAll(String vspId, Version version) { + accessor.deleteAll(vspId, versionMapper.toUDT(version)); + } + + + @Override + public void registerVersioning(String versionableEntityType) { + VersionableEntityMetadata metadata = new VersionableEntityMetadata( + mapper.getTableMetadata().getName(), + mapper.getTableMetadata().getPartitionKey().get(0).getName(), + mapper.getTableMetadata().getPartitionKey().get(1).getName()); + + metadata.setUniqueValuesMetadata(Collections.singletonList(new UniqueValueMetadata( + VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, + Arrays.asList("vsp_id", "version", "component_id", "name")))); + + VersioningManagerFactory.getInstance().createInterface() + .register(versionableEntityType, metadata); + + } + + @Accessor + interface ComponentDependencyModelAccessor { + @Query("delete from vsp_component_dependency_model where vsp_id=? and version=?") + ResultSet deleteAll(String vspId, UDTValue version); + + @Query( + "select * from vsp_component_dependency_model where vsp_id=? and version=?") + Result<ComponentDependencyModelEntity> list(String vspId, UDTValue version); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/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 new file mode 100644 index 0000000000..e90e39bbc3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoFactoryImpl.java @@ -0,0 +1,18 @@ +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; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentDependencyModelDaoZusammenImpl; + +public class ComponentDependencyModelDaoFactoryImpl extends ComponentDependencyModelDaoFactory { + + private static final ComponentDependencyModelDao INSTANCE = new + ComponentDependencyModelDaoZusammenImpl( ZusammenAdaptorFactory.getInstance().createInterface()); + + @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/ComponentArtifactDaoFactoryImpl.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/MibDaoFactoryImpl.java index 07a9f104f4..923744bae7 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/ComponentArtifactDaoFactoryImpl.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/MibDaoFactoryImpl.java @@ -20,14 +20,17 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDaoFactory; +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.MibDaoZusammenImpl; -public class ComponentArtifactDaoFactoryImpl extends ComponentArtifactDaoFactory { - private static final ComponentArtifactDao INSTANCE = new ComponentArtifactDaoCassandraImpl(); +public class MibDaoFactoryImpl extends MibDaoFactory { + private static final MibDao INSTANCE = new MibDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); @Override - public ComponentArtifactDao createInterface() { + public MibDao 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/NetworkDaoCassandraImpl.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/NetworkDaoCassandraImpl.java index f7b8f30f0a..83807af5f8 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/NetworkDaoCassandraImpl.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/NetworkDaoCassandraImpl.java @@ -60,10 +60,10 @@ public class NetworkDaoCassandraImpl extends CassandraBaseDao<NetworkEntity> imp mapper.getTableMetadata().getPartitionKey().get(1).getName()); - metadata.setUniqueValuesMetadata(Collections.singletonList( - new UniqueValueMetadata(VendorSoftwareProductConstants.UniqueValues.NETWORK_NAME, - Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(), - mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name")))); + metadata.setUniqueValuesMetadata(Collections.singletonList(new UniqueValueMetadata( + VendorSoftwareProductConstants.UniqueValues.NETWORK_NAME, + Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(), + mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name")))); VersioningManagerFactory.getInstance().createInterface() .register(versionableEntityType, metadata); @@ -86,28 +86,30 @@ public class NetworkDaoCassandraImpl extends CassandraBaseDao<NetworkEntity> imp entity.getId(), entity.getCompositionData()); } - @Override + /*@Override public void updateQuestionnaireData(String vspId, Version version, String id, String questionnaireData) { accessor.updateQuestionnaireData(questionnaireData, vspId, versionMapper.toUDT(version), id); - } + }*/ @Override - public Collection<NetworkEntity> list(NetworkEntity entity) { - return accessor.list(entity.getVspId(), versionMapper.toUDT(entity.getVersion())).all(); + public void deleteAll(String vspId, Version version) { + accessor.deleteAll(vspId, version); } + + @Override - public void deleteAll(String vspId, Version version) { - accessor.deleteAll(vspId, version); + public Collection<NetworkEntity> list(NetworkEntity entity) { + return accessor.list(entity.getVspId(), versionMapper.toUDT(entity.getVersion())).all(); } @Accessor interface NetworkAccessor { @Query( - "select vsp_id, version, network_id, composition_data from vsp_network where vsp_id=? " - + "and version=?") + "select vsp_id, version, network_id, composition_data from vsp_network where vsp_id=?" + + " and version=?") Result<NetworkEntity> list(String vspId, UDTValue version); @Query( 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 b4360996df..5bccc5ced2 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 @@ -20,11 +20,14 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao; 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 NetworkDaoCassandraImpl(); + private static final NetworkDao INSTANCE = new NetworkDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); @Override public NetworkDao 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/NicDaoCassandraImpl.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/NicDaoCassandraImpl.java index e7e1eed8e0..a84ab38ccc 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/NicDaoCassandraImpl.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/NicDaoCassandraImpl.java @@ -60,9 +60,9 @@ public class NicDaoCassandraImpl extends CassandraBaseDao<NicEntity> implements mapper.getTableMetadata().getPartitionKey().get(1).getName()); - metadata.setUniqueValuesMetadata(Collections - .singletonList(new UniqueValueMetadata(VendorSoftwareProductConstants.UniqueValues.NIC_NAME, - Arrays.asList("vsp_id", "version", "component_id", "name")))); + metadata.setUniqueValuesMetadata(Collections.singletonList(new UniqueValueMetadata( + VendorSoftwareProductConstants.UniqueValues.NIC_NAME, + Arrays.asList("vsp_id", "version", "component_id", "name")))); VersioningManagerFactory.getInstance().createInterface() .register(versionableEntityType, metadata); @@ -91,6 +91,12 @@ public class NicDaoCassandraImpl extends CassandraBaseDao<NicEntity> implements } @Override + public NicEntity getQuestionnaireData(String vspId, Version version, String componentId, + String nicId) { + return null; // TODO: 3/20/2017 + } + + @Override public void updateQuestionnaireData(String vspId, Version version, String id, String componentId, String questionnaireData) { accessor.updateQuestionnaireData(questionnaireData, vspId, versionMapper.toUDT(version), id, @@ -102,12 +108,6 @@ public class NicDaoCassandraImpl extends CassandraBaseDao<NicEntity> implements return accessor.listByVspId(vspId, versionMapper.toUDT(version)).all(); } - @Override - public Collection<NicEntity> list(NicEntity entity) { - return accessor.listByComponentId(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId()).all(); - } - public void deleteByComponentId(String vspId, Version version, String componentId) { accessor.deleteByComponentId(vspId, version, componentId); } @@ -116,26 +116,32 @@ public class NicDaoCassandraImpl extends CassandraBaseDao<NicEntity> implements accessor.deleteByVspId(vspId, versionMapper.toUDT(version)); } + @Override + public Collection<NicEntity> list(NicEntity entity) { + return accessor.listByComponentId(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), + entity.getComponentId()).all(); + } + @Accessor interface NicAccessor { @Query( - "select vsp_id, version, component_id, nic_id, composition_data " - + "from vsp_component_nic where vsp_id=? and version=? and component_id=?") + "select vsp_id, version, component_id, nic_id, composition_data" + + " from vsp_component_nic where vsp_id=? and version=? and component_id=?") Result<NicEntity> listByComponentId(String vspId, UDTValue version, String componentId); @Query("select * from vsp_component_nic where vsp_id=? and version=?") Result<NicEntity> listByVspId(String vspId, UDTValue version); @Query( - "insert into vsp_component_nic (vsp_id, version, component_id, nic_id, composition_data) " - + "values (?,?,?,?,?)") + "insert into vsp_component_nic (vsp_id, version, component_id, nic_id, composition_data)" + + " values (?,?,?,?,?)") ResultSet updateCompositionData(String vspId, UDTValue version, String componentId, String id, String compositionData); @Query( - "update vsp_component_nic set questionnaire_data=? where vsp_id=? and version=? " - + "and component_id=? and nic_id=?") + "update vsp_component_nic set questionnaire_data=? where vsp_id=? and version=?" + + " and component_id=? and nic_id=?") ResultSet updateQuestionnaireData(String questionnaireData, String vspId, UDTValue version, String componentId, String 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/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 f4dd8d5a71..76e5d443f2 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 @@ -20,11 +20,14 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao; 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 NicDaoCassandraImpl(); + private static final NicDao INSTANCE = new NicDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); @Override public NicDao 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/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 new file mode 100644 index 0000000000..8cc2c6f61f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateCandidateDaoFactoryImpl.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; + +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao; +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()); + + @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 new file mode 100644 index 0000000000..8b90462131 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/OrchestrationTemplateDaoFactoryImpl.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; + +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; +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 { + private static final OrchestrationTemplateDao INSTANCE = + new OrchestrationTemplateDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); + + @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/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 9b7b81fe52..37917284e0 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +import com.datastax.driver.core.UDTValue; import com.datastax.driver.mapping.Mapper; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.UDTMapper; @@ -28,10 +29,13 @@ import com.datastax.driver.mapping.annotations.Query; 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.common.utils.CommonUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; import org.openecomp.sdc.versioning.dao.types.Version; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -46,6 +50,8 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements private static final UDTMapper<Version> versionMapper = noSqlDb.getMappingManager().udtMapper(Version.class); + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + @Override protected Mapper<PackageInfo> getMapper() { return mapper; @@ -63,6 +69,8 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements @Override public List<PackageInfo> listByCategory(String category, String subCategory) { + + mdcDataDebugMessage.debugEntryMessage(null, null); Result<PackageInfo> packages = accessor.listInfo(); List<PackageInfo> filteredPackages = new ArrayList<>(); @@ -79,7 +87,7 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements filteredPackages.add(packageInfo); } } - + mdcDataDebugMessage.debugExitMessage(null, null); return filteredPackages; } @@ -88,16 +96,25 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements accessor.deleteRowTranslateContent(vspId, version); } + @Override + public void updateTranslatedContent(String vspId, Version version, ByteBuffer translateContent){ + accessor.updateTranslateContent(translateContent, vspId, versionMapper.toUDT(version)); + } + @Accessor interface PackageInfoAccessor { @Query( - "SELECT vsp_id,version,display_name,vsp_name,vsp_description,vendor_name,category," - + "sub_category,vendor_release,package_checksum,package_type FROM package_details") + "SELECT vsp_id,version,display_name,vsp_name,vsp_description,vendor_name,category" + + " ,sub_category, vendor_release,package_checksum,package_type FROM package_details") Result<PackageInfo> listInfo(); @Query("DELETE TRANSLATE_CONTENT FROM package_details WHERE vsp_id=? and version=?") Result<PackageInfo> deleteRowTranslateContent(String vspId, Version version); + @Query("UPDATE package_details set translate_content = ? where vsp_id = ? and version = ?") + Result<PackageInfo> updateTranslateContent(ByteBuffer translateContent, String vspId, + UDTValue version); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessArtifactDaoCassandraImpl.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/ProcessArtifactDaoCassandraImpl.java deleted file mode 100644 index 0e9fd90a13..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessArtifactDaoCassandraImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; - -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.UDTValue; -import com.datastax.driver.mapping.UDTMapper; -import com.datastax.driver.mapping.annotations.Accessor; -import com.datastax.driver.mapping.annotations.Query; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessArtifactDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessArtifactEntity; -import org.openecomp.sdc.versioning.dao.types.Version; - -import java.nio.ByteBuffer; - -public class ProcessArtifactDaoCassandraImpl implements ProcessArtifactDao { - - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final ProcessArtifactAccessor accessor = - noSqlDb.getMappingManager().createAccessor(ProcessArtifactAccessor.class); - private static final UDTMapper<Version> versionMapper = - noSqlDb.getMappingManager().udtMapper(Version.class); - - @Override - public void update(ProcessArtifactEntity entity) { - accessor.update(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getId(), entity.getArtifactName(), entity.getArtifact()); - } - - @Override - public ProcessArtifactEntity get(ProcessArtifactEntity entity) { - return accessor - .get(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), entity.getComponentId(), - entity.getId()); - } - - @Override - public void delete(ProcessArtifactEntity entity) { - accessor.delete(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getId()); - } - - @Accessor - interface ProcessArtifactAccessor { - - @Query( - "insert into vsp_process (vsp_id, version, component_id, process_id, artifact_name," - + " artifact) values (?,?,?,?,?,?)") - ResultSet update(String vspId, UDTValue version, String componentId, String id, - String artifactName, ByteBuffer artifact); - - @Query( - "select vsp_id, version, component_id, process_id, artifact_name, artifact " - + "from vsp_process where vsp_id=? and version=? and component_id=? and process_id=?") - ProcessArtifactEntity get(String vspId, UDTValue version, String componentId, String id); - - @Query( - "delete artifact_name, artifact from vsp_process where vsp_id=? and version=? and" - + " component_id=? and process_id=?") - ResultSet delete(String vspId, UDTValue version, String componentId, String 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/ProcessDaoCassandraImpl.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/ProcessDaoCassandraImpl.java deleted file mode 100644 index b8900eb5d3..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoCassandraImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; - -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.UDTValue; -import com.datastax.driver.mapping.Mapper; -import com.datastax.driver.mapping.Result; -import com.datastax.driver.mapping.UDTMapper; -import com.datastax.driver.mapping.annotations.Accessor; -import com.datastax.driver.mapping.annotations.Query; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; -import org.openecomp.sdc.versioning.VersioningManagerFactory; -import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdc.versioning.types.UniqueValueMetadata; -import org.openecomp.sdc.versioning.types.VersionableEntityMetadata; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; - -public class ProcessDaoCassandraImpl implements ProcessDao { - - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<ProcessEntity> mapper = - noSqlDb.getMappingManager().mapper(ProcessEntity.class); - private static final ProcessAccessor accessor = - noSqlDb.getMappingManager().createAccessor(ProcessAccessor.class); - private static final UDTMapper<Version> versionMapper = - noSqlDb.getMappingManager().udtMapper(Version.class); - - @Override - public void registerVersioning(String versionableEntityType) { - VersionableEntityMetadata metadata = new VersionableEntityMetadata( - mapper.getTableMetadata().getName(), - mapper.getTableMetadata().getPartitionKey().get(0).getName(), - mapper.getTableMetadata().getPartitionKey().get(1).getName()); - - metadata.setUniqueValuesMetadata(Collections.singletonList( - new UniqueValueMetadata(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, - Arrays.asList("vsp_id", "version", "component_id", "name")))); - - VersioningManagerFactory.getInstance().createInterface() - .register(versionableEntityType, metadata); - } - - @Override - public Collection<ProcessEntity> list(ProcessEntity entity) { - return accessor - .list(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), entity.getComponentId()) - .all(); - } - - @Override - public void create(ProcessEntity entity) { - accessor.update(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getId(), entity.getName(), entity.getDescription()); - } - - @Override - public void update(ProcessEntity entity) { - accessor.update(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getId(), entity.getName(), entity.getDescription()); - } - - @Override - public ProcessEntity get(ProcessEntity entity) { - return accessor - .get(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), entity.getComponentId(), - entity.getId()); - } - - @Override - public void delete(ProcessEntity entity) { - if (entity.getId() == null) { - accessor.deleteAll(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId()); - } else { - accessor.delete(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getId()); - } - } - - public void deleteAll(ProcessEntity entity) { - accessor.deleteAll(entity.getVspId(), versionMapper.toUDT(entity.getVersion())); - } - - @Accessor - interface ProcessAccessor { - - @Query( - "insert into vsp_process (vsp_id, version, component_id, process_id, name, description) " - + "values (?,?,?,?,?,?)") - ResultSet update(String vspId, UDTValue version, String componentId, String id, String name, - String description); - - @Query( - "select vsp_id, version, component_id, process_id, name, description, artifact_name " - + "from vsp_process where vsp_id=? and version=? and component_id=? and process_id=?") - ProcessEntity get(String vspId, UDTValue version, String componentId, String id); - - @Query( - "select vsp_id, version, component_id, process_id, name, description, artifact_name " - + "from vsp_process where vsp_id=? and version=? and component_id=?") - Result<ProcessEntity> list(String vspId, UDTValue version, String componentId); - - @Query( - "delete from vsp_process where vsp_id=? and version=? and component_id=? and process_id=?") - ResultSet delete(String vspId, UDTValue version, String componentId, String id); - - @Query("delete from vsp_process where vsp_id=? and version=? and component_id=?") - ResultSet deleteAll(String vspId, UDTValue version, String componentId); - - @Query("delete from vsp_process where vsp_id=? and version=?") - ResultSet deleteAll(String vspId, UDTValue version); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java index 4c981d8448..ada76e790a 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 @@ -20,11 +20,14 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao; +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ProcessDaoZusammenImpl; public class ProcessDaoFactoryImpl extends ProcessDaoFactory { - private static final ProcessDao INSTANCE = new ProcessDaoCassandraImpl(); + private static final ProcessDao INSTANCE = new ProcessDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); @Override public ProcessDao 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/UploadDataDaoImpl.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/UploadDataDaoImpl.java deleted file mode 100644 index df019a4f53..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/UploadDataDaoImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; - -import com.datastax.driver.core.UDTValue; -import com.datastax.driver.mapping.Mapper; -import com.datastax.driver.mapping.Result; -import com.datastax.driver.mapping.UDTMapper; -import com.datastax.driver.mapping.annotations.Accessor; -import com.datastax.driver.mapping.annotations.Query; -import org.openecomp.core.dao.impl.CassandraBaseDao; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; -import org.openecomp.sdc.versioning.dao.types.Version; - -import java.nio.ByteBuffer; -import java.util.Collection; - -public class UploadDataDaoImpl extends CassandraBaseDao<UploadDataEntity> implements UploadDataDao { - - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<UploadDataEntity> mapper = - noSqlDb.getMappingManager().mapper(UploadDataEntity.class); - private static final UploadDataAccessor accessor = - noSqlDb.getMappingManager().createAccessor(UploadDataAccessor.class); - private static final UDTMapper<Version> versionMapper = - noSqlDb.getMappingManager().udtMapper(Version.class); - - @Override - protected Mapper<UploadDataEntity> getMapper() { - return mapper; - } - - @Override - protected Object[] getKeys(UploadDataEntity entity) { - return new Object[]{entity.getId(), versionMapper.toUDT(entity.getVersion())}; - } - - @Override - public Collection<UploadDataEntity> list(UploadDataEntity entity) { - return accessor.listAll().all(); - } - - @Override - public void deleteContentDataAndValidationData(String vspId, Version version) { - accessor.deleteContentDataAndValidationData(vspId, versionMapper.toUDT(version)); - } - - @Override - public ByteBuffer getContentData(String vspId, Version version) { - return accessor.getContentData(vspId, version).one().getContentData(); - } - - - @Accessor - interface UploadDataAccessor { - - @Query( - "SELECT package_name, package_version, content_data, validation_data FROM vsp_information") - Result<UploadDataEntity> listAll(); - - @Query( - "DELETE package_name, package_version, content_data, validation_data FROM vsp_information " - + "WHERE vsp_id=? and version=?") - Result<VspDetails> deleteContentDataAndValidationData(String vspId, UDTValue udtValue); - - @Query("SELECT CONTENT_DATA FROM vsp_information WHERE vsp_id=? and version=?") - Result<UploadDataEntity> getContentData(String vspId, Version version); - - } -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java index 587f8ac036..96bb16ca70 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/VendorSoftwareProductDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java @@ -20,9 +20,11 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory; + public class VendorSoftwareProductDaoFactoryImpl extends VendorSoftwareProductDaoFactory { private static final VendorSoftwareProductDao INSTANCE = new VendorSoftwareProductDaoImpl(); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java index f592e63280..c0a215fff5 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/VendorSoftwareProductDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java @@ -22,202 +22,97 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; import org.openecomp.core.model.dao.EnrichedServiceArtifactDao; import org.openecomp.core.model.dao.EnrichedServiceArtifactDaoFactory; +import org.openecomp.core.model.dao.EnrichedServiceModelDao; +import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory; import org.openecomp.core.model.dao.ServiceArtifactDaoFactory; import org.openecomp.core.model.dao.ServiceArtifactDaoInter; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDaoFactory; +import org.openecomp.core.model.dao.ServiceModelDao; +import org.openecomp.core.model.dao.ServiceModelDaoFactory; +import org.openecomp.core.model.dao.ServiceTemplateDaoFactory; +import org.openecomp.core.model.dao.ServiceTemplateDaoInter; +import org.openecomp.core.utilities.CommonMethods; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessArtifactDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessArtifactDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VspQuestionnaireDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VspQuestionnaireDaoFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentArtifactEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessArtifactEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; import org.openecomp.sdc.versioning.dao.types.Version; import java.nio.ByteBuffer; import java.util.Collection; import java.util.List; -import java.util.Objects; public class VendorSoftwareProductDaoImpl implements VendorSoftwareProductDao { - private static final VendorSoftwareProductInfoDao vspInfoDao = - VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(); + private static final VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory + .getInstance().createInterface(); private static final PackageInfoDao packageInfoDao = PackageInfoDaoFactory.getInstance().createInterface(); - private static final UploadDataDao uploadDataDao = - UploadDataDaoFactory.getInstance().createInterface(); - private static final VspQuestionnaireDao vspQuestionnaireDao = - VspQuestionnaireDaoFactory.getInstance().createInterface(); + private static final OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao = + OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface(); private static final NetworkDao networkDao = NetworkDaoFactory.getInstance().createInterface(); private static final ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface(); private static final NicDao nicDao = NicDaoFactory.getInstance().createInterface(); private static final ProcessDao processDao = ProcessDaoFactory.getInstance().createInterface(); - private static final ProcessArtifactDao processArtifactDao = - ProcessArtifactDaoFactory.getInstance().createInterface(); - private static final ComponentArtifactDao componentArtifactDao = - ComponentArtifactDaoFactory.getInstance().createInterface(); - private static final ServiceArtifactDaoInter artifactDao = - ServiceArtifactDaoFactory.getInstance().createInterface(); + private static final MibDao + MIB_DAO = MibDaoFactory.getInstance().createInterface(); + private static final ServiceArtifactDaoInter + artifactDao = ServiceArtifactDaoFactory.getInstance().createInterface(); + public static final ServiceTemplateDaoInter + templateDao = ServiceTemplateDaoFactory.getInstance().createInterface(); private static final EnrichedServiceArtifactDao enrichArtifactDao = EnrichedServiceArtifactDaoFactory.getInstance().createInterface(); + private static final EnrichedServiceModelDao enrichedServiceModelDao = + EnrichedServiceModelDaoFactory.getInstance().createInterface(); + private static final ServiceModelDao serviceModelDao = + ServiceModelDaoFactory.getInstance().createInterface(); + private static final ComponentDependencyModelDao componentDependencyModelDao = + ComponentDependencyModelDaoFactory.getInstance().createInterface(); @Override public void registerVersioning(String versionableEntityType) { vspInfoDao.registerVersioning(versionableEntityType); - vspQuestionnaireDao.registerVersioning(versionableEntityType); networkDao.registerVersioning(versionableEntityType); componentDao.registerVersioning(versionableEntityType); nicDao.registerVersioning(versionableEntityType); processDao.registerVersioning(versionableEntityType); + orchestrationTemplateCandidateDataDao.registerVersioning(versionableEntityType); + componentDependencyModelDao.registerVersioning(versionableEntityType); } @Override - public void createVendorSoftwareProductInfo(VspDetails vspDetails) { - vspInfoDao.create(vspDetails); - } - - @Override - public Collection<VspDetails> listVendorSoftwareProductsInfo() { - return vspInfoDao.list(new VspDetails()); - } - - public VspDetails getVendorSoftwareProductInfo(VspDetails vspDetails) { - return vspInfoDao.get(vspDetails); - } - - - @Override - public void updateVendorSoftwareProductInfo(VspDetails vspDetails) { - vspInfoDao.update(vspDetails); - } - - @Override - public void deleteVendorSoftwareProductInfo(VspDetails vspDetails) { - vspInfoDao.delete(vspDetails); - } - - @Override - public void updateUploadData(UploadDataEntity uploadData) { - uploadDataDao.update(uploadData); - } - - @Override - public UploadDataEntity getUploadData(UploadDataEntity uploadData) { - return uploadDataDao.get(uploadData); - } - - @Override - public ByteBuffer getContentData(UploadDataEntity uploadDataEntity) { - return uploadDataDao.getContentData(uploadDataEntity.getId(), uploadDataEntity.getVersion()); - } - - @Override - public void insertPackageDetails(PackageInfo packageInfo) { - packageInfoDao.update(packageInfo); - } - - @Override - public PackageInfo getPackageInfo(PackageInfo packageInfo) { - return packageInfoDao.get(packageInfo); - } - - @Override - public void deletePackageInfo(PackageInfo packageInfo) { - packageInfoDao.delete(packageInfo); - } - - @Override - public Collection<NetworkEntity> listNetworks(String vspId, Version version) { - return networkDao.list(new NetworkEntity(vspId, version, null)); - } - - @Override - public void createNetwork(NetworkEntity network) { - networkDao.create(network); - } - - @Override - public void updateNetwork(NetworkEntity networkEntity) { - networkDao.update(networkEntity); - } - - @Override - public NetworkEntity getNetwork(String vspId, Version version, String networkId) { - return networkDao.get(new NetworkEntity(vspId, version, networkId)); - } - - @Override - public void deleteNetwork(String vspId, Version version) { - NetworkEntity networkEntity = new NetworkEntity(vspId, version, null); - networkDao.delete(networkEntity); - } - - @Override - public List<PackageInfo> listPackages(String category, String subCategory) { - return packageInfoDao.listByCategory(category, subCategory); - } - - - @Override public Collection<ComponentEntity> listComponents(String vspId, Version version) { return componentDao.list(new ComponentEntity(vspId, version, null)); } @Override - public void createComponent(ComponentEntity component) { - componentDao.create(component); - } - - @Override - public void updateComponent(ComponentEntity component) { - componentDao.update(component); - } - - @Override - public ComponentEntity getComponent(String vspId, Version version, String componentId) { - return componentDao.get(new ComponentEntity(vspId, version, componentId)); - } - - @Override public Collection<ComponentEntity> listComponentsQuestionnaire(String vspId, Version version) { return componentDao.listQuestionnaires(vspId, version); } @Override - public void updateComponentQuestionnaire(String vspId, Version version, String componentId, - String questionnaireData) { - componentDao.updateQuestionnaireData(vspId, version, componentId, questionnaireData); - } - - @Override - public void deleteComponent(String vspId, Version version) { - ComponentEntity componentEntity = new ComponentEntity(vspId, version, null); - componentDao.delete(componentEntity); + public Collection<ComponentEntity> listComponentsCompositionAndQuestionnaire(String vspId, + Version version) { + return componentDao.listCompositionAndQuestionnaire(vspId, version); } @Override @@ -255,60 +150,25 @@ public class VendorSoftwareProductDaoImpl implements VendorSoftwareProductDao { @Override public void uploadProcessArtifact(String vspId, Version version, String componentId, String processId, byte[] artifact, String artifactName) { - ProcessArtifactEntity processArtifact = - new ProcessArtifactEntity(vspId, version, componentId, processId); + ProcessEntity + processArtifact = new ProcessEntity(vspId, version, componentId, processId); + processArtifact = processDao.get(processArtifact); processArtifact.setArtifact(ByteBuffer.wrap(artifact)); processArtifact.setArtifactName(artifactName); - processArtifactDao.update(processArtifact); + processDao.update(processArtifact); } @Override - public ProcessArtifactEntity getProcessArtifact(String vspId, Version version, String componentId, - String processId) { - return processArtifactDao - .get(new ProcessArtifactEntity(vspId, version, componentId, processId)); + public ProcessEntity getProcessArtifact(String vspId, Version version, String componentId, + String processId) { + return processDao + .get(new ProcessEntity(vspId, version, componentId, processId)); } @Override public void deleteProcessArtifact(String vspId, Version version, String componentId, String processId) { - processArtifactDao.delete(new ProcessArtifactEntity(vspId, version, componentId, processId)); - } - - @Override - public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) { - return vspQuestionnaireDao.get(new VspQuestionnaireEntity(vspId, version)); - } - - @Override - public void updateQuestionnaire(String vspId, Version version, String questionnaireData) { - vspQuestionnaireDao.updateQuestionnaireData(vspId, version, questionnaireData); - } - - @Override - public Collection<NicEntity> listNics(String vspId, Version version, String componentId) { - return nicDao.list(new NicEntity(vspId, version, componentId, null)); - } - - @Override - public void createNic(NicEntity nic) { - nicDao.create(nic); - } - - @Override - public NicEntity getNic(String vspId, Version version, String componentId, String nicId) { - return nicDao.get(new NicEntity(vspId, version, componentId, nicId)); - } - - @Override - public void updateNic(NicEntity nicEntity) { - nicDao.update(nicEntity); - } - - @Override - public void updateNicQuestionnaire(String vspId, Version version, String componentId, - String nicId, String questionnaireData) { - nicDao.updateQuestionnaireData(vspId, version, componentId, nicId, questionnaireData); + processDao.delete(new ProcessEntity(vspId, version, componentId, processId)); } @Override @@ -317,33 +177,49 @@ public class VendorSoftwareProductDaoImpl implements VendorSoftwareProductDao { } @Override - public void deleteNic(String vspId, Version version, String componentId) { - NicEntity nicEntity = new NicEntity(vspId, version, componentId, null); - nicDao.delete(nicEntity); - } - - @Override public void deleteUploadData(String vspId, Version version) { + networkDao.deleteAll(vspId, version); - nicDao.deleteByVspId(vspId, version); - artifactDao.delete(vspId, version); - enrichArtifactDao.delete(vspId, version); - ComponentArtifactEntity componentArtifactEntity = - new ComponentArtifactEntity(vspId, version, null, null); - ProcessEntity processEntity = new ProcessEntity(vspId, version, null, null); - componentArtifactDao.deleteAll(componentArtifactEntity); - processDao.deleteAll(processEntity); + //nicDao.deleteByVspId(vspId, version); + //artifactDao.delete(vspId, version); + //templateDao.deleteAll(vspId, version); + enrichedServiceModelDao.deleteAll(vspId, version); + serviceModelDao.deleteAll(vspId, version); + //processDao.deleteVspAll(vspId,version); componentDao.deleteAll(vspId, version); - uploadDataDao.deleteContentDataAndValidationData(vspId, version); + vspInfoDao.deleteAll(vspId, version); + +// uploadDataDao.deleteContentDataAndValidationData(vspId, version); + +// enrichArtifactDao.deleteAll(vspId, version); +// artifactDao.deleteAll(vspId, version); } - @Override - public void updateVspLatestModificationTime(String vspId, Version version) { - if (Objects.isNull(vspId) || Objects.isNull(version)) { + /* @Override + public void updateVspLatestModificationTime(String vspId, Version version) { + *//* if (Objects.isNull(vspId) || Objects.isNull(version)) { return; } VspDetails retrieved = getVendorSoftwareProductInfo(new VspDetails(vspId, version)); - updateVendorSoftwareProductInfo(retrieved); + updateVendorSoftwareProductInfo(retrieved);*//* + } +*/ + @Override + public void createComponentDependencyModel(List<ComponentDependencyModelEntity> + componentDependencyModel, String vspId, + Version version) { + componentDependencyModelDao.deleteAll(vspId, version); + for (ComponentDependencyModelEntity entity : componentDependencyModel) { + entity.setId(CommonMethods.nextUuId()); + componentDependencyModelDao.create(entity); + } + } + + @Override + public Collection<ComponentDependencyModelEntity> listComponentDependencies(String vspId, + Version version) { + return componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, + null)); } } 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 1dcb3f4c66..a5f9d17431 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 @@ -20,12 +20,15 @@ package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.VendorSoftwareProductInfoDaoZusammenImpl; public class VendorSoftwareProductInfoDaoFactoryImpl extends VendorSoftwareProductInfoDaoFactory { private static final VendorSoftwareProductInfoDao INSTANCE = - new VendorSoftwareProductInfoDaoImpl(); + new VendorSoftwareProductInfoDaoZusammenImpl( + ZusammenAdaptorFactory.getInstance().createInterface()); @Override public VendorSoftwareProductInfoDao 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/VendorSoftwareProductInfoDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java index c3096dab29..5a8635cf98 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java @@ -30,6 +30,7 @@ import org.openecomp.core.nosqldb.api.NoSqlDb; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; import org.openecomp.sdc.versioning.VersioningManagerFactory; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.types.VersionableEntityMetadata; @@ -71,13 +72,39 @@ public class VendorSoftwareProductInfoDaoImpl extends CassandraBaseDao<VspDetail return accessor.listAll().all(); } + @Override + public void updateOldVersionIndication(VspDetails vspDetails) { + + } + + @Override + public void updateQuestionnaireData(String vspId, Version version, + String questionnaireData) { + + } + + @Override + public String getQuestionnaireData(String vspId, Version version) { + return null; + } + + @Override + public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) { + return null; + } + + @Override + public void deleteAll(String vspId, Version version) { + + } + + @Accessor interface VendorSoftwareProductInfoAccessor { @Query( - "SELECT vsp_id,version,name,description,icon,category,sub_category,vendor_id," - + "vlm_version,license_agreement,feature_groups FROM vsp_information") + "SELECT vsp_id,version,name,description,icon,category,sub_category,vendor_id,vlm_version," + + "license_agreement,feature_groups, is_old_version FROM vsp_information") Result<VspDetails> listAll(); - } } 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/VspQuestionnaireDaoCassandraImpl.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/VspQuestionnaireDaoCassandraImpl.java deleted file mode 100644 index ef4dd0de74..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspQuestionnaireDaoCassandraImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; - -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.UDTValue; -import com.datastax.driver.mapping.Mapper; -import com.datastax.driver.mapping.UDTMapper; -import com.datastax.driver.mapping.annotations.Accessor; -import com.datastax.driver.mapping.annotations.Query; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VspQuestionnaireDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; -import org.openecomp.sdc.versioning.VersioningManagerFactory; -import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdc.versioning.types.VersionableEntityMetadata; - -public class VspQuestionnaireDaoCassandraImpl implements VspQuestionnaireDao { - - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<VspQuestionnaireEntity> mapper = - noSqlDb.getMappingManager().mapper(VspQuestionnaireEntity.class); - private static final VspQuestionnaireAccessor accessor = - noSqlDb.getMappingManager().createAccessor(VspQuestionnaireAccessor.class); - private static final UDTMapper<Version> versionMapper = - noSqlDb.getMappingManager().udtMapper(Version.class); - - @Override - public void registerVersioning(String versionableEntityType) { - VersioningManagerFactory.getInstance().createInterface() - .register(versionableEntityType, new VersionableEntityMetadata( - mapper.getTableMetadata().getName(), - mapper.getTableMetadata().getPartitionKey().get(0).getName(), - mapper.getTableMetadata().getPartitionKey().get(1).getName())); - } - - @Override - public VspQuestionnaireEntity get(VspQuestionnaireEntity entity) { - return mapper.get(entity.getId(), versionMapper.toUDT(entity.getVersion())); - } - - @Override - public void updateQuestionnaireData(String id, Version version, String questionnaireData) { - accessor.updateQuestionnaireData(questionnaireData, id, versionMapper.toUDT(version)); - } - - @Accessor - interface VspQuestionnaireAccessor { - - @Query("update vsp_information set questionnaire_data=? where vsp_id=? and version=?") - ResultSet updateQuestionnaireData(String questionnaireData, String id, UDTValue version); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/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 new file mode 100644 index 0000000000..8ef09ada7b --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java @@ -0,0 +1,244 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.ByteArrayInputStream; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; + +public class ComponentDaoZusammenImpl implements ComponentDao { + + private ZusammenAdaptor zusammenAdaptor; + + public ComponentDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void registerVersioning(String versionableEntityType) { + } + + @Override + public Collection<ComponentEntity> list(ComponentEntity component) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(component.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(component.getVersion())); + + return listComponents(zusammenAdaptor, context, elementContext, component.getVspId(), + component.getVersion()); + } + + static Collection<ComponentEntity> listComponents(ZusammenAdaptor zusammenAdaptor, + SessionContext context, + ElementContext elementContext, + String vspId, Version version) { + return zusammenAdaptor + .listElementsByName(context, elementContext, null, StructureElement.Components.name()) + .stream().map(elementInfo -> mapElementInfoToComponent(vspId, version, elementInfo)) + .collect(Collectors.toList()); + } + + private static ComponentEntity mapElementInfoToComponent(String vspId, Version version, + ElementInfo elementInfo) { + ComponentEntity componentEntity = + new ComponentEntity(vspId, version, elementInfo.getId().getValue()); + componentEntity.setCompositionData( + elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name())); + return componentEntity; + } + + @Override + public void create(ComponentEntity component) { + ZusammenElement componentElement = componentToZusammen(component, Action.CREATE); + ZusammenElement componentsElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Components, null); + componentsElement.getSubElements().add(componentElement); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(component.getVspId()); + Optional<Element> savedElement = zusammenAdaptor.saveElement(context, + new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), + componentsElement, "Create component"); + savedElement.ifPresent(element -> + component.setId(element.getSubElements().iterator().next().getElementId().getValue())); + } + + @Override + public void update(ComponentEntity component) { + ZusammenElement componentElement = componentToZusammen(component, Action.UPDATE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(component.getVspId()); + zusammenAdaptor.saveElement(context, + new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), + componentElement, String.format("Update component with id %s", component.getId())); + } + + @Override + public ComponentEntity get(ComponentEntity component) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(component.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(component.getVersion())); + + Optional<Element> element = + zusammenAdaptor.getElement(context, elementContext, component.getId()); + + if (element.isPresent()) { + component.setCompositionData(new String(FileUtils.toByteArray(element.get().getData()))); + return component; + } + return null; + } + + @Override + public void delete(ComponentEntity component) { + ZusammenElement componentElement = new ZusammenElement(); + componentElement.setElementId(new Id(component.getId())); + componentElement.setAction(Action.DELETE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(component.getVspId()); + zusammenAdaptor.saveElement(context, + new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), + componentElement, String.format("Delete component with id %s", component.getId())); + } + + @Override + public ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(version)); + + return getQuestionnaire(context, elementContext, + 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()), + StructureElement.Questionnaire.name()); + return questionnaireElement.map( + element -> element.getData() == null + ? null + : new String(FileUtils.toByteArray(element.getData()))) + .map(questionnaireData -> { + component.setQuestionnaireData(questionnaireData); + return component; + }) + .orElse(null); + } + + @Override + public void updateQuestionnaireData(String vspId, Version version, String componentId, + String questionnaireData) { + ZusammenElement questionnaireElement = + componentQuestionnaireToZusammen(questionnaireData, Action.UPDATE); + + ZusammenElement componentElement = new ZusammenElement(); + componentElement.setAction(Action.IGNORE); + componentElement.setElementId(new Id(componentId)); + componentElement.setSubElements(Collections.singletonList(questionnaireElement)); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + zusammenAdaptor.saveElement(context, + new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), + 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 = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(version)); + + Collection<ComponentEntity> components = + listComponents(zusammenAdaptor, context, elementContext, vspId, version); + + components.forEach(component -> getQuestionnaire(context, elementContext, component)); + return components; + } + + @Override + public void deleteAll(String vspId, Version version) { + ZusammenElement componentsElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Components, Action.DELETE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + zusammenAdaptor.saveElement(context, + new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), + componentsElement, "Delete all components"); + } + + private ZusammenElement componentToZusammen(ComponentEntity component, Action action) { + ZusammenElement componentElement = buildComponentElement(component, action); + if (action == Action.CREATE) { + componentElement + .setSubElements(Arrays.asList( + componentQuestionnaireToZusammen(component.getQuestionnaireData(), Action.CREATE), + VspZusammenUtil.buildStructuralElement(StructureElement.Nics, Action.CREATE), + VspZusammenUtil.buildStructuralElement(StructureElement.Processes, Action.CREATE), + VspZusammenUtil.buildStructuralElement(StructureElement.Mibs, Action.CREATE))); + } + return componentElement; + } + + private ZusammenElement componentQuestionnaireToZusammen(String questionnaireData, + Action action) { + ZusammenElement questionnaireElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action); + questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); + return questionnaireElement; + } + + private ZusammenElement buildComponentElement(ComponentEntity component, Action action) { + ZusammenElement componentElement = new ZusammenElement(); + componentElement.setAction(action); + if (component.getId() != null) { + componentElement.setElementId(new Id(component.getId())); + } + Info info = new Info(); + info.addProperty(ElementPropertyName.type.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 new file mode 100644 index 0000000000..e36b6c7743 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java @@ -0,0 +1,201 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * Created by ayalaben on 5/16/2017. + */ +public class ComponentDependencyModelDaoZusammenImpl implements ComponentDependencyModelDao { + + private static final Logger logger = + LoggerFactory.getLogger(OrchestrationTemplateCandidateDaoZusammenImpl.class); + + private ZusammenAdaptor zusammenAdaptor; + + public ComponentDependencyModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public ComponentDependencyModelEntity get(ComponentDependencyModelEntity entity) { + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(entity.getVspId()); // entity.getId()? + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(entity.getVersion())); + + Optional<ElementInfo> componentDependencyElement = + zusammenAdaptor.getElementInfo(context, elementContext, new Id(entity.getId())); + + if (componentDependencyElement.isPresent()) { + addComponentDependencyData(entity, componentDependencyElement.get()); + return entity; + } + + return null; + } + + @Override + public void create(ComponentDependencyModelEntity entity) { + + ZusammenElement componentDependencies = + VspZusammenUtil.buildStructuralElement(StructureElement.ComponentDependencies, null); + + ZusammenElement componentDependency = buildComponentDependencyElement(entity); + componentDependency.setAction(Action.CREATE); + + Id itemId = new Id(entity.getVspId()); + SessionContext context = ZusammenUtil.createSessionContext(); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + Optional<Element> savedElement = zusammenAdaptor.saveElement(context, elementContext, + VspZusammenUtil.aggregateElements(componentDependencies, componentDependency), + "Create component dependency model"); + + savedElement.ifPresent(element -> + entity.setId(element.getSubElements().iterator().next().getElementId().getValue())); + } + + @Override + public void update(ComponentDependencyModelEntity entity) { + ZusammenElement componentDependencyElement = buildComponentDependencyElement(entity); + componentDependencyElement.setAction(Action.UPDATE); + + Id itemId = new Id(entity.getVspId()); + SessionContext context = ZusammenUtil.createSessionContext(); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + zusammenAdaptor.saveElement(context, elementContext, + componentDependencyElement, + String.format("Update component dependency model with id %s", entity.getId())); + } + + @Override + public void delete(ComponentDependencyModelEntity entity) { + ZusammenElement componentDependencyElement = new ZusammenElement(); + componentDependencyElement.setElementId(new Id(entity.getId())); + componentDependencyElement.setAction(Action.DELETE); + + Id itemId = new Id(entity.getVspId()); + SessionContext context = ZusammenUtil.createSessionContext(); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + + zusammenAdaptor.saveElement(context, elementContext, + componentDependencyElement, + String.format("Delete component dependency model with id %s", entity.getId())); + } + + @Override + public void deleteAll(String vspId, Version version) { + ZusammenElement componentDependenciesElement = + VspZusammenUtil + .buildStructuralElement(StructureElement.ComponentDependencies, Action.DELETE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + zusammenAdaptor.saveElement(context, new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), + componentDependenciesElement, "Delete all component dependencies"); + } + + @Override + public void registerVersioning(String versionableEntityType) { + //not implemented? + } + + @Override + public Collection<ComponentDependencyModelEntity> list(ComponentDependencyModelEntity entity) { + + Id itemId = new Id(entity.getVspId()); + SessionContext context = ZusammenUtil.createSessionContext(); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(entity.getVersion())); + + return zusammenAdaptor.listElementsByName(context, elementContext, + null, StructureElement.ComponentDependencies.name()) + .stream().map(elementInfo -> mapElementInfoToComponentDependencyModel(entity.getVspId(), + entity.getVersion(), elementInfo)) + .collect(Collectors.toList()); + } + + private static ComponentDependencyModelEntity mapElementInfoToComponentDependencyModel( + String vspId, Version version, + ElementInfo elementInfo) { + ComponentDependencyModelEntity componentDependencyModelEntity = + new ComponentDependencyModelEntity(vspId, version, elementInfo.getId().getValue()); + componentDependencyModelEntity.setSourceComponentId(elementInfo.getInfo() + .getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name())); + componentDependencyModelEntity.setTargetComponentId(elementInfo.getInfo() + .getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name())); + componentDependencyModelEntity.setRelation(elementInfo.getInfo() + .getProperty(ComponentDependencyModelPropertyName.relation.name())); + + return componentDependencyModelEntity; + } + + + private ZusammenElement buildComponentDependencyElement(ComponentDependencyModelEntity entity) { + ZusammenElement componentDependencyElement = new ZusammenElement(); + + if (entity.getId() != null) { + componentDependencyElement.setElementId(new Id(entity.getId())); + } + + Info info = new Info(); + info.addProperty(ComponentDependencyModelPropertyName.id.name(), entity.getId()); + info.addProperty(ComponentDependencyModelPropertyName.relation.name(), entity.getRelation()); + info.addProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name(), + entity.getSourceComponentId()); + info.addProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name(), + entity.getTargetComponentId()); + + componentDependencyElement.setInfo(info); + + return componentDependencyElement; + } + + private void addComponentDependencyData(ComponentDependencyModelEntity componentDependency, + ElementInfo componentDependencyElement) { + componentDependency.setId(componentDependencyElement.getInfo() + .getProperty(ComponentDependencyModelPropertyName.id.name())); + componentDependency.setRelation(componentDependencyElement.getInfo() + .getProperty(ComponentDependencyModelPropertyName.id.name())); + componentDependency.setSourceComponentId(componentDependencyElement.getInfo() + .getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name())); + componentDependency.setTargetComponentId(componentDependencyElement.getInfo() + .getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name())); + } + + + private enum ComponentDependencyModelPropertyName { + id, + relation, + sourcecomponent_id, + targetcomponent_id, + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java new file mode 100644 index 0000000000..9ca0bf721a --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java @@ -0,0 +1,6 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +public enum ElementPropertyName { + type, + compositionData +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java new file mode 100644 index 0000000000..b0313f5b14 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java @@ -0,0 +1,9 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +public enum ElementType { + Network, + Component, + Nic, + Process, + LKG +} 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/MibDaoZusammenImpl.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/MibDaoZusammenImpl.java new file mode 100644 index 0000000000..10cdfbd9da --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/MibDaoZusammenImpl.java @@ -0,0 +1,171 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import org.openecomp.core.enrichment.types.ArtifactType; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity; +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 java.util.stream.Collectors; + +/** + * @author Avrahamg. + * @since March 21, 2017 + */ +public class MibDaoZusammenImpl implements MibDao { + + private static final String ARTIFACT_NAME = "name"; + + private ZusammenAdaptor zusammenAdaptor; + + public MibDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void registerVersioning(String versionableEntityType) { + + } + + @Override + public Optional<MibEntity> getByType(MibEntity mibEntity) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(mibEntity.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(mibEntity.getVersion())); + + Optional<Element> mibsElement = + zusammenAdaptor.getElementByName(context, elementContext, new Id(mibEntity + .getComponentId()), StructureElement.Mibs.toString()); + if (mibsElement.isPresent()) { + Optional<Element> mibElement = zusammenAdaptor + .getElementByName(context, elementContext, mibsElement.get().getElementId(), + getMibStructuralElement(mibEntity.getType()).toString()); + if (mibElement.isPresent()) { + mibEntity.setId(mibElement.get().getElementId().getValue()); + mibEntity.setArtifactName((String) mibElement.get().getInfo().getProperties().get(ARTIFACT_NAME)); + mibEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(mibElement.get().getData()))); + return Optional.of(mibEntity); + } + } + + return Optional.empty(); + } + + @Override + public void create(MibEntity mibEntity) { + ZusammenElement mibElement = buildMibElement(mibEntity); + + ZusammenElement mibsElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Mibs, null); + + ZusammenElement componentElement = buildComponentElement(mibEntity); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(mibEntity.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + Optional<Element> savedElement = zusammenAdaptor.saveElement(context, elementContext, + VspZusammenUtil.aggregateElements(componentElement, mibsElement, mibElement), + "Create mib"); + savedElement.ifPresent(element -> + mibEntity.setId(element.getSubElements().iterator().next() + .getSubElements().iterator().next().getElementId().getValue())); + } + + @Override + public void delete(MibEntity mibEntity) { + ZusammenElement mibElement = new ZusammenElement(); + mibElement.setElementId(new Id(mibEntity.getId())); + mibElement.setAction(Action.DELETE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(mibEntity.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + zusammenAdaptor.saveElement(context, elementContext, mibElement, + String.format("Delete mib with id %s", mibEntity.getId())); + } + + @Override + public Collection<MibEntity> list(MibEntity mib) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(mib.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(mib.getVersion())); + + return zusammenAdaptor.listElementsByName(context, elementContext, new Id(mib.getComponentId()), + StructureElement.Mibs.toString()).stream() + .map(elementInfo -> + mapElementInfoToMib(mib.getVspId(), mib.getVersion(), mib.getComponentId(), + elementInfo)) + .collect(Collectors.toList()); + } + + @Override + public void deleteAll(MibEntity mibEntity) { + ZusammenElement mibsElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Mibs, Action.DELETE); + + ZusammenElement componentElement = buildComponentElement(mibEntity); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(mibEntity.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + zusammenAdaptor.saveElement(context, elementContext, + VspZusammenUtil.aggregateElements(componentElement, mibsElement), "Delete mibs"); + } + + private ZusammenElement buildComponentElement(MibEntity mibEntity) { + ZusammenElement componentElement = new ZusammenElement(); + componentElement.setElementId(new Id(mibEntity.getComponentId())); + componentElement.setAction(Action.IGNORE); + return componentElement; + } + + private ZusammenElement buildMibElement(MibEntity mib) { + ZusammenElement mibElement = VspZusammenUtil + .buildStructuralElement(getMibStructuralElement(mib.getType()), Action.UPDATE); + mibElement.getInfo().getProperties().put(ARTIFACT_NAME, mib.getArtifactName()); + mibElement.setData(new ByteArrayInputStream(mib.getArtifact().array())); + return mibElement; + } + + private MibEntity mapElementInfoToMib(String vspId, Version version, String componentId, + ElementInfo elementInfo) { + MibEntity mib = new MibEntity(vspId, version, componentId, elementInfo.getId().getValue()); + mib.setArtifactName((String) elementInfo.getInfo().getProperties().get(ARTIFACT_NAME)); + mib.setType(ArtifactType.valueOf(elementInfo.getInfo().getName())); + return mib; + } + + private StructureElement getMibStructuralElement(ArtifactType type) { + switch (type) { + case SNMP_POLL: + return StructureElement.SNMP_POLL; + case SNMP_TRAP: + return StructureElement.SNMP_TRAP; + 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/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 new file mode 100644 index 0000000000..898ee434e8 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java @@ -0,0 +1,150 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; + +import java.io.ByteArrayInputStream; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; + +public class NetworkDaoZusammenImpl implements NetworkDao { + + private ZusammenAdaptor zusammenAdaptor; + + public NetworkDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void registerVersioning(String versionableEntityType) { + + } + + @Override + public Collection<NetworkEntity> list(NetworkEntity network) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(network.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(network.getVersion())); + + return zusammenAdaptor + .listElementsByName(context, elementContext, null, StructureElement.Networks.name()) + .stream().map(elementInfo -> + mapElementInfoToNetwork(network.getVspId(), network.getVersion(), elementInfo)) + .collect(Collectors.toList()); + } + + private NetworkEntity mapElementInfoToNetwork(String vspId, Version version, + ElementInfo elementInfo) { + NetworkEntity networkEntity = + new NetworkEntity(vspId, version, elementInfo.getId().getValue()); + networkEntity.setCompositionData( + elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name())); + return networkEntity; + } + + @Override + public void create(NetworkEntity network) { + ZusammenElement networkElement = buildNetworkElement(network, Action.CREATE); + ZusammenElement networksElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Networks, null); + networksElement.setSubElements(Collections.singletonList(networkElement)); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(network.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + Optional<Element> savedElement = + zusammenAdaptor.saveElement(context, elementContext, networksElement, "Create network"); + savedElement.ifPresent(element -> + network.setId(element.getSubElements().iterator().next().getElementId().getValue())); + } + + @Override + public void update(NetworkEntity network) { + ZusammenElement networkElement = buildNetworkElement(network, Action.UPDATE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(network.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + zusammenAdaptor.saveElement(context, elementContext, networkElement, + String.format("Update network with id %s", network.getId())); + } + + @Override + public NetworkEntity get(NetworkEntity network) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(network.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(network.getVersion())); + + Optional<Element> element = + zusammenAdaptor.getElement(context, elementContext, network.getId()); + + if (element.isPresent()) { + network.setCompositionData(new String(FileUtils.toByteArray(element.get().getData()))); + return network; + } else { + return null; + } + } + + @Override + public void delete(NetworkEntity network) { + ZusammenElement networkElement = new ZusammenElement(); + networkElement.setElementId(new Id(network.getId())); + networkElement.setAction(Action.DELETE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(network.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + zusammenAdaptor.saveElement(context, elementContext, + networkElement, String.format("Delete network with id %s", network.getId())); + } + + + @Override + public void deleteAll(String vspId, Version version) { + ZusammenElement networksElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Networks, Action.DELETE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + zusammenAdaptor.saveElement(context, elementContext, networksElement, "Delete all networks"); + } + + private ZusammenElement buildNetworkElement(NetworkEntity network, Action action) { + ZusammenElement networkElement = new ZusammenElement(); + networkElement.setAction(action); + if (network.getId() != null) { + networkElement.setElementId(new Id(network.getId())); + } + Info info = new Info(); + info.addProperty(ElementPropertyName.type.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 new file mode 100644 index 0000000000..e597068d87 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java @@ -0,0 +1,257 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.versioning.dao.types.Version; + +import 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 { + + private ZusammenAdaptor zusammenAdaptor; + + public NicDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void registerVersioning(String versionableEntityType) { + + } + + @Override + public Collection<NicEntity> list(NicEntity nic) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(nic.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(nic.getVersion())); + + return listNics(context, elementContext, nic); + } + + private Collection<NicEntity> listNics(SessionContext context, ElementContext elementContext, + NicEntity nic) { + return zusammenAdaptor + .listElementsByName(context, elementContext, new Id(nic.getComponentId()), + StructureElement.Nics.name()) + .stream().map(elementInfo -> mapElementInfoToNic( + nic.getVspId(), nic.getVersion(), nic.getComponentId(), elementInfo)) + .collect(Collectors.toList()); + } + + private NicEntity mapElementInfoToNic(String vspId, Version version, + String componentId, ElementInfo elementInfo) { + NicEntity nicEntity = + new NicEntity(vspId, version, componentId, elementInfo.getId().getValue()); + nicEntity.setCompositionData( + elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name())); + return nicEntity; + } + + @Override + public void create(NicEntity nic) { + ZusammenElement nicElement = nicToZusammen(nic, Action.CREATE); + + ZusammenElement nicsElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Nics, null); + nicsElement.setSubElements(Collections.singletonList(nicElement)); + + ZusammenElement componentElement = + buildZusammenElement(new Id(nic.getComponentId()), Action.IGNORE); + componentElement.setSubElements(Collections.singletonList(nicsElement)); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(nic.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + Optional<Element> savedElement = + zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create nic"); + savedElement.ifPresent(element -> + nic.setId(element.getSubElements().iterator().next() + .getSubElements().iterator().next().getElementId().getValue())); + } + + @Override + public void update(NicEntity nic) { + ZusammenElement nicElement = nicToZusammen(nic, Action.UPDATE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(nic.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + zusammenAdaptor.saveElement(context, elementContext, nicElement, + String.format("Update nic with id %s", nic.getId())); + } + + @Override + public NicEntity get(NicEntity nic) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(nic.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(nic.getVersion())); + Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, nic.getId()); + + if (element.isPresent()) { + nic.setCompositionData(new String(FileUtils.toByteArray(element.get().getData()))); + return nic; + } else { + return null; + } + } + + @Override + public void delete(NicEntity nic) { + ZusammenElement nicElement = buildZusammenElement(new Id(nic.getId()), Action.DELETE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(nic.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + zusammenAdaptor.saveElement(context, elementContext, nicElement, + String.format("Delete nic with id %s", nic.getId())); + } + + @Override + public NicEntity getQuestionnaireData(String vspId, Version version, String componentId, + String nicId) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(version)); + + return getQuestionnaire(context, elementContext, + 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()), + StructureElement.Questionnaire.name()); + return questionnaireElement.map( + element -> element.getData() == null + ? null + : new String(FileUtils.toByteArray(element.getData()))) + .map(questionnaireData -> { + nic.setQuestionnaireData(questionnaireData); + return nic; + }) + .orElse(null); + } + + @Override + public void updateQuestionnaireData(String vspId, Version version, String componentId, + String nicId, String questionnaireData) { + ZusammenElement questionnaireElement = + nicQuestionnaireToZusammen(questionnaireData, Action.UPDATE); + + ZusammenElement nicElement = new ZusammenElement(); + nicElement.setAction(Action.IGNORE); + nicElement.setElementId(new Id(nicId)); + nicElement.setSubElements(Collections.singletonList(questionnaireElement)); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + zusammenAdaptor.saveElement(context, elementContext, nicElement, "Update nic questionnaire"); + } + + @Override + public Collection<NicEntity> listByVsp(String vspId, Version version) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(version)); + + Collection<ComponentEntity> components = ComponentDaoZusammenImpl + .listComponents(zusammenAdaptor, context, elementContext, vspId, version); + + return components.stream() + .map(component -> + listNics(context, elementContext, + new NicEntity(vspId, version, component.getId(), null)).stream() + .map(nic -> getQuestionnaire(context, elementContext, nic)) + .collect(Collectors.toList())) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + } + + @Override + public void deleteByComponentId(String vspId, Version version, String componentId) { + ZusammenElement componentElement = buildZusammenElement(new Id(componentId), Action.IGNORE); + componentElement.setSubElements(Collections.singletonList( + VspZusammenUtil.buildStructuralElement(StructureElement.Nics, Action.DELETE))); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + zusammenAdaptor.saveElement(context, elementContext, componentElement, + String.format("Delete all nics of component %s", componentId)); + } + + @Override + public void deleteByVspId(String vspId, Version version) { + + } + + 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 = + VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action); + questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); + return questionnaireElement; + } + + private ZusammenElement buildZusammenElement(Id elementId, Action action) { + ZusammenElement element = new ZusammenElement(); + element.setElementId(elementId); + element.setAction(action); + return element; + } + + private ZusammenElement buildNicElement(NicEntity nic, Action action) { + ZusammenElement nicElement = new ZusammenElement(); + nicElement.setAction(action); + if (nic.getId() != null) { + nicElement.setElementId(new Id(nic.getId())); + } + Info info = new Info(); + info.addProperty(ElementPropertyName.type.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 new file mode 100644 index 0000000000..c101955292 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java @@ -0,0 +1,134 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.utils.fileutils.FileUtils; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; + +import java.io.ByteArrayInputStream; +import java.nio.ByteBuffer; +import java.util.Optional; + +public class OrchestrationTemplateCandidateDaoZusammenImpl + implements OrchestrationTemplateCandidateDao { + private static final Logger logger = + LoggerFactory.getLogger(OrchestrationTemplateCandidateDaoZusammenImpl.class); + + private ZusammenAdaptor zusammenAdaptor; + + public OrchestrationTemplateCandidateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void registerVersioning(String versionableEntityType) { + + } + + @Override + public OrchestrationTemplateCandidateData get(String vspId, Version version) { + logger.info("Getting orchestration template for vsp id -> " + vspId); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor); + ElementContext elementContext = new ElementContext(itemId, versionId, + VspZusammenUtil.getVersionTag(version)); + + Optional<Element> candidateElement = + zusammenAdaptor.getElementByName(context, elementContext, null, + StructureElement.OrchestrationTemplateCandidate.name()); + if (candidateElement.isPresent()) { + OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData(); + candidateData.setFilesDataStructure( + new String(FileUtils.toByteArray(candidateElement.get().getData()))); + + zusammenAdaptor + .getElementByName(context, elementContext, candidateElement.get().getElementId(), + StructureElement.OrchestrationTemplateCandidateContent.name()) + .ifPresent(candidateContentElement -> candidateData.setContentData( + ByteBuffer.wrap(FileUtils.toByteArray(candidateContentElement.getData())))); + logger.info("Finished getting orchestration template for vsp id -> " + vspId); + return candidateData; + } + logger.info(String.format("Orchestration template for vsp id %s does not exist", vspId)); + return null; + } + + @Override + public void update(String vspId, OrchestrationTemplateCandidateData candidateData) { + logger.info("Uploading candidate data entity for vsp id -> " + vspId); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor); + ElementContext elementContext = new ElementContext(itemId, versionId); + + ZusammenElement candidateElement = VspZusammenUtil + .buildStructuralElement(StructureElement.OrchestrationTemplateCandidate, Action.UPDATE); + candidateElement + .setData(new ByteArrayInputStream(candidateData.getFilesDataStructure().getBytes())); + ZusammenElement candidateContentElement = VspZusammenUtil + .buildStructuralElement(StructureElement.OrchestrationTemplateCandidateContent, Action.UPDATE); + candidateContentElement + .setData(new ByteArrayInputStream(candidateData.getContentData().array())); + candidateElement.addSubElement(candidateContentElement); + + zusammenAdaptor.saveElement(context, elementContext, candidateElement, + "Update Orchestration Template Candidate"); + logger.info("Finished uploading candidate data entity for vsp id -> " + vspId); + } + + @Override + public void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure) { + logger.info("Updating orchestration template for VSP id -> " + vspId); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor); + ElementContext elementContext = new ElementContext(itemId, versionId); + + ZusammenElement candidateElement = VspZusammenUtil + .buildStructuralElement(StructureElement.OrchestrationTemplateCandidate, Action.UPDATE); + candidateElement + .setData(new ByteArrayInputStream(JsonUtil.object2Json(fileDataStructure).getBytes())); + 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 structure for vsp id -> " + vspId); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor); + ElementContext elementContext = new ElementContext(itemId, versionId, + VspZusammenUtil.getVersionTag(version)); + + logger.info("Finished getting orchestration template structure for vsp id -> " + vspId); + Optional<Element> element = zusammenAdaptor.getElementByName(context, elementContext, null, + StructureElement.OrchestrationTemplateCandidate.name()); + if (element.isPresent()) { + return Optional.of(new String(FileUtils.toByteArray(element.get().getData()))); + } else { + return Optional.empty(); + } + + } +} 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 new file mode 100644 index 0000000000..83a78bc705 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java @@ -0,0 +1,111 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.utils.fileutils.FileUtils; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; + +import java.io.ByteArrayInputStream; +import java.nio.ByteBuffer; +import java.util.Optional; + +public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTemplateDao { + + private ZusammenAdaptor zusammenAdaptor; + + public OrchestrationTemplateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void registerVersioning(String versionableEntityType) { + + } + + @Override + public String getValidationData(String vspId, Version version) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(version)); + + Optional<ElementInfo> elementInfo = zusammenAdaptor + .getElementInfoByName(context, elementContext, null, + StructureElement.OrchestrationTemplate.name()); + if (elementInfo.isPresent()) { + Optional<Element> element = + zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(), + StructureElement.OrchestrationTemplateValidationData.name()); + if (element.isPresent()) { + return new String(FileUtils.toByteArray(element.get().getData())); + } + } + + return null; + } + + @Override + public UploadDataEntity getOrchestrationTemplate(String vspId, Version version) { + + UploadDataEntity uploadData = new UploadDataEntity(); + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(version)); + + Optional<ElementInfo> elementInfo = zusammenAdaptor + .getElementInfoByName(context, elementContext, null, + StructureElement.OrchestrationTemplate.name()); + if (elementInfo.isPresent()) { + Optional<Element> element = + zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(), + StructureElement.OrchestrationTemplateValidationData.name()); + element.ifPresent(element1 -> uploadData + .setValidationData(new String(FileUtils.toByteArray(element1.getData())))); + element = + zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(), + StructureElement.OrchestrationTemplateContent.name()); + element.ifPresent(element1 -> uploadData + .setContentData(ByteBuffer.wrap(FileUtils.toByteArray(element1.getData())))); + } + return uploadData; + } + + @Override + public void updateOrchestrationTemplateData(String vspId, UploadData uploadData) { + ZusammenElement orchestrationTemplateElement = + VspZusammenUtil.buildStructuralElement(StructureElement.OrchestrationTemplate, null); + ZusammenElement orchestrationTemplateValidationDataElement = + VspZusammenUtil + .buildStructuralElement(StructureElement.OrchestrationTemplateValidationData, null); + orchestrationTemplateValidationDataElement.setData(new ByteArrayInputStream(uploadData + .getValidationData().getBytes())); + ZusammenElement orchestrationTemplateContent = + VspZusammenUtil.buildStructuralElement(StructureElement.OrchestrationTemplateContent, null); + orchestrationTemplateContent + .setData(new ByteArrayInputStream(uploadData.getContentData().array())); + orchestrationTemplateElement.addSubElement(orchestrationTemplateValidationDataElement); + orchestrationTemplateElement.addSubElement(orchestrationTemplateContent); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + zusammenAdaptor.saveElement(context, elementContext, orchestrationTemplateElement, "Update " + + "Orchestration Template"); + } + +} 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 new file mode 100644 index 0000000000..ffc9cb2901 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java @@ -0,0 +1,229 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.ByteArrayInputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author Avrahamg. + * @since March 23, 2017 + */ +public class ProcessDaoZusammenImpl implements ProcessDao { + + private static final String NAME = "name"; + private static final String ELEMENT_TYPE = "type"; + private static final String ARTIFACT_NAME = "artifactName"; + private static final String DESCRIPTION = "description"; + private static final String PROCESS_TYPE = "processType"; + + private ZusammenAdaptor zusammenAdaptor; + + public ProcessDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void registerVersioning(String versionableEntityType) { + + } + + @Override + public void create(ProcessEntity processEntity) { + ZusammenElement processElement = buildProcessElement(processEntity, Action.CREATE); + + ZusammenElement processesElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Processes, null); + ZusammenElement aggregatedElement = VspZusammenUtil.aggregateElements(processesElement, + processElement); + ZusammenElement componentElement; + if (processEntity.getComponentId() != null) { + componentElement = createParentElement(processEntity); + aggregatedElement = + VspZusammenUtil.aggregateElements(componentElement, aggregatedElement); + } + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(processEntity.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + Optional<Element> savedElement = + zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Create process"); + savedElement.ifPresent(element -> { + if (processEntity.getComponentId() == null) { + processEntity.setId(element.getSubElements().iterator().next() + .getElementId().getValue()); + } else { + processEntity.setId(element.getSubElements().iterator().next() + .getSubElements().iterator().next().getElementId().getValue()); + } + }); + } + + @Override + public ProcessEntity get(ProcessEntity process) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(process.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(process.getVersion())); + + Optional<Element> elementOptional = + zusammenAdaptor.getElement(context, elementContext, process.getId()); + + if (elementOptional.isPresent()) { + Element element = elementOptional.get(); + process.setName(element.getInfo().getProperty(NAME)); + process.setArtifactName(element.getInfo().getProperty(ARTIFACT_NAME)); + process.setDescription(element.getInfo().getProperty(DESCRIPTION)); + process.setType(element.getInfo().getProperty + (PROCESS_TYPE) != null ? ProcessType.valueOf(element.getInfo().getProperty + (PROCESS_TYPE)) : null); + + process.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData()))); + return process; + } else { + return null; + } + } + + @Override + public void update(ProcessEntity processEntity) { + ZusammenElement processElement = buildProcessElement(processEntity, Action.UPDATE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(processEntity.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + Optional<Element> element = + zusammenAdaptor.saveElement(context, elementContext, processElement, "Create process"); + System.out.println(element.get().getElementId()); + } + + @Override + public void delete(ProcessEntity processEntity) { + ZusammenElement processElement = new ZusammenElement(); + processElement.setElementId(new Id(processEntity.getId())); + processElement.setAction(Action.DELETE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(processEntity.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + zusammenAdaptor.saveElement(context, elementContext, processElement, + String.format("Delete process with id %s", processEntity.getId())); + } + + @Override + public void deleteAll(ProcessEntity processEntity) { + ZusammenElement aggregatedElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Processes, Action.DELETE); + + if (processEntity.getComponentId() != null) { + ZusammenElement componentElement = createParentElement(processEntity); + aggregatedElement = VspZusammenUtil.aggregateElements(componentElement, + aggregatedElement); + } + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(processEntity.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Delete All processes"); + } + + @Override + public void deleteVspAll(String vspId, Version version) { + ProcessEntity processEntity = new ProcessEntity(); + processEntity.setVersion(version); + processEntity.setVspId(vspId); + deleteAll(processEntity); + } + + @Override + public Collection<ProcessEntity> list(ProcessEntity process) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(process.getVspId()); + ElementContext elementContext = new ElementContext(itemId, + VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VspZusammenUtil.getVersionTag(process.getVersion())); + + Optional<ElementInfo> processesOptional = + zusammenAdaptor.getElementInfoByName(context, elementContext, + extractParentElementId(process), StructureElement.Processes.name()); + if (!processesOptional.isPresent()) { + return new ArrayList<>(); + } + return zusammenAdaptor.listElements(context, elementContext, processesOptional.get().getId()) + .stream() + .map(elementInfo -> mapElementInfoToProcess( + process.getVspId(), process.getVersion(), process.getComponentId(), + elementInfo)) + .collect(Collectors.toList()); + } + + private Id extractParentElementId(ProcessEntity processEntity) { + return processEntity.getComponentId() == null ? null : new Id(processEntity.getComponentId()); + } + + private ProcessEntity mapElementInfoToProcess(String vspId, Version version, + String componentId, + ElementInfo elementInfo) { + ProcessEntity processEntity = new ProcessEntity(vspId, version, componentId, elementInfo + .getId().getValue()); + processEntity.setName((String) elementInfo.getInfo().getProperties().get(NAME)); + processEntity + .setArtifactName((String) elementInfo.getInfo().getProperties().get(ARTIFACT_NAME)); + processEntity.setDescription((String) elementInfo.getInfo().getProperties().get(DESCRIPTION)); + return processEntity; + } + + private ZusammenElement buildProcessElement(ProcessEntity process, Action action) { + + Info info = new Info(); + info.setName(process.getName()); + info.addProperty(NAME, process.getName()); + info.addProperty(ELEMENT_TYPE, ElementType.Process); + info.addProperty(ARTIFACT_NAME, process.getArtifactName()); + info.addProperty(DESCRIPTION, process.getDescription()); + info.addProperty(PROCESS_TYPE, process.getType() != null ? process.getType().name() : null); + + ZusammenElement processElement = new ZusammenElement(); + processElement.setElementId(new Id(process.getId())); + processElement.setAction(action); + processElement.setInfo(info); + if (Objects.nonNull(process.getArtifact())) { + processElement.setData(new ByteArrayInputStream(process.getArtifact().array())); + } + return processElement; + } + + private ZusammenElement createParentElement(ProcessEntity entity) { + ZusammenElement componentElement = new ZusammenElement(); + componentElement.setElementId(new Id(entity.getComponentId())); + componentElement.setAction(Action.IGNORE); + return componentElement; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java new file mode 100644 index 0000000000..5d53741ebf --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java @@ -0,0 +1,20 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +public enum StructureElement { + General, + OrchestrationTemplateCandidate, + OrchestrationTemplate, + OrchestrationTemplateValidationData, + OrchestrationTemplateContent, + OrchestrationTemplateCandidateValidationData, + OrchestrationTemplateCandidateContent, + Networks, + Components, + Nics, + Processes, + Mibs, + SNMP_TRAP, + SNMP_POLL, + Questionnaire, + ComponentDependencies, +} 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 new file mode 100644 index 0000000000..65a41330a7 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java @@ -0,0 +1,228 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import com.amdocs.zusammen.datatypes.item.ItemVersion; +import com.amdocs.zusammen.utils.fileutils.FileUtils; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; +import org.openecomp.sdc.versioning.VersioningManagerFactory; +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.Date; +import java.util.stream.Collectors; + +public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareProductInfoDao { + private ZusammenAdaptor zusammenAdaptor; + + public VendorSoftwareProductInfoDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void registerVersioning(String versionableEntityType) { + VersionableEntityMetadata metadata = + new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "vsp", null, null); + + VersioningManagerFactory.getInstance().createInterface() + .register(versionableEntityType, metadata); + } + + @Override + public Collection<VspDetails> list(VspDetails entity) { + return zusammenAdaptor.listItems(ZusammenUtil.createSessionContext()).stream().filter + (vspEntity-> "vsp".equals(vspEntity.getInfo().getProperty("type"))) + .map(item -> mapInfoToVspDetails( + item.getId().getValue(), null, item.getInfo(), + item.getModificationTime(), item.getCreationTime())) + .collect(Collectors.toList()); + } + + @Override + public void create(VspDetails vspDetails) { + SessionContext context = ZusammenUtil.createSessionContext(); + + Id itemId = zusammenAdaptor.createItem(context, mapVspDetailsToZusammenItemInfo(vspDetails)); + Id versionId = + zusammenAdaptor.createVersion(context, itemId, null, ZusammenUtil.createFirstVersionData()); + + ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.CREATE); + zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId), + generalElement, "Create VSP General Info Element"); + + vspDetails.setId(itemId.getValue());//set id for caller + } + + @Override + public void update(VspDetails vspDetails) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspDetails.getId()); + Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor); + + zusammenAdaptor.updateItem(context, itemId, mapVspDetailsToZusammenItemInfo(vspDetails)); + + ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.UPDATE); + zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId), + generalElement, "Update VSP General Info Element"); + } + + @Override + public VspDetails get(VspDetails vspDetails) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspDetails.getId()); + ItemVersion itemVersion = VspZusammenUtil.getFirstVersion(context, itemId, zusammenAdaptor); + ElementContext elementContext = new ElementContext(itemId, itemVersion.getId(), + VspZusammenUtil.getVersionTag(vspDetails.getVersion())); + + return zusammenAdaptor + .getElementInfoByName(context, elementContext, null, StructureElement.General.name()) + .map(generalElementInfo -> mapInfoToVspDetails( + vspDetails.getId(), vspDetails.getVersion(), generalElementInfo.getInfo(), + itemVersion.getModificationTime(), itemVersion.getCreationTime())) + .orElse(null); + } + + + @Override + public void delete(VspDetails entity) { + + } + + @Override + public void updateOldVersionIndication(VspDetails vspDetails) { + VspDetails retrieved = get(vspDetails); + if (retrieved != null) { + retrieved.setOldVersion(vspDetails.getOldVersion()); + update(retrieved); + } + } + + @Override + public void updateQuestionnaireData(String vspId, Version version, String questionnaireData) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor); + + ZusammenElement questionnaireElement = mapQuestionnaireToZusammenElement(questionnaireData); + zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId), + questionnaireElement, "Update VSP Questionnaire"); + } + + + @Override + public String getQuestionnaireData(String vspId, Version version) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(vspId); + Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor); + + return zusammenAdaptor.getElementByName(context, + new ElementContext(itemId, versionId, VspZusammenUtil.getVersionTag(version)), null, + StructureElement.Questionnaire.name()) + .map(questionnaireElement -> + new String(FileUtils.toByteArray(questionnaireElement.getData()))) + .orElse(null); + } + + @Override + public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) { + VspQuestionnaireEntity entity = new VspQuestionnaireEntity(); + entity.setId(vspId); + entity.setVersion(version); + entity.setQuestionnaireData(getQuestionnaireData(vspId, version)); + return entity; + } + + @Override + public void deleteAll(String vspId, Version version) { + + } + + private Info mapVspDetailsToZusammenItemInfo(VspDetails vspDetails) { + Info info = new Info(); + info.setName(vspDetails.getName()); + info.setDescription(vspDetails.getDescription()); + info.addProperty("type", "vsp"); + addVspDetailsToInfo(info, vspDetails); + return info; + } + + private ZusammenElement mapVspDetailsToZusammenElement(VspDetails vspDetails, Action action) { + ZusammenElement generalElement = + VspZusammenUtil.buildStructuralElement(StructureElement.General, action); + addVspDetailsToInfo(generalElement.getInfo(), vspDetails); + return generalElement; + } + + private ZusammenElement mapQuestionnaireToZusammenElement(String questionnaireData) { + ZusammenElement questionnaireElement = + VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, Action.UPDATE); + questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes())); + return questionnaireElement; + } + + private void addVspDetailsToInfo(Info info, VspDetails vspDetails) { + info.addProperty(InfoPropertyName.name.name(), vspDetails.getName()); + info.addProperty(InfoPropertyName.description.name(), vspDetails.getDescription()); + info.addProperty(InfoPropertyName.icon.name(), vspDetails.getIcon()); + info.addProperty(InfoPropertyName.category.name(), vspDetails.getCategory()); + info.addProperty(InfoPropertyName.subCategory.name(), vspDetails.getSubCategory()); + info.addProperty(InfoPropertyName.vendorId.name(), vspDetails.getVendorId()); + info.addProperty(InfoPropertyName.vendorName.name(), vspDetails.getVendorName()); + if (vspDetails.getVlmVersion() != null) { + info.addProperty( + InfoPropertyName.vendorVersion.name(), vspDetails.getVlmVersion().toString()); + } + info.addProperty(InfoPropertyName.licenseAgreement.name(), vspDetails.getLicenseAgreement()); + info.addProperty(InfoPropertyName.featureGroups.name(), vspDetails.getFeatureGroups()); + info.addProperty(InfoPropertyName.oldVersion.name(), vspDetails.getOldVersion()); + } + + private VspDetails mapInfoToVspDetails(String vspId, Version version, Info info, + Date modificationTime, Date creationTime) { + VspDetails vspDetails = new VspDetails(vspId, version); + vspDetails.setName(info.getProperty(InfoPropertyName.name.name())); + vspDetails.setDescription(info.getProperty(InfoPropertyName.description.name())); + vspDetails.setCategory(info.getProperty(InfoPropertyName.category.name())); + vspDetails.setSubCategory(info.getProperty(InfoPropertyName.subCategory.name())); + vspDetails.setVendorId(info.getProperty(InfoPropertyName.vendorId.name())); + vspDetails.setVendorName(info.getProperty(InfoPropertyName.vendorName.name())); + vspDetails.setVlmVersion( + Version.valueOf(info.getProperty(InfoPropertyName.vendorVersion.name()))); + vspDetails.setLicenseAgreement(info.getProperty(InfoPropertyName.licenseAgreement.name())); + vspDetails.setFeatureGroups(info.getProperty(InfoPropertyName.featureGroups.name())); + vspDetails.setWritetimeMicroSeconds( + modificationTime == null ? creationTime.getTime() : modificationTime.getTime()); + vspDetails.setVersion(version); + String oldVersion = info.getProperty(InfoPropertyName.oldVersion.name()); + + //Boolean oldVersion = ind == null || "true".equals( ind.toLowerCase()); + vspDetails.setOldVersion(oldVersion); + return vspDetails; + } + + private enum InfoPropertyName { + name, + description, + icon, + category, + subCategory, + vendorId, + vendorName, + vendorVersion, + licenseAgreement, + featureGroups, + oldVersion + } + +} 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 new file mode 100644 index 0000000000..dde3603896 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java @@ -0,0 +1,61 @@ +package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ItemVersion; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; + +import java.util.Objects; +import java.util.Optional; + +class VspZusammenUtil { + + static ItemVersion getFirstVersion(SessionContext context, Id itemId, ZusammenAdaptor + zusammenAdaptor) { + + Optional<ItemVersion> itemVersion = zusammenAdaptor.getFirstVersion(context, itemId); + + if (!itemVersion.isPresent()) { + throw new CoreException( + new VendorSoftwareProductNotFoundErrorBuilder(itemId.getValue()).build()); + } + return itemVersion.get(); + } + + static Id getFirstVersionId(SessionContext context, Id itemId, ZusammenAdaptor zusammenAdaptor) { + return getFirstVersion(context, itemId, zusammenAdaptor).getId(); + } + + // TODO: 4/25/2017 remove upon working with more than one single version + static String getVersionTag(Version version) { + return version.getStatus() == VersionStatus.Locked + ? null + : version.toString(); + } + + static ZusammenElement buildStructuralElement(StructureElement structureElement, Action action) { + return ZusammenUtil.buildStructuralElement(structureElement.name(), action); + } + + static ZusammenElement aggregateElements(ZusammenElement... elements) { + ZusammenElement head = null; + ZusammenElement father = null; + for (ZusammenElement element : elements) { + if (Objects.isNull(head)) { + head = father = element; + } else { + father.getSubElements().add(element); + father = element; + } + } + + return head; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java new file mode 100644 index 0000000000..2a50f33349 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.errors; + +/** + * Created by TALIO on 4/24/2016. + */ +public class VendorSoftwareProductErrorCodes { + + public static final String VSP_NOT_FOUND = "VSP_NOT_FOUND"; + public static final String VSP_INVALID = "VSP_INVALID"; + public static final String FAILED_TO_CREATE_VSP = "FAILED_TO_CREATE_VSP"; + + public static final String UPLOAD_INVALID = "UPLOAD_INVALID"; + + public static final String PACKAGE_NOT_FOUND = "PACKAGE_NOT_FOUND"; + + public static final String PACKAGE_INVALID = "PACKAGE_INVALID"; + public static final String VSP_COMPOSITION_EDIT_NOT_ALLOWED = "VSP_COMPOSITION_EDIT_NOT_ALLOWED"; + + public static final String CREATE_PACKAGE_FOR_NON_FINAL_VSP = "CREATE_PACKAGE_FOR_NON_FINAL_VSP"; + + public static final String TRANSLATION_FILE_CREATION = "TRANSLATION_FILE_CREATION"; + + public static final String HEAT_PACKAGE_FILE_CREATION = "HEAT_PACKAGE_FILE_CREATION"; + + public static final String TOSCA_ENTRY_NOT_FOUND = "TOSCA_ENTRY_NOT_FOUND"; + public static final String TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE = + "TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE"; + + public static final String MIB_UPLOAD_INVALID = "MIB_UPLOAD_INVALID"; + + public static final String ORCHESTRATION_NOT_FOUND = "ORCHESTRATION_NOT_FOUND"; + + + public static final String CYCLIC_DEPENDENCY_IN_COMPONENTS = "CYCLIC_DEPENDENCY_IN_COMPONENTS"; + + public static final String INVALID_COMPONENT_RELATION_TYPE = "INVALID_COMPONENT_RELATION_TYPE"; + + public static final String NO_SOURCE_COMPONENT = "NO_SOURCE_COMPONENT"; + + public static final String SAME_SOURCE_TARGET_COMPONENT = "SAME_SOURCE_TARGET_COMPONENT"; + +} 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/VspQuestionnaireDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactoryImpl.java index aa91302ca2..df5e44122d 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/VspQuestionnaireDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/InformationArtifactGeneratorFactoryImpl.java @@ -18,16 +18,17 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.sdc.vendorsoftwareproduct.dao.impl; +package org.openecomp.sdc.vendorsoftwareproduct.factory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VspQuestionnaireDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VspQuestionnaireDaoFactory; -public class VspQuestionnaireDaoFactoryImpl extends VspQuestionnaireDaoFactory { - private static final VspQuestionnaireDao INSTANCE = new VspQuestionnaireDaoCassandraImpl(); +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator; +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactGeneratorImpl; + + +public class InformationArtifactGeneratorFactoryImpl extends InformationArtifactGeneratorFactory { @Override - public VspQuestionnaireDao createInterface() { - return INSTANCE; + public InformationArtifactGenerator createInterface() { + return new TxtInformationArtifactGeneratorImpl(); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnaireDataServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnaireDataServiceFactoryImpl.java new file mode 100644 index 0000000000..5c569dbf08 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/QuestionnaireDataServiceFactoryImpl.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory; + + +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator; +import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService; +import org.openecomp.sdc.vendorsoftwareproduct.quiestionnaire.QuestionnaireDataServiceImpl; + + +public class QuestionnaireDataServiceFactoryImpl extends QuestionnnaireDataServiceFactory { + + @Override + public QuestionnaireDataService createInterface() { + return new QuestionnaireDataServiceImpl(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CandidateServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CandidateServiceFactoryImpl.java new file mode 100644 index 0000000000..b98605a53d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CandidateServiceFactoryImpl.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory.impl; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.OrchestrationTemplateCandidateDaoFactoryImpl; +import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory; +import org.openecomp.sdc.vendorsoftwareproduct.factory.ManifestCreatorFactory; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; +import org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule.CandidateServiceImpl; + + +public class CandidateServiceFactoryImpl extends CandidateServiceFactory { + + @Override + public CandidateService createInterface() { + return new CandidateServiceImpl(ManifestCreatorFactory.getInstance().createInterface(), + OrchestrationTemplateCandidateDaoFactoryImpl.getInstance().createInterface()); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionDataExtractorFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionDataExtractorFactoryImpl.java new file mode 100644 index 0000000000..21b0d9c0a8 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionDataExtractorFactoryImpl.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory.impl; + +import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory; +import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor; +import org.openecomp.sdc.vendorsoftwareproduct.services.impl.composition.CompositionDataExtractorImpl; + +public class CompositionDataExtractorFactoryImpl extends CompositionDataExtractorFactory { + + @Override + public CompositionDataExtractor createInterface() { + return new CompositionDataExtractorImpl(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java new file mode 100644 index 0000000000..54d67e60fe --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory.impl; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager; +import org.openecomp.sdc.vendorsoftwareproduct.services.impl.composition.CompositionEntityDataManagerImpl; + +public class CompositionEntityDataManagerFactoryImpl extends CompositionEntityDataManagerFactory { + + @Override + public CompositionEntityDataManager createInterface() { + return new CompositionEntityDataManagerImpl( + VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(), + ComponentDaoFactory.getInstance().createInterface(), + NicDaoFactory.getInstance().createInterface(), + NetworkDaoFactory.getInstance().createInterface()); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/ManifestCreatorFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/ManifestCreatorFactoryImpl.java new file mode 100644 index 0000000000..c7d088408e --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/ManifestCreatorFactoryImpl.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.factory.impl; + +import org.openecomp.sdc.vendorsoftwareproduct.factory.ManifestCreatorFactory; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.ManifestCreator; +import org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule.ManifestCreatorNamingConventionImpl; + +/** + * Created by Talio on 12/15/2016. + */ +public class ManifestCreatorFactoryImpl extends ManifestCreatorFactory { + + @Override + public ManifestCreator createInterface(){ + return new ManifestCreatorNamingConventionImpl(); + } +} 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/informationArtifact/impl/TxtInformationArtifactConstants.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactConstants.java new file mode 100644 index 0000000000..f99d3814e6 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactConstants.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl; + +/** + * @author KATYR + * @since December 07, 2016 + */ + +public class TxtInformationArtifactConstants { + public static final String QUOTEMARK = "\""; + public static final String SPACE = " "; + public static final String TAB = SPACE + SPACE + SPACE + SPACE; + public static final String NL = System.lineSeparator(); + public static final String DELIMITER = ":"; + public static final String FOUR_TABS = TAB + TAB + TAB + TAB; + + public static final String HEADER = "AT&T Proprietary (Restricted)\n" + + "Only for use by authorized individuals or any above-designated team(s)\n" + + "within the AT&T companies and not for general distribution" + NL + NL + NL; + + public static final String FOOTER = NL + NL + NL + "AT&T Proprietary (Restricted)\n" + + "Only for use by authorized individuals or any above-designated team(s)\n" + + "within the AT&T companies and not for general distribution"; + + + public static final String TITLE = "1." + TAB + "VSP Details" + DELIMITER; + public static final String VSP_NAME = "a." + TAB + "Name" + DELIMITER; + public static final String VSP_DESC = "b." + TAB + "Description"; + public static final String VSP_VENDOR = "d." + TAB + "Vendor" + DELIMITER; + public static final String VSP_VERSION = "c." + TAB + "Version" + DELIMITER; + public static final String VSP_CATEGORY = "e." + TAB + "Category" + DELIMITER; + public static final String LICENSE_DETAILS = "f." + TAB + "License Details" + DELIMITER; + public static final String LICENSE_MODEL_VERSION = + "i." + TAB + "License Model Version" + DELIMITER; + public static final String LICENSE_AGREEMENT_NAME = + "ii." + TAB + "License Agreement Name" + DELIMITER; + public static final String LIST_OF_FEATURE_GROUPS = "iii" + TAB + "List of Feature Groups"+DELIMITER; + public static final String HIGH_AVAILABILITY = "g." + TAB + "High Availability"; + public static final String USING_AVAILABILITY_ZONES = "i." + TAB + "Using Availability " + + "Zones" + DELIMITER; + public static final String STORAGE_BACKUP_DETAILS = "h." + TAB + "Storage Data Back-up " + + "Details" + DELIMITER; + public static final String IS_DATA_REPLICATION = + "i." + TAB + "Data Replication Required?" + DELIMITER; + public static final String DATA_SIZE_TO_REP = + "ii." + TAB + " Data Size to replicate in GB" + DELIMITER; + public static final String DATA_REP_FREQUENCY = + "iii." + TAB + "Data replication frequency" + DELIMITER; + public static final String DATA_REP_SOURCE = "iv." + TAB + "Replication Source" + DELIMITER; + public static final String DATA_REP_DEST = "v." + TAB + "Replication Destination" + DELIMITER; + public static final String LIST_OF_NETWORKS = "List of Internal Networks";//currently not used + public static final String LIST_OF_VFCS = "3." + TAB + "List of VFCs"; + public static final String FOR_EACH_VFC = "a." + TAB + "For each VFC" + DELIMITER; + public static final String VFC_NAME = "i." + TAB + "VFC Name" + DELIMITER; + public static final String VFC_DESC = "ii." + TAB + "Description" + DELIMITER; + public static final String VFC_IMAGES = "iii." + TAB + "Images" + DELIMITER; + public static final String VFC_COMPUTE = "iv." + TAB + "Compute/VM Characteristics"; + public static final String VFC_COMPUTE_VCPU = "1." + TAB + "vCPU" + DELIMITER; + public static final String VFC_COMPUTE_CPU_OVER_SUBSCRIPTION = "2." + TAB + "CPU " + + "over-subscription" + DELIMITER; + public static final String VFC_COMPUTE_MEMORY = "3." + TAB + "Memory" + DELIMITER; + public static final String VFC_COMPUTE_DISK = "4." + TAB + "Disk" + DELIMITER; + public static final String HYPERVISOR_DETAILS = "v." + TAB + "Hypervisor Details"; + public static final String HYPERVISOR_DETAILS_NAME = "1." + TAB + "Name" + DELIMITER; + public static final String HYPERVISOR_DETAILS_DRIVERS = "2." + TAB + "Drivers" + DELIMITER; + public static final String GUEST_OS_DETAILS = "vi." + TAB + "Guest OS Details"; + public static final String GUEST_OS_NAME = "1." + TAB + "Name" + DELIMITER; + public static final String GUEST_OS_BIT_SIZE = "2." + TAB + "Bit Size" + DELIMITER; + public static final String GUEST_OS_TOOLS = "3." + TAB + "Tools" + DELIMITER; + public static final String VFC_INSTANCE_NUMBER = "vii." + TAB + "Number of VFC Instances"; + public static final String VFC_INSTANCE_NUMBER_MIN = "1." + TAB + "Minimum" + DELIMITER; + public static final String VFC_INSTANCE_NUMBER_MAX = "2." + TAB + "Maximum" + DELIMITER; + public static final String VNICS = "viii." + TAB + "vNICs"; + public static final String VNICS_NAME = "1." + TAB + "Name" + DELIMITER; + public static final String VNICS_PURPOSE = "2." + TAB + "Purpose" + DELIMITER; + public static final String VNICS_INT_EXT = "3." + TAB + "Internal/External" + DELIMITER; + public static final String VNICS_NETWORK = "4." + TAB + "Network" + DELIMITER; + public static final String VNICS_PROTOCOLS = "5." + TAB + "Protocols" + DELIMITER; + public static final String VNICS_IPV4 = "6." + TAB + "IP v4 Required" + DELIMITER; + public static final String VNICS_IPV6 = "7." + TAB + "IP v6 Required" + DELIMITER; + public static final String RECOVERY_DETAILS = "ix." + TAB + "Recovery Details" + DELIMITER; + public static final String RECOVERY_DETAILS_POINT = "1." + TAB + "Recovery Point" + DELIMITER; + public static final String RECOVERY_DETAILS_TIME = "2." + TAB + "Recovery Time" + DELIMITER; + + +} 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/informationArtifact/impl/TxtInformationArtifactGeneratorImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImpl.java new file mode 100644 index 0000000000..d15014286f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImpl.java @@ -0,0 +1,304 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl; + +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.factory.QuestionnnaireDataServiceFactory; +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData; +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator; +import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ComponentQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.GuestOS; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.NumOfVMs; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.Hypervisor; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.Recovery; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.IpConfiguration; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.Network; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.NicQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.VspQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.Availability; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.General; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.StorageDataReplication; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.List; +import java.util.Optional; + +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.*; + +/** + * @author katyr + * @since November 23, 2016 + */ + +public class TxtInformationArtifactGeneratorImpl implements InformationArtifactGenerator { + private QuestionnaireDataService questionnaireDataService = QuestionnnaireDataServiceFactory + .getInstance().createInterface(); + private StringBuilder textArtifact; + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + + @Override + public String generate(String vspId, Version version) { + InformationArtifactData informationArtifactData = + questionnaireDataService.generateQuestionnaireDataForInformationArtifact(vspId, version); + return createTxtArtifact(informationArtifactData); + } + + private String createTxtArtifact(InformationArtifactData informationArtifactData) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + textArtifact = new StringBuilder(TxtInformationArtifactConstants.HEADER); + addVspVlmEntries(informationArtifactData); + addAvailabilityEntries(); + addDataEntries(informationArtifactData); + addEntryWithIndent(LIST_OF_VFCS, "", TAB); + addEntryWithIndent(FOR_EACH_VFC, "", TAB + TAB); + List<ComponentQuestionnaire> componentQuestionnaires = + informationArtifactData.getComponentQuestionnaires(); + + for (ComponentQuestionnaire componentQuestionnaire : componentQuestionnaires) { + addEntriesPerComponent(componentQuestionnaire); + + } + + List<NicQuestionnaire> nicQuestionnaires = informationArtifactData.getNicQuestionnaires(); + for (NicQuestionnaire nicQuestionnaire : nicQuestionnaires) { + addEntriesPerNic(nicQuestionnaire); + + } + for (ComponentQuestionnaire componentQuestionnaire : componentQuestionnaires) { + addRecoveryEntriesPerComponent(componentQuestionnaire); + } + textArtifact.append(TxtInformationArtifactConstants.FOOTER); + + mdcDataDebugMessage.debugExitMessage(null); + return textArtifact.toString(); + + } + + private void addDataEntries(InformationArtifactData informationArtifactData) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + addEntryWithIndent(STORAGE_BACKUP_DETAILS, "", TAB); + + Optional<StorageDataReplication> storageDataReplication = + Optional.of(informationArtifactData).map(InformationArtifactData::getVspQuestionnaire) + .map(VspQuestionnaire::getGeneral).map(General::getStorageDataReplication); + storageDataReplication + .ifPresent(replication -> addEntryWithIndent(IS_DATA_REPLICATION, + String.valueOf(replication.isStorageReplicationAcrossRegion()), TAB + TAB)); + + + storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_SIZE_TO_REP, + String.valueOf(rep.getStorageReplicationSize()), TAB + TAB)); + + storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_REP_FREQUENCY, + String.valueOf(rep.getStorageReplicationFrequency()), TAB + TAB)); + + storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_REP_SOURCE, + String.valueOf(rep.getStorageReplicationSource()), TAB + TAB)); + + storageDataReplication.ifPresent(rep -> addEntryWithIndent(DATA_REP_DEST, + String.valueOf(rep.getStorageReplicationDestination()), TAB + TAB)); + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void addAvailabilityEntries() { + mdcDataDebugMessage.debugEntryMessage(null); + + addEntryWithIndent(HIGH_AVAILABILITY, "", TAB); + + Optional<Availability> availability = + Optional.of(new InformationArtifactData()).map(InformationArtifactData::getVspQuestionnaire) + .map(VspQuestionnaire::getGeneral).map(General::getAvailability); + availability + .ifPresent(availabilityVal -> addEntryWithIndent(USING_AVAILABILITY_ZONES, String.valueOf( + availabilityVal.isUseAvailabilityZonesForHighAvailability()), TAB + TAB)); + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void addVspVlmEntries(InformationArtifactData informationArtifactData) { + mdcDataDebugMessage.debugEntryMessage(null); + + addEntryWithIndent(TITLE, "", ""); + Optional<VspDetails> vspDetails = Optional.of(informationArtifactData).map + (InformationArtifactData::getVspDetails); + addEntryWithIndent(VSP_NAME, informationArtifactData.getVspDetails().getName(), TAB); + addEntryWithIndent(VSP_DESC, informationArtifactData.getVspDetails().getDescription(), TAB); + addEntryWithIndent(VSP_VERSION, + roundVersionAsNeeded(informationArtifactData.getVspDetails().getVersion()), TAB); + addEntryWithIndent(VSP_VENDOR, informationArtifactData.getVspDetails().getVendorName(), TAB); + addEntryWithIndent(VSP_CATEGORY, informationArtifactData.getVspDetails().getCategory(), TAB); + addEntryWithIndent(LICENSE_DETAILS, "", TAB); + addEntryWithIndent(LICENSE_MODEL_VERSION, + informationArtifactData.getVspDetails().getVlmVersion() == null + ? "" + : informationArtifactData.getVspDetails().getVlmVersion().toString(), + TAB + TAB); + addEntryWithIndent(LICENSE_AGREEMENT_NAME, informationArtifactData.getVspDetails() + .getLicenseAgreement(), TAB + TAB); + addEntryWithIndent(LIST_OF_FEATURE_GROUPS, "", TAB + TAB); + vspDetails.ifPresent(vspDets -> addListEntriesWithIndent(vspDets + .getFeatureGroups(), TAB + TAB + TAB)); + + mdcDataDebugMessage.debugExitMessage(null); + } + + static String roundVersionAsNeeded(Version version) { + if (version.isFinal()) { + return version.toString(); + } else { + return String.valueOf(Math.ceil(Double.valueOf(version.toString()))); + } + } + + private void addRecoveryEntriesPerComponent(ComponentQuestionnaire componentQuestionnaire) { + + mdcDataDebugMessage.debugEntryMessage(null); + + addEntryWithIndent(RECOVERY_DETAILS, "", TAB + TAB + TAB); + Optional<Recovery> recovery = Optional.of(componentQuestionnaire).map( + ComponentQuestionnaire::getGeneral).map( + org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general + .General::getRecovery); + recovery.ifPresent(recoveryVal -> addEntryWithIndent(RECOVERY_DETAILS_POINT, String.valueOf( + recoveryVal.getPointObjective()), TAB + TAB + TAB + TAB)); + + recovery.ifPresent(recoveryVal -> addEntryWithIndent(RECOVERY_DETAILS_TIME, String.valueOf( + recoveryVal.getTimeObjective()), TAB + TAB + TAB + TAB)); + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void addEntriesPerNic(NicQuestionnaire nicQuestionnaire) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + addEntryWithIndent(VNICS, "", TAB + TAB + TAB); + Optional<Network> networkOpt = Optional.of(nicQuestionnaire).map( + NicQuestionnaire::getNetwork); + + networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_NAME, network + .getNetworkDescription(), + TAB + TAB + TAB + TAB)); + networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_PURPOSE, network + .getNetworkDescription(), TAB + TAB + TAB + TAB)); + networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_INT_EXT, network + .getNetworkDescription(), TAB + TAB + TAB + TAB)); + networkOpt.ifPresent(network -> addEntryWithIndent(VNICS_NETWORK, network.toString(), + TAB + TAB + TAB + TAB)); + addEntryWithIndent(VNICS_PROTOCOLS, nicQuestionnaire.getProtocols().toString(), + TAB + TAB + TAB + TAB); + + Optional<IpConfiguration> ipconfigOpt = Optional.of(nicQuestionnaire).map + (NicQuestionnaire::getIpConfiguration); + ipconfigOpt.ifPresent(ipconfig -> addEntryWithIndent(VNICS_IPV4, String.valueOf(ipconfig + .isIpv4Required()), TAB + TAB + TAB + TAB)); + ipconfigOpt.ifPresent(ipconfig -> addEntryWithIndent(VNICS_IPV6, String.valueOf(ipconfig + .isIpv6Required()), TAB + TAB + TAB + TAB)); + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void addEntriesPerComponent(ComponentQuestionnaire componentQuestionnaire) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + addEntryWithIndent(VFC_NAME, "", TAB + TAB + TAB); + addEntryWithIndent(VFC_DESC, "", TAB + TAB + TAB); + addEntryWithIndent(VFC_IMAGES, "", TAB + TAB + TAB); + //todo component name +desc +img+vcpu + addEntryWithIndent(VFC_COMPUTE, "", TAB + TAB + TAB); + addEntryWithIndent(VFC_COMPUTE_VCPU, "", TAB + TAB + TAB + TAB); + addEntryWithIndent(VFC_COMPUTE_CPU_OVER_SUBSCRIPTION, "", + TAB + TAB + TAB + TAB); + addEntryWithIndent(VFC_COMPUTE_MEMORY, "", TAB + TAB + TAB + TAB); + addEntryWithIndent(VFC_COMPUTE_DISK, "", TAB + TAB + TAB + TAB); + + addEntryWithIndent(HYPERVISOR_DETAILS, "", TAB + TAB + TAB); + + Optional<Hypervisor> hypervisorOpt = Optional.of(componentQuestionnaire).map( + ComponentQuestionnaire::getGeneral).map( + org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general + .General::getHypervisor); + hypervisorOpt.ifPresent(hypervisor -> addEntryWithIndent(HYPERVISOR_DETAILS_NAME, hypervisor + .getHypervisor(), TAB + + TAB + TAB + TAB)); + + hypervisorOpt.ifPresent(hypervisor -> addEntryWithIndent(HYPERVISOR_DETAILS_DRIVERS, hypervisor + .getDrivers(), TAB + TAB + TAB + TAB)); + + addEntryWithIndent(GUEST_OS_DETAILS, "", TAB + TAB + TAB); + Optional<GuestOS> guestOSOptional = Optional.of(componentQuestionnaire).map + (ComponentQuestionnaire::getCompute).map(Compute::getGuestOS); + guestOSOptional.ifPresent(guestOs -> addEntryWithIndent(GUEST_OS_NAME, guestOs.getName(), + TAB + TAB + TAB + TAB)); + + + guestOSOptional + .ifPresent(guestOs -> addEntryWithIndent(GUEST_OS_BIT_SIZE, String.valueOf(guestOs + .getBitSize()), TAB + TAB + TAB + TAB)); + guestOSOptional.ifPresent(guestOs -> addEntryWithIndent(GUEST_OS_TOOLS, guestOs.getTools + (), TAB + TAB + TAB + TAB)); + + addEntryWithIndent(VFC_INSTANCE_NUMBER, "", + TAB + TAB + TAB); + + Optional<NumOfVMs> numVmsOpt = Optional.of(componentQuestionnaire).map + (ComponentQuestionnaire::getCompute).map(Compute::getNumOfVMs); + numVmsOpt.ifPresent(numVms -> addEntryWithIndent(VFC_INSTANCE_NUMBER_MIN, String.valueOf + (numVms.getMinimum()), TAB + TAB + TAB + TAB)); + + numVmsOpt.ifPresent(numVms -> addEntryWithIndent(VFC_INSTANCE_NUMBER_MAX, String.valueOf + (numVms.getMaximum()), TAB + TAB + TAB + TAB)); + + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void addListEntriesWithIndent(List<String> fieldValues, String indent) { + int counter = 1; + if (fieldValues == null) { + return; + } + for (String fieldValue : fieldValues) { + textArtifact.append(indent).append(counter++).append(".").append(TAB).append(fieldValue) + .append + (NL); + } + + } + + + private void addEntryWithIndent(String fieldName, String fieldValue, String indent) { + textArtifact.append(indent).append(fieldName).append(SPACE).append(fieldValue).append(NL); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java new file mode 100644 index 0000000000..76d8210ca5 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.quiestionnaire; + + +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.common.utils.CommonUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*; +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData; +import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ComponentQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.NicQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.VspQuestionnaire; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Created by TALIO on 11/22/2016 + */ +public class QuestionnaireDataServiceImpl implements QuestionnaireDataService { + private static final VendorSoftwareProductDao vendorSoftwareProductDao = + VendorSoftwareProductDaoFactory.getInstance().createInterface(); + private static final VendorSoftwareProductInfoDao vspInfoDao = + VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(); + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + + + public InformationArtifactData generateQuestionnaireDataForInformationArtifact(String vspId, + Version version) { + + + mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId); + + VspDetails vspDetails = + vspInfoDao.get(new VspDetails(vspId, version)); + Collection<ComponentEntity> componentEntities = + vendorSoftwareProductDao.listComponentsQuestionnaire(vspId, version); + Collection<NicEntity> nicEntities = vendorSoftwareProductDao.listNicsByVsp(vspId, version); + + VspQuestionnaire vspQuestionnaire = getVspQuestionnaireFromJson(vspId, version); + List<ComponentQuestionnaire> componentQuestionnaireList = + getListOfComponentQuestionnaireFromJson(componentEntities); + List<NicQuestionnaire> nicQuestionnaireList = getListOfNicQuestionnaireFromJson(nicEntities); + + mdcDataDebugMessage.debugExitMessage("VSP Id", vspId); + return new InformationArtifactData(vspDetails, vspQuestionnaire, componentQuestionnaireList, + nicQuestionnaireList); + } + + private VspQuestionnaire getVspQuestionnaireFromJson(String vspId, Version version) { + VspQuestionnaireEntity vspQuestionnaireEntity = + vspInfoDao.getQuestionnaire(vspId, version); + + if (vspQuestionnaireEntity == null) { + return null; + } + + return JsonUtil + .json2Object(vspQuestionnaireEntity.getQuestionnaireData(), VspQuestionnaire.class); + } + + private List<ComponentQuestionnaire> getListOfComponentQuestionnaireFromJson( + Collection<ComponentEntity> entities) { + List<ComponentQuestionnaire> componentQuestionnaireList = new ArrayList<>(); + + for (CompositionEntity componentEntity : entities) { + componentQuestionnaireList.add(JsonUtil + .json2Object(componentEntity.getQuestionnaireData(), ComponentQuestionnaire.class)); + } + + return componentQuestionnaireList; + } + + + private List<NicQuestionnaire> getListOfNicQuestionnaireFromJson(Collection<NicEntity> entities) { + List<NicQuestionnaire> nicQuestionnaireList = new ArrayList<>(); + + for (NicEntity nicEntity : entities) { + nicQuestionnaireList + .add(JsonUtil.json2Object(nicEntity.getQuestionnaireData(), NicQuestionnaire.class)); + } + + return nicQuestionnaireList; + } + + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java new file mode 100644 index 0000000000..d72a0dbe23 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java @@ -0,0 +1,470 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.impl.composition; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerErrorCode; +import org.openecomp.sdc.logging.types.LoggerErrorDescription; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; +import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; +import org.openecomp.sdc.tosca.datatypes.ToscaFunctions; +import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; +import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; +import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition; +import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; +import org.openecomp.sdc.tosca.errors.ToscaInvalidEntryNotFoundErrorBuilder; +import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstituteNodeTemplateErrorBuilder; +import org.openecomp.sdc.tosca.errors.ToscaMissingSubstitutionMappingForReqCapErrorBuilder; +import org.openecomp.sdc.tosca.services.ToscaAnalyzerService; +import org.openecomp.sdc.tosca.services.ToscaConstants; +import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl; +import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; +import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ExtractCompositionDataContext; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class CompositionDataExtractorImpl implements CompositionDataExtractor { + + protected static Logger logger; + private static ToscaAnalyzerService toscaAnalyzerService; + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + + static { + logger = LoggerFactory.getLogger(CompositionDataExtractorImpl.class); + toscaAnalyzerService = new ToscaAnalyzerServiceImpl(); + } + + /** + * Extract service composition data composition data. + * + * @param toscaServiceModel the tosca service model + * @return the composition data + */ + public CompositionData extractServiceCompositionData(ToscaServiceModel toscaServiceModel) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + ExtractCompositionDataContext context = new ExtractCompositionDataContext(); + String entryDefinitionServiceTemplateFileName = + toscaServiceModel.getEntryDefinitionServiceTemplate(); + ServiceTemplate entryDefinitionServiceTemplate = + toscaServiceModel.getServiceTemplates().get(entryDefinitionServiceTemplateFileName); + extractServiceCompositionData(entryDefinitionServiceTemplateFileName, + entryDefinitionServiceTemplate, toscaServiceModel, context); + + CompositionData compositionData = new CompositionData(); + compositionData.setNetworks(context.getNetworks()); + compositionData.setComponents(context.getComponents()); + + mdcDataDebugMessage.debugExitMessage(null); + return compositionData; + } + + private void extractServiceCompositionData(String serviceTemplateFileName, + ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel, + ExtractCompositionDataContext context) { + if (context.getHandledServiceTemplates().contains(serviceTemplateFileName)) { + return; + } + context.addNetworks(extractNetworks(serviceTemplate, toscaServiceModel)); + extractComponents(serviceTemplate, toscaServiceModel, context); + handleSubstitution(serviceTemplate, toscaServiceModel, context); + context.addHandledServiceTemplates(serviceTemplateFileName); + } + + private void handleSubstitution(ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel, + ExtractCompositionDataContext context) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + Map<String, NodeTemplate> substitutableNodeTemplates = + toscaAnalyzerService.getSubstitutableNodeTemplates(serviceTemplate); + + if (substitutableNodeTemplates != null) { + for (String substitutableNodeTemplateId : substitutableNodeTemplates.keySet()) { + handleSubstitutableNodeTemplate(serviceTemplate, toscaServiceModel, + substitutableNodeTemplateId, + substitutableNodeTemplates.get(substitutableNodeTemplateId), context); + } + } + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void handleSubstitutableNodeTemplate(ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel, + String substitutableNodeTemplateId, + NodeTemplate substitutableNodeTemplate, + ExtractCompositionDataContext context) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); + Optional<String> substituteServiceTemplateFileName = toscaAnalyzerService + .getSubstituteServiceTemplateName(substitutableNodeTemplateId, substitutableNodeTemplate); + if (!substituteServiceTemplateFileName.isPresent()) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.EXTRACT_COMPOSITION_DATA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), + LoggerErrorDescription.EXTRACT_COMPOSITION_DATA); + throw new CoreException( + new ToscaInvalidSubstituteNodeTemplateErrorBuilder(substitutableNodeTemplateId).build()); + } + if (context.getHandledServiceTemplates().contains(substituteServiceTemplateFileName.get())) { + //each substitution is should be handled once, and will get the connection to the upper + // service level according to the first one which was processed + mdcDataDebugMessage.debugExitMessage(null); + return; + } + + ServiceTemplate substituteServiceTemplate = + toscaServiceModel.getServiceTemplates().get(substituteServiceTemplateFileName.get()); + extractServiceCompositionData(substituteServiceTemplateFileName.get(), + substituteServiceTemplate, toscaServiceModel, context); + + List<Map<String, RequirementAssignment>> substitutableRequirements = + substitutableNodeTemplate.getRequirements(); + + if (CollectionUtils.isEmpty(substitutableRequirements)) { + mdcDataDebugMessage.debugExitMessage(null); + return; + } + + for (Map<String, RequirementAssignment> substitutableReq : substitutableRequirements) { + substitutableReq.keySet().stream().filter(reqId -> { + RequirementAssignment reqAssignment = toscaExtensionYamlUtil + .yamlToObject(toscaExtensionYamlUtil.objectToYaml(substitutableReq.get(reqId)), + RequirementAssignment.class); + + mdcDataDebugMessage.debugExitMessage(null); + return isLinkToNetworkRequirementAssignment(reqAssignment); + }).forEach(reqId -> { + RequirementAssignment linkToNetworkRequirement = toscaExtensionYamlUtil + .yamlToObject(toscaExtensionYamlUtil.objectToYaml(substitutableReq.get(reqId)), + RequirementAssignment.class); + String connectedNodeId = linkToNetworkRequirement.getNode(); + Optional<NodeTemplate> connectedNodeTemplate = + toscaAnalyzerService.getNodeTemplateById(serviceTemplate, connectedNodeId); + + if (connectedNodeTemplate.isPresent() && toscaAnalyzerService + .isTypeOf(connectedNodeTemplate.get(), ToscaNodeType.NATIVE_NETWORK, + serviceTemplate, toscaServiceModel)) { + Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService + .getSubstitutionMappedNodeTemplateByExposedReq( + substituteServiceTemplateFileName.get(), substituteServiceTemplate, reqId); + if (!mappedNodeTemplate.isPresent()) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.EXTRACT_COMPOSITION_DATA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), + LoggerErrorDescription.EXTRACT_COMPOSITION_DATA); + throw new CoreException(new ToscaMissingSubstitutionMappingForReqCapErrorBuilder( + ToscaMissingSubstitutionMappingForReqCapErrorBuilder.MappingExposedEntry + .REQUIREMENT, connectedNodeId).build()); + } + + if (toscaAnalyzerService.isTypeOf(mappedNodeTemplate.get().getValue(), + ToscaNodeType.NATIVE_NETWORK_PORT, serviceTemplate, + toscaServiceModel)) { + Nic port = context.getNics().get(mappedNodeTemplate.get().getKey()); + if (port != null) { + port.setNetworkName(connectedNodeId); + } else { + logger.warn( + "Different ports define for the same component which is used in different " + + "substitution service templates."); + } + } + } else if (!connectedNodeTemplate.isPresent()) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.EXTRACT_COMPOSITION_DATA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), + LoggerErrorDescription.EXTRACT_COMPOSITION_DATA); + throw new CoreException( + new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", connectedNodeId).build()); + } + }); + } + } + + private boolean isLinkToNetworkRequirementAssignment(RequirementAssignment requirement) { + return toscaAnalyzerService.isDesiredRequirementAssignment(requirement, + ToscaCapabilityType.NATIVE_NETWORK_LINKABLE, null, + ToscaRelationshipType.NATIVE_NETWORK_LINK_TO); + } + + + private void connectPortToNetwork(Nic port, NodeTemplate portNodeTemplate) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + List<RequirementAssignment> linkRequirementsToNetwork = + toscaAnalyzerService.getRequirements(portNodeTemplate, ToscaConstants.LINK_REQUIREMENT_ID); + + //port is connected to one network + for (RequirementAssignment linkRequirementToNetwork : linkRequirementsToNetwork) { + port.setNetworkName(linkRequirementToNetwork.getNode()); + } + + mdcDataDebugMessage.debugExitMessage(null); + } + + /* + return Map with key - compute node template id, value - list of connected port node template id + */ + private Map<String, List<String>> getComputeToPortsConnection( + Map<String, NodeTemplate> portNodeTemplates) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + Map<String, List<String>> computeToPortConnection = new HashMap<>(); + if (MapUtils.isEmpty(portNodeTemplates)) { + return computeToPortConnection; + } + for (String portId : portNodeTemplates.keySet()) { + List<RequirementAssignment> bindingRequirementsToCompute = toscaAnalyzerService + .getRequirements(portNodeTemplates.get(portId), ToscaConstants.BINDING_REQUIREMENT_ID); + for (RequirementAssignment bindingRequirementToCompute : bindingRequirementsToCompute) { + computeToPortConnection + .putIfAbsent(bindingRequirementToCompute.getNode(), new ArrayList<>()); + computeToPortConnection.get(bindingRequirementToCompute.getNode()).add(portId); + } + } + + mdcDataDebugMessage.debugExitMessage(null); + return computeToPortConnection; + } + + private void extractComponents(ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel, + ExtractCompositionDataContext context) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + Map<String, NodeTemplate> computeNodeTemplates = toscaAnalyzerService + .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NATIVE_COMPUTE, + toscaServiceModel); + if (MapUtils.isEmpty(computeNodeTemplates)) { + return; + } + Map<String, NodeTemplate> portNodeTemplates = toscaAnalyzerService + .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NATIVE_NETWORK_PORT, + toscaServiceModel); + Map<String, List<String>> computeToPortsConnection = + getComputeToPortsConnection(portNodeTemplates); + Map<String, List<String>> computesGroupedByType = + getNodeTemplatesGroupedByType(computeNodeTemplates); + + computesGroupedByType.keySet() + .stream() + .filter(nodeType -> + !context.getCreatedComponents().contains(nodeType)) + .forEach(nodeType -> extractComponent(serviceTemplate, computeToPortsConnection, + computesGroupedByType, nodeType, context)); + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void extractComponent(ServiceTemplate serviceTemplate, + Map<String, List<String>> computeToPortsConnection, + Map<String, List<String>> computesGroupedByType, + String computeNodeType, + ExtractCompositionDataContext context) { + ComponentData component = new ComponentData(); + component.setName(computeNodeType); + component.setDisplayName(getComponentDisplayName(component.getName())); + component.setVfcCode(component.getDisplayName()); + Component componentModel = new Component(); + componentModel.setData(component); + + String computeId = computesGroupedByType.get(computeNodeType).get(0); + List<String> connectedPortIds = computeToPortsConnection.get(computeId); + + if (connectedPortIds != null) { + componentModel.setNics(new ArrayList<>()); + for (String portId : connectedPortIds) { + Nic port = extractPort(serviceTemplate, portId); + componentModel.getNics().add(port); + context.addNic(portId, port); + } + } + context.addComponent(componentModel); + context.getCreatedComponents().add(computeNodeType); + } + + private Nic extractPort(ServiceTemplate serviceTemplate, String portNodeTemplateId) { + Optional<NodeTemplate> portNodeTemplate = + toscaAnalyzerService.getNodeTemplateById(serviceTemplate, portNodeTemplateId); + if (portNodeTemplate.isPresent()) { + Nic port = new Nic(); + port.setName(portNodeTemplateId); + connectPortToNetwork(port, portNodeTemplate.get()); + return port; + } else { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.EXTRACT_COMPOSITION_DATA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), + LoggerErrorDescription.EXTRACT_COMPOSITION_DATA); + throw new CoreException( + new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", portNodeTemplateId).build()); + } + } + + + private Map<String, List<String>> getNodeTemplatesGroupedByType( + Map<String, NodeTemplate> nodeTemplates) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + Map<String, List<String>> nodeTemplatesGrouped = + new HashMap<>(); //key - node type, value - list of node ids with this type + for (String nodeId : nodeTemplates.keySet()) { + String nodeType = nodeTemplates.get(nodeId).getType(); + nodeTemplatesGrouped.putIfAbsent(nodeType, new ArrayList<>()); + nodeTemplatesGrouped.get(nodeType).add(nodeId); + } + + mdcDataDebugMessage.debugExitMessage(null); + return nodeTemplatesGrouped; + } + + private List<Network> extractNetworks(ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + List<Network> networks = new ArrayList<>(); + Map<String, NodeTemplate> networkNodeTemplates = toscaAnalyzerService + .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NATIVE_NETWORK, + toscaServiceModel); + if (MapUtils.isEmpty(networkNodeTemplates)) { + mdcDataDebugMessage.debugExitMessage(null); + return networks; + } + for (String networkId : networkNodeTemplates.keySet()) { + Network network = new Network(); + network.setName(networkId); + Optional<Boolean> networkDhcpValue = + getNetworkDhcpValue(serviceTemplate, networkNodeTemplates.get(networkId)); + network.setDhcp(networkDhcpValue.isPresent() ? networkDhcpValue.get() : true); + networks.add(network); + } + + mdcDataDebugMessage.debugExitMessage(null); + return networks; + } + + //dhcp default value is true + private Optional<Boolean> getNetworkDhcpValue(ServiceTemplate serviceTemplate, + NodeTemplate networkNodeTemplate) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + if (networkNodeTemplate == null) { + return Optional.empty(); + } + if (networkNodeTemplate.getProperties() == null + || networkNodeTemplate.getProperties().get(ToscaConstants.DHCP_ENABLED_PROPERTY_NAME) + == null) { + mdcDataDebugMessage.debugExitMessage(null); + return Optional.of(true); + } + + Object dhcp = + networkNodeTemplate.getProperties().get(ToscaConstants.DHCP_ENABLED_PROPERTY_NAME); + if (dhcp instanceof String) { + mdcDataDebugMessage.debugExitMessage(null); + return Optional.of(Boolean.valueOf((String) dhcp)); + } else if (dhcp instanceof Boolean) { + mdcDataDebugMessage.debugExitMessage(null); + return Optional.of((Boolean) dhcp); + } else if (dhcp instanceof Map) { + String inputParameterName = + (String) ((Map) dhcp).get(ToscaFunctions.GET_INPUT.getDisplayName()); + if (inputParameterName != null) { + ParameterDefinition inputParameterDefinition = + serviceTemplate.getTopology_template().getInputs().get(inputParameterName); + if (inputParameterDefinition != null) { + if (inputParameterDefinition.get_default() != null) { + mdcDataDebugMessage.debugExitMessage(null); + return Optional.of(Boolean.valueOf(inputParameterDefinition.get_default().toString())); + } + } else { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.EXTRACT_COMPOSITION_DATA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), + LoggerErrorDescription.EXTRACT_COMPOSITION_DATA); + throw new CoreException( + new ToscaInvalidEntryNotFoundErrorBuilder("Input Parameter", inputParameterName) + .build()); + } + } + } + + mdcDataDebugMessage.debugExitMessage(null); + return Optional.of(true); + } + + @Override + public String getComponentDisplayName(String componentName) { + if (componentName == null) { + return null; + } + String delimiterChar = "."; + if (componentName.contains(delimiterChar)) { + return componentName.substring(componentName.lastIndexOf(delimiterChar) + 1); + } + return componentName; + + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java new file mode 100644 index 0000000000..81cacf75ac --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java @@ -0,0 +1,585 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.impl.composition; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.openecomp.core.utilities.json.JsonSchemaDataGenerator; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; +import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager; +import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +public class CompositionEntityDataManagerImpl implements CompositionEntityDataManager { + + private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR = + "COMPOSITION_ENTITY_DATA_MANAGER_ERR"; + private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG = + "Invalid input: %s may not be null"; + + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + + private Map<CompositionEntityId, CompositionEntityData> entities = new HashMap<>(); + private Map<CompositionEntityType, String> nonDynamicSchemas = new HashMap<>(); + private List<CompositionEntityValidationData> roots = new ArrayList<>(); + + private VendorSoftwareProductInfoDao vspInfoDao; + private ComponentDao componentDao; + private NicDao nicDao; + private NetworkDao networkDao; + + public CompositionEntityDataManagerImpl(VendorSoftwareProductInfoDao vspInfoDao, + ComponentDao componentDao, + NicDao nicDao, NetworkDao networkDao) { + this.vspInfoDao = vspInfoDao; + this.componentDao = componentDao; + this.nicDao = nicDao; + this.networkDao = networkDao; + } + + /** + * Validate entity composition entity validation data. + * + * @param entity the entity + * @param schemaTemplateContext the schema template context + * @param schemaTemplateInput the schema template input + * @return the composition entity validation data + */ + @Override + public CompositionEntityValidationData validateEntity(CompositionEntity entity, + SchemaTemplateContext schemaTemplateContext, + SchemaTemplateInput schemaTemplateInput) { + mdcDataDebugMessage.debugEntryMessage(null); + + if (entity == null) { + throw new CoreException( + new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION) + .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage( + String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity")) + .build()); + } + if (schemaTemplateContext == null) { + throw new CoreException( + new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION) + .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage( + String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "schema template context")) + .build()); + } + + CompositionEntityValidationData validationData = + new CompositionEntityValidationData(entity.getType(), entity.getId()); + String json = + schemaTemplateContext == SchemaTemplateContext.composition ? entity.getCompositionData() + : entity.getQuestionnaireData(); + validationData.setErrors(JsonUtil.validate( + json == null ? JsonUtil.object2Json(new Object()) : json, + generateSchema(schemaTemplateContext, entity.getType(), schemaTemplateInput))); + + mdcDataDebugMessage.debugExitMessage(null); + return validationData; + } + + /** + * Add entity. + * + * @param entity the entity + * @param schemaTemplateInput the schema template input + */ + @Override + public void addEntity(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput) { + if (entity == null) { + throw new CoreException( + new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION) + .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage( + String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity")) + .build()); + } + entities.put(entity.getCompositionEntityId(), + new CompositionEntityData(entity, schemaTemplateInput)); + } + + /** + * Validate entities questionnaire map. + * + * @return the map + */ + @Override + public Map<CompositionEntityId, Collection<String>> validateEntitiesQuestionnaire() { + mdcDataDebugMessage.debugEntryMessage(null); + + Map<CompositionEntityId, Collection<String>> errorsByEntityId = new HashMap<>(); + entities.entrySet().forEach(entry -> { + Collection<String> errors = validateQuestionnaire(entry.getValue()); + if (errors != null) { + errorsByEntityId.put(entry.getKey(), errors); + } + }); + + mdcDataDebugMessage.debugExitMessage(null); + return errorsByEntityId; + } + + /** + * Build trees. + */ + @Override + public void buildTrees() { + Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData = + new HashMap<>(); + entities.entrySet().forEach( + entry -> addValidationDataEntity(entitiesValidationData, entry.getKey(), + entry.getValue().entity)); + } + + public Collection<CompositionEntityValidationData> getTrees() { + return roots; + } + + @Override + public void saveCompositionData(String vspId, Version version, CompositionData compositionData) { + mdcDataDebugMessage.debugEntryMessage(null); + + if (Objects.isNull(compositionData)) { + return; + } + + Map<String, String> networkIdByName = saveNetworks(vspId, version, compositionData); + saveComponents(vspId, version, compositionData, networkIdByName); + + mdcDataDebugMessage.debugExitMessage(null); + } + + @Override + public Set<CompositionEntityValidationData> getAllErrorsByVsp(String vspId) { + CompositionEntityValidationData matchVsp = null; + Set<CompositionEntityValidationData> entitiesWithErrors = new HashSet<>(); + for (CompositionEntityValidationData root : roots) { + if (root.getEntityId().equals(vspId)) { + matchVsp = root; + break; + } + } + + getEntityListWithErrors(matchVsp, entitiesWithErrors); + if (CollectionUtils.isNotEmpty(entitiesWithErrors)) { + updateValidationCompositionEntityName(entitiesWithErrors); + return entitiesWithErrors; + } + + return null; + } + + private boolean isThereErrorsInSubTree(CompositionEntityValidationData entity) { + if (Objects.isNull(entity)) { + return false; + } + + if (CollectionUtils.isNotEmpty(entity.getErrors())) { + return true; + } + + Collection<CompositionEntityValidationData> subEntitiesValidationData = + entity.getSubEntitiesValidationData(); + return !CollectionUtils.isEmpty(subEntitiesValidationData) && + checkForErrorsInChildren(subEntitiesValidationData); + + } + + private boolean checkForErrorsInChildren( + Collection<CompositionEntityValidationData> subEntitiesValidationData) { + boolean result = false; + for (CompositionEntityValidationData subEntity : subEntitiesValidationData) { + if (CollectionUtils.isNotEmpty(subEntity.getErrors())) { + return true; + } + + result = result || isThereErrorsInSubTree(subEntity); + if (result) { + return true; + } + } + return false; + } + + public void saveComponents(String vspId, Version version, CompositionData compositionData, + Map<String, String> networkIdByName) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + if (CollectionUtils.isNotEmpty(compositionData.getComponents())) { + for (Component component : compositionData.getComponents()) { + ComponentEntity componentEntity = new ComponentEntity(vspId, version, null); + componentEntity.setComponentCompositionData(component.getData()); + + String componentId = createComponent(componentEntity).getId(); + + saveNicsByComponent(vspId, version, networkIdByName, component, componentId); + } + } + + mdcDataDebugMessage.debugExitMessage(null); + } + + public void saveNicsByComponent(String vspId, Version version, + Map<String, String> networkIdByName, Component component, + String componentId) { + if (CollectionUtils.isNotEmpty(component.getNics())) { + for (Nic nic : component.getNics()) { + if (nic.getNetworkName() != null && MapUtils.isNotEmpty(networkIdByName)) { + nic.setNetworkId(networkIdByName.get(nic.getNetworkName())); + } + nic.setNetworkName(null); + + NicEntity nicEntity = new NicEntity(vspId, version, componentId, null); + nicEntity.setNicCompositionData(nic); + createNic(nicEntity); + } + } + } + + public Map<String, String> saveNetworks(String vspId, Version version, + CompositionData compositionData) { + mdcDataDebugMessage.debugEntryMessage(null); + + Map<String, String> networkIdByName = new HashMap<>(); + if (CollectionUtils.isNotEmpty(compositionData.getNetworks())) { + for (Network network : compositionData.getNetworks()) { + + NetworkEntity networkEntity = new NetworkEntity(vspId, version, null); + networkEntity.setNetworkCompositionData(network); + + if (network.getName() != null) { + networkIdByName.put(network.getName(), createNetwork(networkEntity).getId()); + } + } + } + + mdcDataDebugMessage.debugExitMessage(null); + return networkIdByName; + } + + @Override + public NetworkEntity createNetwork(NetworkEntity network) { + mdcDataDebugMessage.debugEntryMessage(null); + + //network.setId(CommonMethods.nextUuId()); will be set by the dao + networkDao.create(network); + mdcDataDebugMessage.debugExitMessage(null); + return network; + } + + @Override + public ComponentEntity createComponent(ComponentEntity component) { + mdcDataDebugMessage.debugEntryMessage(null); + + //component.setId(CommonMethods.nextUuId()); will be set by the dao + component.setQuestionnaireData( + new JsonSchemaDataGenerator( + generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.component, + null)) + .generateData()); + + componentDao.create(component); + + mdcDataDebugMessage.debugExitMessage(null); + return component; + } + + @Override + public NicEntity createNic(NicEntity nic) { + mdcDataDebugMessage.debugEntryMessage(null); + + //nic.setId(CommonMethods.nextUuId()); will be set by the dao + nic.setQuestionnaireData( + new JsonSchemaDataGenerator( + generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, null)) + .generateData()); + + nicDao.create(nic); + + mdcDataDebugMessage.debugExitMessage(null); + return nic; + } + + + public void addErrorsToTrees(Map<CompositionEntityId, Collection<String>> errors) { + roots.forEach(root -> addErrorsToTree(root, null, errors)); + } + + /* * + * get a flat list of all questionnaire entities that have validation errors + * */ + public Set<CompositionEntityValidationData> getEntityListWithErrors() { + mdcDataDebugMessage.debugEntryMessage(null); + Set<CompositionEntityValidationData> treeAsList = new HashSet<>(); + + for (CompositionEntityValidationData entity : roots) { + if (CollectionUtils.isNotEmpty(entity.getErrors())) { + addNodeWithErrors(entity, treeAsList); + } + getEntityListWithErrors(entity, treeAsList); + } + + updateValidationCompositionEntityName(treeAsList); + + mdcDataDebugMessage.debugExitMessage(null); + return treeAsList; + } + + public void getEntityListWithErrors(CompositionEntityValidationData entity, + Set<CompositionEntityValidationData> compositionSet) { + Collection<CompositionEntityValidationData> childNodes = + entity.getSubEntitiesValidationData(); + + if (CollectionUtils.isEmpty(childNodes)) { + return; + } + + for (CompositionEntityValidationData child : childNodes) { + if (CollectionUtils.isNotEmpty(child.getErrors())) { + addNodeWithErrors(child, compositionSet); + } + getEntityListWithErrors(child, compositionSet); + } + } + + + public void addNodeWithErrors(CompositionEntityValidationData node, + Set<CompositionEntityValidationData> entitiesWithErrors) { + CompositionEntityValidationData compositionNodeToAdd = new CompositionEntityValidationData(node + .getEntityType(), node.getEntityId()); + compositionNodeToAdd.setErrors(node.getErrors()); + compositionNodeToAdd.setSubEntitiesValidationData(null); + + entitiesWithErrors.add(compositionNodeToAdd); + } + + public void removeNodesWithoutErrors() { + roots.forEach(root -> removeNodesWithoutErrors(root, null)); + } + + + private CompositionEntityData getCompositionEntityDataById(CompositionEntityValidationData + entity) { + for (Map.Entry<CompositionEntityId, CompositionEntityData> entityEntry : entities + .entrySet()) { + if (entityEntry.getKey().getId().equals(entity.getEntityId())) { + return entityEntry.getValue(); + } + } + return null; + } + + + private void updateValidationCompositionEntityName(Set<CompositionEntityValidationData> + compositionSet) { + for (CompositionEntityValidationData entity : compositionSet) { + String compositionData = getCompositionDataAsString(entity); + if (entity.getEntityType().equals(CompositionEntityType.vsp) || + Objects.nonNull(compositionData)) { + entity.setEntityName(getEntityNameByEntityType(compositionData, entity)); + } + } + } + + private String getCompositionDataAsString(CompositionEntityValidationData entity) { + CompositionEntityData compositionEntityData = getCompositionEntityDataById(entity); + return compositionEntityData == null ? null : compositionEntityData.entity.getCompositionData(); + } + + + private String getEntityNameByEntityType(String compositionData, + CompositionEntityValidationData entity) { + switch (entity.getEntityType()) { + case component: + ComponentData component = JsonUtil.json2Object(compositionData, ComponentData.class); + return component.getDisplayName(); + + case nic: + Nic nic = JsonUtil.json2Object(compositionData, Nic.class); + return nic.getName(); + + case network: + Network network = JsonUtil.json2Object(compositionData, Network.class); + return network.getName(); + + case vsp: + CompositionEntityData vspEntity = getCompositionEntityDataById(entity); + VspQuestionnaireEntity vspQuestionnaireEntity = (VspQuestionnaireEntity) vspEntity.entity; + VspDetails vspDetails = + vspInfoDao.get(new VspDetails(vspQuestionnaireEntity.getId(), + vspQuestionnaireEntity.getVersion())); + return vspDetails.getName(); + } + + return null; + } + + private void removeNodesWithoutErrors(CompositionEntityValidationData node, + CompositionEntityValidationData parent) { + + if (Objects.isNull(node)) { + return; + } + + if (hasChildren(node)) { + Collection<CompositionEntityValidationData> subNodes = + new ArrayList<>(node.getSubEntitiesValidationData()); + subNodes.forEach(subNode -> removeNodesWithoutErrors(subNode, node)); + node.setSubEntitiesValidationData(subNodes); + + if (canNodeGetRemovedFromValidationDataTree(node)) { + removeNodeFromChildren(parent, node); + } + } else if (canNodeGetRemovedFromValidationDataTree(node)) { + removeNodeFromChildren(parent, node); + } + } + + private void removeNodeFromChildren(CompositionEntityValidationData parent, + CompositionEntityValidationData childToRemove) { + if (!Objects.isNull(parent)) { + parent.getSubEntitiesValidationData().remove(childToRemove); + } + } + + private boolean hasChildren(CompositionEntityValidationData node) { + return !CollectionUtils.isEmpty(node.getSubEntitiesValidationData()); + } + + private boolean canNodeGetRemovedFromValidationDataTree(CompositionEntityValidationData node) { + return !hasChildren(node) && CollectionUtils.isEmpty(node.getErrors()); + } + + + private void addValidationDataEntity( + Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData, + CompositionEntityId entityId, CompositionEntity entity) { + if (entitiesValidationData.containsKey(entityId)) { + return; + } + + CompositionEntityValidationData validationData = + new CompositionEntityValidationData(entity.getType(), entity.getId()); + entitiesValidationData.put(entityId, validationData); + + CompositionEntityId parentEntityId = entityId.getParentId(); + if (parentEntityId == null) { + roots.add(validationData); + } else { + CompositionEntityData parentEntity = entities.get(parentEntityId); + if (parentEntity == null) { + roots.add(validationData); + } else { + addValidationDataEntity(entitiesValidationData, parentEntityId, parentEntity.entity); + entitiesValidationData.get(parentEntityId).addSubEntityValidationData(validationData); + } + } + } + + private void addErrorsToTree(CompositionEntityValidationData node, + CompositionEntityId parentNodeId, + Map<CompositionEntityId, Collection<String>> errors) { + if (node == null) { + return; + } + CompositionEntityId nodeId = new CompositionEntityId(node.getEntityId(), parentNodeId); + node.setErrors(errors.get(nodeId)); + + if (node.getSubEntitiesValidationData() != null) { + node.getSubEntitiesValidationData() + .forEach(subNode -> addErrorsToTree(subNode, nodeId, errors)); + } + } + + private Collection<String> validateQuestionnaire(CompositionEntityData compositionEntityData) { + return JsonUtil.validate( + compositionEntityData.entity.getQuestionnaireData() == null + ? JsonUtil.object2Json(new Object()) + : compositionEntityData.entity.getQuestionnaireData(), + getSchema(compositionEntityData.entity.getType(), SchemaTemplateContext.questionnaire, + compositionEntityData.schemaTemplateInput)); + } + + private String getSchema(CompositionEntityType compositionEntityType, + SchemaTemplateContext schemaTemplateContext, + SchemaTemplateInput schemaTemplateInput) { + return schemaTemplateInput == null + ? nonDynamicSchemas.computeIfAbsent(compositionEntityType, + k -> generateSchema(schemaTemplateContext, compositionEntityType, null)) + : generateSchema(schemaTemplateContext, compositionEntityType, schemaTemplateInput); + } + + private static class CompositionEntityData { + private CompositionEntity entity; + private SchemaTemplateInput schemaTemplateInput; + + CompositionEntityData(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput) { + this.entity = entity; + this.schemaTemplateInput = schemaTemplateInput; + } + + } + + // todo - make SchemaGenerator non static and mock it in UT instead of mocking this method (and + // make the method private + + protected String generateSchema(SchemaTemplateContext schemaTemplateContext, + CompositionEntityType compositionEntityType, + SchemaTemplateInput schemaTemplateInput) { + return SchemaGenerator + .generate(schemaTemplateContext, compositionEntityType, schemaTemplateInput); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java new file mode 100644 index 0000000000..2822d958d0 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java @@ -0,0 +1,621 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule; + +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.common.utils.SdcCommon; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.heat.datatypes.manifest.FileData; +import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; +import org.openecomp.sdc.heat.datatypes.structure.Artifact; +import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.errors.utils.ErrorsUtil; +import org.openecomp.sdc.vendorsoftwareproduct.services.HeatFileAnalyzer; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.ManifestCreator; +import org.openecomp.sdc.vendorsoftwareproduct.services.utils.CandidateServiceValidator; +import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + +public class CandidateServiceImpl implements CandidateService { + protected static final Logger logger = LoggerFactory.getLogger(CandidateServiceImpl.class); + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + + private CandidateServiceValidator candidateServiceValidator = new CandidateServiceValidator(); + private ManifestCreator manifestCreator; + private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao; + + public CandidateServiceImpl(ManifestCreator manifestCreator, + OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao) { + this.manifestCreator = manifestCreator; + this.orchestrationTemplateCandidateDataDao = orchestrationTemplateCandidateDataDao; + + } + + public CandidateServiceImpl() { + } + + @Override + public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + if (Objects.isNull(heatFileToUpload)) { + return Optional.of(new ErrorMessage(ErrorLevel.ERROR, + Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage())); + } else { + try { + int available = heatFileToUpload.available(); + if (available == 0) { + mdcDataDebugMessage.debugExitMessage(null); + return Optional.of(new ErrorMessage(ErrorLevel.ERROR, + Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage())); + } + } catch (IOException e) { + mdcDataDebugMessage.debugExitMessage(null); + return Optional.of(new ErrorMessage(ErrorLevel.ERROR, + Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage())); + } + } + + mdcDataDebugMessage.debugExitMessage(null); + return Optional.empty(); + } + + @Override + public Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData) { + if (Objects.isNull(uploadedFileData)) { + return Optional.of(new ErrorMessage(ErrorLevel.ERROR, + Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage())); + } + return Optional.empty(); + } + + private String heatStructureTreeToFileDataStructure(HeatStructureTree tree, + FileContentHandler zipContentMap, + Map<String, List<ErrorMessage>> uploadErrors, + AnalyzedZipHeatFiles analyzedZipHeatFiles) + throws Exception { + FilesDataStructure structure = new FilesDataStructure(); + Set<String> usedEnvFiles = new HashSet<>(); + addHeatsToFileDataStructure(tree, usedEnvFiles, structure, uploadErrors, + analyzedZipHeatFiles); + handleOtherResources(tree, usedEnvFiles, structure); + FilesDataStructure fileDataStructureFromManifest = + createFileDataStructureFromManifest(zipContentMap.getFileContent + (SdcCommon.MANIFEST_NAME)); + structure.getArtifacts().addAll(fileDataStructureFromManifest.getArtifacts()); + handleArtifactsFromTree(tree, structure); + + return JsonUtil.object2Json(structure); + } + + @Override + public OrchestrationTemplateCandidateData createCandidateDataEntity( + CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest, + AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception { + + + mdcDataDebugMessage.debugEntryMessage(null); + + FileContentHandler zipContentMap = candidateDataEntityTo.getContentMap(); + FilesDataStructure filesDataStructure; + String dataStructureJson; + + if (zipFileManifest != null) { + // create data structure from manifest + filesDataStructure = createFileDataStructureFromManifest(zipFileManifest); + Set<String> zipFileList = zipContentMap.getFileList(); + balanceManifestFilesWithZipFiles(filesDataStructure, + zipContentMap, analyzedZipHeatFiles); + Set<String> filesDataStructureFiles = getFlatFileNames(filesDataStructure); + filesDataStructure.getUnassigned().addAll(zipFileList.stream() + .filter(fileName -> (!filesDataStructureFiles.contains(fileName) && + !filesDataStructure.getNested().contains(fileName) && + !fileName.equals(SdcCommon.MANIFEST_NAME))) + .collect(Collectors.toList())); + dataStructureJson = JsonUtil.object2Json(filesDataStructure); + } else { + // create data structure from based on naming convention + dataStructureJson = + heatStructureTreeToFileDataStructure(candidateDataEntityTo.getTree(), zipContentMap, + candidateDataEntityTo.getErrors(), analyzedZipHeatFiles); + } + + mdcDataDebugMessage.debugExitMessage(null); + return new OrchestrationTemplateCandidateData( + ByteBuffer.wrap(candidateDataEntityTo.getUploadedFileData()), dataStructureJson); + } + + private void balanceManifestFilesWithZipFiles( + FilesDataStructure filesDataStructure, + FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles) + throws Exception { + Set<String> zipFileList = fileContentHandler.getFileList(); + filesDataStructure.getNested().addAll(analyzedZipHeatFiles.getNestedFiles()); + List<Module> modules = filesDataStructure.getModules(); + if (CollectionUtils.isEmpty(modules)) { + return; + } + + for (int i = 0; i < modules.size(); i++) { + Module module = modules.get(i); + if (!isFileExistInZipContains(zipFileList, module.getYaml())) { + addFileToUnassigned(filesDataStructure, zipFileList, module.getEnv()); + addFileToUnassigned(filesDataStructure, zipFileList, module.getVol()); + addFileToUnassigned(filesDataStructure, zipFileList, module.getVolEnv()); + modules.remove(i--); + } else if (Objects.nonNull(module.getVol()) && !zipFileList.contains(module.getVol())) { + module.setVol(null); + CollectionUtils.addIgnoreNull(filesDataStructure.getUnassigned(), module.getVolEnv()); + } else { + if (filesDataStructure.getNested().contains(module.getYaml())) { + moveModuleFileToNested(filesDataStructure, i--, module); + } + } + } + } + + private void addFileToUnassigned(FilesDataStructure filesDataStructure, Set<String> zipFileList, + String fileName) { + if (isFileExistInZipContains(zipFileList, fileName)) { + filesDataStructure.getUnassigned().add(fileName); + } + } + + private boolean isFileExistInZipContains(Set<String> zipFileList, String fileName) { + return Objects.nonNull(fileName) && zipFileList.contains(fileName); + } + + private void moveModuleFileToNested(FilesDataStructure filesDataStructure, int i, Module module) { + if (!filesDataStructure.getNested().contains(module.getYaml())) { + filesDataStructure.getNested().add(module.getYaml()); + } + if (Objects.nonNull(module.getEnv())) { + filesDataStructure.getNested().add(module.getEnv()); + } + if (Objects.nonNull(module.getVol())) { + filesDataStructure.getNested().add(module.getVol()); + } + if (Objects.nonNull(module.getVolEnv())) { + filesDataStructure.getNested().add(module.getVolEnv()); + } + filesDataStructure.getModules().remove(i); + } + + private Set<String> getFlatFileNames(FilesDataStructure filesDataStructure) { + Set<String> fileNames = new HashSet<>(); + if (!CollectionUtils.isEmpty(filesDataStructure.getModules())) { + for (Module module : filesDataStructure.getModules()) { + CollectionUtils.addIgnoreNull(fileNames, module.getEnv()); + CollectionUtils.addIgnoreNull(fileNames, module.getVol()); + CollectionUtils.addIgnoreNull(fileNames, module.getVolEnv()); + CollectionUtils.addIgnoreNull(fileNames, module.getYaml()); + } + } + fileNames.addAll(filesDataStructure.getArtifacts().stream().collect(Collectors.toSet())); + fileNames.addAll(filesDataStructure.getNested().stream().collect(Collectors.toSet())); + fileNames.addAll(filesDataStructure.getUnassigned().stream().collect(Collectors.toSet())); + + return fileNames; + } + + private FilesDataStructure createFileDataStructureFromManifest(InputStream isManifestContent) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + ManifestContent manifestContent = + JsonUtil.json2Object(isManifestContent, ManifestContent.class); + FilesDataStructure structure = new FilesDataStructure(); + for (FileData fileData : manifestContent.getData()) { + if (Objects.nonNull(fileData.getType()) && fileData.getType().equals(FileData.Type.HEAT)) { + Module module = new Module(); + module.setYaml(fileData.getFile()); + module.setIsBase(fileData.getBase()); + addHeatDependenciesToModule(module, fileData.getData()); + structure.getModules().add(module); + } else if (HeatFileAnalyzer.isYamlOrEnvFile(fileData.getFile()) && + !FileData.Type.isArtifact(fileData.getType())) { + structure.getUnassigned().add(fileData.getFile()); + } else { + structure.getArtifacts().add(fileData.getFile()); + } + } + + mdcDataDebugMessage.debugExitMessage(null); + return structure; + } + + private void addHeatDependenciesToModule(Module module, List<FileData> data) { + if (CollectionUtils.isEmpty(data)) { + return; + } + + for (FileData fileData : data) { + if (fileData.getType().equals(FileData.Type.HEAT_ENV)) { + module.setEnv(fileData.getFile()); + } else if (fileData.getType().equals(FileData.Type.HEAT_VOL))// must be volume + { + module.setVol(fileData.getFile()); + if (!CollectionUtils.isEmpty(fileData.getData())) { + FileData volEnv = fileData.getData().get(0); + if (volEnv.getType().equals(FileData.Type.HEAT_ENV)) { + module.setVolEnv(volEnv.getFile()); + } else { + throw new CoreException((new ErrorCode.ErrorCodeBuilder()) + .withMessage(Messages.ILLEGAL_MANIFEST.getErrorMessage()) + .withId(Messages.ILLEGAL_MANIFEST.getErrorMessage()) + .withCategory(ErrorCategory.APPLICATION).build()); + } + } + } else { + throw new CoreException((new ErrorCode.ErrorCodeBuilder()) + .withMessage(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage()) + .withId(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage()) + .withCategory(ErrorCategory.APPLICATION).build()); + } + } + } + + @Override + public void updateCandidateUploadData(OrchestrationTemplateCandidateData uploadData, + String itemId) { + mdcDataDebugMessage.debugEntryMessage(null); + + //vendorSoftwareProductDao.updateCandidateUploadData(uploadData); + orchestrationTemplateCandidateDataDao.update(itemId, uploadData); + + mdcDataDebugMessage.debugExitMessage(null); + } + + @Override + public Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure( + String vspId, Version version) { + + mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId); + + Optional<String> jsonFileDataStructure = + orchestrationTemplateCandidateDataDao.getStructure(vspId, version); + + if (jsonFileDataStructure.isPresent()) { + mdcDataDebugMessage.debugExitMessage("VSP Id", vspId); + return Optional + .of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class)); + } else { + mdcDataDebugMessage.debugExitMessage("VSP Id", vspId); + return Optional.empty(); + } + } + + @Override + public void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version, + FilesDataStructure fileDataStructure) { + OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface() + .updateStructure(vspId, version, fileDataStructure); + } + + @Override + public OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId, + Version version) { + mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId); + mdcDataDebugMessage.debugExitMessage("VSP Id", vspId); + + return orchestrationTemplateCandidateDataDao.get(vspId, version); + } + + @Override + public String createManifest(VspDetails vspDetails, FilesDataStructure structure) { + + mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId()); + + Optional<ManifestContent> manifest = manifestCreator.createManifest(vspDetails, structure); + if (!manifest.isPresent()) { + throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()); + } + + mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId()); + return JsonUtil.object2Json(manifest.get()); + } + + @Override + public Optional<ManifestContent> createManifest(VspDetails vspDetails, + FileContentHandler fileContentHandler, + AnalyzedZipHeatFiles analyzedZipHeatFiles) { + + + mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId()); + + mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId()); + return manifestCreator.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles); + } + + @Override + public Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId, + OrchestrationTemplateCandidateData candidateDataEntity, + String manifest, + Map<String, List<ErrorMessage>> uploadErrors) { + byte[] file; + ByteArrayInputStream byteArrayInputStream = null; + try { + file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, vspId); + byteArrayInputStream = new ByteArrayInputStream( + Objects.isNull(file) ? candidateDataEntity.getContentData().array() + : file); + } catch (IOException e) { + ErrorMessage errorMessage = + new ErrorMessage(ErrorLevel.ERROR, Messages.CANDIDATE_PROCESS_FAILED.getErrorMessage()); + logger.error(errorMessage.getMessage(), e); + ErrorsUtil.addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, errorMessage, uploadErrors); + } + return Optional.ofNullable(byteArrayInputStream); + } + + @Override + public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId) + throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + try (final ZipOutputStream zos = new ZipOutputStream(baos); + ZipInputStream zipStream = new ZipInputStream( + new ByteArrayInputStream(contentData.array()))) { + ZipEntry zipEntry; + boolean manifestWritten = false; + while ((zipEntry = zipStream.getNextEntry()) != null) { + if (!zipEntry.getName().equalsIgnoreCase(SdcCommon.MANIFEST_NAME)) { + ZipEntry loc_ze = new ZipEntry(zipEntry.getName()); + zos.putNextEntry(loc_ze); + byte[] buf = new byte[1024]; + int len; + while ((len = zipStream.read(buf)) > 0) { + zos.write(buf, 0, (len < buf.length) ? len : buf.length); + } + } else { + manifestWritten = true; + writeManifest(manifest, zos); + } + zos.closeEntry(); + } + if (!manifestWritten) { + writeManifest(manifest, zos); + zos.closeEntry(); + } + } + return baos.toByteArray(); + } + + @Override + public Optional<List<ErrorMessage>> validateFileDataStructure( + FilesDataStructure filesDataStructure) { + return candidateServiceValidator.validateFileDataStructure(filesDataStructure); + } + + private void writeManifest(String manifest, ZipOutputStream zos) throws IOException { + zos.putNextEntry(new ZipEntry(SdcCommon.MANIFEST_NAME)); + try (InputStream manifestStream = new ByteArrayInputStream( + manifest.getBytes(StandardCharsets.UTF_8))) { + byte[] buf = new byte[1024]; + int len; + while ((len = (manifestStream.read(buf))) > 0) { + zos.write(buf, 0, (len < buf.length) ? len : buf.length); + } + } + } + + private void handleArtifactsFromTree(HeatStructureTree tree, FilesDataStructure structure) { + + if (Objects.isNull(tree) || Objects.isNull(tree.getArtifacts())) { + return; + } + + if (CollectionUtils.isNotEmpty(tree.getArtifacts())) { + structure.getArtifacts().addAll( + tree.getArtifacts() + .stream() + .map(Artifact::getFileName) + .filter(fileName -> !structure.getArtifacts().contains(fileName)) + .collect(Collectors.toList())); + } + } + + private void handleOtherResources(HeatStructureTree tree, Set<String> usedEnvFiles, + FilesDataStructure structure) { + Set<HeatStructureTree> others = tree.getOther(); + if (Objects.isNull(others)) { + return; + } + + List<String> artifacts = new ArrayList<>(); + List<String> unassigned = new ArrayList<>(); + for (HeatStructureTree other : others) { + if (HeatFileAnalyzer.isYamlOrEnvFile(other.getFileName())) { + if (isEnvFileUsedByHeatFile(usedEnvFiles, other)) { + continue; + } + unassigned.add(other.getFileName()); + } else { + artifacts.add(other.getFileName()); + } + handleArtifactsFromTree(other, structure); + } + structure.getArtifacts().addAll(artifacts); + structure.getUnassigned().addAll(unassigned); + } + + private boolean isEnvFileUsedByHeatFile(Set<String> usedEnvFiles, HeatStructureTree other) { + if (HeatFileAnalyzer.isEnvFile(other.getFileName())) { + if (usedEnvFiles.contains(other.getFileName())) { + return true; + } + } + return false; + } + + private void addHeatsToFileDataStructure(HeatStructureTree tree, Set<String> usedEnvFiles, + FilesDataStructure structure, + Map<String, List<ErrorMessage>> uploadErrors, + AnalyzedZipHeatFiles analyzedZipHeatFiles) + throws Exception { + List<Module> modules = new ArrayList<>(); + Set<HeatStructureTree> heatsSet = tree.getHeat(); + if (Objects.isNull(heatsSet)) { + return; + } + for (HeatStructureTree heat : heatsSet) { + if (isFileBaseFile(heat.getFileName())) { + handleSingleHeat(structure, modules, heat, uploadErrors); + } else if (isFileModuleFile(heat.getFileName(), analyzedZipHeatFiles.getModuleFiles())) { + handleSingleHeat(structure, modules, heat, uploadErrors); + } else { + structure.getUnassigned().add(heat.getFileName()); + addNestedToFileDataStructure(heat, structure); + } + if (!Objects.isNull(heat.getEnv())) { + usedEnvFiles.add(heat.getEnv() == null ? null : heat.getEnv().getFileName()); + } + } + structure.setModules(modules); + + } + + private boolean isFileModuleFile(String fileName, Set<String> modulesFileNames) { + return modulesFileNames.contains(fileName); + } + + private boolean isFileBaseFile(String fileName) { + return manifestCreator.isFileBaseFile(fileName); + } + + private void handleSingleHeat(FilesDataStructure structure, List<Module> modules, + HeatStructureTree heat, + Map<String, List<ErrorMessage>> uploadErrors) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + Module module = new Module(); + module.setYaml(heat.getFileName()); + module.setIsBase(heat.getBase()); + addNestedToFileDataStructure(heat, structure); + Set<HeatStructureTree> volumeSet = heat.getVolume(); + int inx = 0; + if (Objects.nonNull(volumeSet)) { + handleVolumes(module, volumeSet, structure, inx, uploadErrors); + } + handleEnv(module, heat, false, structure); + modules.add(module); + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void handleVolumes(Module module, Set<HeatStructureTree> volumeSet, + FilesDataStructure structure, int inx, + Map<String, List<ErrorMessage>> uploadErrors) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + for (HeatStructureTree volume : volumeSet) { + if (inx++ > 0) { + ErrorsUtil.addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, + new ErrorMessage(ErrorLevel.WARNING, + Messages.MORE_THEN_ONE_VOL_FOR_HEAT.getErrorMessage()), uploadErrors); + break; + } + handleArtifactsFromTree(volume, structure); + module.setVol(volume.getFileName()); + handleEnv(module, volume, true, structure); + } + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void handleEnv(Module module, HeatStructureTree tree, boolean isVolEnv, + FilesDataStructure structure) { + + + mdcDataDebugMessage.debugEntryMessage(null); + + if (Objects.nonNull(tree.getEnv())) { + if (isVolEnv) { + module.setVolEnv(tree.getEnv().getFileName()); + } else { + module.setEnv(tree.getEnv().getFileName()); + } + handleArtifactsFromTree(tree.getEnv(), structure); + } + + mdcDataDebugMessage.debugExitMessage(null); + } + + private void addNestedToFileDataStructure(HeatStructureTree heat, FilesDataStructure structure) { + Set<HeatStructureTree> nestedSet = heat.getNested(); + if (Objects.isNull(nestedSet)) { + return; + } + for (HeatStructureTree nested : nestedSet) { + if (structure.getNested().contains(nested.getFileName())) { + continue; + } + structure.getNested().add(nested.getFileName()); + if (CollectionUtils.isNotEmpty(nested.getArtifacts())) { + handleArtifactsFromTree(nested, structure); + } + addNestedToFileDataStructure(nested, structure); + } + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java new file mode 100644 index 0000000000..eed575ff02 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java @@ -0,0 +1,309 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule; + +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.heat.datatypes.manifest.FileData; +import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.services.HeatFileAnalyzer; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.ManifestCreator; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Constants; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.regex.Pattern; + +public class ManifestCreatorNamingConventionImpl implements ManifestCreator { + protected static final Logger logger = + LoggerFactory.getLogger(ManifestCreatorNamingConventionImpl.class); + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + + + @Override + public Optional<ManifestContent> createManifest( + VspDetails vspDetails, FilesDataStructure filesDataStructure) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (Objects.isNull(filesDataStructure)) { + return Optional.empty(); + } + + List<FileData> fileDataList = new ArrayList<>(); + addModulesToManifestFileDataList(filesDataStructure, fileDataList); + addNestedToManifest(filesDataStructure, fileDataList); + addArtifactsToManifestFileDataList(filesDataStructure, fileDataList); + ManifestContent manifestContent = createManifest(vspDetails, fileDataList); + + mdcDataDebugMessage.debugExitMessage(null, null); + return Optional.of(manifestContent); + } + + private void addNestedToManifest( + FilesDataStructure filesDataStructure, List<FileData> fileDataList) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (CollectionUtils.isNotEmpty(filesDataStructure.getNested())) { + for (String nested : filesDataStructure.getNested()) { + fileDataList.add(createBaseFileData(FileData.Type.HEAT, nested)); + } + } + + mdcDataDebugMessage.debugExitMessage(null, null); + } + + @Override + public Optional<ManifestContent> createManifest(VspDetails vspDetails, + FileContentHandler fileContentHandler, + AnalyzedZipHeatFiles analyzedZipHeatFiles) { + logger.info("Trying to generate manifest"); + if (Objects.isNull(fileContentHandler) + || CollectionUtils.isEmpty(fileContentHandler.getFileList())) { + logger.info("fileContentHandler or filesList is empty. ManifestContent will not be created"); + return Optional.empty(); + } + + Map<String, byte[]> files = fileContentHandler.getFiles(); + + List<FileData> fileDataList = + createFileDataListFromZipFiles(fileContentHandler, files, + analyzedZipHeatFiles.getFilesNotEligbleForModules()); + ManifestContent manifestContent = createManifest(vspDetails, fileDataList); + + return Optional.of(manifestContent); + } + + private ManifestContent createManifest(VspDetails vspDetails, List<FileData> fileDataList) { + ManifestContent manifestContent = new ManifestContent(); + manifestContent.setName(vspDetails.getName()); + manifestContent.setDescription(vspDetails.getDescription()); + manifestContent + .setVersion(vspDetails.getVersion() == null ? null : vspDetails.getVersion().toString()); + // vsp version, need to check in confluence + manifestContent.setData(fileDataList); + return manifestContent; + } + + private List<FileData> createFileDataListFromZipFiles(FileContentHandler fileContentHandler, + Map<String, byte[]> files, + Collection<String> filesNotEligibleForModules) { + + Set<String> processedFiles = new HashSet<>(); + List<FileData> fileDataList = new ArrayList<>(); + for (String fileName : files.keySet()) { + if (processedFiles.contains(fileName)) { + continue; + } + if (isFileBaseFile(fileName)) { + fileDataList + .add(createModuleFileData( + fileName, true, processedFiles, fileContentHandler.getFileList(), fileDataList)); + } else if (isFileModuleFile(fileName, filesNotEligibleForModules)) { + fileDataList + .add(createModuleFileData( + fileName, false, processedFiles, fileContentHandler.getFileList(), fileDataList)); + } else { + if (HeatFileAnalyzer.isYamlFile(fileName)) { + fileDataList.add(createBasicFileData(fileName, FileData.Type.HEAT, null)); + } else if (HeatFileAnalyzer.isEnvFile(fileName)) { + fileDataList.add(createBasicFileData(fileName, FileData.Type.HEAT_ENV, null)); + } else { + fileDataList.add(createBasicFileData(fileName, FileData.Type.OTHER, null)); + } + } + } + return fileDataList; + } + + private boolean doesHeatTemplateVersionExist(byte[] value) { + return false; + } + + private boolean isFileModuleFile(String fileName, Collection<String> filesCannotBeModule) { + return !filesCannotBeModule.contains(fileName); + } + + @Override + public boolean isFileBaseFile(String fileName) { + return Pattern.matches(Constants.BASE_HEAT_REGEX, fileName) && !isVolFile(fileName); + } + + + private void addArtifactsToManifestFileDataList( + FilesDataStructure filesDataStructure, List<FileData> fileDataList) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + Collection<String> forArtifacts = CollectionUtils + .union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned()); + if (CollectionUtils.isNotEmpty(forArtifacts)) { + for (String artifact : forArtifacts) { + fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact)); + } + } + + mdcDataDebugMessage.debugExitMessage(null, null); + } + + private void addModulesToManifestFileDataList( + FilesDataStructure filesDataStructure, List<FileData> fileDataList) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (CollectionUtils.isNotEmpty(filesDataStructure.getModules())) { + for (Module module : filesDataStructure.getModules()) { + FileData fileData = createBaseFileData(FileData.Type.HEAT, module.getYaml()); + fileData.setBase(module.getIsBase()); + addEnv(module, fileData); + addVolume(module, fileData); + fileDataList.add(fileData); + } + } + + mdcDataDebugMessage.debugExitMessage(null, null); + } + + private void addEnv(Module module, FileData fileData) { + if (Objects.nonNull(module.getEnv())) { + FileData env = createBaseFileData(FileData.Type.HEAT_ENV, module.getEnv()); + fileData.addFileData(env); + } + } + + private void addVolume(Module module, FileData fileData) { + String volModule = module.getVol(); + if (Objects.nonNull(volModule)) { + FileData vol = createBaseFileData(FileData.Type.HEAT_VOL, volModule); + if (Objects.nonNull(module.getVolEnv())) { + vol.addFileData(createBaseFileData(FileData.Type.HEAT_ENV, module.getVolEnv())); + } + fileData.addFileData(vol); + } + } + + private FileData createBaseFileData(FileData.Type heat, String yaml) { + FileData fileData = new FileData(); + fileData.setType(heat); + fileData.setFile(yaml); + return fileData; + } + + private FileData createModuleFileData( + String moduleFileName, boolean isBase, Set<String> processedFiles, + Set<String> fileNames, List<FileData> fileDataList) { + FileData moduleFileData = createBasicFileData(moduleFileName, FileData.Type.HEAT, isBase); + Optional<String> volFile = fetchRelatedVolume(moduleFileName, fileNames); + volFile.ifPresent(vol -> { + markFileAsProcessed(vol, processedFiles); + removeFromFileDataListIfAlreadyProcessed(fileDataList, vol); + FileData volFileData = createBasicFileData(vol, FileData.Type.HEAT_VOL, null); + Optional<String> envFile = fetchRelatedEnv(vol, fileNames); + envFile.ifPresent(env -> { + markFileAsProcessed(env, processedFiles); + removeFromFileDataListIfAlreadyProcessed(fileDataList, env); + FileData envFileData = createBasicFileData(env, FileData.Type.HEAT_ENV, null); + volFileData.addFileData(envFileData); + }); + moduleFileData.addFileData(volFileData); + }); + Optional<String> envFile = fetchRelatedEnv(moduleFileName, fileNames); + envFile.ifPresent(env -> { + markFileAsProcessed(env, processedFiles); + FileData envFileData = createBasicFileData(env, FileData.Type.HEAT_ENV, null); + moduleFileData.addFileData(envFileData); + }); + return moduleFileData; + } + + private void removeFromFileDataListIfAlreadyProcessed(List<FileData> fileDataList, String vol) { + fileDataList.removeIf(fileData -> fileData.getFile().equals(vol)); + } + + private FileData createBasicFileData(String fileName, FileData.Type type, Boolean isBase) { + FileData fileData = new FileData(); + if (isBase != null) { + fileData.setBase(isBase); + } + fileData.setType(type); + fileData.setFile(fileName); + return fileData; + } + + private Optional<String> fetchRelatedEnv(String fileName, Set<String> fileNames) { + String envFileName + = fileName.substring(0, fileName.lastIndexOf(".")) + Constants.ENV_FILE_EXTENSION; + return fileNames.contains(envFileName) ? Optional.of(envFileName) : Optional.empty(); + } + + private Optional<String> fetchRelatedVolume(String fileName, Set<String> fileNames) { + + String volFile1stExt = + extractVolFileName(fileName, ".yaml"); + String volFile2ndExt = + extractVolFileName(fileName, ".yml"); + + if (fileNames.contains(volFile1stExt)) { + return Optional.of(volFile1stExt); + } + if (fileNames.contains(volFile2ndExt)) { + return Optional.of(volFile2ndExt); + } + return Optional.empty(); + } + + private String extractVolFileName(String fileName, String fileExt) { + return fileName.substring( + 0, fileName.lastIndexOf(".")) + + Constants.VOL_FILE_NAME_SUFFIX + fileExt; + } + + + private boolean isVolFile(String fileName) { + return fileName + .endsWith( + Constants.VOL_FILE_NAME_SUFFIX + ".yaml") + || fileName.endsWith(Constants.VOL_FILE_NAME_SUFFIX + ".yml"); + } + + + private void markFileAsProcessed(String fileName, Set<String> processedFiles) { + processedFiles.add(fileName); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateServiceValidator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateServiceValidator.java new file mode 100644 index 0000000000..05c95a7596 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateServiceValidator.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.services.utils; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Created by Talio on 12/6/2016. + */ +public class CandidateServiceValidator { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + + public Optional<List<ErrorMessage>> validateFileDataStructure( + FilesDataStructure filesDataStructure) { + if (Objects.isNull(filesDataStructure)) { + return Optional.empty(); + } + if (validateAtLeaseOneModuleExist(filesDataStructure)) { + return Optional.of(Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, Messages + .NO_MODULES_IN_MANIFEST.getErrorMessage()))); + } + + List<ErrorMessage> errors = new ArrayList<>(); + for (Module module : filesDataStructure.getModules()) { + validateModuleHaveYaml(errors, module); + validateNoVolEnvWithoutVol(errors, module); + } + return Optional.of(errors); + } + + + private boolean validateAtLeaseOneModuleExist(FilesDataStructure filesDataStructure) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + + mdcDataDebugMessage.debugExitMessage(null, null); + return CollectionUtils.isEmpty(filesDataStructure.getModules()); + } + + private void validateNoVolEnvWithoutVol(List<ErrorMessage> errors, Module module) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (StringUtils.isEmpty(module.getVol()) && StringUtils.isNotEmpty(module.getVolEnv())) { + errors.add(new ErrorMessage(ErrorLevel.ERROR, ErrorMessagesFormatBuilder + .getErrorWithParameters(Messages.MODULE_IN_MANIFEST_VOL_ENV_NO_VOL.getErrorMessage(), + module.getName()))); + } + + mdcDataDebugMessage.debugExitMessage(null, null); + } + + private void validateModuleHaveYaml(List<ErrorMessage> errors, Module module) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (StringUtils.isEmpty(module.getYaml())) { + errors.add(new ErrorMessage(ErrorLevel.ERROR, ErrorMessagesFormatBuilder + .getErrorWithParameters(Messages.MODULE_IN_MANIFEST_NO_YAML.getErrorMessage(), + module.getName()))); + } + + mdcDataDebugMessage.debugExitMessage(null, null); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java index 2c8ffb1ded..5cfe33ba90 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java @@ -1,18 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.vendorsoftwareproduct.dao; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.UserInfo; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import com.amdocs.zusammen.datatypes.item.Item; +import com.amdocs.zusammen.datatypes.item.ItemVersion; +import com.amdocs.zusammen.datatypes.item.ItemVersionData; +import com.amdocs.zusammen.datatypes.itemversion.Tag; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.core.utilities.yaml.YamlUtil; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.sdc.model.impl.zusammen.ServiceModelDaoZusammenImpl; +import org.openecomp.sdc.model.impl.zusammen.StructureElement; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; - import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.core.model.dao.ServiceModelDaoFactory; -import org.openecomp.core.model.types.ServiceArtifact; -import org.openecomp.core.utilities.CommonMethods; -import org.openecomp.core.utilities.file.FileContentHandler; import org.testng.Assert; import org.testng.annotations.Test; +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Optional; public class ServiceModelDaoFactoryTest { @@ -22,19 +60,64 @@ public class ServiceModelDaoFactoryTest { private static String artifact001; -// @Test + @Test public void storeServiceModelTest() { + ItemVersion itemVersionmock = new ItemVersion(); + itemVersionmock.setId(new Id()); + ZusammenAdaptorMock zusammenAdaptor = new ZusammenAdaptorMock(); + ServiceModelDaoZusammenImpl serviceModelDaoZusammen = new ServiceModelDaoZusammenImpl( + zusammenAdaptor); + + zusammenAdaptor.setItemVersion(itemVersionmock); ToscaServiceModel model = getToscaServiceModel(); - ServiceModelDaoFactory.getInstance().createInterface().storeServiceModel(vspId, version, model); + serviceModelDaoZusammen.storeServiceModel(vspId, version, model); + } + + private SessionContext getSessionContext() { + SessionContext context = new SessionContext(); + context.setUser(new UserInfo("USER_A")); + context.setTenant("asdc"); + return context; } -// @Test(dependsOnMethods = "storeServiceModelTest") + @Test public void getServiceModelTest() { + + ItemVersion itemVersionmock = new ItemVersion(); + itemVersionmock.setId(new Id()); + + ElementInfo elementInfo = new ElementInfo(); + Info info = new Info(); + info.addProperty("base","baseElement"); + elementInfo.setInfo(info); + + ElementInfo artifactElementInfo = new ElementInfo(); + artifactElementInfo.setInfo(info); + ElementInfo templateElementInfo = new ElementInfo(); + artifactElementInfo.setInfo(info); + + ZusammenElement element = new ZusammenElement(); + ServiceTemplate serviceTemplate = new ServiceTemplate(); + YamlUtil yamlUtil = new YamlUtil(); + element.setData(new ByteArrayInputStream(yamlUtil.objectToYaml(serviceTemplate).getBytes())); + info = new Info(); + info.setName("dataFileName"); + element.setInfo(info); + ZusammenAdaptorMock zusammenAdaptor = new ZusammenAdaptorMock(); + ServiceModelDaoZusammenImpl serviceModelDaoZusammen = new ServiceModelDaoZusammenImpl( + zusammenAdaptor); + + zusammenAdaptor.setItemVersion(itemVersionmock); + zusammenAdaptor.addElementInfo("null"+StructureElement.ServiceModel.name(),elementInfo); + zusammenAdaptor.addElementInfo("null"+StructureElement.Artifacts.name(),artifactElementInfo); + zusammenAdaptor.addElementInfo("null"+StructureElement.Templates.name(),templateElementInfo); + zusammenAdaptor.addElement(element); + Object model = - ServiceModelDaoFactory.getInstance().createInterface().getServiceModel(vspId, version); + serviceModelDaoZusammen.getServiceModel(vspId, version); Assert.assertNotNull(model); Assert.assertTrue(model instanceof ToscaServiceModel); if (model instanceof ToscaServiceModel) { @@ -44,16 +127,6 @@ public class ServiceModelDaoFactoryTest { } } -// @Test(dependsOnMethods = "getServiceModelTest") - public void getServiceModelInfoTest() { - Object info = ServiceModelDaoFactory.getInstance().createInterface() - .getServiceModelInfo(vspId, version, artifact001); - Assert.assertNotNull(info); - Assert.assertTrue(info instanceof ServiceArtifact); - if (info instanceof ServiceArtifact) { - Assert.assertEquals(((ServiceArtifact) info).getName(), artifact001); - } - } private ToscaServiceModel getToscaServiceModel() { @@ -94,4 +167,119 @@ public class ServiceModelDaoFactoryTest { serviceTemplate.setDescription(CommonMethods.nextUuId()); return serviceTemplate; } + + private class ZusammenAdaptorMock implements ZusammenAdaptor + { + + private ItemVersion itemVersion; + private Map<String,ElementInfo> elementInfoMap = new HashMap(); + private Collection<Element> elements = new ArrayList<>(); + + public void setItemVersion(ItemVersion itemVersion){ + this.itemVersion = itemVersion; + } + + public void addElementInfo(String key,ElementInfo elementInfo){ + elementInfoMap.put(key,elementInfo); + } + public void addElement(Element element){ + elements.add(element); + } + @Override + public Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId) { + + return Optional.ofNullable(itemVersion); + } + + @Override + public Optional<Element> getElement(SessionContext context, ElementContext elementContext, + String elementId) { + return null; + } + + @Override + public Optional<Element> getElementByName(SessionContext context, + ElementContext elementContext, + Id parentElementId, String elementName) { + return null; + } + + @Override + public Collection<ElementInfo> listElements(SessionContext context, + ElementContext elementContext, + Id parentElementId) { + return null; + } + + @Override + public Collection<Element> listElementData(SessionContext context, + ElementContext elementContext, + Id parentElementId) { + return elements; + } + + @Override + public Collection<ElementInfo> listElementsByName(SessionContext context, + ElementContext elementContext, + Id parentElementId, String elementName) { + return null; + } + + @Override + public Optional<ElementInfo> getElementInfoByName(SessionContext context, + ElementContext elementContext, + Id parentElementId, String elementName) { + return Optional.ofNullable(elementInfoMap.get(parentElementId+elementName)); + } + + @Override + public Optional<Element> saveElement(SessionContext context, ElementContext elementContext, + ZusammenElement element, String message) { + return null; + } + + @Override + public Id createItem(SessionContext context, Info info) { + return null; + } + + @Override + public void updateItem(SessionContext context, Id itemId, Info info) { + + } + + @Override + public Id createVersion(SessionContext context, Id itemId, Id baseVersionId, + ItemVersionData itemVersionData) { + return null; + } + + @Override + public void updateVersion(SessionContext context, Id itemId, Id versionId, + ItemVersionData itemVersionData) { + + } + + @Override + public void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag) { + + } + + @Override + public void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef) { + + } + + @Override + public Optional<ElementInfo> getElementInfo(SessionContext context, + ElementContext elementContext, + Id elementId) { + return null; + } + + @Override + public Collection<Item> listItems(SessionContext context) { + return null; + } + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java new file mode 100644 index 0000000000..6652c271ac --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java @@ -0,0 +1,252 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl; + + +import org.junit.Assert; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData; +import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ComponentQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.GuestOS; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.NumOfVMs; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.Hypervisor; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.Recovery; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network.NetworkCapacity; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage.Backup; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.storage.Storage; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.IpConfiguration; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.Network; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.NicQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.Protocols; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.VspQuestionnaire; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.Availability; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.General; +import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.StorageDataReplication; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.annotation.processing.SupportedAnnotationTypes; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anyString; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.HEADER; +import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_COMPUTE_CPU_OVER_SUBSCRIPTION; + + +/** + * @author KATYR + * @since December 07, 2016 + */ + +public class TxtInformationArtifactGeneratorImplTest { + + private static final String NETWORK_DESC = "\"network desc\""; + private static final String HYPERVIZOR_NAME = "\"hyper hyper hypervizor\""; + private static final String TOOLS ="all tools possible" ; + @Mock + QuestionnaireDataService questionnaireDataServiceMock; + @InjectMocks + TxtInformationArtifactGeneratorImpl informationArtifactGenerator; + + @BeforeMethod(alwaysRun = true) + public void injectDoubles() { + MockitoAnnotations.initMocks(this); + +// InformationArtifactData returnedQuestionnaire = new InformationArtifactData(); +// Mockito.when(questionnaireDataServiceMock.generateQuestionnaireDataForInformationArtifact +// (anyString(), anyObject())) +// .thenReturn(returnedQuestionnaire); +// + + } + + @Test + public void testRoundVersion(){ + Version version = new Version(2,1); + String rounded = TxtInformationArtifactGeneratorImpl.roundVersionAsNeeded(version); + Assert.assertEquals("3.0",rounded); + + version = Version.valueOf("2.0"); + rounded = TxtInformationArtifactGeneratorImpl.roundVersionAsNeeded(version); + Assert.assertEquals("2.0",rounded); + + } + + @Test + public void testArtifactCreation() throws IOException { + InformationArtifactData informationArtifactData = initArtifactData(); + Mockito.when(questionnaireDataServiceMock.generateQuestionnaireDataForInformationArtifact + (anyString(), anyObject())) + .thenReturn(informationArtifactData); + + + String result = informationArtifactGenerator.generate("vsp", new Version(0, 1)); + System.out.println("result = \n" + result); + + Assert.assertTrue(result.contains(HYPERVIZOR_NAME)); + Assert.assertTrue(result.contains(HEADER)); + Assert.assertTrue(result.contains(VFC_COMPUTE_CPU_OVER_SUBSCRIPTION)); + Assert.assertTrue(result.contains(TOOLS)); + Assert.assertTrue(result.contains(TxtInformationArtifactConstants.LICENSE_AGREEMENT_NAME)); + Assert.assertTrue(result.contains(TxtInformationArtifactConstants.LIST_OF_FEATURE_GROUPS)); + + } + + private InformationArtifactData initArtifactData() { + InformationArtifactData informationArtifactData = new InformationArtifactData(); + + informationArtifactData.setVspDetails(initVspDetails()); + + informationArtifactData.setVspQuestionnaire(initVspQuestionnaire()); + informationArtifactData.setComponentQuestionnaires(initComponentQuestionnaires()); + informationArtifactData.setNicQuestionnaires(initNicQuestionnaires()); + return informationArtifactData; + } + + private List<NicQuestionnaire> initNicQuestionnaires() { + List<NicQuestionnaire> nicQuestionnaires = new ArrayList<>(); + NicQuestionnaire nic1 = new NicQuestionnaire(); + NicQuestionnaire nic2 = new NicQuestionnaire(); + nic1 = initNicQuestionnaire(); + nic2 = initNicQuestionnaire(); + nicQuestionnaires.add(nic1); + nicQuestionnaires.add(nic2); + return nicQuestionnaires; + + } + + private NicQuestionnaire initNicQuestionnaire() { + NicQuestionnaire nic = new NicQuestionnaire(); + Network network = new Network(); + network.setNetworkDescription(NETWORK_DESC); + nic.setNetwork(network); + + IpConfiguration ipconfig = new IpConfiguration(); + ipconfig.setIpv4Required(true); + ipconfig.setIpv6Required(false); + + nic.setIpConfiguration(ipconfig); + + Protocols protocols = new Protocols(); + List<String> protocolsList = new ArrayList<>(); + protocolsList.add("45"); + protocolsList.add("55"); + protocolsList.add("HTTP"); + protocols.setProtocols(protocolsList); + + nic.setProtocols(protocols); + + return nic; + } + + private List<ComponentQuestionnaire> initComponentQuestionnaires() { + List<ComponentQuestionnaire> componentQuestionnaires = new ArrayList<>(); + ComponentQuestionnaire componentQuestionnaire1 = new ComponentQuestionnaire(); + ComponentQuestionnaire componentQuestionnaire2 = new ComponentQuestionnaire(); + + componentQuestionnaire1 = initComponent(); + componentQuestionnaire2 = initComponent(); + + componentQuestionnaires.add(componentQuestionnaire1); + componentQuestionnaires.add(componentQuestionnaire2); + + return componentQuestionnaires; + } + + private ComponentQuestionnaire initComponent() { + ComponentQuestionnaire componentQuestionnaire = new ComponentQuestionnaire(); + org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.General general = + new org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.General(); + Hypervisor hypervisor = new Hypervisor(); + hypervisor.setDrivers("driving drivers"); + hypervisor.setHypervisor(HYPERVIZOR_NAME); + general.setHypervisor(hypervisor); + Recovery recovery = new Recovery(); + recovery.setPointObjective(22); + recovery.setTimeObjective(33); + general.setRecovery(recovery); + componentQuestionnaire.setGeneral( + general); + org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network.Network net = + new org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network.Network(); + net.setNetworkCapacity(new NetworkCapacity()); + componentQuestionnaire.setNetwork(net); + Compute compute = new Compute(); + GuestOS guestOS = new GuestOS(); + guestOS.setBitSize(32); + guestOS.setTools(TOOLS); + guestOS.setName("Ubuntu"); + compute.setGuestOS(guestOS); + NumOfVMs numOfVMs = new NumOfVMs(); + numOfVMs.setMaximum(256); + numOfVMs.setMinimum(2); + compute.setNumOfVMs(numOfVMs); + componentQuestionnaire.setCompute(compute); + + return componentQuestionnaire; + } + + private VspQuestionnaire initVspQuestionnaire() { + VspQuestionnaire vspQuestionnaire = new VspQuestionnaire(); + Availability availability = new Availability(); + availability.setUseAvailabilityZonesForHighAvailability(true); + General general = new General(); + general.setAvailability(availability); + + StorageDataReplication storageDataReplication = new StorageDataReplication(); + storageDataReplication.setStorageReplicationAcrossRegion(true); + storageDataReplication.setStorageReplicationDestination("in a galaxy far, far away"); + storageDataReplication.setStorageReplicationFrequency(6); + storageDataReplication.setStorageReplicationSize(128); + storageDataReplication.setStorageReplicationSource("here below"); + general.setStorageDataReplication(storageDataReplication); + vspQuestionnaire.setGeneral(general); + return vspQuestionnaire; + } + + private VspDetails initVspDetails() { + VspDetails vspDetails = new VspDetails(); + vspDetails.setCategory("vspCategory"); + vspDetails.setDescription("described"); + vspDetails.setName("vsp named Alice"); + vspDetails.setVendorName("Fortigate"); + vspDetails.setVersion(new Version(0, 79)); + vspDetails.setVlmVersion(new Version(0, 1)); + vspDetails.setLicenseAgreement("the usual license agreement"); + List<String> featureGroups = new ArrayList<>(); + featureGroups.add("first feature group"); + featureGroups.add("one too many feature group"); + featureGroups.add("the very last feature group"); + vspDetails.setFeatureGroups(featureGroups); + return vspDetails; + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/resources/logback.xml b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/resources/logback.xml new file mode 100644 index 0000000000..03ce9d1243 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/resources/logback.xml @@ -0,0 +1,13 @@ +<!-- only one line, shut up logback ! --> +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <Pattern> + %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n + </Pattern> + </encoder> + </appender> + <root level="off"> + <appender-ref ref="STDOUT" /> + </root> +</configuration>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml index 9792a22e0c..9a9abeca29 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml @@ -1,23 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>openecomp-sdc-vendor-software-product-lib</artifactId> + <packaging>pom</packaging> <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-lib</artifactId> <version>1.1.0-SNAPSHOT</version> + <relativePath>..</relativePath> </parent> - <artifactId>openecomp-sdc-vendor-software-product-lib</artifactId> - <packaging>pom</packaging> - <modules> <module>openecomp-sdc-vendor-software-product-api</module> <module>openecomp-sdc-vendor-software-product-core</module> </modules> - -</project>
\ No newline at end of file + +</project> diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml.versionsBackup new file mode 100644 index 0000000000..a1ee8d3985 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/pom.xml.versionsBackup @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <artifactId>openecomp-sdc-vendor-software-product-lib</artifactId> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + + <modules> + <module>openecomp-sdc-vendor-software-product-api</module> + <module>openecomp-sdc-vendor-software-product-core</module> + </modules> + + +</project>
\ No newline at end of file |