summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-11-18 18:13:58 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-01-15 13:59:55 +0000
commitbd5a1006210092f9ac5c48352cc94f6264e961ef (patch)
treea91d4fc711dacb4e9833a1f7ff5134ff8407c931 /catalog-model/src/main/java/org
parent3849231a17930b1bb2ba09af15673bfd07538b9d (diff)
Initial support for relationship_templates
Change-Id: Ia246b9f11a77815c0585abfa0b3de5433728001a Issue-ID: SDC-3435 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model/src/main/java/org')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityRequirementRelationship.java26
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java77
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java45
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/OperationUi.java43
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/PropertyAssignmentUi.java31
5 files changed, 194 insertions, 28 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityRequirementRelationship.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityRequirementRelationship.java
index d25bd2fcf8..9eb0357a5c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityRequirementRelationship.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityRequirementRelationship.java
@@ -20,33 +20,23 @@
package org.openecomp.sdc.be.model;
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
+import org.openecomp.sdc.be.ui.model.OperationUi;
+
/**
* Contains the Capability, Requirement and Relationship info
*/
+@Getter
+@Setter
public class CapabilityRequirementRelationship {
private RelationshipInfo relation;
private CapabilityDataDefinition capability;
private RequirementDataDefinition requirement;
+ private List<OperationUi> operations;
- public RelationshipInfo getRelation() {
- return relation;
- }
- public void setRelation(RelationshipInfo relation) {
- this.relation = relation;
- }
- public CapabilityDataDefinition getCapability() {
- return capability;
- }
- public void setCapability(CapabilityDataDefinition capability) {
- this.capability = capability;
- }
- public RequirementDataDefinition getRequirement() {
- return requirement;
- }
- public void setRequirement(RequirementDataDefinition requirement) {
- this.requirement = requirement;
- }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
index 5fb07a01b3..7d53abfe21 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
@@ -61,6 +61,7 @@ import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
@@ -71,6 +72,8 @@ import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
@@ -90,6 +93,7 @@ import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
+import org.openecomp.sdc.be.ui.model.OperationUi;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
@@ -1366,12 +1370,13 @@ public class NodeTemplateOperation extends BaseOperation {
return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(JanusGraphOperationStatus.ILLEGAL_ARGUMENT));
}
- for (CapabilityRequirementRelationship immutablePair : relationships) {
- String requirement = immutablePair.getRelation().getRequirement();
+ for (final CapabilityRequirementRelationship relationship : relationships) {
+ final String requirement = relationship.getRelation().getRequirement();
- Either<Map<JsonPresentationFields, T>, StorageOperationStatus> associateRes = connectInstancesInContainer(fromNode, toNode, immutablePair.getRelation(), relation.isOriginUI(), calculatedCapabilty, calculatedRequirement,
+ Either<Map<JsonPresentationFields, T>, StorageOperationStatus> associateRes = connectInstancesInContainer(fromNode, toNode, relationship.getRelation(), relation.isOriginUI(), calculatedCapabilty, calculatedRequirement,
fullFilledCapabilty, fullfilledRequirement, compositionDataDefinition, containerV.getUniqueId());
+
if (associateRes.isRight()) {
status = associateRes.right().value();
BeEcompErrorManager.getInstance().logBeFailedAddingResourceInstanceError("AssociateResourceInstances - missing relationship", fromNode, componentId);
@@ -1381,21 +1386,25 @@ public class NodeTemplateOperation extends BaseOperation {
return Either.right(status);
}
- RelationshipInstDataDefinition relationshipInstData = (RelationshipInstDataDefinition) associateRes.left().value().get(JsonPresentationFields.RELATIONSHIP);
+ final Map<JsonPresentationFields, T> relationshipFieldsMap = associateRes.left().value();
+ final RelationshipInstDataDefinition relationshipInstData =
+ (RelationshipInstDataDefinition) relationshipFieldsMap.get(JsonPresentationFields.RELATIONSHIP);
+ createRelationshipInterfaces(relationship.getOperations()).ifPresent(relationshipInstData::setInterfaces);
RelationshipImpl relationshipImplResult = new RelationshipImpl();
relationshipImplResult.setType(relationshipInstData.getType());
RelationshipInfo requirementAndRelationshipPair = new RelationshipInfo(requirement, relationshipImplResult);
- requirementAndRelationshipPair.setCapability(immutablePair.getRelation().getCapability());
- requirementAndRelationshipPair.setRequirement(immutablePair.getRelation().getRequirement());
+ requirementAndRelationshipPair.setCapability(relationship.getRelation().getCapability());
+ requirementAndRelationshipPair.setRequirement(relationship.getRelation().getRequirement());
requirementAndRelationshipPair.setCapabilityOwnerId(relationshipInstData.getCapabilityOwnerId());
requirementAndRelationshipPair.setRequirementOwnerId(relationshipInstData.getRequirementOwnerId());
- requirementAndRelationshipPair.setCapabilityUid(immutablePair.getRelation().getCapabilityUid());
- requirementAndRelationshipPair.setRequirementUid(immutablePair.getRelation().getRequirementUid());
+ requirementAndRelationshipPair.setCapabilityUid(relationship.getRelation().getCapabilityUid());
+ requirementAndRelationshipPair.setRequirementUid(relationship.getRelation().getRequirementUid());
requirementAndRelationshipPair.setId(relationshipInstData.getUniqueId());
CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
capReqRel.setRelation(requirementAndRelationshipPair);
- capReqRel.setCapability((CapabilityDataDefinition) associateRes.left().value().get(JsonPresentationFields.CAPABILITY));
- capReqRel.setRequirement((RequirementDataDefinition) associateRes.left().value().get(JsonPresentationFields.REQUIREMENT));
+ capReqRel.setCapability((CapabilityDataDefinition) relationshipFieldsMap.get(JsonPresentationFields.CAPABILITY));
+ capReqRel.setRequirement((RequirementDataDefinition) relationshipFieldsMap.get(JsonPresentationFields.REQUIREMENT));
+ capReqRel.setOperations(relationship.getOperations());
relationshipsResult.add(capReqRel);
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "update customization UUID for from CI {} and to CI {}", relation.getFromNode(), relation.getToNode());
status = updateCustomizationUUID(relation.getFromNode(), compositionDataDefinition);
@@ -1420,6 +1429,54 @@ public class NodeTemplateOperation extends BaseOperation {
return Either.left(relationsList);
}
+ private Optional<ListDataDefinition<InterfaceDataDefinition>> createRelationshipInterfaces(
+ final List<OperationUi> operationList) {
+
+ if (CollectionUtils.isEmpty(operationList)) {
+ return Optional.empty();
+ }
+ final ListDataDefinition<InterfaceDataDefinition> interfaceList = new ListDataDefinition<>();
+ final Map<String, List<OperationUi>> operationByInterfaceType = operationList.stream()
+ .collect(Collectors.groupingBy(OperationUi::getInterfaceType));
+ for (final Entry<String, List<OperationUi>> interfaceEntry : operationByInterfaceType.entrySet()) {
+ interfaceList.add(createInterface(interfaceEntry.getKey(), interfaceEntry.getValue()));
+ }
+ return Optional.of(interfaceList);
+ }
+
+ private InterfaceDataDefinition createInterface(final String interfaceType, final List<OperationUi> operationList) {
+ final InterfaceDataDefinition interfaceDataDefinition = new InterfaceDataDefinition();
+ interfaceDataDefinition.setType(interfaceType);
+ if (CollectionUtils.isNotEmpty(operationList)) {
+ final Map<String, OperationDataDefinition> operationMap =
+ operationList.stream().collect(Collectors.toMap(OperationUi::getOperationType, this::createOperation));
+ interfaceDataDefinition.setOperations(operationMap);
+ }
+ return interfaceDataDefinition;
+ }
+
+ private OperationDataDefinition createOperation(final OperationUi operation) {
+ final OperationDataDefinition operationDataDefinition = new OperationDataDefinition();
+ operationDataDefinition.setName(operation.getOperationType());
+ operationDataDefinition.setUniqueId(UUID.randomUUID().toString());
+ final ArtifactDataDefinition implementation = new ArtifactDataDefinition();
+ implementation.setArtifactName(operation.getImplementation());
+ operationDataDefinition.setImplementation(implementation);
+ if (CollectionUtils.isNotEmpty(operation.getInputs())) {
+ final ListDataDefinition<OperationInputDefinition> inputs = new ListDataDefinition<>();
+ operation.getInputs().forEach(input -> {
+ final OperationInputDefinition operationInputDefinition = new OperationInputDefinition();
+ operationInputDefinition.setLabel(input.getName());
+ operationInputDefinition.setType(input.getType());
+ operationInputDefinition.setValue(input.getValue());
+ inputs.add(operationInputDefinition);
+ });
+ operationDataDefinition.setInputs(inputs);
+ }
+
+ return operationDataDefinition;
+ }
+
private StorageOperationStatus updateAllAndCalculatedCapReqOnGraph(String componentId, GraphVertex containerV, Either<Pair<GraphVertex, Map<String, MapListCapabilityDataDefinition>>, StorageOperationStatus> capResult,
Either<Pair<GraphVertex, Map<String, MapListCapabilityDataDefinition>>, StorageOperationStatus> capFullResult, Either<Pair<GraphVertex, Map<String, MapListRequirementDataDefinition>>, StorageOperationStatus> reqResult,
Either<Pair<GraphVertex, Map<String, MapListRequirementDataDefinition>>, StorageOperationStatus> reqFullResult) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
index bbda9776f7..8cdced1685 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
@@ -24,6 +24,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -61,6 +62,7 @@ import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
@@ -70,6 +72,8 @@ import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ProductMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
@@ -119,6 +123,8 @@ import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
import org.openecomp.sdc.be.resources.data.ProductMetadataData;
import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
import org.openecomp.sdc.be.resources.data.ServiceMetadataData;
+import org.openecomp.sdc.be.ui.model.OperationUi;
+import org.openecomp.sdc.be.ui.model.PropertyAssignmentUi;
import org.openecomp.sdc.common.log.wrappers.Logger;
public class ModelConverter {
@@ -444,11 +450,50 @@ public class ModelConverter {
CapabilityRequirementRelationship rel = new CapabilityRequirementRelationship();
RelationshipInfo relationshipPair = getRelationshipInfo(relation);
rel.setRelation(relationshipPair);
+ rel.setOperations(convertToOperations(relation.getInterfaces()));
requirementCapabilityRelDef.setRelationships(Arrays.asList(rel));
return requirementCapabilityRelDef;
}
+ private static List<OperationUi> convertToOperations(final ListDataDefinition<InterfaceDataDefinition> interfaces) {
+ if (interfaces == null || interfaces.isEmpty()) {
+ return Collections.emptyList();
+ }
+ final List<OperationUi> operationUiList = new ArrayList<>();
+ for (final InterfaceDataDefinition interfaceDataDefinition : interfaces.getListToscaDataDefinition()) {
+ if (MapUtils.isEmpty(interfaceDataDefinition.getOperations())) {
+ continue;
+ }
+ for (final Entry<String, OperationDataDefinition> operationEntry :
+ interfaceDataDefinition.getOperations().entrySet()) {
+ final OperationUi operationUi = new OperationUi();
+ operationUi.setOperationType(operationEntry.getKey());
+ operationUi.setInterfaceType(interfaceDataDefinition.getType());
+ final OperationDataDefinition operationDataDefinition = operationEntry.getValue();
+ final ArtifactDataDefinition implementation = operationDataDefinition.getImplementation();
+ if (implementation != null) {
+ operationUi.setImplementation(implementation.getArtifactName());
+ }
+
+ final ListDataDefinition<OperationInputDefinition> inputs = operationDataDefinition.getInputs();
+ if (inputs != null && !inputs.isEmpty()) {
+ final List<OperationInputDefinition> operationInputDefinitionList =
+ inputs.getListToscaDataDefinition();
+ operationInputDefinitionList.forEach(operationInputDefinition -> {
+ final PropertyAssignmentUi propertyAssignmentUi = new PropertyAssignmentUi();
+ propertyAssignmentUi.setName(operationInputDefinition.getLabel());
+ propertyAssignmentUi.setType(operationInputDefinition.getType());
+ propertyAssignmentUi.setValue(operationInputDefinition.getValue());
+ operationUi.addToInputs(propertyAssignmentUi);
+ });
+ }
+ operationUiList.add(operationUi);
+ }
+ }
+ return operationUiList;
+ }
+
/**
* @param relation
* @return
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/OperationUi.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/OperationUi.java
new file mode 100644
index 0000000000..e5c2074c0c
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/OperationUi.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.ui.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class OperationUi {
+
+ private String interfaceType;
+ private String operationType;
+ private String implementation;
+ private List<PropertyAssignmentUi> inputs;
+
+ public void addToInputs(final PropertyAssignmentUi input) {
+ if (inputs == null) {
+ inputs = new ArrayList<>();
+ }
+ inputs.add(input);
+ }
+
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/PropertyAssignmentUi.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/PropertyAssignmentUi.java
new file mode 100644
index 0000000000..de6265b3e8
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/PropertyAssignmentUi.java
@@ -0,0 +1,31 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.ui.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class PropertyAssignmentUi {
+ private String name;
+ private String value;
+ private String type;
+}