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;
8 import java.util.Arrays;
9 import java.util.Collections;
10 import java.util.HashMap;
11 import java.util.List;
14 import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MAJOR_VERSION;
15 import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MINOR_VERSION;
17 public class MigrationTasksTableDescription implements ITableDescription {
19 private static final String MIGRATION_TASKS_TABLE = "migrationTasks";
22 public List<ImmutablePair<String, DataType>> primaryKeys() {
23 return Collections.singletonList(ImmutablePair.of(MAJOR_VERSION.getFieldName(), MAJOR_VERSION.getFieldType()));
27 public List<ImmutablePair<String, DataType>> clusteringKeys() {
28 return Collections.singletonList(ImmutablePair.of(MINOR_VERSION.getFieldName(), MINOR_VERSION.getFieldType()));
32 public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
33 Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
34 Arrays.stream(SdcRepoFieldsDescription.values())
35 .filter(column -> !column.equals(MAJOR_VERSION) && !column.equals(MINOR_VERSION))
36 .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
41 public String getKeyspace() {
42 return AuditingTypesConstants.REPO_KEYSPACE;
46 public String getTableName() {
47 return MIGRATION_TASKS_TABLE;
50 enum SdcRepoFieldsDescription {
51 MAJOR_VERSION("major_version", DataType.bigint(), true),
52 MINOR_VERSION("minor_version", DataType.bigint(), false),
53 TIMESTAMP("timestamp", DataType.timestamp(), false),
54 NAME("task_name", DataType.varchar(), false),
55 STATUS("task_status", DataType.varchar(), false),
56 MESSAGE("msg", DataType.varchar(), false),
57 EXECUTION_TIME("execution_time", DataType.cdouble(), false);
59 private String fieldName;
60 private boolean isIndexed;
61 private DataType fieldType;
63 SdcRepoFieldsDescription(String fieldName, DataType dataType, boolean indexed ) {
64 this.fieldName = fieldName;
65 this.fieldType = dataType;
66 this.isIndexed = indexed;
69 public String getFieldName() {
73 public boolean isIndexed() {
77 public DataType getFieldType() {