aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorIdan Amit <ia096e@intl.att.com>2017-09-13 17:21:33 +0300
committerIdan Amit <ia096e@intl.att.com>2017-09-13 17:21:33 +0300
commit6cc9a11a09a9b650442bf301eb8fd1aa6cad66bc (patch)
treed7a891f71608fd32b1a5a61054530ce0244fe149 /catalog-model
parent45e38d57442499a535f2915aab95a057e106d79f (diff)
ComponentBaseTest.java enhancement and
new onboarding class that test onboarding only And merge release/1710 branch into master Change-Id: I300d897b151010aa26f8732518fa2e3b7ed4291b Issue-Id: SDC-331 Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/pom.xml4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java50
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java8
3 files changed, 56 insertions, 6 deletions
diff --git a/catalog-model/pom.xml b/catalog-model/pom.xml
index 444686d3a2..3752d79a20 100644
--- a/catalog-model/pom.xml
+++ b/catalog-model/pom.xml
@@ -119,8 +119,8 @@
</dependency>
<dependency>
- <groupId>com.thinkaurelius.titan</groupId>
- <artifactId>titan-cassandra</artifactId>
+ <groupId>org.openecomp.sdc.sdc-titan-cassandra</groupId>
+ <artifactId>sdc-titan-cassandra</artifactId>
<version>${titan.version}</version>
<scope>provided</scope>
<exclusions>
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java
index d52aa038a3..27b9ba2d4d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java
@@ -54,6 +54,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
@@ -584,11 +585,11 @@ public class NodeTypeOperation extends ToscaElementOperation {
return Either.right(StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND);
} else {
if (resources.size() > 1) {
- log.error("Multiple parent resources called {} found in the graph.", parentResource);
- return Either.right(StorageOperationStatus.MULTIPLE_PARENT_RESOURCE_FOUND);
+ return handleMultipleParent(parentResource, derivedResources, resources);
+ } else {
+ GraphVertex parentResourceData = resources.get(0);
+ derivedResources.add(parentResourceData);
}
- GraphVertex parentResourceData = resources.get(0);
- derivedResources.add(parentResourceData);
}
}
@@ -597,6 +598,47 @@ public class NodeTypeOperation extends ToscaElementOperation {
}
return Either.left(derivedResources);
}
+
+ Either<List<GraphVertex>, StorageOperationStatus> handleMultipleParent(String parentResource, List<GraphVertex> derivedResource, List<GraphVertex> fetchedDerivedResources){
+
+ Either<List<GraphVertex>, StorageOperationStatus> result = Either.left(derivedResource);
+ try{
+ fetchedDerivedResources.sort((d1,d2)->{
+ return new Double(Double.parseDouble((String)d1.getMetadataProperty(GraphPropertyEnum.VERSION)))
+ .compareTo(Double.parseDouble((String)d2.getMetadataProperty(GraphPropertyEnum.VERSION)));
+ });
+
+ int actualHighestIndex = fetchedDerivedResources.size() - 1;
+ derivedResource.add(fetchedDerivedResources.get(actualHighestIndex));
+ fetchedDerivedResources.remove(actualHighestIndex);
+
+ StorageOperationStatus status = fixMultipleParent(fetchedDerivedResources);
+ if(status != StorageOperationStatus.OK){
+ result = Either.right(status);
+ }
+ } catch (Exception e){
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Exception occured during handle multiple parent {}. Exception is {}",
+ parentResource, e.getMessage());
+ result = Either.right(StorageOperationStatus.GENERAL_ERROR);
+ }
+ return result;
+ }
+
+ private StorageOperationStatus fixMultipleParent(List<GraphVertex> fetchedDerivedResources) {
+ StorageOperationStatus result = StorageOperationStatus.OK;
+ for(GraphVertex fetchedDerivedResource : fetchedDerivedResources){
+ fetchedDerivedResource.addMetadataProperty(GraphPropertyEnum.IS_HIGHEST_VERSION, false);
+ Either<GraphVertex, TitanOperationStatus> updateVertexRes = titanDao.updateVertex(fetchedDerivedResource);
+ if (updateVertexRes.isRight()) {
+ TitanOperationStatus titatStatus = updateVertexRes.right().value();
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to set highest version of node type {} to false. Status is {}",
+ fetchedDerivedResource.getMetadataProperty(GraphPropertyEnum.TOSCA_RESOURCE_NAME), titatStatus);
+ result = DaoStatusConverter.convertTitanStatusToStorageStatus(titatStatus);
+ break;
+ }
+ }
+ return result;
+ }
private GraphVertex fillMetadata(GraphVertex nodeTypeVertex, NodeType nodeType) {
nodeTypeVertex.setLabel(VertexTypeEnum.NODE_TYPE);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
index 3cc80eaf36..b11036df49 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
@@ -2207,5 +2207,13 @@ public class ToscaOperationFacade {
public StorageOperationStatus deleteComponentInstanceInputsFromTopologyTemplate(Component containerComponent, ComponentTypeEnum componentType, List<InputDefinition> inputsToDelete) {
return topologyTemplateOperation.deleteToscaDataElements(containerComponent.getUniqueId(), EdgeLabelEnum.INPUTS, inputsToDelete.stream().map(i -> i.getName()).collect(Collectors.toList()));
}
+
+ public StorageOperationStatus deleteAllCalculatedCapabilitiesRequirements(String topologyTemplateId) {
+ StorageOperationStatus status = topologyTemplateOperation.removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAPABILITIES, VertexTypeEnum.CALCULATED_CAPABILITIES);
+ if(status == StorageOperationStatus.OK){
+ status = topologyTemplateOperation.removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_REQUIREMENTS, VertexTypeEnum.CALCULATED_REQUIREMENTS);
+ }
+ return status;
+ }
}