summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
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/main
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/main')
-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
6 files changed, 109 insertions, 46 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;
}