1 package org.openecomp.sdc.be.dao.cassandra.schema.tables;
3 import java.util.ArrayList;
4 import java.util.Arrays;
5 import java.util.HashMap;
6 import java.util.LinkedList;
10 import org.apache.commons.lang3.tuple.ImmutablePair;
11 import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
12 import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
14 import com.datastax.driver.core.DataType;
17 public class OperationalEnvironmentsTableDescription implements ITableDescription {
19 private static final String OPERATIONAL_ENVIRONMENT_TABLE = "operationalEnvironment";
20 private static final String ENVIRONMENT_ID = "environment_id";
23 public List<ImmutablePair<String, DataType>> primaryKeys() {
24 List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
25 keys.add(new ImmutablePair<String, DataType>( ENVIRONMENT_ID, DataType.varchar()));
30 public List<ImmutablePair<String, DataType>> clusteringKeys() {
31 return new LinkedList<>();
35 public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
36 Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
37 Arrays.stream(SdcOperationalEnvironmentFieldsDescription.values())
38 .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
43 public String getKeyspace() {
44 return AuditingTypesConstants.REPO_KEYSPACE;
48 public String getTableName() {
49 return OPERATIONAL_ENVIRONMENT_TABLE;
52 enum SdcOperationalEnvironmentFieldsDescription {
53 //there is also PK field "environmentID"
54 TENANT("tenant", DataType.varchar(), false),
55 IS_PRODUCTION("is_production", DataType.cboolean(), false),
56 ECOMP_WORKLOAD_CONTEXT("ecomp_workload_context", DataType.varchar(), false),
57 DMAAP_UEB_ADDRESS("dmaap_ueb_address", DataType.set(DataType.varchar()), false),
58 UEB_API_KEY("ueb_api_key",DataType.varchar(), false),
59 UEB_SECRET_KEY("ueb_secret_key",DataType.varchar(), false),
60 STATUS("status",DataType.varchar() ,true),
61 LAST_MODIFIED("last_modified",DataType.timestamp() ,false);
63 private String fieldName;
64 private boolean isIndexed;
65 private DataType fieldType;
67 SdcOperationalEnvironmentFieldsDescription(String fieldName, DataType dataType, boolean indexed ) {
68 this.fieldName = fieldName;
69 this.fieldType = dataType;
70 this.isIndexed = indexed;
73 public String getFieldName() {
77 public boolean isIndexed() {
81 public DataType getFieldType() {