diff options
author | priyanshu <pagarwal@amdocs.com> | 2018-09-05 18:05:36 +0530 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-09-13 13:00:27 +0000 |
commit | b65c8eeb334a2c579a2dc0241f480d81e9309f9c (patch) | |
tree | b3b3ed06b53703f771da51bec4b40e71b9e1bd1d /catalog-model/src/main | |
parent | f1e032cf4ae3505eb8acbce56ac978649d6f63d4 (diff) |
Interface operation support for service - BE
1. Interface operation support for service
2. Refactored common code of operationspa
3. ONAP Bug fixes VF operations
Change-Id: If1c4fd5f17626dbe568ee66ad997eb8ffb772e29
Issue-ID: SDC-1739
Signed-off-by: priyanshu <pagarwal@amdocs.com>
Diffstat (limited to 'catalog-model/src/main')
7 files changed, 92 insertions, 55 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/config/CatalogModelSpringConfig.java b/catalog-model/src/main/java/org/openecomp/sdc/be/config/CatalogModelSpringConfig.java index 9e0b104986..6ba7a35836 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/config/CatalogModelSpringConfig.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/config/CatalogModelSpringConfig.java @@ -10,6 +10,7 @@ import org.springframework.context.annotation.Configuration; "org.openecomp.sdc.be.model.cache", "org.openecomp.sdc.be.model.jsontitan.utils", "org.openecomp.sdc.be.model.jsontitan.operations", + "org.openecomp.sdc.be.dao.cassandra" }) public class CatalogModelSpringConfig { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java index 579dcdb074..115f084dbc 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java @@ -66,6 +66,15 @@ public abstract class Component { private String derivedFromGenericVersion; private String toscaType; protected List<AdditionalInformationDefinition> additionalInformation; + private Map<String, InterfaceDefinition> interfaces; + + public Map<String, InterfaceDefinition> getInterfaces() { + return interfaces; + } + + public void setInterfaces(Map<String, InterfaceDefinition> interfaces) { + this.interfaces = interfaces; + } public Component(ComponentMetadataDefinition componentMetadataDefinition) { this.componentMetadataDefinition = componentMetadataDefinition; @@ -545,6 +554,7 @@ public abstract class Component { result = prime * result + ((policies == null) ? 0 : policies.hashCode()); result = prime * result + ((derivedFromGenericType == null) ? 0 : derivedFromGenericType.hashCode()); result = prime * result + ((derivedFromGenericVersion == null) ? 0 : derivedFromGenericVersion.hashCode()); + result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode()); return result; } @@ -673,6 +683,14 @@ public abstract class Component { else if (!derivedFromGenericVersion.equals(other.derivedFromGenericVersion)) { return false; } + if (interfaces == null) { + if (other.interfaces != null) { + return false; + } + } + else if (!interfaces.equals(other.interfaces)) { + return false; + } return true; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java index 766cae4432..f3996ed42b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java @@ -23,7 +23,6 @@ package org.openecomp.sdc.be.model; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.utils.MapUtil; import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; @@ -43,8 +42,6 @@ public class Resource extends Component { private List<PropertyDefinition> attributes; - private Map<String, InterfaceDefinition> interfaces; - private List<String> defaultCapabilities; public Resource() { @@ -104,14 +101,6 @@ public class Resource extends Component { this.attributes = attributes; } - public Map<String, InterfaceDefinition> getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map<String, InterfaceDefinition> interfaces) { - this.interfaces = interfaces; - } - public Boolean isAbstract() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) .isAbstract(); @@ -158,7 +147,6 @@ public class Resource extends Component { result = prime * result + ((attributes == null) ? 0 : attributes.hashCode()); result = prime * result + ((defaultCapabilities == null) ? 0 : defaultCapabilities.hashCode()); result = prime * result + ((derivedFrom == null) ? 0 : derivedFrom.hashCode()); - result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode()); result = prime * result + ((properties == null) ? 0 : properties.hashCode()); result = prime * result + ((derivedList == null) ? 0 : derivedList.hashCode()); return result; @@ -194,11 +182,6 @@ public class Resource extends Component { return false; } else if (!derivedList.equals(other.derivedList)) return false; - if (interfaces == null) { - if (other.interfaces != null) - return false; - } else if (!interfaces.equals(other.interfaces)) - return false; if (properties == null) { if (other.properties != null) return false; @@ -210,7 +193,6 @@ public class Resource extends Component { @Override public String toString() { return "Resource [derivedFrom=" + derivedFrom + ", properties=" + properties + ", attributes=" + attributes - + ", interfaces=" + interfaces + ", defaultCapabilities=" + defaultCapabilities + ", additionalInformation=" + additionalInformation + "Metadata [" + getComponentMetadataDefinition().getMetadataDataDefinition().toString() + "]"; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfaceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfaceOperation.java index 18bd13dce3..916a34c0f3 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfaceOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfaceOperation.java @@ -17,7 +17,7 @@ package org.openecomp.sdc.be.model.jsontitan.operations; import fj.data.Either; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -71,7 +71,8 @@ public class InterfaceOperation extends BaseOperation { if (!isUpdateAction) { interfaceDefinition.setUniqueId(UUID.randomUUID().toString()); } - statusRes = performUpdateToscaAction(isUpdateAction, componentVertex, Arrays.asList(interfaceDefinition), EdgeLabelEnum.INTERFACE, VertexTypeEnum.INTERFACE); + statusRes = performUpdateToscaAction(isUpdateAction, componentVertex, + Collections.singletonList(interfaceDefinition), EdgeLabelEnum.INTERFACE, VertexTypeEnum.INTERFACE); if (!statusRes.equals(StorageOperationStatus.OK)) { return Either.right(statusRes); } @@ -107,8 +108,8 @@ public class InterfaceOperation extends BaseOperation { } GraphVertex interfaceVertex = getToscaElementInt.left().value(); - statusRes = performUpdateToscaAction(isUpdateAction, interfaceVertex, Arrays.asList(operation), - EdgeLabelEnum.INTERFACE_OPERATION, VertexTypeEnum.INTERFACE_OPERATION); + statusRes = performUpdateToscaAction(isUpdateAction, interfaceVertex, + Collections.singletonList(operation), EdgeLabelEnum.INTERFACE_OPERATION, VertexTypeEnum.INTERFACE_OPERATION); if (!statusRes.equals(StorageOperationStatus.OK)) { return Either.right(statusRes); } @@ -126,7 +127,7 @@ public class InterfaceOperation extends BaseOperation { Either<GraphVertex, TitanOperationStatus> getInterfaceVertex; Either<GraphVertex, TitanOperationStatus> getComponentVertex; Operation operation = new Operation(); - StorageOperationStatus status = null; + StorageOperationStatus status; getComponentVertex = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse); if (getComponentVertex.isRight()) { @@ -144,14 +145,16 @@ public class InterfaceOperation extends BaseOperation { Map.Entry<String, Operation> stringOperationEntry = operationToRemove.get(); operation = stringOperationEntry.getValue(); ArtifactDefinition implementationArtifact = operation.getImplementationArtifact(); - String artifactUUID = implementationArtifact.getArtifactUUID(); - CassandraOperationStatus cassandraStatus = artifactCassandraDao.deleteArtifact(artifactUUID); - if (cassandraStatus != CassandraOperationStatus.OK) { - return Either.right(DaoStatusConverter.convertCassandraStatusToStorageStatus(cassandraStatus)); + if(implementationArtifact != null){ + String artifactUUID = implementationArtifact.getArtifactUUID(); + CassandraOperationStatus cassandraStatus = artifactCassandraDao.deleteArtifact(artifactUUID); + if (cassandraStatus != CassandraOperationStatus.OK) { + return Either.right(DaoStatusConverter.convertCassandraStatusToStorageStatus(cassandraStatus)); + } } if(interfaceDef.getOperationsMap().size() > 1){ - status = deleteToscaDataElements(getInterfaceVertex.left().value(), EdgeLabelEnum.INTERFACE_OPERATION, Arrays.asList(operationToDelete)); + status = deleteToscaDataElements(getInterfaceVertex.left().value(), EdgeLabelEnum.INTERFACE_OPERATION, Collections.singletonList(operationToDelete)); if (status != StorageOperationStatus.OK) { return Either.right(status); } @@ -164,7 +167,7 @@ public class InterfaceOperation extends BaseOperation { getUpdatedInterfaceDef(interfaceDef, null, operationToDelete); if (interfaceDef.getOperations().isEmpty()) { - status = deleteToscaDataElements(getComponentVertex.left().value(), EdgeLabelEnum.INTERFACE, Arrays.asList(interfaceDef.getUniqueId())); + status = deleteToscaDataElements(getComponentVertex.left().value(), EdgeLabelEnum.INTERFACE, Collections.singletonList(interfaceDef.getUniqueId())); if (status != StorageOperationStatus.OK) { return Either.right(status); } @@ -192,7 +195,7 @@ public class InterfaceOperation extends BaseOperation { } } - private InterfaceDefinition getUpdatedInterfaceDef(InterfaceDefinition interfaceDef, Operation operation, String operationId){ + private void getUpdatedInterfaceDef(InterfaceDefinition interfaceDef, Operation operation, String operationId){ Map<String, Operation> operationMap = interfaceDef.getOperationsMap(); if(operation != null){ operationMap.put(operationId, operation); @@ -202,7 +205,6 @@ public class InterfaceOperation extends BaseOperation { operationMap.remove(operationId); interfaceDef.setOperationsMap(operationMap); } - return interfaceDef; } } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java index 3b2cb97132..82dcfef1ee 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java @@ -143,6 +143,8 @@ public class ModelConverter { convertServicePaths(topologyTemplate, service); + convertServiceInterfaces(topologyTemplate, service); + return service; } @@ -207,6 +209,17 @@ public class ModelConverter { resource.setInterfaces(copy); } + private static void convertServiceInterfaces(TopologyTemplate toscaElement, Service service) { + Map<String, InterfaceDataDefinition> interfaces = toscaElement.getInterfaces(); + Map<String, InterfaceDefinition> copy; + if (interfaces != null) { + copy = interfaces.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new InterfaceDefinition(e.getValue()))); + } else { + copy = new HashMap<>(); + } + service.setInterfaces(copy); + } + private static void convertAttributes(NodeType nodeType, Resource resource) { Map<String, PropertyDataDefinition> attributes = nodeType.getAttributes(); if (attributes != null) { @@ -922,10 +935,21 @@ public class ModelConverter { topologyTemplate.setInterfaces(copy); } } + + private static void convertServiceInterfaces(Service service, TopologyTemplate topologyTemplate) { + Map<String, InterfaceDefinition> interfaces = service.getInterfaces(); + if (interfaces != null && !interfaces.isEmpty()) { + Map<String, InterfaceDataDefinition> copy = interfaces.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, e -> new InterfaceDataDefinition(e.getValue()))); + topologyTemplate.setInterfaces(copy); + } + } + private static void convertServiceSpecificEntities(Service service, TopologyTemplate topologyTemplate) { convertServiceMetaData(service, topologyTemplate); convertServiceApiArtifacts(service, topologyTemplate); convertServicePaths(service,topologyTemplate); + convertServiceInterfaces(service, topologyTemplate); } private static void convertServicePaths(Service service, TopologyTemplate topologyTemplate) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java index f324cf83ad..0090f86f0e 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java @@ -20,8 +20,20 @@ package org.openecomp.sdc.be.ui.model; +import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.be.model.AdditionalInformationDefinition; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.CapabilityDefinition; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceInput; +import org.openecomp.sdc.be.model.ComponentInstanceProperty; +import org.openecomp.sdc.be.model.GroupDefinition; +import org.openecomp.sdc.be.model.InputDefinition; +import org.openecomp.sdc.be.model.InterfaceDefinition; +import org.openecomp.sdc.be.model.PolicyDefinition; +import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; +import org.openecomp.sdc.be.model.RequirementDefinition; import org.openecomp.sdc.be.model.category.CategoryDefinition; import java.util.List; @@ -66,6 +78,25 @@ public class UiComponentDataTransfer { protected List<AdditionalInformationDefinition> additionalInformation; + private Map<String, InterfaceOperationDataDefinition> interfaceOperations; + private Map<String, InterfaceDefinition> interfaces; + + public Map<String, InterfaceOperationDataDefinition> getInterfaceOperations() { + return interfaceOperations; + } + + public void setInterfaceOperations(Map<String, InterfaceOperationDataDefinition> interfaceOperations) { + this.interfaceOperations = interfaceOperations; + } + + public Map<String, InterfaceDefinition> getInterfaces() { + return interfaces; + } + + public void setInterfaces(Map<String, InterfaceDefinition> interfaces) { + this.interfaces = interfaces; + } + public UiComponentDataTransfer() { } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java index 32e4b1002d..b3afd9617b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,13 +20,10 @@ package org.openecomp.sdc.be.ui.model; -import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationDataDefinition; import org.openecomp.sdc.be.model.AdditionalInformationDefinition; -import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import java.util.List; -import java.util.Map; public class UiResourceDataTransfer extends UiComponentDataTransfer{ @@ -40,11 +37,9 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer{ private List<PropertyDefinition> attributes; - private Map<String, InterfaceDefinition> interfaces; private List<String> defaultCapabilities; - private Map<String, InterfaceOperationDataDefinition> interfaceOperations; public UiResourceDataTransfer(){} @@ -96,14 +91,6 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer{ this.attributes = attributes; } - public Map<String, InterfaceDefinition> getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map<String, InterfaceDefinition> interfaces) { - this.interfaces = interfaces; - } - public List<String> getDefaultCapabilities() { return defaultCapabilities; } @@ -111,12 +98,4 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer{ public void setDefaultCapabilities(List<String> defaultCapabilities) { this.defaultCapabilities = defaultCapabilities; } - public Map<String, InterfaceOperationDataDefinition> getInterfaceOperations() { - return interfaceOperations; - } - - public void setInterfaceOperations(Map<String, InterfaceOperationDataDefinition> interfaceOperations) { - this.interfaceOperations = interfaceOperations; - } - } |