summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2021-10-01 11:30:49 +0100
committerAndr� Schmid <andre.schmid@est.tech>2021-11-05 17:14:06 +0000
commit1de1692115d1df5b4e07c1feb21d098899a6604b (patch)
tree1e26079e5cc5dc708eb666611f98dd0fc0af571d /catalog-be/src
parent2b55a906b7115ff2b156b35a4ff66811157111ee (diff)
Add UI support for adding tosca artifact types
UI support for adding artifacts to an interface operation implementation Issue-ID: SDC-3768 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: I71b3e49a160521e35a45515ad7adef836f901e78
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java29
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaArtifactDefinition.java41
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceOperationImplementation.java36
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinition.java45
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaOperationAssignment.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/builder/ToscaRelationshipBuilderTest.java7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java8
8 files changed, 116 insertions, 54 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java
index e73ade119e..9eaf1eec3d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java
@@ -175,7 +175,7 @@ public class ComponentInterfaceOperationBusinessLogic extends BaseBusinessLogic
}
private void updateOperationDefinitionImplementation(final OperationDataDefinition updatedOperationDataDefinition) {
- final ArtifactDataDefinition artifactInfo = new ArtifactDataDefinition();
+ final ArtifactDataDefinition artifactInfo = new ArtifactDataDefinition(updatedOperationDataDefinition.getImplementation());
artifactInfo.setArtifactName(String.format("'%s'", updatedOperationDataDefinition.getImplementation().getArtifactName()));
updatedOperationDataDefinition.setImplementation(artifactInfo);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
index 438ad5bc26..52e7562bbe 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
@@ -32,10 +32,13 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections.MapUtils;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition;
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.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.DataTypeDefinition;
@@ -43,9 +46,11 @@ import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Product;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.tosca.PropertyConvertor.PropertyType;
+import org.openecomp.sdc.be.tosca.model.ToscaArtifactDefinition;
import org.openecomp.sdc.be.tosca.model.ToscaInput;
import org.openecomp.sdc.be.tosca.model.ToscaInterfaceDefinition;
import org.openecomp.sdc.be.tosca.model.ToscaInterfaceNodeType;
+import org.openecomp.sdc.be.tosca.model.ToscaInterfaceOperationImplementation;
import org.openecomp.sdc.be.tosca.model.ToscaLifecycleOperationDefinition;
import org.openecomp.sdc.be.tosca.model.ToscaNodeType;
import org.openecomp.sdc.be.tosca.model.ToscaProperty;
@@ -285,12 +290,32 @@ public class InterfacesOperationsConverter {
final Entry<String, OperationDataDefinition> operationEntry,
final ToscaLifecycleOperationDefinition toscaOperation) {
final String operationArtifactPath;
+ final ToscaInterfaceOperationImplementation toscaInterfaceOperationImplementation = new ToscaInterfaceOperationImplementation();
+ toscaInterfaceOperationImplementation.setPrimary(new ToscaArtifactDefinition());
+ final ToscaArtifactDefinition toscaArtifactDefinition = toscaInterfaceOperationImplementation.getPrimary();
if (isArtifactPresent(operationEntry) && StringUtils.isNotEmpty(operationEntry.getValue().getImplementation().getArtifactName())) {
operationArtifactPath = OperationArtifactUtil
.createOperationArtifactPath(component, componentInstance, operationEntry.getValue(), isAssociatedComponent);
- toscaOperation.setImplementation(operationArtifactPath);
+ toscaArtifactDefinition.setFile(operationArtifactPath);
+ toscaArtifactDefinition.setArtifact_version(!operationEntry.getValue().getImplementation().getArtifactVersion()
+ .equals(NumberUtils.INTEGER_ZERO.toString()) ? operationEntry.getValue().getImplementation().getArtifactVersion() : null);
+ toscaArtifactDefinition.setType(operationEntry.getValue().getImplementation().getArtifactType());
+ handleInterfaceOperationImplementationProperties(operationEntry, toscaArtifactDefinition);
+ toscaOperation.setImplementation(
+ toscaArtifactDefinition.getType() != null ? toscaInterfaceOperationImplementation : operationArtifactPath);
} else {
- toscaOperation.setImplementation(operationEntry.getValue().getImplementation().getArtifactName());
+ toscaArtifactDefinition.setFile(operationEntry.getValue().getImplementation().getArtifactName());
+ toscaOperation.setImplementation(toscaInterfaceOperationImplementation);
+ }
+ }
+
+ private void handleInterfaceOperationImplementationProperties(final Entry<String, OperationDataDefinition> operationEntry,
+ final ToscaArtifactDefinition toscaArtifactDefinition) {
+ final var properties = operationEntry.getValue().getImplementation().getProperties();
+ if (CollectionUtils.isNotEmpty(properties)) {
+ final Map<String, PropertyDataDefinition> propertiesMap = new HashMap<>();
+ properties.forEach(propertyDefinition -> propertiesMap.put(propertyDefinition.getName(), propertyDefinition));
+ toscaArtifactDefinition.setProperties(propertiesMap);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaArtifactDefinition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaArtifactDefinition.java
new file mode 100644
index 0000000000..f49d0478b9
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaArtifactDefinition.java
@@ -0,0 +1,41 @@
+/*
+ * -
+ * ============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.tosca.model;
+
+import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+
+@Getter
+@Setter
+public class ToscaArtifactDefinition {
+
+ private String type;
+ private String file;
+ private String repository;
+ private String description;
+ private String deploy_path;
+ private String artifact_version;
+ private String checksum;
+ private String checksum_algorithm;
+ private Map<String, PropertyDataDefinition> properties;
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceOperationImplementation.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceOperationImplementation.java
new file mode 100644
index 0000000000..270bd723ff
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceOperationImplementation.java
@@ -0,0 +1,36 @@
+/*
+ * -
+ * ============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.tosca.model;
+
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+
+@Getter
+@Setter
+public class ToscaInterfaceOperationImplementation {
+
+ private ToscaArtifactDefinition primary;
+ private List<ArtifactDataDefinition> dependencies;
+ private Integer timeout;
+ private String operation_host;
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinition.java
index f35cab2795..575c0259d2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinition.java
@@ -16,56 +16,17 @@
package org.openecomp.sdc.be.tosca.model;
import java.util.Map;
-import java.util.Objects;
+import lombok.Data;
/**
* @author KATYR
* @since March 26, 2018
*/
+@Data
public class ToscaLifecycleOperationDefinition {
private String description;
- private String implementation;
+ private Object implementation;
private Map<String, ToscaProperty> inputs;
- public String getImplementation() {
- return implementation;
- }
-
- public void setImplementation(String implementation) {
- this.implementation = implementation;
- }
-
- public Map<String, ToscaProperty> getInputs() {
- return inputs;
- }
-
- public void setInputs(Map<String, ToscaProperty> inputs) {
- this.inputs = inputs;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- ToscaLifecycleOperationDefinition that = (ToscaLifecycleOperationDefinition) o;
- return Objects.equals(implementation, that.implementation) && Objects.equals(inputs, that.inputs);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(implementation, inputs);
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaOperationAssignment.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaOperationAssignment.java
index d7f918de53..23e50cfaa4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaOperationAssignment.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaOperationAssignment.java
@@ -27,6 +27,6 @@ import lombok.Setter;
public class ToscaOperationAssignment {
private String description;
- private String implementation;
+ private Object implementation;
private Map<String, ToscaPropertyAssignment> inputs;
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/builder/ToscaRelationshipBuilderTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/builder/ToscaRelationshipBuilderTest.java
index cee70661be..a5008b3e27 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/builder/ToscaRelationshipBuilderTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/builder/ToscaRelationshipBuilderTest.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
import org.openecomp.sdc.be.model.RelationshipImpl;
import org.openecomp.sdc.be.model.RelationshipInfo;
@@ -55,13 +56,13 @@ class ToscaRelationshipBuilderTest {
final OperationUi operationUi1 = new OperationUi();
operationUi1.setInterfaceType("interfaceType1");
operationUi1.setOperationType("operation1");
- operationUi1.setImplementation("implementation");
+ operationUi1.setImplementation(new ArtifactDataDefinition());
operationList.add(operationUi1);
final OperationUi operationUi2 = new OperationUi();
operationUi2.setInterfaceType("interfaceType1");
operationUi2.setOperationType("operation2");
- operationUi2.setImplementation("implementation");
+ operationUi2.setImplementation(new ArtifactDataDefinition());
operationList.add(operationUi2);
final List<PropertyAssignmentUi> operation2InputList = new ArrayList<>();
final PropertyAssignmentUi propertyAssignmentUi1 = new PropertyAssignmentUi();
@@ -79,7 +80,7 @@ class ToscaRelationshipBuilderTest {
final OperationUi operationUi3 = new OperationUi();
operationUi3.setInterfaceType("interfaceType2");
operationUi3.setOperationType("operation1");
- operationUi3.setImplementation("implementation");
+ operationUi3.setImplementation(new ArtifactDataDefinition());
operationList.add(operationUi3);
relationship.setOperations(operationList);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java
index 054a6cfa6c..7d5e957900 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java
@@ -20,11 +20,10 @@
package org.openecomp.sdc.be.tosca.model;
+import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
-import java.util.Map;
-
public class ToscaLifecycleOperationDefinitionTest {
private ToscaLifecycleOperationDefinition createTestSubject() {
@@ -34,7 +33,7 @@ public class ToscaLifecycleOperationDefinitionTest {
@Test
public void testGetImplementation() throws Exception {
ToscaLifecycleOperationDefinition testSubject;
- String result;
+ Object result;
// default test
testSubject = createTestSubject();
@@ -44,11 +43,10 @@ public class ToscaLifecycleOperationDefinitionTest {
@Test
public void testSetImplementation() throws Exception {
ToscaLifecycleOperationDefinition testSubject;
- String implementation = "";
// default test
testSubject = createTestSubject();
- testSubject.setImplementation(implementation);
+ testSubject.setImplementation(new ToscaInterfaceOperationImplementation());
}
@Test