1 package org.openecomp.sdc.be.dao.cassandra.schema.tables;
3 import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MAJOR_VERSION;
4 import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MINOR_VERSION;
6 import java.util.Arrays;
7 import java.util.Collections;
8 import java.util.HashMap;
12 import org.apache.commons.lang3.tuple.ImmutablePair;
13 import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
14 import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
16 import com.datastax.driver.core.DataType;
18 public class MigrationTasksTableDescription implements ITableDescription {
20 private static final String MIGRATION_TASKS_TABLE = "migrationTasks";
23 public List<ImmutablePair<String, DataType>> primaryKeys() {
24 return Collections.singletonList(ImmutablePair.of(MAJOR_VERSION.getFieldName(), MAJOR_VERSION.getFieldType()));
28 public List<ImmutablePair<String, DataType>> clusteringKeys() {
29 return Collections.singletonList(ImmutablePair.of(MINOR_VERSION.getFieldName(), MINOR_VERSION.getFieldType()));
33 public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
34 Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
35 Arrays.stream(SdcRepoFieldsDescription.values())
36 .filter(column -> !column.equals(MAJOR_VERSION) && !column.equals(MINOR_VERSION))
37 .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
42 public String getKeyspace() {
43 return AuditingTypesConstants.REPO_KEYSPACE;
47 public String getTableName() {
48 return MIGRATION_TASKS_TABLE;
51 enum SdcRepoFieldsDescription {
52 MAJOR_VERSION("major_version", DataType.bigint(), true),
53 MINOR_VERSION("minor_version", DataType.bigint(), false),
54 TIMESTAMP("timestamp", DataType.timestamp(), false),
55 NAME("task_name", DataType.varchar(), false),
56 STATUS("task_status", DataType.varchar(), false),
57 MESSAGE("msg", DataType.varchar(), false),
58 DESCRIPTION("description", DataType.varchar(), false),
59 EXECUTION_TIME("execution_time", DataType.cdouble(), false);
61 private String fieldName;
62 private boolean isIndexed;
63 private DataType fieldType;
65 SdcRepoFieldsDescription(String fieldName, DataType dataType, boolean indexed ) {
66 this.fieldName = fieldName;
67 this.fieldType = dataType;
68 this.isIndexed = indexed;
71 public String getFieldName() {
75 public boolean isIndexed() {
79 public DataType getFieldType() {