summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java
diff options
context:
space:
mode:
authorAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
committerAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
commit280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch)
tree9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java
parentfd3821dad11780d33c5373d74c957c442489945e (diff)
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraFactoryImpl.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraImpl.java32
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraFactoryImpl.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraImpl.java54
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraFactoryImpl.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraImpl.java36
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraFactoryImpl.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraImpl.java53
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ElementType.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java51
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java208
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/StructureElement.java10
16 files changed, 399 insertions, 83 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraFactoryImpl.java
index 13e351c257..479668ec0c 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraFactoryImpl.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.model.impl;
-
import org.openecomp.core.model.dao.EnrichedServiceArtifactDao;
import org.openecomp.core.model.dao.EnrichedServiceArtifactDaoFactory;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraImpl.java
index d9ebe849e3..2a0b964066 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraImpl.java
@@ -44,17 +44,18 @@ public class EnrichedServiceArtifactDaoCassandraImpl implements EnrichedServiceA
private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
private static final Mapper<EnrichedServiceArtifactEntity> mapper =
- noSqlDb.getMappingManager().mapper(EnrichedServiceArtifactEntity.class);
+ noSqlDb.getMappingManager().mapper(
+ EnrichedServiceArtifactEntity.class);
private static final VspServiceArtifactAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(VspServiceArtifactAccessor.class);
+ noSqlDb.getMappingManager().createAccessor(
+ VspServiceArtifactAccessor.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(),
+ VersioningManagerFactory.getInstance().createInterface().register(versionableEntityType,
+ new VersionableEntityMetadata(mapper.getTableMetadata().getName(),
mapper.getTableMetadata().getPartitionKey().get(0).getName(),
mapper.getTableMetadata().getPartitionKey().get(1).getName()));
}
@@ -103,8 +104,8 @@ public class EnrichedServiceArtifactDaoCassandraImpl implements EnrichedServiceA
@Override
public ServiceArtifact getArtifactInfo(String vspId, Version version, String name) {
- EnrichedServiceArtifactEntity enrichedServiceArtifactEntity =
- accessor.getArtifactInfo(vspId, versionMapper.toUDT(version), name).one();
+ EnrichedServiceArtifactEntity enrichedServiceArtifactEntity = accessor.getArtifactInfo(vspId,
+ versionMapper.toUDT(version), name).one();
if (enrichedServiceArtifactEntity == null) {
return null;
}
@@ -112,6 +113,10 @@ public class EnrichedServiceArtifactDaoCassandraImpl implements EnrichedServiceA
return enrichedServiceArtifactEntity.getServiceArtifact();
}
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ accessor.deleteAll(vspId, versionMapper.toUDT(version));
+ }
@Accessor
interface VspServiceArtifactAccessor {
@@ -120,18 +125,21 @@ public class EnrichedServiceArtifactDaoCassandraImpl implements EnrichedServiceA
Result<EnrichedServiceArtifactEntity> listAll();
@Query(
- "SELECT vsp_id, version, name ,content_data FROM vsp_enriched_service_artifact "
- + "where vsp_id=? and version=? ")
+ "SELECT vsp_id, version, name ,content_data FROM "
+ + "vsp_enriched_service_artifact where vsp_id=? and version=? ")
Result<EnrichedServiceArtifactEntity> list(String vspId, UDTValue version);
-
@Query(
- "SELECT vsp_id,version,name,content_data FROM vsp_enriched_service_artifact "
- + "where vsp_id=? and version=? and name=?")
+ "SELECT vsp_id,version,name,content_data FROM "
+ + "vsp_enriched_service_artifact where vsp_id=? and version=? and name=?")
Result<EnrichedServiceArtifactEntity> getArtifactInfo(String vspId, UDTValue version,
String name);
@Query("DELETE from vsp_enriched_service_artifact where vsp_id=? and version=?")
ResultSet delete(String vspId, UDTValue version);
+
+ @Query("DELETE FROM vsp_enriched_service_artifact where vsp_id=? and version=?")
+ ResultSet deleteAll(String vspId, UDTValue version);
}
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java
index 326e5e78fc..98cb8724df 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java
@@ -20,12 +20,14 @@
package org.openecomp.sdc.model.impl;
-
import org.openecomp.core.model.dao.EnrichedServiceModelDao;
import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.openecomp.sdc.model.impl.zusammen.EnrichedServiceModelDaoZusammenImpl;
public class EnrichedServiceModelDaoFactoryImpl extends EnrichedServiceModelDaoFactory {
- private static final EnrichedServiceModelDao INSTANCE = new EnrichedServiceModelDaoImpl();
+ private static final EnrichedServiceModelDao INSTANCE = new EnrichedServiceModelDaoZusammenImpl( ZusammenAdaptorFactory
+ .getInstance().createInterface());
@Override
public EnrichedServiceModelDao createInterface() {
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java
index 9e784c7fef..14eda9ee4d 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java
@@ -37,8 +37,15 @@ public class EnrichedServiceModelDaoImpl extends AbstractServiceModelDao
artifactDao = EnrichedServiceArtifactDaoFactory.getInstance().createInterface();
}
- @Override
+ /*@Override
public List<ServiceArtifact> getExternalArtifacts(String vspId, Version version) {
return (List<ServiceArtifact>) artifactDao.list(vspId, version);
}
+*/
+
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ templateDao.deleteAll(vspId, version);
+ artifactDao.deleteAll(vspId, version);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraFactoryImpl.java
index 8103b2cea6..14aa986bd8 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraFactoryImpl.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.model.impl;
-
import org.openecomp.core.model.dao.EnrichedServiceTemplateDao;
import org.openecomp.core.model.dao.EnrichedServiceTemplateDaoFactory;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraImpl.java
index f0d4b56204..ab13e6a9f0 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraImpl.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.model.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;
@@ -43,30 +44,23 @@ public class EnrichedServiceTemplateDaoCassandraImpl implements EnrichedServiceT
private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
private static final Mapper<EnrichedServiceTemplateEntity> mapper =
- noSqlDb.getMappingManager().mapper(EnrichedServiceTemplateEntity.class);
+ noSqlDb.getMappingManager().mapper(
+ EnrichedServiceTemplateEntity.class);
private static final VspServiceTemplateAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(VspServiceTemplateAccessor.class);
+ noSqlDb.getMappingManager().createAccessor(
+ VspServiceTemplateAccessor.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(),
+ VersioningManagerFactory.getInstance().createInterface().register(versionableEntityType,
+ new VersionableEntityMetadata(mapper.getTableMetadata().getName(),
mapper.getTableMetadata().getPartitionKey().get(0).getName(),
mapper.getTableMetadata().getPartitionKey().get(1).getName()));
}
@Override
- public Collection<ServiceTemplate> list(String vspId, Version version) {
-
- List<EnrichedServiceTemplateEntity> entityList = accessor.list(vspId, version).all();
- return entityList.stream().map(entity -> entity.getServiceTemplate())
- .collect(Collectors.toList());
- }
-
- @Override
public void create(ServiceTemplate entity) {
EnrichedServiceTemplateEntity vspEnrichedServiceTemplateEntity =
new EnrichedServiceTemplateEntity(entity);
@@ -90,7 +84,6 @@ public class EnrichedServiceTemplateDaoCassandraImpl implements EnrichedServiceT
mapper.delete(vspId, version);
}
-
@Override
public Object[] getKeys(String vspId, Version version) {
return new Object[]{vspId, versionMapper.toUDT(version)};
@@ -98,8 +91,8 @@ public class EnrichedServiceTemplateDaoCassandraImpl implements EnrichedServiceT
@Override
public ServiceTemplate getTemplateInfo(String vspId, Version version, String name) {
- EnrichedServiceTemplateEntity enrichedServiceTemplateEntity =
- accessor.getTemplateInfo(vspId, versionMapper.toUDT(version), name).one();
+ EnrichedServiceTemplateEntity enrichedServiceTemplateEntity = accessor.getTemplateInfo(vspId,
+ versionMapper.toUDT(version), name).one();
if (enrichedServiceTemplateEntity == null) {
return null;
}
@@ -107,6 +100,14 @@ public class EnrichedServiceTemplateDaoCassandraImpl implements EnrichedServiceT
}
@Override
+ public Collection<ServiceTemplate> list(String vspId, Version version) {
+
+ List<EnrichedServiceTemplateEntity> entityList = accessor.list(vspId, version).all();
+ return entityList.stream().map(entity -> entity.getServiceTemplate())
+ .collect(Collectors.toList());
+ }
+
+ @Override
public String getBase(String vspId, Version version) {
Result<EnrichedServiceTemplateEntity> element =
accessor.getBase(vspId, versionMapper.toUDT(version));
@@ -119,6 +120,10 @@ public class EnrichedServiceTemplateDaoCassandraImpl implements EnrichedServiceT
return null;
}
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ accessor.deleteAll(vspId, versionMapper.toUDT(version));
+ }
@Accessor
interface VspServiceTemplateAccessor {
@@ -128,20 +133,23 @@ public class EnrichedServiceTemplateDaoCassandraImpl implements EnrichedServiceT
Result<EnrichedServiceTemplateEntity> listAll();
@Query(
- "SELECT vsp_id, version, name, base_name ,content_data FROM vsp_enriched_service_template "
- + "where vsp_id=? and version=?")
+ "SELECT vsp_id, version, name, base_name ,content_data FROM "
+ + "vsp_enriched_service_template where vsp_id=? and version=?")
Result<EnrichedServiceTemplateEntity> list(String vspId, Version version);
-
@Query(
- "SELECT vsp_id, version, name, base_name ,content_data FROM vsp_enriched_service_template "
- + "where vsp_id=? and version=? and name=?")
+ "SELECT vsp_id, version, name, base_name ,content_data FROM "
+ + "vsp_enriched_service_template where vsp_id=? and version=? and name=?")
Result<EnrichedServiceTemplateEntity> getTemplateInfo(String vspId, UDTValue version,
String name);
@Query(
- "SELECT vsp_id, version, name, base_name FROM vsp_enriched_service_template "
- + "where vsp_id=? and version=?")
+ "SELECT vsp_id, version, name, base_name FROM "
+ + "vsp_enriched_service_template where vsp_id=? and version=?")
Result<EnrichedServiceTemplateEntity> getBase(String vspId, UDTValue version);
+
+ @Query("DELETE FROM vsp_enriched_service_template where vsp_id = ? and version = ?")
+ ResultSet deleteAll(String vspId, UDTValue version);
}
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraFactoryImpl.java
index f24fb1b475..ee40dad385 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraFactoryImpl.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.model.impl;
-
import org.openecomp.core.model.dao.ServiceArtifactDao;
import org.openecomp.core.model.dao.ServiceArtifactDaoFactory;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraImpl.java
index c7851c0fd9..15aae0f710 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraImpl.java
@@ -43,18 +43,18 @@ import java.util.stream.Collectors;
public class ServiceArtifactDaoCassandraImpl implements ServiceArtifactDao {
private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final Mapper<ServiceArtifactEntity> mapper =
- noSqlDb.getMappingManager().mapper(ServiceArtifactEntity.class);
+ private static final Mapper<ServiceArtifactEntity> mapper = noSqlDb.getMappingManager().mapper(
+ ServiceArtifactEntity.class);
private static final VspServiceArtifactAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(VspServiceArtifactAccessor.class);
+ noSqlDb.getMappingManager().createAccessor(
+ VspServiceArtifactAccessor.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(),
+ VersioningManagerFactory.getInstance().createInterface().register(versionableEntityType,
+ new VersionableEntityMetadata(mapper.getTableMetadata().getName(),
mapper.getTableMetadata().getPartitionKey().get(0).getName(),
mapper.getTableMetadata().getPartitionKey().get(1).getName()));
}
@@ -94,10 +94,10 @@ public class ServiceArtifactDaoCassandraImpl implements ServiceArtifactDao {
accessor.delete(vspId, versionMapper.toUDT(version));
}
- // @Override
- // public void deleteArtifacts(String vspId, Version version){
- // accessor.delete(vspId, versionMapper.toUDT(version));
- // }
+ // @Override
+ // public void deleteArtifacts(String vspId, Version version){
+ // accessor.delete(vspId, versionMapper.toUDT(version));
+ // }
@Override
public Object[] getKeys(String vspId, Version version) {
@@ -107,7 +107,8 @@ public class ServiceArtifactDaoCassandraImpl implements ServiceArtifactDao {
@Override
public ServiceArtifact getArtifactInfo(String vspId, Version version, String name) {
ServiceArtifactEntity serviceArtifactEntity =
- accessor.getArtifactInfo(vspId, versionMapper.toUDT(version), name).one();
+ accessor.getArtifactInfo(vspId, versionMapper.toUDT(version),
+ name).one();
if (serviceArtifactEntity == null) {
return null;
}
@@ -115,6 +116,10 @@ public class ServiceArtifactDaoCassandraImpl implements ServiceArtifactDao {
return serviceArtifactEntity.getServiceArtifact();
}
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ accessor.deleteAll(vspId, versionMapper.toUDT(version));
+ }
@Accessor
interface VspServiceArtifactAccessor {
@@ -124,16 +129,19 @@ public class ServiceArtifactDaoCassandraImpl implements ServiceArtifactDao {
@Query(
"SELECT vsp_id, version, name ,content_data "
- + "FROM vsp_service_artifact where vsp_id=? and version=? ")
+ + "FROM vsp_service_artifact where vsp_id=? and version=? ")
Result<ServiceArtifactEntity> list(String vspId, UDTValue version);
@Query(
- "SELECT vsp_id,version,name,content_data FROM "
- + "vsp_service_artifact where vsp_id=? and version=? and name=?")
+ "SELECT vsp_id,version,name,content_data FROM"
+ + " vsp_service_artifact where vsp_id=? and version=? and name=?")
Result<ServiceArtifactEntity> getArtifactInfo(String vspId, UDTValue version, String name);
@Query("DELETE from vsp_service_artifact where vsp_id=? and version=?")
ResultSet delete(String vspId, UDTValue version);
+
+ @Query("DELETE FROM vsp_service_artifact where vsp_id=? and version=?")
+ ResultSet deleteAll(String vspId, UDTValue version);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java
index 1347636bf1..85508670aa 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java
@@ -20,12 +20,14 @@
package org.openecomp.sdc.model.impl;
-
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.openecomp.sdc.model.impl.zusammen.ServiceModelDaoZusammenImpl;
public class ServiceModelDaoFactoryImpl extends ServiceModelDaoFactory {
- private static final ServiceModelDao INSTANCE = new ServiceModelDaoImpl();
+ private static final ServiceModelDao INSTANCE = new ServiceModelDaoZusammenImpl(
+ ZusammenAdaptorFactory.getInstance().createInterface());
@Override
public ServiceModelDao createInterface() {
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoImpl.java
index c397aec61d..4ad8d7c98a 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoImpl.java
@@ -25,14 +25,18 @@ import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.dao.ServiceTemplateDaoFactory;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.versioning.dao.types.Version;
public class ServiceModelDaoImpl extends AbstractServiceModelDao
implements ServiceModelDao<ToscaServiceModel, ServiceElement> {
-
public ServiceModelDaoImpl() {
templateDao = ServiceTemplateDaoFactory.getInstance().createInterface();
artifactDao = ServiceArtifactDaoFactory.getInstance().createInterface();
}
+ @Override
+ public void deleteAll(String vspId, Version version) {
+
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraFactoryImpl.java
index 23c43b76d3..bc249701f2 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraFactoryImpl.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.model.impl;
-
import org.openecomp.core.model.dao.ServiceTemplateDao;
import org.openecomp.core.model.dao.ServiceTemplateDaoFactory;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraImpl.java
index ffc9a24677..71334ce8d3 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraImpl.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.model.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;
@@ -41,33 +42,24 @@ import java.util.stream.Collectors;
public class ServiceTemplateDaoCassandraImpl implements ServiceTemplateDao {
-
private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final Mapper<ServiceTemplateEntity> mapper =
- noSqlDb.getMappingManager().mapper(ServiceTemplateEntity.class);
+ private static final Mapper<ServiceTemplateEntity> mapper = noSqlDb.getMappingManager().mapper(
+ ServiceTemplateEntity.class);
private static final VspServiceTemplateAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(VspServiceTemplateAccessor.class);
+ noSqlDb.getMappingManager().createAccessor(
+ VspServiceTemplateAccessor.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(),
+ VersioningManagerFactory.getInstance().createInterface().register(versionableEntityType,
+ new VersionableEntityMetadata(mapper.getTableMetadata().getName(),
mapper.getTableMetadata().getPartitionKey().get(0).getName(),
mapper.getTableMetadata().getPartitionKey().get(1).getName()));
}
@Override
- public Collection<ServiceTemplate> list(String vspId, Version version) {
-
- List<ServiceTemplateEntity> entityList = accessor.list(vspId, version).all();
- return entityList.stream().map(entity -> entity.getServiceTemplate())
- .collect(Collectors.toList());
- }
-
- @Override
public void create(ServiceTemplate entity) {
ServiceTemplateEntity vspServiceTemplateEntity = new ServiceTemplateEntity(entity);
mapper.save(vspServiceTemplateEntity);
@@ -89,7 +81,6 @@ public class ServiceTemplateDaoCassandraImpl implements ServiceTemplateDao {
mapper.delete(vspId, version);
}
-
@Override
public Object[] getKeys(String vspId, Version version) {
return new Object[]{vspId, versionMapper.toUDT(version)};
@@ -98,7 +89,8 @@ public class ServiceTemplateDaoCassandraImpl implements ServiceTemplateDao {
@Override
public ServiceTemplate getTemplateInfo(String vspId, Version version, String name) {
ServiceTemplateEntity serviceTemplateEntity =
- accessor.getTemplateInfo(vspId, versionMapper.toUDT(version), name).one();
+ accessor.getTemplateInfo(vspId, versionMapper.toUDT(version),
+ name).one();
if (serviceTemplateEntity == null) {
return null;
}
@@ -106,6 +98,14 @@ public class ServiceTemplateDaoCassandraImpl implements ServiceTemplateDao {
}
@Override
+ public Collection<ServiceTemplate> list(String vspId, Version version) {
+
+ List<ServiceTemplateEntity> entityList = accessor.list(vspId, version).all();
+ return entityList.stream().map(entity -> entity.getServiceTemplate())
+ .collect(Collectors.toList());
+ }
+
+ @Override
public String getBase(String vspId, Version version) {
Result<ServiceTemplateEntity> element = accessor.getBase(vspId, versionMapper.toUDT(version));
if (element != null) {
@@ -117,6 +117,10 @@ public class ServiceTemplateDaoCassandraImpl implements ServiceTemplateDao {
return null;
}
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ accessor.deleteAll(vspId, versionMapper.toUDT(version));
+ }
@Accessor
interface VspServiceTemplateAccessor {
@@ -126,20 +130,21 @@ public class ServiceTemplateDaoCassandraImpl implements ServiceTemplateDao {
@Query(
"SELECT vsp_id, version, name, base_name ,content_data"
- + " FROM vsp_service_template where vsp_id=? and version=?")
+ + " FROM vsp_service_template where vsp_id=? and version=?")
Result<ServiceTemplateEntity> list(String vspId, Version version);
-
@Query(
- "SELECT vsp_id, version, name, base_name ,content_data "
- + "FROM vsp_service_template where vsp_id=? and version=? and name=?")
+ "SELECT vsp_id, version, name, base_name ,content_data"
+ + " FROM vsp_service_template where vsp_id=? and version=? and name=?")
Result<ServiceTemplateEntity> getTemplateInfo(String vspId, UDTValue version, String name);
@Query(
- "SELECT vsp_id, version, name, base_name "
- + "FROM vsp_service_template where vsp_id=? and version=?")
+ "SELECT vsp_id, version, name, base_name"
+ + " FROM vsp_service_template where vsp_id=? and version=?")
Result<ServiceTemplateEntity> getBase(String vspId, UDTValue version);
- }
+ @Query("DELETE FROM vsp_service_template where vsp_id = ? and version = ?")
+ ResultSet deleteAll(String vspId, UDTValue version);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ElementType.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ElementType.java
new file mode 100644
index 0000000000..e51d7e0c45
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ElementType.java
@@ -0,0 +1,7 @@
+package org.openecomp.sdc.model.impl.zusammen;
+
+public enum ElementType {
+ Servicetemplate,Artifact;
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
new file mode 100644
index 0000000000..b038c70372
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
@@ -0,0 +1,51 @@
+package org.openecomp.sdc.model.impl.zusammen;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import org.openecomp.core.model.dao.EnrichedServiceModelDao;
+import org.openecomp.core.model.types.ServiceArtifact;
+import org.openecomp.core.model.types.ServiceElement;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public class EnrichedServiceModelDaoZusammenImpl extends ServiceModelDaoZusammenImpl implements
+ EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(EnrichedServiceModelDaoZusammenImpl.class);
+
+ public EnrichedServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ super(zusammenAdaptor);
+ this.name = StructureElement.EnrichedServiceModel.name();
+ }
+
+ @Override
+ public void storeExternalArtifact(ServiceArtifact serviceArtifact) {
+ ZusammenElement artifactElement = buildArtifactElement(serviceArtifact.getName(),
+ FileUtils.toByteArray(serviceArtifact.getContent()), Action.CREATE);
+
+ ZusammenElement artifactsElement =
+ buildStructuralElement(StructureElement.Artifacts.name(), null);
+ artifactsElement.addSubElement(artifactElement);
+
+ ZusammenElement enrichedServiceModelElement = buildStructuralElement(name, null);
+ enrichedServiceModelElement.addSubElement(artifactsElement);
+
+ SessionContext context = ZusammenUtil.createSessionContext();
+ Id itemId = new Id(serviceArtifact.getVspId());
+ ElementContext elementContext = new ElementContext(itemId, getFirstVersionId(context, itemId));
+ zusammenAdaptor
+ .saveElement(context, elementContext, enrichedServiceModelElement, "add service artifact.");
+
+ logger.info("Finished adding artifact to service model for vsp id -> " +
+ elementContext.getItemId().getValue());
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
new file mode 100644
index 0000000000..530ad44574
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
@@ -0,0 +1,208 @@
+package org.openecomp.sdc.model.impl.zusammen;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import org.openecomp.core.model.dao.ServiceModelDao;
+import org.openecomp.core.model.types.ServiceElement;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+
+import java.io.ByteArrayInputStream;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+public class ServiceModelDaoZusammenImpl
+ implements ServiceModelDao<ToscaServiceModel, ServiceElement> {
+ private static final Logger logger = LoggerFactory.getLogger(ServiceModelDaoZusammenImpl.class);
+
+ protected ZusammenAdaptor zusammenAdaptor;
+ protected String name;
+
+ public ServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ this.name = StructureElement.ServiceModel.name();
+ }
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+
+ }
+
+ @Override
+ public ToscaServiceModel getServiceModel(String vspId, Version version) {
+ SessionContext context = ZusammenUtil.createSessionContext();
+ Id itemId = new Id(vspId);
+ ElementContext elementContext = new ElementContext(itemId, getFirstVersionId(context, itemId),
+ version.getStatus() == VersionStatus.Locked ? null : version.toString());
+
+ Optional<ElementInfo> serviceModelElement = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, name);
+
+ if (serviceModelElement.isPresent()) {
+ String entryDefinitionServiceTemplate =
+ serviceModelElement.get().getInfo().getProperty("base");
+ Id serviceModelElementId = serviceModelElement.get().getId();
+ Map<String, ServiceTemplate> serviceTemplates =
+ getTemplates(context, elementContext, serviceModelElementId);
+ if (serviceTemplates == null) {
+ return null;
+ }
+ FileContentHandler artifacts = getArtifacts(context, elementContext, serviceModelElementId);
+
+
+ return new ToscaServiceModel(
+ artifacts, serviceTemplates, entryDefinitionServiceTemplate);
+ } else {
+ return null;
+ }
+ }
+
+ protected Map<String, ServiceTemplate> getTemplates(SessionContext context,
+ ElementContext elementContext,
+ Id serviceModelElementId) {
+ Optional<ElementInfo> templatesElementInfo = zusammenAdaptor.getElementInfoByName(
+ context, elementContext, serviceModelElementId, StructureElement.Templates.name());
+
+ if (templatesElementInfo.isPresent()) {
+
+ //Map<String, ServiceTemplate> serviceTemplateMap = new HashMap<>();
+ Collection<Element> elements = zusammenAdaptor.listElementData(context, elementContext,
+ templatesElementInfo.get().getId());
+
+ return elements.stream().collect(Collectors.toMap(
+ element -> element.getInfo().getName(),
+ this::elementToServiceTemplate));
+
+ /*elements.stream().forEach(element ->serviceTemplateMap.put(element.getInfo().getName(),
+ elementToServiceTemplate(element)));
+ return serviceTemplateMap;*/
+ }
+ return null;
+ }
+
+ protected FileContentHandler getArtifacts(SessionContext context, ElementContext elementContext,
+ Id serviceModelElementId) {
+ Optional<ElementInfo> artifactsElement = zusammenAdaptor.getElementInfoByName(
+ context, elementContext, serviceModelElementId, StructureElement.Artifacts.name());
+
+ if (artifactsElement.isPresent()) {
+
+ Collection<Element> elements = zusammenAdaptor.listElementData(context, elementContext,
+ artifactsElement.get().getId());
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ elements.forEach(element -> fileContentHandler.addFile(element.getInfo().getName(),
+ element.getData()));
+ return fileContentHandler;
+ }
+
+ return null;
+ }
+
+ @Override
+ public void storeServiceModel(String vspId, Version version, ToscaServiceModel serviceModel) {
+ logger.info("Storing service model for vsp id -> " + vspId);
+
+ ZusammenElement templatesElement =
+ buildStructuralElement(StructureElement.Templates.name(), null);
+ serviceModel.getServiceTemplates().entrySet().forEach(entry -> templatesElement.addSubElement(
+ buildServiceTemplateElement(entry.getKey(), entry.getValue(),
+ serviceModel.getEntryDefinitionServiceTemplate(), Action.CREATE)));
+
+ ZusammenElement artifactsElement =
+ buildStructuralElement(StructureElement.Artifacts.name(), Action.UPDATE);
+ serviceModel.getArtifactFiles().getFiles().entrySet().forEach(entry -> artifactsElement
+ .addSubElement(buildArtifactElement(entry.getKey(), entry.getValue(), Action.CREATE)));
+
+ ZusammenElement serviceModelElement = buildStructuralElement(name, Action.UPDATE);
+ serviceModelElement.getInfo()
+ .addProperty("base", serviceModel.getEntryDefinitionServiceTemplate());
+
+ serviceModelElement.addSubElement(templatesElement);
+ serviceModelElement.addSubElement(artifactsElement);
+
+ SessionContext context = ZusammenUtil.createSessionContext();
+ Id itemId = new Id(vspId);
+ ElementContext elementContext = new ElementContext(itemId, getFirstVersionId(context, itemId));
+ zusammenAdaptor
+ .saveElement(context, elementContext, serviceModelElement, "Store service model");
+
+ logger.info("Finished storing service model for vsp id -> " + vspId);
+ }
+
+ @Override
+ public ServiceElement getServiceModelInfo(String vspId, Version version, String name) {
+ return null;
+ }
+
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ logger.info("started deleting service model for vsp id -> " + vspId);
+ SessionContext context = ZusammenUtil.createSessionContext();
+ Id itemId = new Id(vspId);
+ ElementContext elementContext = new ElementContext(itemId, getFirstVersionId(context, itemId));
+
+ ZusammenElement zusammenElement = ZusammenUtil.buildStructuralElement(name, Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement, "delete:" + name + ".");
+ logger.info("Finished deleting service model for vsp id -> " + vspId);
+ }
+
+ protected ZusammenElement buildArtifactElement(String name, byte[] artifact, Action action) {
+ ZusammenElement artifactElement = new ZusammenElement();
+ artifactElement.setAction(action);
+ Info info = new Info();
+ info.setName(name);
+ info.addProperty("type", ElementType.Artifact.name());
+ artifactElement.setInfo(info);
+ artifactElement.setData(new ByteArrayInputStream(artifact));
+
+ return artifactElement;
+ }
+
+ private ServiceTemplate elementToServiceTemplate(Element element) {
+ return new ToscaExtensionYamlUtil().yamlToObject(element.getData(), ServiceTemplate.class);
+ }
+
+ private Element buildServiceTemplateElement(String name, ServiceTemplate serviceTemplate,
+ String entryDefinitionServiceTemplate,
+ Action action) {
+ ZusammenElement zusammenElement = new ZusammenElement();
+ zusammenElement.setAction(action);
+ Info info = new Info();
+ info.setName(name);
+ info.setDescription(serviceTemplate.getDescription());
+ info.addProperty("type", ElementType.Servicetemplate.name());
+ info.addProperty("base", entryDefinitionServiceTemplate);
+ String yaml = new ToscaExtensionYamlUtil().objectToYaml(serviceTemplate);
+ zusammenElement.setData(new ByteArrayInputStream(yaml.getBytes()));
+ zusammenElement.setInfo(info);
+ return zusammenElement;
+ }
+
+ protected Id getFirstVersionId(SessionContext context, Id vspId) {
+ Optional<ItemVersion> itemVersionOptional = zusammenAdaptor.getFirstVersion(context, vspId);
+ ItemVersion itemVersion = itemVersionOptional.orElseThrow(() ->
+ new RuntimeException(String.format("Vsp %s does not contain any version.", vspId))); //todo
+ return itemVersion.getId();
+ }
+
+ protected ZusammenElement buildStructuralElement(String structureElement, Action action) {
+ return ZusammenUtil.buildStructuralElement(structureElement, action);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/StructureElement.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/StructureElement.java
new file mode 100644
index 0000000000..212c754b5d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/StructureElement.java
@@ -0,0 +1,10 @@
+package org.openecomp.sdc.model.impl.zusammen;
+
+public enum StructureElement {
+ ServiceModel,
+ EnrichedServiceModel,
+ Artifacts,
+ Templates,
+ EntryDefinition,
+
+}