summaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/main/java/org/openecomp/sdc/be/dao
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-dao/src/main/java/org/openecomp/sdc/be/dao')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksAccessor.java17
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksDao.java73
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java23
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java81
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java15
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java4
7 files changed, 198 insertions, 24 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
index 0a7a009ad4..4ae3e61841 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
@@ -27,7 +27,9 @@ public enum ActionStatus {
// CapabilityType related
CAPABILITY_TYPE_ALREADY_EXIST, MISSING_CAPABILITY_TYPE, REQ_CAP_NOT_SATISFIED_BEFORE_CERTIFICATION, IMPORT_DUPLICATE_REQ_CAP_NAME, IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED,
// Resource related
- RESOURCE_NOT_FOUND, MISSING_DERIVED_FROM_TEMPLATE, PARENT_RESOURCE_NOT_FOUND, PARENT_RESOURCE_DOES_NOT_EXTEND, INVALID_DEFAULT_VALUE, INVALID_COMPLEX_DEFAULT_VALUE, MULTIPLE_PARENT_RESOURCE_FOUND, INVALID_RESOURCE_PAYLOAD, INVALID_TOSCA_FILE_EXTENSION, INVALID_YAML_FILE, INVALID_TOSCA_TEMPLATE, NOT_RESOURCE_TOSCA_TEMPLATE, NOT_SINGLE_RESOURCE, INVALID_RESOURCE_NAMESPACE, RESOURCE_ALREADY_EXISTS, INVALID_RESOURCE_CHECKSUM, RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, NO_ASSETS_FOUND, GENERIC_TYPE_NOT_FOUND, TOSCA_PARSE_ERROR,
+ RESOURCE_NOT_FOUND, MISSING_DERIVED_FROM_TEMPLATE, PARENT_RESOURCE_NOT_FOUND, PARENT_RESOURCE_DOES_NOT_EXTEND, INVALID_DEFAULT_VALUE, INVALID_COMPLEX_DEFAULT_VALUE, MULTIPLE_PARENT_RESOURCE_FOUND, INVALID_RESOURCE_PAYLOAD, INVALID_TOSCA_FILE_EXTENSION, INVALID_YAML_FILE, INVALID_TOSCA_TEMPLATE, NOT_RESOURCE_TOSCA_TEMPLATE, NOT_SINGLE_RESOURCE, INVALID_RESOURCE_NAMESPACE, RESOURCE_ALREADY_EXISTS, INVALID_RESOURCE_CHECKSUM, RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, NO_ASSETS_FOUND, GENERIC_TYPE_NOT_FOUND,INVALID_RESOURCE_TYPE, TOSCA_PARSE_ERROR,
+ // Service related
+ SERVICE_TYPE_EXCEEDS_LIMIT, INVALID_SERVICE_TYPE, SERVICE_ROLE_EXCEEDS_LIMIT, INVALID_SERVICE_ROLE,
// Component name related
COMPONENT_NAME_ALREADY_EXIST, COMPONENT_NAME_EXCEEDS_LIMIT, MISSING_COMPONENT_NAME, INVALID_COMPONENT_NAME,
// Component description related
@@ -39,7 +41,7 @@ public enum ActionStatus {
// contactId related
COMPONENT_MISSING_CONTACT, COMPONENT_INVALID_CONTACT,
// Vendor related
- VENDOR_NAME_EXCEEDS_LIMIT, VENDOR_RELEASE_EXCEEDS_LIMIT, INVALID_VENDOR_NAME, INVALID_VENDOR_RELEASE, MISSING_VENDOR_NAME, MISSING_VENDOR_RELEASE,
+ VENDOR_NAME_EXCEEDS_LIMIT, VENDOR_RELEASE_EXCEEDS_LIMIT, INVALID_VENDOR_NAME, INVALID_VENDOR_RELEASE, MISSING_VENDOR_NAME, MISSING_VENDOR_RELEASE, RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, INVALID_RESOURCE_VENDOR_MODEL_NUMBER,
// Category related
COMPONENT_MISSING_CATEGORY, COMPONENT_INVALID_CATEGORY, COMPONENT_ELEMENT_INVALID_NAME_FORMAT, COMPONENT_ELEMENT_INVALID_NAME_LENGTH, COMPONENT_CATEGORY_ALREADY_EXISTS, COMPONENT_CATEGORY_NOT_FOUND, COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY, COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY, COMPONENT_GROUPING_EXISTS_FOR_SUB_CATEGORY,
// Service API URL
@@ -71,7 +73,7 @@ public enum ActionStatus {
GROUP_MEMBER_EMPTY, GROUP_TYPE_ALREADY_EXIST,
// CSAR
- MISSING_CSAR_UUID, CSAR_INVALID, CSAR_INVALID_FORMAT, CSAR_NOT_FOUND, YAML_NOT_FOUND_IN_CSAR, VSP_ALREADY_EXISTS, RESOURCE_LINKED_TO_DIFFERENT_VSP, RESOURCE_FROM_CSAR_NOT_FOUND, AAI_ARTIFACT_GENERATION_FAILED, ASSET_NOT_FOUND_DURING_CSAR_CREATION, ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION, TOSCA_SCHEMA_FILES_NOT_FOUND,
+ MISSING_CSAR_UUID, CSAR_INVALID, CSAR_INVALID_FORMAT, CSAR_NOT_FOUND, YAML_NOT_FOUND_IN_CSAR, VSP_ALREADY_EXISTS, RESOURCE_LINKED_TO_DIFFERENT_VSP, RESOURCE_FROM_CSAR_NOT_FOUND, AAI_ARTIFACT_GENERATION_FAILED, ASSET_NOT_FOUND_DURING_CSAR_CREATION, ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION, TOSCA_SCHEMA_FILES_NOT_FOUND, ARTIFACT_NAME_INVALID,
// Group
GROUP_HAS_CYCLIC_DEPENDENCY, GROUP_ALREADY_EXIST, GROUP_TYPE_IS_INVALID, GROUP_MISSING_GROUP_TYPE, GROUP_INVALID_COMPONENT_INSTANCE, GROUP_INVALID_TOSCA_NAME_OF_COMPONENT_INSTANCE, GROUP_IS_MISSING, GROUP_ARTIFACT_ALREADY_ASSOCIATED, GROUP_ARTIFACT_ALREADY_DISSOCIATED, GROUP_PROPERTY_NOT_FOUND, INVALID_VF_MODULE_NAME, INVALID_VF_MODULE_NAME_MODIFICATION, INVALID_VF_MODULE_TYPE,
@@ -86,6 +88,7 @@ public enum ActionStatus {
// Inputs
INPUT_IS_NOT_CHILD_OF_COMPONENT,
+ CFVC_LOOP_DETECTED,
;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksAccessor.java
new file mode 100644
index 0000000000..e548a594d9
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksAccessor.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdc.be.dao.cassandra;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Param;
+import com.datastax.driver.mapping.annotations.Query;
+
+@Accessor
+public interface MigrationTasksAccessor {
+
+ @Query("SELECT minor_version FROM sdcrepository.migrationTasks WHERE major_version = :majorVersion order by minor_version desc limit 1")
+ ResultSet getLatestMinorVersion(@Param("majorVersion") Long majorVersion);
+
+ @Query("DELETE FROM sdcrepository.migrationTasks WHERE major_version = :majorVersion")
+ void deleteTasksForMajorVersion(@Param("majorVersion") Long majorVersion);
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksDao.java
new file mode 100644
index 0000000000..89ad9662fa
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/MigrationTasksDao.java
@@ -0,0 +1,73 @@
+package org.openecomp.sdc.be.dao.cassandra;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.MappingManager;
+import fj.data.Either;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.resources.data.MigrationTaskEntry;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.math.BigInteger;
+
+@Component("sdc-migration-tasks-cassandra-dao")
+public class MigrationTasksDao extends CassandraDao {
+
+ private static Logger logger = LoggerFactory.getLogger(MigrationTasksDao.class.getName());
+ private MigrationTasksAccessor migrationTasksAccessor;
+ private Mapper<MigrationTaskEntry> migrationTaskMapper;
+
+ @PostConstruct
+ public void init() {
+ String keyspace = AuditingTypesConstants.REPO_KEYSPACE;
+ if (client.isConnected()) {
+ Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
+ if (result.isLeft()) {
+ session = result.left().value().left;
+ manager = result.left().value().right;
+ migrationTasksAccessor = manager.createAccessor(MigrationTasksAccessor.class);
+ migrationTaskMapper = manager.mapper(MigrationTaskEntry.class);
+ logger.info("** migrationTasksAccessor created");
+ } else {
+ logger.info("** migrationTasksAccessor failed");
+ throw new RuntimeException("Artifact keyspace [" + keyspace + "] failed to connect with error : "
+ + result.right().value());
+ }
+ } else {
+ logger.info("** Cassandra client isn't connected");
+ logger.info("** migrationTasksAccessor created, but not connected");
+ }
+ }
+
+ public BigInteger getLatestMinorVersion(BigInteger majorVersion) {
+ try {
+ ResultSet latestMinorVersion = migrationTasksAccessor.getLatestMinorVersion(majorVersion.longValue());
+ Row minorVersionRow = latestMinorVersion.one();
+ return minorVersionRow == null ? BigInteger.valueOf(Long.MIN_VALUE) : BigInteger.valueOf(minorVersionRow.getLong(0));
+ } catch (RuntimeException e) {
+ logger.error("failed to get latest minor version for major version {}", majorVersion, e);
+ throw e;
+ }
+ }
+
+ public void deleteAllTasksForVersion(BigInteger majorVersion) {
+ try {
+ migrationTasksAccessor.deleteTasksForMajorVersion(majorVersion.longValue());
+ } catch (RuntimeException e) {
+ logger.error("failed to delete tasks for major version {}", majorVersion, e);
+ throw e;
+ }
+ }
+
+ public void createMigrationTask(MigrationTaskEntry migrationTask) {
+ migrationTaskMapper.save(migrationTask);
+ }
+
+
+}
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 8fb594f2ff..f6fd29bd1f 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
@@ -20,24 +20,7 @@
package org.openecomp.sdc.be.dao.cassandra.schema;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.ArtifactTableDescription;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.AuthEventTableDescription;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.CategoryEventTableDescription;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.ComponentCacheTableDescription;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.ConsumerEventTableDefinition;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribDeployEventTableDesc;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribDownloadEventTableDesc;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribEngineEventTableDesc;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribNotifEventTableDesc;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribStatusEventTableDesc;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.ExternalApiEventTableDesc;
-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;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.*;
public enum Table {
@@ -58,8 +41,8 @@ public enum Table {
GET_CATEGORY_HIERARCHY_EVENT(new GetCatHierEventTableDesc()),
EXTERNAL_API_EVENT(new ExternalApiEventTableDesc()),
COMPONENT_CACHE(new ComponentCacheTableDescription()),
- SDC_SCHEMA_FILES(new SdcSchemaFilesTableDescription());
-
+ SDC_SCHEMA_FILES(new SdcSchemaFilesTableDescription()),
+ SDC_REPO(new MigrationTasksTableDescription());
ITableDescription tableDescription;
Table(ITableDescription tableDescription) {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java
new file mode 100644
index 0000000000..f7506f77e1
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java
@@ -0,0 +1,81 @@
+package org.openecomp.sdc.be.dao.cassandra.schema.tables;
+
+import com.datastax.driver.core.DataType;
+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 java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MAJOR_VERSION;
+import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MINOR_VERSION;
+
+public class MigrationTasksTableDescription implements ITableDescription {
+
+ private static final String MIGRATION_TASKS_TABLE = "migrationTasks";
+
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ return Collections.singletonList(ImmutablePair.of(MAJOR_VERSION.getFieldName(), MAJOR_VERSION.getFieldType()));
+ }
+
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ return Collections.singletonList(ImmutablePair.of(MINOR_VERSION.getFieldName(), MINOR_VERSION.getFieldType()));
+ }
+
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ Arrays.stream(SdcRepoFieldsDescription.values())
+ .filter(column -> !column.equals(MAJOR_VERSION) && !column.equals(MINOR_VERSION))
+ .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
+ return columns;
+ }
+
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.REPO_KEYSPACE;
+ }
+
+ @Override
+ public String getTableName() {
+ return MIGRATION_TASKS_TABLE;
+ }
+
+ enum SdcRepoFieldsDescription {
+ MAJOR_VERSION("major_version", DataType.bigint(), true),
+ MINOR_VERSION("minor_version", DataType.bigint(), false),
+ TIMESTAMP("timestamp", DataType.timestamp(), false),
+ NAME("task_name", DataType.varchar(), false),
+ STATUS("task_status", DataType.varchar(), false),
+ MESSAGE("msg", DataType.varchar(), false),
+ EXECUTION_TIME("execution_time", DataType.cdouble(), false);
+
+ private String fieldName;
+ private boolean isIndexed;
+ private DataType fieldType;
+
+ SdcRepoFieldsDescription(String fieldName, DataType dataType, boolean indexed ) {
+ this.fieldName = fieldName;
+ this.fieldType = dataType;
+ this.isIndexed = indexed;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public boolean isIndexed() {
+ return isIndexed;
+ }
+
+ public DataType getFieldType() {
+ return fieldType;
+ }
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
index 2d9c029ea9..387b413dd5 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
@@ -456,7 +456,11 @@ public class TitanDao {
}
if (hasNotProps != null && !hasNotProps.isEmpty()) {
for (Map.Entry<GraphPropertyEnum, Object> entry : hasNotProps.entrySet()) {
- query = query.hasNot(entry.getKey().getProperty(), entry.getValue());
+ if(entry.getValue() instanceof List){
+ buildMultipleNegateQueryFromList(entry, query);
+ }else{
+ query = query.hasNot(entry.getKey().getProperty(), entry.getValue());
+ }
}
}
Iterable<TitanVertex> vertices = query.vertices();
@@ -499,6 +503,15 @@ public class TitanDao {
}
+
+ private void buildMultipleNegateQueryFromList(Map.Entry<GraphPropertyEnum, Object> entry, TitanGraphQuery query){
+ List<Object> negateList = (List<Object>) entry.getValue();
+ for (Object listItem : negateList) {
+ query.hasNot(entry.getKey().getProperty(), listItem);
+ }
+ }
+
+
/**
*
* @param parentVertex
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
index 001544c4a4..3018915066 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
@@ -67,4 +67,8 @@ public enum EdgeLabelEnum {
}
return null;
}
+
+ public boolean isInstanceArtifactsLabel() {
+ return this.equals(INSTANCE_ARTIFACTS) || this.equals(INST_DEPLOYMENT_ARTIFACTS);
+ }
}