1 package org.openecomp.sdc.be.dao.cassandra.schema.tables;
3 import com.datastax.driver.core.DataType;
4 import org.apache.commons.lang3.tuple.ImmutablePair;
5 import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
6 import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
10 import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MAJOR_VERSION;
11 import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MINOR_VERSION;
13 public class MigrationTasksTableDescription implements ITableDescription {
15 private static final String MIGRATION_TASKS_TABLE = "migrationTasks";
18 public List<ImmutablePair<String, DataType>> primaryKeys() {
19 return Collections.singletonList(ImmutablePair.of(MAJOR_VERSION.getFieldName(), MAJOR_VERSION.getFieldType()));
23 public List<ImmutablePair<String, DataType>> clusteringKeys() {
24 return Collections.singletonList(ImmutablePair.of(MINOR_VERSION.getFieldName(), MINOR_VERSION.getFieldType()));
28 public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
29 Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
30 Arrays.stream(SdcRepoFieldsDescription.values())
31 .filter(column -> !column.equals(MAJOR_VERSION) && !column.equals(MINOR_VERSION))
32 .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
37 public String getKeyspace() {
38 return AuditingTypesConstants.REPO_KEYSPACE;
42 public String getTableName() {
43 return MIGRATION_TASKS_TABLE;
46 enum SdcRepoFieldsDescription {
47 MAJOR_VERSION("major_version", DataType.bigint(), true),
48 MINOR_VERSION("minor_version", DataType.bigint(), false),
49 TIMESTAMP("timestamp", DataType.timestamp(), false),
50 NAME("task_name", DataType.varchar(), false),
51 STATUS("task_status", DataType.varchar(), false),
52 MESSAGE("msg", DataType.varchar(), false),
53 DESCRIPTION("description", DataType.varchar(), false),
54 EXECUTION_TIME("execution_time", DataType.cdouble(), false);
56 private String fieldName;
57 private boolean isIndexed;
58 private DataType fieldType;
60 SdcRepoFieldsDescription(String fieldName, DataType dataType, boolean indexed ) {
61 this.fieldName = fieldName;
62 this.fieldType = dataType;
63 this.isIndexed = indexed;
66 public String getFieldName() {
70 public boolean isIndexed() {
74 public DataType getFieldType() {