aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml67
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentArtifactDaoCassandraImpl.java159
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentArtifactDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDaoCassandraImpl.java139
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NetworkDaoCassandraImpl.java127
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NetworkDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NicDaoCassandraImpl.java148
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/NicDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java103
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessArtifactDaoCassandraImpl.java82
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessArtifactDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoCassandraImpl.java139
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/UploadDataDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/UploadDataDaoImpl.java92
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java349
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoFactoryImpl.java34
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java83
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspQuestionnaireDaoCassandraImpl.java72
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspQuestionnaireDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java97
24 files changed, 2021 insertions, 0 deletions
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
new file mode 100644
index 0000000000..c732472152
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/pom.xml
@@ -0,0 +1,67 @@
+<?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"
+ 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.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.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>
+ </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>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-model-impl</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </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-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
new file mode 100644
index 0000000000..2525537cef
--- /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/ComponentArtifactDaoCassandraImpl.java
@@ -0,0 +1,159 @@
+/*-
+ * ============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/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/ComponentArtifactDaoFactoryImpl.java
new file mode 100644
index 0000000000..07a9f104f4
--- /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/ComponentArtifactDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDaoFactory;
+
+public class ComponentArtifactDaoFactoryImpl extends ComponentArtifactDaoFactory {
+ private static final ComponentArtifactDao INSTANCE = new ComponentArtifactDaoCassandraImpl();
+
+ @Override
+ public ComponentArtifactDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/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
new file mode 100644
index 0000000000..85372380c0
--- /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/ComponentDaoCassandraImpl.java
@@ -0,0 +1,139 @@
+/*-
+ * ============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.VendorSoftwareProductConstants;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+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 ComponentDaoCassandraImpl extends CassandraBaseDao<ComponentEntity>
+ implements ComponentDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<ComponentEntity> mapper =
+ noSqlDb.getMappingManager().mapper(ComponentEntity.class);
+ private static final ComponentAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(ComponentAccessor.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_NAME,
+ Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name"))));
+
+ VersioningManagerFactory.getInstance().createInterface()
+ .register(versionableEntityType, metadata);
+ }
+
+ @Override
+ protected Mapper<ComponentEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(ComponentEntity entity) {
+ return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId()};
+ }
+
+ @Override
+ public void update(ComponentEntity entity) {
+ accessor.updateCompositionData(entity.getVspId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId(), entity.getCompositionData());
+ }
+
+ @Override
+ public Collection<ComponentEntity> list(ComponentEntity entity) {
+ return accessor.list(entity.getVspId(), versionMapper.toUDT(entity.getVersion())).all();
+ }
+
+ @Override
+ public void updateQuestionnaireData(String vspId, Version version, String id,
+ String questionnaireData) {
+ accessor.updateQuestionnaireData(questionnaireData, vspId, versionMapper.toUDT(version), id);
+ }
+
+ @Override
+ public Collection<ComponentEntity> listQuestionnaires(String vspId, Version version) {
+ return accessor.listQuestionnaires(vspId, versionMapper.toUDT(version)).all();
+ }
+
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ accessor.deleteAll(vspId, version);
+ }
+
+ @Accessor
+ interface ComponentAccessor {
+
+ @Query(
+ "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=?")
+ Result<ComponentEntity> listQuestionnaires(String vspId, UDTValue version);
+
+ @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=?")
+ ResultSet updateQuestionnaireData(String questionnaireData, String vspId, UDTValue version,
+ String id);
+
+ @Query("delete from vsp_component where vsp_id=? and version=?")
+ ResultSet deleteAll(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/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
new file mode 100644
index 0000000000..1e57242ce1
--- /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/ComponentDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+
+public class ComponentDaoFactoryImpl extends ComponentDaoFactory {
+ private static final ComponentDao INSTANCE = new ComponentDaoCassandraImpl();
+
+ @Override
+ public ComponentDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/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
new file mode 100644
index 0000000000..f7b8f30f0a
--- /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/NetworkDaoCassandraImpl.java
@@ -0,0 +1,127 @@
+/*-
+ * ============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.VendorSoftwareProductConstants;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
+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 NetworkDaoCassandraImpl extends CassandraBaseDao<NetworkEntity> implements NetworkDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<NetworkEntity> mapper =
+ noSqlDb.getMappingManager().mapper(NetworkEntity.class);
+ private static final NetworkAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(NetworkAccessor.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.NETWORK_NAME,
+ Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name"))));
+
+ VersioningManagerFactory.getInstance().createInterface()
+ .register(versionableEntityType, metadata);
+ }
+
+ @Override
+ protected Mapper<NetworkEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(NetworkEntity entity) {
+ return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId()};
+ }
+
+ @Override
+ public void update(NetworkEntity entity) {
+ accessor.updateCompositionData(entity.getVspId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId(), entity.getCompositionData());
+ }
+
+ @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();
+ }
+
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ accessor.deleteAll(vspId, version);
+ }
+
+ @Accessor
+ interface NetworkAccessor {
+
+ @Query(
+ "select vsp_id, version, network_id, composition_data from vsp_network where vsp_id=? "
+ + "and version=?")
+ Result<NetworkEntity> list(String vspId, UDTValue version);
+
+ @Query(
+ "insert into vsp_network (vsp_id, version, network_id, composition_data) values (?,?,?,?)")
+ ResultSet updateCompositionData(String vspId, UDTValue version, String id,
+ String compositionData);
+
+ @Query(
+ "update vsp_network set questionnaire_data=? where vsp_id=? and version=? and network_id=?")
+ ResultSet updateQuestionnaireData(String questionnaireData, String vspId, UDTValue version,
+ String id);
+
+ @Query("delete from vsp_network where vsp_id=? and version=?")
+ ResultSet deleteAll(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/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
new file mode 100644
index 0000000000..b4360996df
--- /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/NetworkDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
+
+public class NetworkDaoFactoryImpl extends NetworkDaoFactory {
+ private static final NetworkDao INSTANCE = new NetworkDaoCassandraImpl();
+
+ @Override
+ public NetworkDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/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
new file mode 100644
index 0000000000..e7e1eed8e0
--- /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/NicDaoCassandraImpl.java
@@ -0,0 +1,148 @@
+/*-
+ * ============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.VendorSoftwareProductConstants;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+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 NicDaoCassandraImpl extends CassandraBaseDao<NicEntity> implements NicDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<NicEntity> mapper =
+ noSqlDb.getMappingManager().mapper(NicEntity.class);
+ private static final NicAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(NicAccessor.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.NIC_NAME,
+ Arrays.asList("vsp_id", "version", "component_id", "name"))));
+
+ VersioningManagerFactory.getInstance().createInterface()
+ .register(versionableEntityType, metadata);
+ }
+
+ @Override
+ protected Mapper<NicEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(NicEntity entity) {
+ return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getComponentId(), entity.getId()};
+ }
+
+ @Override
+ public void create(NicEntity entity) {
+ super.create(entity);
+ }
+
+ @Override
+ public void update(NicEntity entity) {
+ accessor.updateCompositionData(entity.getVspId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getComponentId(), entity.getId(), entity.getCompositionData());
+ }
+
+ @Override
+ public void updateQuestionnaireData(String vspId, Version version, String id, String componentId,
+ String questionnaireData) {
+ accessor.updateQuestionnaireData(questionnaireData, vspId, versionMapper.toUDT(version), id,
+ componentId);
+ }
+
+ @Override
+ public Collection<NicEntity> listByVsp(String vspId, Version version) {
+ 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);
+ }
+
+ public void deleteByVspId(String vspId, Version version) {
+ accessor.deleteByVspId(vspId, versionMapper.toUDT(version));
+ }
+
+ @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=?")
+ 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 (?,?,?,?,?)")
+ 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=?")
+ ResultSet updateQuestionnaireData(String questionnaireData, String vspId, UDTValue version,
+ String componentId, String id);
+
+ @Query("delete from vsp_component_nic where vsp_id=? and version=? and component_id=?")
+ ResultSet deleteByComponentId(String vspId, Version version, String componentId);
+
+ @Query("delete from vsp_component_nic where vsp_id=? and version=?")
+ ResultSet deleteByVspId(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/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
new file mode 100644
index 0000000000..f4dd8d5a71
--- /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/NicDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
+
+public class NicDaoFactoryImpl extends NicDaoFactory {
+ private static final NicDao INSTANCE = new NicDaoCassandraImpl();
+
+ @Override
+ public NicDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoFactoryImpl.java
new file mode 100644
index 0000000000..8b9bedcd3a
--- /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/PackageInfoDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
+
+public class PackageInfoDaoFactoryImpl extends PackageInfoDaoFactory {
+ private static final PackageInfoDao INSTANCE = new PackageInfoDaoImpl();
+
+ @Override
+ public PackageInfoDao createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..9b7b81fe52
--- /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/PackageInfoDaoImpl.java
@@ -0,0 +1,103 @@
+/*-
+ * ============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.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.PackageInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements PackageInfoDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<PackageInfo> mapper =
+ noSqlDb.getMappingManager().mapper(PackageInfo.class);
+ private static final PackageInfoAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(PackageInfoAccessor.class);
+ private static final UDTMapper<Version> versionMapper =
+ noSqlDb.getMappingManager().udtMapper(Version.class);
+
+ @Override
+ protected Mapper<PackageInfo> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(PackageInfo entity) {
+ return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion())};
+ }
+
+ @Override
+ public Collection<PackageInfo> list(PackageInfo entity) {
+ return accessor.listInfo().all();
+ }
+
+ @Override
+ public List<PackageInfo> listByCategory(String category, String subCategory) {
+ Result<PackageInfo> packages = accessor.listInfo();
+
+ List<PackageInfo> filteredPackages = new ArrayList<>();
+ for (PackageInfo packageInfo : packages) {
+ if (category != null) {
+ if (category.equals(packageInfo.getCategory())) {
+ filteredPackages.add(packageInfo);
+ }
+ } else if (subCategory != null) {
+ if (subCategory.equals(packageInfo.getSubCategory())) {
+ filteredPackages.add(packageInfo);
+ }
+ } else {
+ filteredPackages.add(packageInfo);
+ }
+ }
+
+ return filteredPackages;
+ }
+
+ @Override
+ public void deleteRowTranslateContent(String vspId, Version version) {
+ accessor.deleteRowTranslateContent(vspId, 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")
+ Result<PackageInfo> listInfo();
+
+ @Query("DELETE TRANSLATE_CONTENT FROM package_details WHERE vsp_id=? and version=?")
+ Result<PackageInfo> deleteRowTranslateContent(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/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
new file mode 100644
index 0000000000..0e9fd90a13
--- /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/ProcessArtifactDaoCassandraImpl.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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/ProcessArtifactDaoFactoryImpl.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/ProcessArtifactDaoFactoryImpl.java
new file mode 100644
index 0000000000..2a5d9013bd
--- /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/ProcessArtifactDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessArtifactDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessArtifactDaoFactory;
+
+public class ProcessArtifactDaoFactoryImpl extends ProcessArtifactDaoFactory {
+ private static final ProcessArtifactDao INSTANCE = new ProcessArtifactDaoCassandraImpl();
+
+ @Override
+ public ProcessArtifactDao 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/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
new file mode 100644
index 0000000000..b8900eb5d3
--- /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/ProcessDaoCassandraImpl.java
@@ -0,0 +1,139 @@
+/*-
+ * ============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
new file mode 100644
index 0000000000..4c981d8448
--- /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/ProcessDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
+
+public class ProcessDaoFactoryImpl extends ProcessDaoFactory {
+ private static final ProcessDao INSTANCE = new ProcessDaoCassandraImpl();
+
+ @Override
+ public ProcessDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/UploadDataDaoFactoryImpl.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/UploadDataDaoFactoryImpl.java
new file mode 100644
index 0000000000..317bc344c4
--- /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/UploadDataDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDaoFactory;
+
+public class UploadDataDaoFactoryImpl extends UploadDataDaoFactory {
+ private static final UploadDataDao INSTANCE = new UploadDataDaoImpl();
+
+ @Override
+ public UploadDataDao 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/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
new file mode 100644
index 0000000000..df019a4f53
--- /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/UploadDataDaoImpl.java
@@ -0,0 +1,92 @@
+/*-
+ * ============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
new file mode 100644
index 0000000000..587f8ac036
--- /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/VendorSoftwareProductDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+
+public class VendorSoftwareProductDaoFactoryImpl extends VendorSoftwareProductDaoFactory {
+ private static final VendorSoftwareProductDao INSTANCE = new VendorSoftwareProductDaoImpl();
+
+ @Override
+ public VendorSoftwareProductDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java
new file mode 100644
index 0000000000..f592e63280
--- /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/VendorSoftwareProductDaoImpl.java
@@ -0,0 +1,349 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
+
+import org.openecomp.core.model.dao.EnrichedServiceArtifactDao;
+import org.openecomp.core.model.dao.EnrichedServiceArtifactDaoFactory;
+import org.openecomp.core.model.dao.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.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+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.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.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 PackageInfoDao packageInfoDao =
+ PackageInfoDaoFactory.getInstance().createInterface();
+ private static final UploadDataDao uploadDataDao =
+ UploadDataDaoFactory.getInstance().createInterface();
+ private static final VspQuestionnaireDao vspQuestionnaireDao =
+ VspQuestionnaireDaoFactory.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 EnrichedServiceArtifactDao enrichArtifactDao =
+ EnrichedServiceArtifactDaoFactory.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);
+ }
+
+ @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);
+ }
+
+ @Override
+ public Collection<ProcessEntity> listProcesses(String vspId, Version version,
+ String componentId) {
+ return processDao.list(new ProcessEntity(vspId, version, componentId, null));
+ }
+
+ @Override
+ public void deleteProcesses(String vspId, Version version, String componentId) {
+ processDao.delete(new ProcessEntity(vspId, version, componentId, null));
+ }
+
+ @Override
+ public ProcessEntity getProcess(String vspId, Version version, String componentId,
+ String processId) {
+ return processDao.get(new ProcessEntity(vspId, version, componentId, processId));
+ }
+
+ @Override
+ public void createProcess(ProcessEntity processEntity) {
+ processDao.create(processEntity);
+ }
+
+ @Override
+ public void updateProcess(ProcessEntity processEntity) {
+ processDao.update(processEntity);
+ }
+
+ @Override
+ public void deleteProcess(String vspId, Version version, String componentId, String processId) {
+ processDao.delete(new ProcessEntity(vspId, version, componentId, processId));
+ }
+
+ @Override
+ public void uploadProcessArtifact(String vspId, Version version, String componentId,
+ String processId, byte[] artifact, String artifactName) {
+ ProcessArtifactEntity processArtifact =
+ new ProcessArtifactEntity(vspId, version, componentId, processId);
+ processArtifact.setArtifact(ByteBuffer.wrap(artifact));
+ processArtifact.setArtifactName(artifactName);
+ processArtifactDao.update(processArtifact);
+ }
+
+ @Override
+ public ProcessArtifactEntity getProcessArtifact(String vspId, Version version, String componentId,
+ String processId) {
+ return processArtifactDao
+ .get(new ProcessArtifactEntity(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);
+ }
+
+ @Override
+ public Collection<NicEntity> listNicsByVsp(String vspId, Version version) {
+ return nicDao.listByVsp(vspId, version);
+ }
+
+ @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);
+ componentDao.deleteAll(vspId, version);
+ uploadDataDao.deleteContentDataAndValidationData(vspId, 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);
+ }
+}
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
new file mode 100644
index 0000000000..1dcb3f4c66
--- /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/VendorSoftwareProductInfoDaoFactoryImpl.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.dao.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+
+public class VendorSoftwareProductInfoDaoFactoryImpl extends VendorSoftwareProductInfoDaoFactory {
+ private static final VendorSoftwareProductInfoDao INSTANCE =
+ new VendorSoftwareProductInfoDaoImpl();
+
+ @Override
+ public VendorSoftwareProductInfoDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/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
new file mode 100644
index 0000000000..c3096dab29
--- /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/VendorSoftwareProductInfoDaoImpl.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.dao.impl;
+
+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.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
+
+import java.util.Collection;
+
+public class VendorSoftwareProductInfoDaoImpl extends CassandraBaseDao<VspDetails>
+ implements VendorSoftwareProductInfoDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<VspDetails> mapper =
+ noSqlDb.getMappingManager().mapper(VspDetails.class);
+ private static final VendorSoftwareProductInfoAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(VendorSoftwareProductInfoAccessor.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
+ protected Mapper<VspDetails> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(VspDetails entity) {
+ return new Object[]{entity.getId(), versionMapper.toUDT(entity.getVersion())};
+ }
+
+ @Override
+ public Collection<VspDetails> list(VspDetails entity) {
+ return accessor.listAll().all();
+ }
+
+ @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")
+ 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
new file mode 100644
index 0000000000..ef4dd0de74
--- /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/VspQuestionnaireDaoCassandraImpl.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.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/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/dao/impl/VspQuestionnaireDaoFactoryImpl.java
new file mode 100644
index 0000000000..aa91302ca2
--- /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/VspQuestionnaireDaoFactoryImpl.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.dao.impl;
+
+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();
+
+ @Override
+ public VspQuestionnaireDao createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..2c8ffb1ded
--- /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/dao/ServiceModelDaoFactoryTest.java
@@ -0,0 +1,97 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao;
+
+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.util.HashMap;
+import java.util.Map;
+
+public class ServiceModelDaoFactoryTest {
+
+ private static final String vspId = CommonMethods.nextUuId();
+ private static final Version version = Version.valueOf("1.0");
+ private static final String baseServiceTemplateName = "baseYaml.yaml";
+ private static String artifact001;
+
+
+// @Test
+ public void storeServiceModelTest() {
+
+
+ ToscaServiceModel model = getToscaServiceModel();
+ ServiceModelDaoFactory.getInstance().createInterface().storeServiceModel(vspId, version, model);
+ }
+
+
+// @Test(dependsOnMethods = "storeServiceModelTest")
+ public void getServiceModelTest() {
+ Object model =
+ ServiceModelDaoFactory.getInstance().createInterface().getServiceModel(vspId, version);
+ Assert.assertNotNull(model);
+ Assert.assertTrue(model instanceof ToscaServiceModel);
+ if (model instanceof ToscaServiceModel) {
+
+ artifact001 =
+ (String) ((ToscaServiceModel) model).getArtifactFiles().getFileList().toArray()[0];
+ }
+ }
+
+// @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() {
+
+ Map<String, ServiceTemplate> serviceTemplates = getServiceTemplates(baseServiceTemplateName);
+ FileContentHandler artifacts = getArtifacts();
+ return new ToscaServiceModel(artifacts, serviceTemplates, baseServiceTemplateName);
+ }
+
+
+ private Map<String, ServiceTemplate> getServiceTemplates(String base) {
+
+ Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
+
+ serviceTemplates.put(base, getServiceTemplate());
+ serviceTemplates.put("SERV1", getServiceTemplate());
+ serviceTemplates.put("SERV2", getServiceTemplate());
+ serviceTemplates.put("SERV3", getServiceTemplate());
+ serviceTemplates.put("SERV4", getServiceTemplate());
+
+ return serviceTemplates;
+ }
+
+ public FileContentHandler getArtifacts() {
+ Map<String, byte[]> artifacts = new HashMap<>();
+ artifacts.put("art1", "this is art1".getBytes());
+ artifacts.put("art2", ("this is art2 desc:" + CommonMethods.nextUuId()).getBytes());
+ artifacts.put("art2", ("this is art3 desc:" + CommonMethods.nextUuId()).getBytes());
+ artifacts.put("art2", ("this is art4 desc:" + CommonMethods.nextUuId()).getBytes());
+
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ fileContentHandler.putAll(artifacts);
+ return fileContentHandler;
+ }
+
+ public ServiceTemplate getServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setTosca_definitions_version("version 1.0");
+ serviceTemplate.setDescription(CommonMethods.nextUuId());
+ return serviceTemplate;
+ }
+}