diff options
Diffstat (limited to 'catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema')
21 files changed, 493 insertions, 220 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java index 0f54a25c14..f9dc9b22a4 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java @@ -28,12 +28,11 @@ import com.datastax.driver.core.schemabuilder.SchemaStatement; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.config.*; import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.dao.cassandra.schema.tables.OldExternalApiEventTableDesc; import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.net.ssl.SSLContext; -import java.security.NoSuchAlgorithmException; import java.util.*; import java.util.stream.Collectors; @@ -50,11 +49,19 @@ public class SdcSchemaBuilder { private static Logger log = LoggerFactory.getLogger(SdcSchemaBuilder.class.getName()); + //TODO remove after 1707_OS migration + private static void handle1707OSMigration(Map<String, Map<String, List<String>>> cassndraMetadata, Map<String, List<ITableDescription>> schemeData){ + if(cassndraMetadata.containsKey("attaudit")){ + List<ITableDescription> list = new ArrayList<>(); + list.add(new OldExternalApiEventTableDesc()); + schemeData.put("attaudit", list); + } + + } /** * the method creates all keyspaces, tables and indexes in case they do not * already exist. the method can be run multiple times. the method uses the - * internal enums and external configuration for its operation - * + * internal enums and external configuration for its operation * * @return true if the create operation was successful */ public static boolean createSchema() { @@ -62,7 +69,7 @@ public class SdcSchemaBuilder { Session session = null; try { log.info("creating Schema for Cassandra."); - cluster = createCluster(); + cluster = SdcSchemaUtils.createCluster(); if (cluster == null) { return false; } @@ -73,17 +80,18 @@ public class SdcSchemaBuilder { return false; } log.debug("retrived Cassndra metadata."); - Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata( - keyspacesMetadateFromCassandra); + Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata(keyspacesMetadateFromCassandra); + Map<String, Map<String, List<String>>> metadataTablesStructure = getMetadataTablesStructure(keyspacesMetadateFromCassandra); Map<String, List<ITableDescription>> schemeData = getSchemeData(); + //TODO remove after 1707_OS migration + handle1707OSMigration(cassndraMetadata, schemeData); log.info("creating Keyspaces."); for (String keyspace : schemeData.keySet()) { if (!createKeyspace(keyspace, cassndraMetadata, session)) { return false; } Map<String, List<String>> keyspaceMetadate = cassndraMetadata.get(keyspace); - createTables(schemeData.get(keyspace), keyspaceMetadate, session); - + createTables(schemeData.get(keyspace), keyspaceMetadate, session,metadataTablesStructure.get(keyspace)); } return true; } catch (Exception e) { @@ -106,7 +114,7 @@ public class SdcSchemaBuilder { Session session = null; try { log.info("delete Data from Cassandra."); - cluster = createCluster(); + cluster = SdcSchemaUtils.createCluster(); if (cluster == null) { return false; } @@ -117,11 +125,9 @@ public class SdcSchemaBuilder { return false; } log.debug("retrived Cassndra metadata."); - Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata( - keyspacesMetadateFromCassandra); + Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata(keyspacesMetadateFromCassandra); cassndraMetadata.forEach((k, v) -> { if (AuditingTypesConstants.TITAN_KEYSPACE.equals(k)) { - // session.execute("") } else if (AuditingTypesConstants.ARTIFACT_KEYSPACE.equals(k)) { @@ -147,54 +153,7 @@ public class SdcSchemaBuilder { return false; } - /** - * the method creates the cluster object using the supplied cassandra nodes - * in the configuration - * - * @return cluster object our null in case of an invalid configuration - */ - private static Cluster createCluster() { - List<String> nodes = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig() - .getCassandraHosts(); - if (nodes == null) { - log.info("no nodes were supplied in configuration."); - return null; - } - log.info("connecting to node:{}.", nodes); - Cluster.Builder clusterBuilder = Cluster.builder(); - nodes.forEach(host -> clusterBuilder.addContactPoint(host)); - - clusterBuilder.withMaxSchemaAgreementWaitSeconds(60); - - boolean authenticate = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig() - .isAuthenticate(); - if (authenticate) { - String username = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig() - .getUsername(); - String password = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig() - .getPassword(); - if (username == null || password == null) { - log.info("authentication is enabled but username or password were not supplied."); - return null; - } - clusterBuilder.withCredentials(username, password); - } - boolean ssl = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().isSsl(); - if (ssl) { - String truststorePath = ConfigurationManager.getConfigurationManager().getConfiguration() - .getCassandraConfig().getTruststorePath(); - String truststorePassword = ConfigurationManager.getConfigurationManager().getConfiguration() - .getCassandraConfig().getTruststorePassword(); - if (truststorePath == null || truststorePassword == null) { - log.info("ssl is enabled but truststorePath or truststorePassword were not supplied."); - return null; - } - System.setProperty("javax.net.ssl.trustStore", truststorePath); - System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword); - clusterBuilder.withSSL(); - } - return clusterBuilder.build(); - } + /** * the method prcess the metadata retrieved from the cassandra for the @@ -206,8 +165,7 @@ public class SdcSchemaBuilder { * cassndra mmetadata * @return a map of maps of lists holding parsed info */ - private static Map<String, Map<String, List<String>>> parseKeyspaceMetadata( - List<KeyspaceMetadata> keyspacesMetadata) { + private static Map<String, Map<String, List<String>>> parseKeyspaceMetadata(List<KeyspaceMetadata> keyspacesMetadata) { Map<String, Map<String, List<String>>> cassndraMetadata = keyspacesMetadata.stream() .collect(Collectors.toMap(keyspaceMetadata -> keyspaceMetadata.getName(), keyspaceMetadata -> keyspaceMetadata.getTables().stream() @@ -217,16 +175,25 @@ public class SdcSchemaBuilder { .collect(Collectors.toList()))))); return cassndraMetadata; } + + private static Map<String, Map<String, List<String>>> getMetadataTablesStructure( + List<KeyspaceMetadata> keyspacesMetadata) { + return keyspacesMetadata.stream().collect( + Collectors.toMap(keyspaceMetadata -> keyspaceMetadata.getName(), + keyspaceMetadata -> keyspaceMetadata.getTables().stream().collect( + Collectors.toMap(tableMetadata -> tableMetadata.getName(), + tableMetadata -> tableMetadata.getColumns().stream().map( + columnMetadata -> columnMetadata.getName().toLowerCase()).collect( + Collectors.toList()))))); + } /** * the method builds an index name according to a defined logic * <table> * _<column>_idx * - * @param table - * table name - * @param column - * column name + * @param table: table name + * @param column: column name * @return string name of the index */ private static String createIndexName(String table, String column) { @@ -236,24 +203,21 @@ public class SdcSchemaBuilder { /** * the method creats all the tables and indexes thet do not already exist * - * @param iTableDescriptions - * a list of table description we want to create - * @param keyspaceMetadate - * the current tables that exist in the cassandra under this + * @param iTableDescriptions: a list of table description we want to create + * @param keyspaceMetadate: the current tables that exist in the cassandra under this keyspace + * @param session: the session object used for the execution of the query. + * @param existingTablesMetadata + * the current tables columns that exist in the cassandra under this * keyspace - * @param session - * the session object used for the execution of the query. */ - private static void createTables(List<ITableDescription> iTableDescriptions, - Map<String, List<String>> keyspaceMetadate, Session session) { - + private static void createTables(List<ITableDescription> iTableDescriptions, Map<String, List<String>> keyspaceMetadate, Session session, + Map<String, List<String>> existingTablesMetadata) { for (ITableDescription tableDescription : iTableDescriptions) { String tableName = tableDescription.getTableName().toLowerCase(); Map<String, ImmutablePair<DataType, Boolean>> columnDescription = tableDescription.getColumnDescription(); log.info("creating tables:{}.", tableName); if (keyspaceMetadate == null || !keyspaceMetadate.keySet().contains(tableName)) { - Create create = SchemaBuilder.createTable(tableDescription.getKeyspace(), - tableDescription.getTableName()); + Create create = SchemaBuilder.createTable(tableDescription.getKeyspace(),tableDescription.getTableName()); for (ImmutablePair<String, DataType> key : tableDescription.primaryKeys()) { create.addPartitionKey(key.getLeft(), key.getRight()); } @@ -267,12 +231,14 @@ public class SdcSchemaBuilder { create.addColumn(columnName, columnDescription.get(columnName).getLeft()); } log.trace("exacuting :{}", create.toString()); - ResultSet result = session.execute(create); + session.execute(create); log.info("table:{} created succsesfully.", tableName); } else { log.info("table:{} already exists skiping.", tableName); + alterTable(session, existingTablesMetadata, tableDescription, tableName, columnDescription); } - List<String> indexNames = (keyspaceMetadate != null ? keyspaceMetadate.get(tableName) : new ArrayList<>()); + log.info("keyspacemetdata{}",keyspaceMetadate); + List<String> indexNames = (keyspaceMetadate != null && keyspaceMetadate.get(tableName) != null ? keyspaceMetadate.get(tableName) : new ArrayList<>()); log.info("table:{} creating indexes.", tableName); for (String columnName : columnDescription.keySet()) { String indexName = createIndexName(tableName, columnName).toLowerCase(); @@ -293,25 +259,44 @@ public class SdcSchemaBuilder { } /** + * check if there are new columns that were added to definition but don't exist in DB + * @param session + * @param existingTablesMetadata + * @param tableDescription + * @param tableName + * @param columnDescription + */ + private static void alterTable(Session session, Map<String, List<String>> existingTablesMetadata, + ITableDescription tableDescription, String tableName, + Map<String, ImmutablePair<DataType, Boolean>> columnDescription) { + List<String> definedTableColumns = existingTablesMetadata.get(tableName); + //add column to casandra if was added to table definition + for (Map.Entry<String, ImmutablePair<DataType, Boolean>> column : columnDescription.entrySet()) { + String columnName = column.getKey(); + if (!definedTableColumns.contains(columnName.toLowerCase())){ + log.info("Adding new column {} to the table {}", columnName,tableName); + Alter alter = SchemaBuilder.alterTable(tableDescription.getKeyspace(),tableDescription.getTableName()); + SchemaStatement addColumn = alter.addColumn(columnName).type(column.getValue().getLeft()); + log.trace("exacuting :{}", addColumn.toString()); + session.execute(addColumn); + } + } + } + + /** * the method create the keyspace in case it does not already exists the * method uses configurtion to select the needed replication strategy * - * @param keyspace - * name of the keyspace we want to create - * @param cassndraMetadata - * cassndra metadata - * @param session - * the session object used for the execution of the query. + * @param keyspace: name of the keyspace we want to create + * @param cassndraMetadata: cassndra metadata + * @param session: the session object used for the execution of the query. * @return true in case the operation was successful */ - private static boolean createKeyspace(String keyspace, Map<String, Map<String, List<String>>> cassndraMetadata, - Session session) { - List<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfigList = ConfigurationManager - .getConfigurationManager().getConfiguration().getCassandraConfig().getKeySpaces(); + private static boolean createKeyspace(String keyspace, Map<String, Map<String, List<String>>> cassndraMetadata, Session session) { + List<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfigList = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getKeySpaces(); log.info("creating keyspace:{}.", keyspace); if (!cassndraMetadata.keySet().contains(keyspace)) { - Optional<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfig = keyspaceConfigList.stream() - .filter(keyspaceInfo -> keyspace.equalsIgnoreCase(keyspaceInfo.getName())).findFirst(); + Optional<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfig = keyspaceConfigList.stream().filter(keyspaceInfo -> keyspace.equalsIgnoreCase(keyspaceInfo.getName())).findFirst(); if (keyspaceConfig.isPresent()) { Configuration.CassandrConfig.KeyspaceConfig keyspaceInfo = keyspaceConfig.get(); String createKeyspaceQuery = createKeyspaceQuereyString(keyspace, keyspaceInfo); @@ -356,7 +341,7 @@ public class SdcSchemaBuilder { } /** - * the methoed creates the query string for the given keyspace the methoed + * the methoed creates the query string for the given keyspace the methoed * valides the given data according the the requirments of the replication * strategy SimpleStrategy: "CREATE KEYSPACE IF NOT EXISTS * <keyspaceName></keyspaceName> WITH replication = @@ -370,11 +355,9 @@ public class SdcSchemaBuilder { * configuration info regurding the replication of the keyspace * @return a querey string for the creation of the keyspace */ - private static String createKeyspaceQuereyString(String keyspace, - Configuration.CassandrConfig.KeyspaceConfig keyspaceInfo) { + private static String createKeyspaceQuereyString(String keyspace, Configuration.CassandrConfig.KeyspaceConfig keyspaceInfo) { String query = null; - if (ReplicationStrategy.NETWORK_TOPOLOGY_STRATEGY.getName() - .equalsIgnoreCase(keyspaceInfo.getReplicationStrategy())) { + if (ReplicationStrategy.NETWORK_TOPOLOGY_STRATEGY.getName().equalsIgnoreCase(keyspaceInfo.getReplicationStrategy())) { List<String> dcList = keyspaceInfo.getReplicationInfo(); if (dcList.size() % 2 != 0) { log.error("the supplied replication info is in valid expected dc1,2,dc2,2 etc received:{}", dcList); @@ -389,8 +372,7 @@ public class SdcSchemaBuilder { } query = String.format(CREATE_KEYSPACE_NETWORK_TOPOLOGY_STRATEGY, keyspace, sb.toString()); - } else if (ReplicationStrategy.SIMPLE_STRATEGY.getName() - .equalsIgnoreCase(keyspaceInfo.getReplicationStrategy())) { + } else if (ReplicationStrategy.SIMPLE_STRATEGY.getName().equalsIgnoreCase(keyspaceInfo.getReplicationStrategy())) { List<String> dcList = keyspaceInfo.getReplicationInfo(); if (dcList.size() != 1) { log.error("the supplied replication info is in valid expected <number> etc received:{}", dcList); diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java new file mode 100644 index 0000000000..f52faa5886 --- /dev/null +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java @@ -0,0 +1,90 @@ +package org.openecomp.sdc.be.dao.cassandra.schema; + +import com.datastax.driver.core.*; +import org.openecomp.sdc.be.config.ConfigurationManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +public class SdcSchemaUtils { + + private static Logger log = LoggerFactory.getLogger(SdcSchemaUtils.class.getName()); + + /** + * the method creates the cluster object using the supplied cassandra nodes + * in the configuration + * + * @return cluster object our null in case of an invalid configuration + */ + public static Cluster createCluster() { + List<String> nodes = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getCassandraHosts(); + if (nodes == null) { + log.info("no nodes were supplied in configuration."); + return null; + } + log.info("connecting to node:{}.", nodes); + Cluster.Builder clusterBuilder = Cluster.builder(); + nodes.forEach(host -> clusterBuilder.addContactPoint(host)); + + clusterBuilder.withMaxSchemaAgreementWaitSeconds(60); + + boolean authenticate = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().isAuthenticate(); + if (authenticate) { + String username = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getUsername(); + String password = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getPassword(); + if (username == null || password == null) { + log.info("authentication is enabled but username or password were not supplied."); + return null; + } + clusterBuilder.withCredentials(username, password); + } + boolean ssl = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().isSsl(); + if (ssl) { + String truststorePath = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getTruststorePath(); + String truststorePassword = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getTruststorePassword(); + if (truststorePath == null || truststorePassword == null) { + log.info("ssl is enabled but truststorePath or truststorePassword were not supplied."); + return null; + } + System.setProperty("javax.net.ssl.trustStore", truststorePath); + System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword); + clusterBuilder.withSSL(); + } + return clusterBuilder.build(); + } + + public static boolean executeStatement(String statement) { + return executeStatements(statement); + } + + public static boolean executeStatements(String ... statements) { + Cluster cluster = null; + Session session = null; + try { + cluster = createCluster(); + if (cluster == null) { + return false; + } + session = cluster.connect(); + for (String statement : statements) { + session.execute(statement); + } + return true; + } catch (RuntimeException e) { + log.error(String.format("could not execute statements"), e); + return false; + } finally { + if (session != null) { + session.close(); + } + if (cluster != null) { + cluster.close(); + } + + } + } + + + +} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java index 6de40a7117..8fb594f2ff 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java @@ -35,6 +35,7 @@ import org.openecomp.sdc.be.dao.cassandra.schema.tables.GetCatHierEventTableDesc import org.openecomp.sdc.be.dao.cassandra.schema.tables.GetUebClusterEventTableDesc; import org.openecomp.sdc.be.dao.cassandra.schema.tables.GetUsersListEventTableDesc; import org.openecomp.sdc.be.dao.cassandra.schema.tables.ResAdminEventTableDescription; +import org.openecomp.sdc.be.dao.cassandra.schema.tables.SdcSchemaFilesTableDescription; import org.openecomp.sdc.be.dao.cassandra.schema.tables.UserAccessEventTableDescription; import org.openecomp.sdc.be.dao.cassandra.schema.tables.UserAdminEventTableDescription; @@ -46,17 +47,18 @@ public enum Table { RESOURCE_ADMIN_EVENT(new ResAdminEventTableDescription()), DISTRIBUTION_DOWNLOAD_EVENT(new DistribDownloadEventTableDesc()), DISTRIBUTION_ENGINE_EVENT(new DistribEngineEventTableDesc()), - DISTRIBUTION_NOTIFICATION_EVENT(new DistribNotifEventTableDesc()), + DISTRIBUTION_NOTIFICATION_EVENT(new DistribNotifEventTableDesc()), DISTRIBUTION_STATUS_EVENT(new DistribStatusEventTableDesc()), DISTRIBUTION_DEPLOY_EVENT(new DistribDeployEventTableDesc()), - DISTRIBUTION_GET_UEB_CLUSTER_EVENT(new GetUebClusterEventTableDesc()), + DISTRIBUTION_GET_UEB_CLUSTER_EVENT(new GetUebClusterEventTableDesc()), AUTH_EVENT(new AuthEventTableDescription()), CONSUMER_EVENT(new ConsumerEventTableDefinition()), CATEGORY_EVENT(new CategoryEventTableDescription()), GET_USERS_LIST_EVENT(new GetUsersListEventTableDesc()), GET_CATEGORY_HIERARCHY_EVENT(new GetCatHierEventTableDesc()), - EXTERNAL_API_EVENT(new ExternalApiEventTableDesc()), - COMPONENT_CACHE(new ComponentCacheTableDescription()); + EXTERNAL_API_EVENT(new ExternalApiEventTableDesc()), + COMPONENT_CACHE(new ComponentCacheTableDescription()), + SDC_SCHEMA_FILES(new SdcSchemaFilesTableDescription()); ITableDescription tableDescription; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ArtifactTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ArtifactTableDescription.java index 2e26bd2675..ad7cffaa63 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ArtifactTableDescription.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ArtifactTableDescription.java @@ -20,11 +20,12 @@ package org.openecomp.sdc.be.dao.cassandra.schema.tables; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.config.Configuration; -import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription; import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; @@ -32,8 +33,6 @@ import com.datastax.driver.core.DataType; public class ArtifactTableDescription implements ITableDescription { - private static final String keyspaceType = "artifact"; - @Override public List<ImmutablePair<String, DataType>> primaryKeys() { List<ImmutablePair<String, DataType>> keys = new ArrayList<>(); diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/AuthEventTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/AuthEventTableDescription.java index ef7be5deb7..ab2b207888 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/AuthEventTableDescription.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/AuthEventTableDescription.java @@ -26,13 +26,10 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription; -import org.openecomp.sdc.be.dao.cassandra.schema.tables.UserAdminEventTableDescription.UAEFieldsDescription; import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; import com.datastax.driver.core.DataType; -import com.datastax.driver.mapping.annotations.Column; public class AuthEventTableDescription implements ITableDescription { @Override @@ -71,11 +68,14 @@ public class AuthEventTableDescription implements ITableDescription { } enum AEFieldsDescription { - - URL("url", DataType.varchar(), false), REQUEST_ID("request_id", DataType.varchar(), true), USER("user", - DataType.varchar(), false), AUTH_STATUS("auth_status", DataType.varchar(), false), REALM("realm", - DataType.varchar(), false), ACTION("action", DataType.varchar(), true), STATUS("status", - DataType.varchar(), false), DESC("description", DataType.varchar(), false); + URL("url", DataType.varchar(), false), + REQUEST_ID("request_id", DataType.varchar(), true), + USER("user", DataType.varchar(), false), + AUTH_STATUS("auth_status", DataType.varchar(), false), + REALM("realm", DataType.varchar(), false), + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESC("description", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/CategoryEventTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/CategoryEventTableDescription.java index efefac57b6..c49651e548 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/CategoryEventTableDescription.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/CategoryEventTableDescription.java @@ -71,13 +71,16 @@ public class CategoryEventTableDescription implements ITableDescription { enum CEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESC("description", - DataType.varchar(), false), CATEGORY_NAME("category_Name", DataType.varchar(), - false), SUB_CATEGORY_NAME("sub_Category_Name", DataType.varchar(), false), GROUPING_NAME( - "grouping_name", DataType.varchar(), false), MODIFIER("modifier", DataType.varchar(), - false), REQUEST_ID("request_id", DataType.varchar(), false), RESOURCE_TYPE( - "resource_type", DataType.varchar(), false), SERVICE_INSTANCE_ID( - "service_instance_id", DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESC("description", DataType.varchar(), false), + CATEGORY_NAME("category_Name", DataType.varchar(), false), + SUB_CATEGORY_NAME("sub_Category_Name", DataType.varchar(), false), + GROUPING_NAME("grouping_name", DataType.varchar(), false), + MODIFIER("modifier", DataType.varchar(), false), + REQUEST_ID("request_id", DataType.varchar(), false), + RESOURCE_TYPE("resource_type", DataType.varchar(), false), + SERVICE_INSTANCE_ID("service_instance_id", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java index 6396da5c32..611138efa0 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java @@ -61,9 +61,11 @@ public class ComponentCacheTableDescription implements ITableDescription { } enum PartialComponentFieldsDescription { - DATA("data", DataType.blob(), false), MODIFICATION_TIME("modification_time", DataType.timestamp(), false), TYPE( - "type", DataType.varchar(), false), IS_DIRTY("is_dirty", DataType.cboolean(), - false), IS_ZIPPED("is_zipped", DataType.cboolean(), false),; + DATA("data", DataType.blob(), false), + MODIFICATION_TIME("modification_time", DataType.timestamp(), false), + TYPE("type", DataType.varchar(), false), + IS_DIRTY("is_dirty", DataType.cboolean(), false), + IS_ZIPPED("is_zipped", DataType.cboolean(), false),; private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ConsumerEventTableDefinition.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ConsumerEventTableDefinition.java index 554a7a7a51..68ec5620ba 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ConsumerEventTableDefinition.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ConsumerEventTableDefinition.java @@ -70,10 +70,12 @@ public class ConsumerEventTableDefinition implements ITableDescription { } enum DEEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESCRIPTION( - "description", DataType.varchar(), - false), ECOMP_USER("ecomp_user", DataType.varchar(), false), MODIFIER("modifier", DataType.varchar(), - false), REQUEST_ID("request_id", DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION("description", DataType.varchar(), false), + ECOMP_USER("ecomp_user", DataType.varchar(), false), + MODIFIER("modifier", DataType.varchar(), false), + REQUEST_ID("request_id", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java index 5fc1dc8bd4..32c2365b95 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java @@ -70,13 +70,16 @@ public class DistribDeployEventTableDesc implements ITableDescription { } enum DSEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), true), DESCRIPTION( - "description", DataType.varchar(), false), REQUEST_ID("request_id", DataType.varchar(), - false), SERVICE_INST_ID("service_instance_id", DataType.varchar(), true), MODIFIER("modifier", - DataType.varchar(), false), CURR_VERSION("curr_version", DataType.varchar(), - false), DID("did", DataType.varchar(), true), RESOURCE_NAME("resource_name", - DataType.varchar(), - false), RESOURCE_TYPE("resource_type", DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), true), + DESCRIPTION("description", DataType.varchar(), false), + REQUEST_ID("request_id", DataType.varchar(), false), + SERVICE_INST_ID("service_instance_id", DataType.varchar(), true), + MODIFIER("modifier", DataType.varchar(), false), + CURR_VERSION("curr_version", DataType.varchar(), false), + DID("did", DataType.varchar(), true), + RESOURCE_NAME("resource_name", DataType.varchar(), false), + RESOURCE_TYPE("resource_type", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java index 0ed4f55a7b..0ac31352f2 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java @@ -69,10 +69,13 @@ public class DistribDownloadEventTableDesc implements ITableDescription { } enum DSEFieldsDescription { - REQUEST_ID("request_Id", DataType.varchar(), false), SERVICE_INST_ID("service_Instance_Id", DataType.varchar(), - false), ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), - false), DESCRIPTION("description", DataType.varchar(), false), CONSUMER_ID("consumer_Id", - DataType.varchar(), false), RESOURCE_URL("resource_URL", DataType.varchar(), false); + REQUEST_ID("request_Id", DataType.varchar(), false), + SERVICE_INST_ID("service_Instance_Id", DataType.varchar(),false), + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION("description", DataType.varchar(), false), + CONSUMER_ID("consumer_Id", DataType.varchar(), false), + RESOURCE_URL("resource_URL", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java index 5ce5bffb7c..16d9af084f 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java @@ -68,14 +68,17 @@ public class DistribEngineEventTableDesc implements ITableDescription { } enum DEEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESCRIPTION( - "description", DataType.varchar(), - false), CONSUMER_ID("consumer_id", DataType.varchar(), false), REQUEST_ID("request_id", - DataType.varchar(), true), SERVICE_INST_ID("service_instance_id", DataType.varchar(), - false), ROLE("role", DataType.varchar(), false), D_ENV("d_env", DataType.varchar(), - false), API_KEY("api_key", DataType.varchar(), false), DSTATUS_TOPIC( - "dstatus_topic", DataType.varchar(), - false), DNOTIF_TOPIC("dnotif_topic", DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION("description", DataType.varchar(), false), + CONSUMER_ID("consumer_id", DataType.varchar(), false), + REQUEST_ID("request_id", DataType.varchar(), true), + SERVICE_INST_ID("service_instance_id", DataType.varchar(), false), + ROLE("role", DataType.varchar(), false), + D_ENV("d_env", DataType.varchar(), false), + API_KEY("api_key", DataType.varchar(), false), + DSTATUS_TOPIC("dstatus_topic", DataType.varchar(), false), + DNOTIF_TOPIC("dnotif_topic", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java index 96fab66701..371b5c4886 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java @@ -68,15 +68,18 @@ public class DistribNotifEventTableDesc implements ITableDescription { } enum DNEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESCRIPTION( - "description", DataType.varchar(), - false), REQUEST_ID("request_id", DataType.varchar(), false), SERVICE_INST_ID("service_instance_id", - DataType.varchar(), true), TOPIC_NAME("topic_name", DataType.varchar(), false), MODIFIER( - "modifier", DataType.varchar(), false), CURR_STATE("curr_state", DataType.varchar(), - false), CURR_VERSION("curr_version", DataType.varchar(), false), DID("did", - DataType.varchar(), true), RESOURCE_NAME("resource_name", - DataType.varchar(), false), RESOURCE_TYPE("resource_type", - DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION("description", DataType.varchar(), false), + REQUEST_ID("request_id", DataType.varchar(), false), + SERVICE_INST_ID("service_instance_id", DataType.varchar(), true), + TOPIC_NAME("topic_name", DataType.varchar(), false), + MODIFIER("modifier", DataType.varchar(), false), + CURR_STATE("curr_state", DataType.varchar(), false), + CURR_VERSION("curr_version", DataType.varchar(), false), + DID("did", DataType.varchar(), true), + RESOURCE_NAME("resource_name", DataType.varchar(), false), + RESOURCE_TYPE("resource_type", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java index bc564e3743..d1c73bf46e 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java @@ -69,13 +69,16 @@ public class DistribStatusEventTableDesc implements ITableDescription { } enum DSEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESCRIPTION( - "description", DataType.varchar(), - false), DID("did", DataType.varchar(), true), CONSUMER_ID("consumer_id", DataType.varchar(), - false), REQUEST_ID("request_id", DataType.varchar(), false), RESOURCE_URL("resoure_URL", - DataType.varchar(), false), SERVICE_INST_ID("service_instance_id", DataType.varchar(), - false), TOPIC_NAME("topic_name", DataType.varchar(), - false), STATUS_TIME("status_time", DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION("description", DataType.varchar(), false), + DID("did", DataType.varchar(), true), + CONSUMER_ID("consumer_id", DataType.varchar(), false), + REQUEST_ID("request_id", DataType.varchar(), false), + RESOURCE_URL("resoure_URL", DataType.varchar(), false), + SERVICE_INST_ID("service_instance_id", DataType.varchar(), false), + TOPIC_NAME("topic_name", DataType.varchar(), false), + STATUS_TIME("status_time", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ExternalApiEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ExternalApiEventTableDesc.java index a67c9ef4ef..cb659b9a8a 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ExternalApiEventTableDesc.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ExternalApiEventTableDesc.java @@ -67,16 +67,23 @@ public class ExternalApiEventTableDesc implements ITableDescription { } enum EGAEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESCRIPTION( - "description", DataType.varchar(), false), CONSUMER_ID("consumer_id", DataType.varchar(), - false), RESOURCE_URL("resource_URL", DataType.varchar(), false), RESOURCE_NAME("resource_name", - DataType.varchar(), - false), RESOURCE_TYPE("resource_type", DataType.varchar(), false), SERVICE_INST_ID( - "service_instance_id", DataType.varchar(), - true), MODIFIER("modifier", DataType.varchar(), false), PREV_ARTIFACT_UUID( - "prev_artifact_uuid", DataType.varchar(), false), CURR_ARTIFACT_UUID( - "curr_artifact_uuid", DataType.varchar(), false), ARTIFACT_DATA( - "artifact_data", DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION( "description", DataType.varchar(), false), + CONSUMER_ID("consumer_id", DataType.varchar(), false), + RESOURCE_URL("resource_URL", DataType.varchar(), false), + RESOURCE_NAME("resource_name", DataType.varchar(), false), + RESOURCE_TYPE("resource_type", DataType.varchar(), false), + SERVICE_INST_ID( "service_instance_id", DataType.varchar(), true), + INVARIANT_UUID("invariant_uuid", DataType.varchar(), true), + MODIFIER("modifier", DataType.varchar(), false), + PREV_VERSION( "prev_version", DataType.varchar(), false), + CURR_VERSION("curr_version", DataType.varchar(), false), + PREV_STATE("prev_state", DataType.varchar(), false), + CURR_STATE( "curr_state", DataType.varchar(), false), + PREV_ARTIFACT_UUID( "prev_artifact_uuid", DataType.varchar(), false), + CURR_ARTIFACT_UUID( "curr_artifact_uuid", DataType.varchar(), false), + ARTIFACT_DATA( "artifact_data", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetCatHierEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetCatHierEventTableDesc.java index 2d1a5c3c75..3858b7d8f6 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetCatHierEventTableDesc.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetCatHierEventTableDesc.java @@ -69,9 +69,12 @@ public class GetCatHierEventTableDesc implements ITableDescription { } enum DEEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESCRIPTION( - "description", DataType.varchar(), false), DETAILS("details", DataType.varchar(), false), REQUEST_ID( - "request_id", DataType.varchar(), false), MODIFIER("modifier", DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION("description", DataType.varchar(), false), + DETAILS("details", DataType.varchar(), false), + REQUEST_ID("request_id", DataType.varchar(), false), + MODIFIER("modifier", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUebClusterEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUebClusterEventTableDesc.java index 8ef1f01186..40a1827e36 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUebClusterEventTableDesc.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUebClusterEventTableDesc.java @@ -70,10 +70,12 @@ public class GetUebClusterEventTableDesc implements ITableDescription { } enum DEEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESCRIPTION( - "description", DataType.varchar(), - false), CONSUMER_ID("consumer_Id", DataType.varchar(), false), REQUEST_ID("request_Id", - DataType.varchar(), false), SERVICE_INST_ID("service_Instance_Id", DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION("description", DataType.varchar(), false), + CONSUMER_ID("consumer_Id", DataType.varchar(), false), + REQUEST_ID("request_Id", DataType.varchar(), false), + SERVICE_INST_ID("service_Instance_Id", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUsersListEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUsersListEventTableDesc.java index 5d94bd3f4d..4bd3e296ef 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUsersListEventTableDesc.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUsersListEventTableDesc.java @@ -69,9 +69,12 @@ public class GetUsersListEventTableDesc implements ITableDescription { } enum DEEFieldsDescription { - ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESCRIPTION( - "description", DataType.varchar(), false), DETAILS("details", DataType.varchar(), false), REQUEST_ID( - "request_id", DataType.varchar(), false), MODIFIER("modifier", DataType.varchar(), false); + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION("description", DataType.varchar(), false), + DETAILS("details", DataType.varchar(), false), + REQUEST_ID("request_id", DataType.varchar(), false), + MODIFIER("modifier", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OldExternalApiEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OldExternalApiEventTableDesc.java new file mode 100644 index 0000000000..b075f0ef4e --- /dev/null +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OldExternalApiEventTableDesc.java @@ -0,0 +1,94 @@ +package org.openecomp.sdc.be.dao.cassandra.schema.tables; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription; +import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; + +import com.datastax.driver.core.DataType; + +public class OldExternalApiEventTableDesc implements ITableDescription { + @Override + public List<ImmutablePair<String, DataType>> primaryKeys() { + List<ImmutablePair<String, DataType>> keys = new ArrayList<>(); + keys.add(new ImmutablePair<String, DataType>(TIMEBASED_UUID_FIELD, DataType.timeuuid())); + return keys; + } + + @Override + public List<ImmutablePair<String, DataType>> clusteringKeys() { + List<ImmutablePair<String, DataType>> keys = new ArrayList<>(); + keys.add(new ImmutablePair<String, DataType>(TIMESTAMP_FIELD, DataType.timestamp())); + return keys; + } + + @Override + public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() { + Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>(); + + for (EGAEFieldsDescription field : EGAEFieldsDescription.values()) { + columns.put(field.getName(), new ImmutablePair<DataType, Boolean>(field.type, field.indexed)); + } + + return columns; + } + + @Override + public String getKeyspace() { + return AuditingTypesConstants.AUDIT_KEYSPACE.replace("sdc", "att"); + } + + + + @Override + public String getTableName() { + return AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE; + } + + enum EGAEFieldsDescription { + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION( "description", DataType.varchar(), false), + CONSUMER_ID("consumer_id", DataType.varchar(), false), + RESOURCE_URL("resource_URL", DataType.varchar(), false), + RESOURCE_NAME("resource_name", DataType.varchar(), false), + RESOURCE_TYPE("resource_type", DataType.varchar(), false), + SERVICE_INST_ID( "service_instance_id", DataType.varchar(), true), + INVARIANT_UUID("invariant_uuid", DataType.varchar(), true), + MODIFIER("modifier", DataType.varchar(), false), + PREV_VERSION( "prev_version", DataType.varchar(), false), + CURR_VERSION("curr_version", DataType.varchar(), false), + PREV_STATE("prev_state", DataType.varchar(), false), + CURR_STATE( "curr_state", DataType.varchar(), false), + PREV_ARTIFACT_UUID( "prev_artifact_uuid", DataType.varchar(), false), + CURR_ARTIFACT_UUID( "curr_artifact_uuid", DataType.varchar(), false), + ARTIFACT_DATA( "artifact_data", DataType.varchar(), false); + + private String name; + private DataType type; + private boolean indexed; + + EGAEFieldsDescription(String name, DataType type, boolean indexed) { + this.name = name; + this.type = type; + this.indexed = indexed; + } + + public String getName() { + return name; + } + + public DataType getType() { + return type; + } + + public boolean isIndexed() { + return indexed; + } + } + +} + diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ResAdminEventTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ResAdminEventTableDescription.java index a6f0ba905d..e928982127 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ResAdminEventTableDescription.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ResAdminEventTableDescription.java @@ -71,40 +71,27 @@ public class ResAdminEventTableDescription implements ITableDescription { } enum AEFieldsDescription { - REQUEST_ID("request_id", DataType.varchar(), false), SERVICE_INST_ID("service_instance_id", DataType.varchar(), - true), INVARIANT_UUID("invariant_UUID", DataType.varchar(), true), ACTION("action", DataType.varchar(), - true), STATUS("status", DataType.varchar(), false), DESCRIPTION("description", - DataType.varchar(), - false), RESOURCE_TYPE("resource_type", DataType.varchar(), false), PREV_VERSION( - "prev_version", DataType.varchar(), - true), PREV_STATE("prev_state", DataType.varchar(), true), CURR_STATE( - "curr_state", DataType.varchar(), false), RESOURCE_NAME("resource_name", - DataType.varchar(), false), CURR_VERSION("curr_version", - DataType.varchar(), true), MODIFIER("modifier", - DataType.varchar(), - false), PREV_ARTIFACT_UUID("prev_artifact_UUID", - DataType.varchar(), - false), CURR__ARTIFACT_UUID( - "curr_artifact_UUID", - DataType.varchar(), - false), ARTIFACT_DATA( - "artifact_data", - DataType.varchar(), - false), DID("did", - DataType.varchar(), - true), DPREV_STATUS( - "dprev_status", - DataType.varchar(), - false), DCURR_STATUS( - "dcurr_status", - DataType.varchar(), - false), TOSCA_NODE_TYPE( - "tosca_node_type", - DataType.varchar(), - false), COMMENT( - "comment", - DataType.varchar(), - false); + REQUEST_ID("request_id", DataType.varchar(), false), + SERVICE_INST_ID("service_instance_id", DataType.varchar(), true), + INVARIANT_UUID("invariant_UUID", DataType.varchar(), true), + ACTION("action", DataType.varchar(), true), + STATUS("status", DataType.varchar(), false), + DESCRIPTION("description",DataType.varchar(), false), + RESOURCE_TYPE("resource_type", DataType.varchar(), false), + PREV_VERSION( "prev_version", DataType.varchar(), true), + PREV_STATE("prev_state", DataType.varchar(), true), + CURR_STATE("curr_state", DataType.varchar(), false), + RESOURCE_NAME("resource_name", DataType.varchar(), false), + CURR_VERSION("curr_version", DataType.varchar(), true), + MODIFIER("modifier", DataType.varchar(), false), + PREV_ARTIFACT_UUID("prev_artifact_UUID", DataType.varchar(), false), + CURR__ARTIFACT_UUID("curr_artifact_UUID", DataType.varchar(), false), + ARTIFACT_DATA("artifact_data", DataType.varchar(), false), + DID("did", DataType.varchar(), true), + DPREV_STATUS("dprev_status", DataType.varchar(), false), + DCURR_STATUS("dcurr_status", DataType.varchar(), false), + TOSCA_NODE_TYPE("tosca_node_type", DataType.varchar(), false), + COMMENT("comment", DataType.varchar(), false); private String name; private DataType type; diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/SdcSchemaFilesTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/SdcSchemaFilesTableDescription.java new file mode 100644 index 0000000000..09a01fb962 --- /dev/null +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/SdcSchemaFilesTableDescription.java @@ -0,0 +1,83 @@ +package org.openecomp.sdc.be.dao.cassandra.schema.tables; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription; +import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; + +import com.datastax.driver.core.DataType; + +public class SdcSchemaFilesTableDescription implements ITableDescription { + + private static final String SDC_RELEASE_NUM = "sdcReleaseNum"; + private static final String TIMESTAMP = "timestamp"; + private static final String CONFORMANCE_LEVEL = "conformanceLevel"; + + @Override + public List<ImmutablePair<String, DataType>> primaryKeys() { + List<ImmutablePair<String, DataType>> keys = new ArrayList<>(); + keys.add(new ImmutablePair<String, DataType>(SDC_RELEASE_NUM, DataType.varchar())); + keys.add(new ImmutablePair<String, DataType>(CONFORMANCE_LEVEL, DataType.varchar())); + return keys; + } + + @Override + public List<ImmutablePair<String, DataType>> clusteringKeys() { + List<ImmutablePair<String, DataType>> keys = new ArrayList<>(); + keys.add(new ImmutablePair<String, DataType>(TIMESTAMP, DataType.timestamp())); + return keys; + } + + @Override + public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() { + Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>(); + + for (SdcSchemaFilesFieldsDescription field : SdcSchemaFilesFieldsDescription.values()) { + columns.put(field.getName(), new ImmutablePair<DataType, Boolean>(field.type, field.indexed)); + } + + return columns; + } + + @Override + public String getKeyspace() { + return AuditingTypesConstants.ARTIFACT_KEYSPACE; + } + + @Override + public String getTableName() { + return "sdcSchemaFiles"; + } + + enum SdcSchemaFilesFieldsDescription { + FILE_NAME("fileName", DataType.varchar(), false), + PAYLOAD("payload", DataType.blob(), false), + CHECKSUM("checksum", DataType.varchar(), false); + + private String name; + private DataType type; + private boolean indexed; + + SdcSchemaFilesFieldsDescription(String name, DataType type, boolean indexed) { + this.name = name; + this.type = type; + this.indexed = indexed; + } + + public String getName() { + return name; + } + + public DataType getType() { + return type; + } + + public boolean isIndexed() { + return indexed; + } + } +} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAccessEventTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAccessEventTableDescription.java index 7f482ae3ac..93f5640c30 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAccessEventTableDescription.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAccessEventTableDescription.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription; import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; |