aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-07-20 01:29:49 +0300
committerMichael Lando <ml636r@att.com>2017-07-20 01:30:06 +0300
commit3c3c833897dbfc0e85feaf36086a505f990ecb76 (patch)
tree8c308fbe7298aa65066ba0fc8a71e51d20d8e0de /catalog-dao/src
parent30db4407bab8cfea48e278d29e55b11c6c0a528c (diff)
[SDC] 1710 rebase + pom modifications
Change-Id: I1f9c0a5201576c7a6b124f6a786db12c1a8cd7c0 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-dao/src')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksAccessor.java17
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksDao.java73
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java1
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java11
4 files changed, 12 insertions, 90 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksAccessor.java
deleted file mode 100644
index e548a594d9..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksAccessor.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.openecomp.sdc.be.dao.cassandra;
-
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Param;
-import com.datastax.driver.mapping.annotations.Query;
-
-@Accessor
-public interface MigrationTasksAccessor {
-
- @Query("SELECT minor_version FROM sdcrepository.migrationTasks WHERE major_version = :majorVersion order by minor_version desc limit 1")
- ResultSet getLatestMinorVersion(@Param("majorVersion") Long majorVersion);
-
- @Query("DELETE FROM sdcrepository.migrationTasks WHERE major_version = :majorVersion")
- void deleteTasksForMajorVersion(@Param("majorVersion") Long majorVersion);
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksDao.java
deleted file mode 100644
index 89ad9662fa..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksDao.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.openecomp.sdc.be.dao.cassandra;
-
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.core.Session;
-import com.datastax.driver.mapping.Mapper;
-import com.datastax.driver.mapping.MappingManager;
-import fj.data.Either;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.resources.data.MigrationTaskEntry;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-import java.math.BigInteger;
-
-@Component("sdc-migration-tasks-cassandra-dao")
-public class MigrationTasksDao extends CassandraDao {
-
- private static Logger logger = LoggerFactory.getLogger(MigrationTasksDao.class.getName());
- private MigrationTasksAccessor migrationTasksAccessor;
- private Mapper<MigrationTaskEntry> migrationTaskMapper;
-
- @PostConstruct
- public void init() {
- String keyspace = AuditingTypesConstants.REPO_KEYSPACE;
- if (client.isConnected()) {
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
- if (result.isLeft()) {
- session = result.left().value().left;
- manager = result.left().value().right;
- migrationTasksAccessor = manager.createAccessor(MigrationTasksAccessor.class);
- migrationTaskMapper = manager.mapper(MigrationTaskEntry.class);
- logger.info("** migrationTasksAccessor created");
- } else {
- logger.info("** migrationTasksAccessor failed");
- throw new RuntimeException("Artifact keyspace [" + keyspace + "] failed to connect with error : "
- + result.right().value());
- }
- } else {
- logger.info("** Cassandra client isn't connected");
- logger.info("** migrationTasksAccessor created, but not connected");
- }
- }
-
- public BigInteger getLatestMinorVersion(BigInteger majorVersion) {
- try {
- ResultSet latestMinorVersion = migrationTasksAccessor.getLatestMinorVersion(majorVersion.longValue());
- Row minorVersionRow = latestMinorVersion.one();
- return minorVersionRow == null ? BigInteger.valueOf(Long.MIN_VALUE) : BigInteger.valueOf(minorVersionRow.getLong(0));
- } catch (RuntimeException e) {
- logger.error("failed to get latest minor version for major version {}", majorVersion, e);
- throw e;
- }
- }
-
- public void deleteAllTasksForVersion(BigInteger majorVersion) {
- try {
- migrationTasksAccessor.deleteTasksForMajorVersion(majorVersion.longValue());
- } catch (RuntimeException e) {
- logger.error("failed to delete tasks for major version {}", majorVersion, e);
- throw e;
- }
- }
-
- public void createMigrationTask(MigrationTaskEntry migrationTask) {
- migrationTaskMapper.save(migrationTask);
- }
-
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java
index f7506f77e1..885a7a7ce3 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java
@@ -54,6 +54,7 @@ public class MigrationTasksTableDescription implements ITableDescription {
NAME("task_name", DataType.varchar(), false),
STATUS("task_status", DataType.varchar(), false),
MESSAGE("msg", DataType.varchar(), false),
+ DESCRIPTION("description", DataType.varchar(), false),
EXECUTION_TIME("execution_time", DataType.cdouble(), false);
private String fieldName;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java
index 08376b616f..b64ef201dd 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java
@@ -34,6 +34,9 @@ public class MigrationTaskEntry {
@Column(name = "msg")
private String message;
+ @Column(name = "description")
+ private String description;
+
public void setMajorVersion(Long majorVersion) {
this.majorVersion = majorVersion;
}
@@ -89,4 +92,12 @@ public class MigrationTaskEntry {
public double getExecutionTime() {
return executionTime;
}
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
}