aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-02-05 19:24:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-02-24 08:03:45 +0000
commitb6d953c506c08a5369c0be7242ef3ce3ec888452 (patch)
treedbe45662f4252e88df9161c917664ba578bcc7a3 /catalog-model
parentb485c37b36ddb3ab5e8085c009b26e97c8e62d74 (diff)
Implement Attributes/Outputs BE (part 2)
This commit includes support for: - declare Attribute as Output - undeclare Attribute as Output - export 'Tosca Artifacts' with Attributes/Outputs Change-Id: Iedfbf936e439fd2f7d252b660fe2c42b8d9b9113 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3448
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstOutputsMap.java60
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribOutput.java49
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceOutput.java26
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/InputDefinition.java23
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/OutputDefinition.java12
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java131
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java23
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java269
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java34
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java5
15 files changed, 526 insertions, 121 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
index f9e0d646b3..ee819310c1 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
@@ -47,11 +47,13 @@ public class AttributeDefinition extends AttributeDataDefinition implements IOpe
}
public AttributeDefinition(final AttributeDefinition attributeDefinition) {
+ super(attributeDefinition);
this.type = attributeDefinition.getType();
this.description = attributeDefinition.getDescription();
this._default = attributeDefinition.get_default();
this.status = attributeDefinition.getStatus();
this.entry_schema = attributeDefinition.getEntry_schema();
+ this.toscaPresentation = attributeDefinition.toscaPresentation;
}
@Override
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 600451d193..c40eef3309 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
@@ -349,6 +349,10 @@ public abstract class Component implements PropertiesOwner {
return componentInstancesProperties == null ? emptyMap() : componentInstancesProperties;
}
+ public Map<String, List<ComponentInstanceAttribute>> safeGetComponentInstancesAttributes() {
+ return componentInstancesAttributes == null ? emptyMap() : componentInstancesAttributes;
+ }
+
public Map<String, List<ComponentInstanceProperty>> safeGetUiComponentInstancesProperties() {
return componentInstancesProperties == null ? emptyMap() : findUiComponentInstancesProperties();
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstOutputsMap.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstOutputsMap.java
new file mode 100644
index 0000000000..98b39fd1c2
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstOutputsMap.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.model;
+
+import static org.apache.commons.collections.MapUtils.isNotEmpty;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import lombok.Setter;
+import org.apache.commons.lang3.tuple.Pair;
+
+@Setter
+public class ComponentInstOutputsMap {
+
+ private Map<String, List<ComponentInstanceAttribOutput>> componentInstanceOutputsMap;
+ private Map<String, List<ComponentInstanceAttribOutput>> componentInstanceAttributes;
+
+ public Pair<String, List<ComponentInstanceAttribOutput>> resolveAttributesToDeclare() {
+ if (isNotEmpty(componentInstanceOutputsMap)) {
+ return singleMapEntry(componentInstanceOutputsMap);
+ }
+ if (isNotEmpty(componentInstanceAttributes)) {
+ return singleMapEntry(componentInstanceAttributes);
+ }
+ throw new IllegalStateException("there are no properties selected for declaration");
+ }
+
+ private Pair<String, List<ComponentInstanceAttribOutput>> singleMapEntry(final Map<String, List<ComponentInstanceAttribOutput>> attributesMap) {
+ final Map.Entry<String, List<ComponentInstanceAttribOutput>> singleEntry = attributesMap.entrySet().iterator().next();
+ return Pair.of(singleEntry.getKey(), singleEntry.getValue());
+ }
+
+ public Map<String, List<ComponentInstanceAttribOutput>> getComponentInstanceOutputsMap() {
+ return componentInstanceOutputsMap == null ? new HashMap<>() : componentInstanceOutputsMap;
+ }
+
+ public Map<String, List<ComponentInstanceAttribOutput>> getComponentInstanceAttributes() {
+ return componentInstanceAttributes == null ? new HashMap<>() : componentInstanceAttributes;
+ }
+
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribOutput.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribOutput.java
new file mode 100644
index 0000000000..9b14e1af54
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribOutput.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ComponentInstanceAttribOutput extends ComponentInstanceAttribute {
+
+ private String attributesName;
+ private AttributeDefinition output;
+
+ public ComponentInstanceAttribOutput() {
+ super();
+ }
+
+ public ComponentInstanceAttribOutput(ComponentInstanceAttribute p) {
+ super(p);
+ }
+
+ public String[] getParsedAttribNames() {
+ String[] tokens = null;
+ if (attributesName != null && !attributesName.isEmpty()) {
+ tokens = attributesName.split("#");
+ }
+ return tokens;
+ }
+
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceOutput.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceOutput.java
index db79511a67..be3f87eb9b 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceOutput.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceOutput.java
@@ -22,12 +22,16 @@ package org.openecomp.sdc.be.model;
import java.util.List;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
+import lombok.ToString;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
@Getter
@Setter
+@NoArgsConstructor
+@ToString(callSuper = true)
public class ComponentInstanceOutput extends OutputDefinition implements IComponentInstanceConnectedElement, IAttributeOutputCommon {
/**
@@ -35,21 +39,25 @@ public class ComponentInstanceOutput extends OutputDefinition implements ICompon
*/
private String valueUniqueUid;
- private List<String> path = null;
+ private List<String> path;
- private List<PropertyRule> rules = null;
+ private List<PropertyRule> rules;
private String componentInstanceName;
private String componentInstanceId;
- public ComponentInstanceOutput(AttributeDataDefinition curPropertyDef, String outputId, String value,
- String valueUniqueUid) {
+ public ComponentInstanceOutput(final AttributeDataDefinition curPropertyDef,
+ final String outputId,
+ final String value,
+ final String valueUniqueUid) {
super(curPropertyDef);
setOutputId(outputId);
setValue(value);
this.valueUniqueUid = valueUniqueUid;
}
- public ComponentInstanceOutput(OutputDefinition pd, String value, String valueUniqueUid) {
+ public ComponentInstanceOutput(final OutputDefinition pd,
+ final String value,
+ final String valueUniqueUid) {
super(pd);
setValue(value);
@@ -60,14 +68,8 @@ public class ComponentInstanceOutput extends OutputDefinition implements ICompon
super(attributeDataDefinition);
if (attributeDataDefinition.getGetOutputValues() != null && !attributeDataDefinition.getGetOutputValues()
.isEmpty()) {
- setOutputId(attributeDataDefinition.getGetOutputValues().get(0).getInputId());
+ setOutputId(attributeDataDefinition.getGetOutputValues().get(0).getOutputId());
}
}
- @Override
- public String toString() {
- return "ComponentInstanceOutput [ " + super.toString() + " , value=" + getValue() + ", valueUniqueUid = "
- + valueUniqueUid + " , rules=" + rules + " , path=" + path + " ]";
- }
-
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java
index 87917d7861..4c8cb3d866 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java
@@ -151,6 +151,10 @@ public class ComponentParametersView {
this.setIgnoreComponentInstances(false);
this.setIgnoreComponentInstancesInputs(false);
break;
+ case COMPONENT_INSTANCE_OUTPUTS:
+ this.setIgnoreComponentInstances(false);
+ this.setIgnoreComponentInstancesOutputs(false);
+ break;
case INSTANCE_CAPABILTY_PROPERTIES:
this.setIgnoreCapabiltyProperties(false);
break;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/InputDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/InputDefinition.java
index 2f61e9e6f3..bbb71463fc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/InputDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/InputDefinition.java
@@ -20,6 +20,8 @@
package org.openecomp.sdc.be.model;
+import lombok.Getter;
+import lombok.Setter;
import org.openecomp.sdc.be.datatypes.elements.Annotation;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
@@ -27,12 +29,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+@Getter
+@Setter
public class InputDefinition extends PropertyDefinition {
private List<ComponentInstanceInput> inputs;
private List<ComponentInstanceProperty> properties;
-
public InputDefinition(PropertyDataDefinition p) {
super(p);
}
@@ -49,26 +52,8 @@ public class InputDefinition extends PropertyDefinition {
super(other);
}
- public List<ComponentInstanceInput> getInputs() {
- return inputs;
- }
-
- public void setInputs(List<ComponentInstanceInput> inputs) {
- this.inputs = inputs;
- }
-
- public List<ComponentInstanceProperty> getProperties() {
- return properties;
- }
-
- public void setProperties(List<ComponentInstanceProperty> properties) {
- this.properties = properties;
- }
-
public void setAnnotationsToInput(Collection<Annotation> annotations){
this.setAnnotations(new ArrayList<>(annotations));
}
-
-
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/OutputDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/OutputDefinition.java
index cbff8fa3af..354a5b2ae3 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/OutputDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/OutputDefinition.java
@@ -19,12 +19,20 @@
package org.openecomp.sdc.be.model;
+import java.util.List;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+@Getter
+@Setter
+@NoArgsConstructor
public class OutputDefinition extends AttributeDefinition {
+ private List<ComponentInstanceAttribute> attributes;
- public OutputDefinition(final AttributeDataDefinition propertyDataDefinition) {
- super(propertyDataDefinition);
+ public OutputDefinition(final AttributeDataDefinition attributeDataDefinition) {
+ super(attributeDataDefinition);
}
public OutputDefinition(AttributeDefinition propertyDefinition) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
index 1bf35fbd9f..483e79c53b 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
@@ -26,10 +26,10 @@ import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections.MapUtils;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
@@ -59,7 +59,9 @@ public class TopologyTemplate extends ToscaElement {
}
private Map<String, PropertyDataDefinition> inputs;
+ private Map<String, AttributeDataDefinition> outputs;
private Map<String, MapPropertiesDataDefinition> instInputs;
+ private Map<String, MapAttributesDataDefinition> instOutputs;
private Map<String, ? extends ToscaDataDefinition> heatParameters;
private Map<String, MapAttributesDataDefinition> instAttributes;
private Map<String, MapPropertiesDataDefinition> instProperties;
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 3f3e54146d..babe44234e 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
@@ -23,6 +23,7 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
import fj.data.Either;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
@@ -33,7 +34,6 @@ import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
-import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
@@ -82,7 +82,25 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceOutput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RelationshipImpl;
+import org.openecomp.sdc.be.model.RelationshipInfo;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.RequirementDefinition;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.NodeType;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
@@ -233,37 +251,40 @@ public class NodeTemplateOperation extends BaseOperation {
addToscaDataDeepElementsBlockToToscaElement(updatedContainer.getUniqueId(), EdgeLabelEnum.CALCULATED_CAPABILITIES, VertexTypeEnum.CALCULATED_CAPABILITIES, allCalculatedCap, componentInstance.getUniqueId());
/******** capability property ****************************/
- status = deleteToscaDataDeepElementsBlockOfToscaElement(updatedContainer.getUniqueId(), EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, VertexTypeEnum.CALCULATED_CAP_PROPERTIES, componentInstanceData.getUniqueId());
+ status = deleteToscaDataDeepElementsBlockOfToscaElement(updatedContainer.getUniqueId(), EdgeLabelEnum.CALCULATED_CAP_PROPERTIES,
+ VertexTypeEnum.CALCULATED_CAP_PROPERTIES, componentInstanceData.getUniqueId());
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove calculated capabilty properties for instance {} in container {}. error {] ", componentInstanceData.getUniqueId(), updatedContainer.getUniqueId(), status);
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
+ "Failed to remove calculated capabilty properties for instance {} in container {}. error {] ",
+ componentInstanceData.getUniqueId(), updatedContainer.getUniqueId(), status);
return Either.right(status);
}
- MapCapabilityProperty allCalculatedCapProp = calcCapProp == null || !calcCapProp.containsKey(componentInstanceData.getUniqueId()) ? new MapCapabilityProperty() : calcCapProp.get(componentInstanceData.getUniqueId());
-
- additionalCap.forEach(new BiConsumer<String, List<CapabilityDefinition>>() {
- @Override
- public void accept(String s, List<CapabilityDefinition> caps) {
- if (caps != null && !caps.isEmpty()) {
- MapPropertiesDataDefinition dataToCreate;
- for (CapabilityDefinition cap : caps) {
- dataToCreate = new MapPropertiesDataDefinition();
- List<ComponentInstanceProperty> capPrps = cap.getProperties();
- if (capPrps != null) {
- for (ComponentInstanceProperty cip : capPrps) {
- dataToCreate.put(cip.getName(), new PropertyDataDefinition(cip));
- }
- StringBuilder sb = new StringBuilder(componentInstance.getUniqueId());
- sb.append(ModelConverter.CAP_PROP_DELIM);
- sb.append(cap.getOwnerId());
- sb.append(ModelConverter.CAP_PROP_DELIM).append(s).append(ModelConverter.CAP_PROP_DELIM).append(cap.getName());
- allCalculatedCapProp.put(sb.toString(), dataToCreate);
+ MapCapabilityProperty allCalculatedCapProp =
+ calcCapProp == null || !calcCapProp.containsKey(componentInstanceData.getUniqueId()) ? new MapCapabilityProperty()
+ : calcCapProp.get(componentInstanceData.getUniqueId());
+
+ additionalCap.forEach((s, caps) -> {
+ if (caps != null && !caps.isEmpty()) {
+ MapPropertiesDataDefinition dataToCreate;
+ for (CapabilityDefinition cap : caps) {
+ dataToCreate = new MapPropertiesDataDefinition();
+ List<ComponentInstanceProperty> capPrps = cap.getProperties();
+ if (capPrps != null) {
+ for (ComponentInstanceProperty cip : capPrps) {
+ dataToCreate.put(cip.getName(), new PropertyDataDefinition(cip));
}
+ StringBuilder sb = new StringBuilder(componentInstance.getUniqueId());
+ sb.append(ModelConverter.CAP_PROP_DELIM);
+ sb.append(cap.getOwnerId());
+ sb.append(ModelConverter.CAP_PROP_DELIM).append(s).append(ModelConverter.CAP_PROP_DELIM).append(cap.getName());
+ allCalculatedCapProp.put(sb.toString(), dataToCreate);
}
}
}
});
- addToscaDataDeepElementsBlockToToscaElement(updatedContainer.getUniqueId(), EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, VertexTypeEnum.CALCULATED_CAP_PROPERTIES, allCalculatedCapProp, componentInstance.getUniqueId());
+ addToscaDataDeepElementsBlockToToscaElement(updatedContainer.getUniqueId(), EdgeLabelEnum.CALCULATED_CAP_PROPERTIES,
+ VertexTypeEnum.CALCULATED_CAP_PROPERTIES, allCalculatedCapProp, componentInstance.getUniqueId());
}
/******** Requirements property ****************************/
@@ -1294,8 +1315,7 @@ public class NodeTemplateOperation extends BaseOperation {
private Boolean isUniqueInstanceName(TopologyTemplate container, String instanceName) {
Boolean isUniqueName = true;
try {
- isUniqueName = !container.getComponentInstances().values().stream().anyMatch(ci -> ci.getName() != null && ci.getName().equals(instanceName));
-
+ isUniqueName = container.getComponentInstances().values().stream().noneMatch(ci -> ci.getName() != null && ci.getName().equals(instanceName));
} catch (Exception e) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Exception occured during fetching component instance with name {} from component container {}. {} ", instanceName, container.getName(), e.getMessage());
}
@@ -2134,10 +2154,8 @@ public class NodeTemplateOperation extends BaseOperation {
if (!validateInstanceNames(componentInstanceTMap)) {
throw new StorageException(StorageOperationStatus.INCONSISTENCY);
}
- if (!allowDeleted) {
- if (!validateDeletedResources(componentInstanceTMap)) {
- throw new StorageException(StorageOperationStatus.INCONSISTENCY);
- }
+ if (!allowDeleted && !validateDeletedResources(componentInstanceTMap)) {
+ throw new StorageException(StorageOperationStatus.INCONSISTENCY);
}
instancesJsonData = convertToComponentInstanceDataDefinition(componentInstanceTMap, containerId, isUpdateCsar);
@@ -2313,32 +2331,53 @@ public class NodeTemplateOperation extends BaseOperation {
public StorageOperationStatus addComponentInstanceProperty(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property) {
List<String> pathKeys = new ArrayList<>();
pathKeys.add(componentInstanceId);
- return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES, property, pathKeys, JsonPresentationFields.NAME);
+ return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES,
+ property, pathKeys, JsonPresentationFields.NAME);
}
- public StorageOperationStatus updateComponentInstanceProperties(Component containerComponent, String componentInstanceId, List<ComponentInstanceProperty> properties) {
+ public StorageOperationStatus updateComponentInstanceProperties(Component containerComponent, String componentInstanceId,
+ List<ComponentInstanceProperty> properties) {
List<String> pathKeys = new ArrayList<>();
pathKeys.add(componentInstanceId);
- return updateToscaDataDeepElementsOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES, properties, pathKeys, JsonPresentationFields.NAME);
+ return updateToscaDataDeepElementsOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_PROPERTIES,
+ VertexTypeEnum.INST_PROPERTIES, properties, pathKeys, JsonPresentationFields.NAME);
}
- public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute property){
+ public StorageOperationStatus updateComponentInstanceAttributes(final Component containerComponent,
+ final String componentInstanceId,
+ final List<ComponentInstanceAttribute> attributes) {
+ final List<String> pathKeys = Arrays.asList(componentInstanceId);
+ return updateToscaDataDeepElementsOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES,
+ VertexTypeEnum.INST_ATTRIBUTES, attributes, pathKeys, JsonPresentationFields.NAME);
+ }
+
+ public StorageOperationStatus updateComponentInstanceAttribute(final Component containerComponent,
+ final String componentInstanceId,
+ final ComponentInstanceAttribute attribute) {
+ final List<String> pathKeys = Arrays.asList(componentInstanceId);
+ return updateToscaDataDeepElementOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES,
+ VertexTypeEnum.INST_ATTRIBUTES, attribute, pathKeys, JsonPresentationFields.NAME);
+ }
+
+ public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId,
+ ComponentInstanceAttribute attribute) {
List<String> pathKeys = new ArrayList<>();
pathKeys.add(componentInstanceId);
- return updateToscaDataDeepElementOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, property, pathKeys, JsonPresentationFields.NAME);
+ return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES,
+ attribute, pathKeys, JsonPresentationFields.NAME);
}
- public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute attribute){
+ public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId,
+ ComponentInstanceInput property) {
List<String> pathKeys = new ArrayList<>();
pathKeys.add(componentInstanceId);
- return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, attribute, pathKeys, JsonPresentationFields.NAME);
+ return updateToscaDataDeepElementOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS, property, pathKeys, JsonPresentationFields.NAME);
}
- public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) {
-
+ public StorageOperationStatus updateComponentInstanceOutput(Component containerComponent, String componentInstanceId, ComponentInstanceOutput property) {
List<String> pathKeys = new ArrayList<>();
pathKeys.add(componentInstanceId);
- return updateToscaDataDeepElementOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS, property, pathKeys, JsonPresentationFields.NAME);
+ return updateToscaDataDeepElementOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_OUTPUTS, VertexTypeEnum.INST_OUTPUTS, property, pathKeys, JsonPresentationFields.NAME);
}
public StorageOperationStatus updateComponentInstanceInputs(Component containerComponent, String componentInstanceId, List<ComponentInstanceInput> properties) {
@@ -2347,12 +2386,24 @@ public class NodeTemplateOperation extends BaseOperation {
return updateToscaDataDeepElementsOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS, properties, pathKeys, JsonPresentationFields.NAME);
}
+ public StorageOperationStatus updateComponentInstanceOutputs(Component containerComponent, String componentInstanceId, List<ComponentInstanceOutput> properties) {
+ List<String> pathKeys = new ArrayList<>();
+ pathKeys.add(componentInstanceId);
+ return updateToscaDataDeepElementsOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_OUTPUTS, VertexTypeEnum.INST_OUTPUTS, properties, pathKeys, JsonPresentationFields.NAME);
+ }
+
public StorageOperationStatus addComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) {
List<String> pathKeys = new ArrayList<>();
pathKeys.add(componentInstanceId);
return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS, property, pathKeys, JsonPresentationFields.NAME);
}
+ public StorageOperationStatus addComponentInstanceOutput(Component containerComponent, String componentInstanceId, ComponentInstanceOutput property) {
+ List<String> pathKeys = new ArrayList<>(){};
+ pathKeys.add(componentInstanceId);
+ return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_OUTPUTS, VertexTypeEnum.INST_OUTPUTS, property, pathKeys, JsonPresentationFields.NAME);
+ }
+
public StorageOperationStatus createInstanceEdge(GraphVertex metadataVertex, ComponentInstanceDataDefinition componentInstance) {
String instUniqueId = componentInstance.getUniqueId();
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
index 1860e696e5..e8aba6dcb6 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
@@ -932,6 +932,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
case ARTIFACTS:
case GROUPS:
case INPUTS:
+ case OUTPUTS:
return true;
default:
return false;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
index ed9196098e..a27989bc9e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
@@ -35,6 +35,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.category.MetadataKeyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
@@ -721,6 +722,14 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
}
}
+
+ if (!componentParametersView.isIgnoreOutputs()) {
+ final JanusGraphOperationStatus storageStatus = setOutputsFromGraph(componentV, toscaElement);
+ if (storageStatus != JanusGraphOperationStatus.OK) {
+ return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(storageStatus));
+ }
+ }
+
if (!componentParametersView.isIgnoreProperties()) {
status = setPropertiesFromGraph(componentV, toscaElement);
if (status != JanusGraphOperationStatus.OK) {
@@ -1130,6 +1139,20 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
return JanusGraphOperationStatus.OK;
}
+ private JanusGraphOperationStatus setOutputsFromGraph(final GraphVertex componentV,
+ final TopologyTemplate toscaElement) {
+ final Either<Map<String, AttributeDataDefinition>, JanusGraphOperationStatus> result =
+ getDataFromGraph(componentV, EdgeLabelEnum.OUTPUTS);
+ if (result.isLeft()) {
+ toscaElement.setOutputs(result.left().value());
+ } else {
+ if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
+ return result.right().value();
+ }
+ }
+ return JanusGraphOperationStatus.OK;
+ }
+
private JanusGraphOperationStatus setGroupsFromGraph(GraphVertex componentV, TopologyTemplate toscaElement) {
Either<Map<String, GroupDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.GROUPS);
if (result.isLeft()) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
index cdddb2049f..b4517e47c5 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
@@ -91,6 +91,7 @@ import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceInterface;
+import org.openecomp.sdc.be.model.ComponentInstanceOutput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
@@ -99,6 +100,7 @@ import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RelationshipInfo;
@@ -1245,6 +1247,36 @@ public class ToscaOperationFacade {
}
+ public Either<List<OutputDefinition>, StorageOperationStatus> addOutputsToComponent(Map<String, OutputDefinition> outputs,
+ String componentId) {
+
+ Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao
+ .getVertexById(componentId, JsonParseFlagEnum.NoParse);
+ if (getVertexEither.isRight()) {
+ log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, componentId, getVertexEither.right().value());
+ return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value()));
+
+ }
+
+ GraphVertex vertex = getVertexEither.left().value();
+ Map<String, AttributeDefinition> outputsMap = outputs.entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> new AttributeDefinition(e.getValue())));
+
+ StorageOperationStatus status = topologyTemplateOperation
+ .addToscaDataToToscaElement(vertex, EdgeLabelEnum.OUTPUTS, VertexTypeEnum.OUTPUTS, outputsMap, JsonPresentationFields.NAME);
+
+ if (StorageOperationStatus.OK == status) {
+ log.debug(COMPONENT_CREATED_SUCCESSFULLY);
+ List<OutputDefinition> outputsResList = null;
+ if (outputsMap != null && !outputsMap.isEmpty()) {
+ outputsResList = outputsMap.values().stream().map(OutputDefinition::new).collect(Collectors.toList());
+ }
+ return Either.left(outputsResList);
+ }
+ return Either.right(status);
+
+ }
+
/**
* Add data types into a Component.
*
@@ -1252,7 +1284,8 @@ public class ToscaOperationFacade {
* @param componentId unique ID of Component.
* @return list of data types.
*/
- public Either<List<DataTypeDefinition>, StorageOperationStatus> addDataTypesToComponent(Map<String, DataTypeDefinition> dataTypes, String componentId) {
+ public Either<List<DataTypeDefinition>, StorageOperationStatus> addDataTypesToComponent(Map<String, DataTypeDefinition> dataTypes,
+ String componentId) {
log.trace("#addDataTypesToComponent - enter, componentId={}", componentId);
@@ -1511,7 +1544,38 @@ public class ToscaOperationFacade {
return Either.left(instProperties);
}
- public Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addComponentInstancePropertiesToComponent(Component containerComponent, Map<String, List<ComponentInstanceProperty>> instProperties) {
+ public Either<Map<String, List<ComponentInstanceOutput>>, StorageOperationStatus> addComponentInstanceOutputsToComponent(
+ Component containerComponent, Map<String, List<ComponentInstanceOutput>> instProperties) {
+ requireNonNull(instProperties);
+ StorageOperationStatus status;
+ for (final Entry<String, List<ComponentInstanceOutput>> entry : instProperties.entrySet()) {
+ final List<ComponentInstanceOutput> props = entry.getValue();
+ final String componentInstanceId = entry.getKey();
+ if (!isEmpty(props)) {
+ for (final ComponentInstanceOutput property : props) {
+ final List<ComponentInstanceOutput> componentInstancesInputs
+ = containerComponent.getComponentInstancesOutputs().get(componentInstanceId);
+ final Optional<ComponentInstanceOutput> instanceProperty = componentInstancesInputs.stream()
+ .filter(p -> p.getName().equals(property.getName())).findAny();
+ if (instanceProperty.isPresent()) {
+ status = updateComponentInstanceOutput(containerComponent, componentInstanceId, property);
+ } else {
+ status = addComponentInstanceOutput(containerComponent, componentInstanceId, property);
+ }
+ if (status != StorageOperationStatus.OK) {
+ log.debug("Failed to update instance input {} for instance {} error {} ", property, componentInstanceId, status);
+ return Either.right(status);
+ } else {
+ log.trace("instance input {} for instance {} updated", property, componentInstanceId);
+ }
+ }
+ }
+ }
+ return Either.left(instProperties);
+ }
+
+ public Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addComponentInstancePropertiesToComponent(
+ Component containerComponent, Map<String, List<ComponentInstanceProperty>> instProperties) {
requireNonNull(instProperties);
for (Entry<String, List<ComponentInstanceProperty>> entry : instProperties.entrySet()) {
List<ComponentInstanceProperty> props = entry.getValue();
@@ -1520,7 +1584,7 @@ public class ToscaOperationFacade {
containerComponent.getComponentInstancesProperties().get(componentInstanceId);
Map<String, List<CapabilityDefinition>> containerComponentCapabilities = containerComponent.getCapabilities();
- if(isEmpty(props)) {
+ if (isEmpty(props)) {
continue;
}
for (ComponentInstanceProperty property : props) {
@@ -1528,15 +1592,38 @@ public class ToscaOperationFacade {
String propertyParentUniqueId = property.getParentUniqueId();
Optional<CapabilityDefinition>
capPropDefinition = getPropertyCapability(propertyParentUniqueId, containerComponent);
- if(capPropDefinition.isPresent() && MapUtils.isNotEmpty(containerComponentCapabilities)) {
+ if (capPropDefinition.isPresent() && MapUtils.isNotEmpty(containerComponentCapabilities)) {
status = populateAndUpdateInstanceCapProperty(containerComponent, componentInstanceId,
- containerComponentCapabilities, property, capPropDefinition.get());
+ containerComponentCapabilities, property, capPropDefinition.get());
}
- if(status == null) {
+ if (status == null) {
status = updateOrAddComponentInstanceProperty(containerComponent, componentInstanceId,
originalComponentInstProps, property);
}
- if(status != StorageOperationStatus.OK) {
+ if (status != StorageOperationStatus.OK) {
+ return Either.right(status);
+ }
+ }
+ }
+ return Either.left(instProperties);
+ }
+
+ public Either<Map<String, List<ComponentInstanceAttribute>>, StorageOperationStatus> addComponentInstanceAttributesToComponent(
+ final Component containerComponent, final Map<String, List<ComponentInstanceAttribute>> instProperties) {
+ requireNonNull(instProperties);
+ for (final Entry<String, List<ComponentInstanceAttribute>> entry : instProperties.entrySet()) {
+ final List<ComponentInstanceAttribute> props = entry.getValue();
+ if (isEmpty(props)) {
+ continue;
+ }
+ final String componentInstanceId = entry.getKey();
+ final List<ComponentInstanceAttribute> originalComponentInstProps =
+ containerComponent.getComponentInstancesAttributes().get(componentInstanceId);
+
+ for (final ComponentInstanceAttribute property : props) {
+ final StorageOperationStatus status = updateOrAddComponentInstanceAttribute(
+ containerComponent, componentInstanceId, originalComponentInstProps, property);
+ if (status != StorageOperationStatus.OK) {
return Either.right(status);
}
}
@@ -1549,7 +1636,7 @@ public class ToscaOperationFacade {
ComponentInstanceProperty property,
CapabilityDefinition capabilityDefinition) {
List<CapabilityDefinition> capabilityDefinitions = containerComponentCapabilities.get(capabilityDefinition.getType());
- if(CollectionUtils.isEmpty(capabilityDefinitions)) {
+ if (CollectionUtils.isEmpty(capabilityDefinitions)) {
return null;
}
Optional<CapabilityDefinition> capDefToGetProp = capabilityDefinitions.stream()
@@ -1578,13 +1665,13 @@ public class ToscaOperationFacade {
}
private StorageOperationStatus updateOrAddComponentInstanceProperty(Component containerComponent,
- String componentInstanceId, List<ComponentInstanceProperty> originalComponentInstProps,
- ComponentInstanceProperty property)
- {
+ String componentInstanceId,
+ List<ComponentInstanceProperty> originalComponentInstProps,
+ ComponentInstanceProperty property) {
StorageOperationStatus status;
// check if the property already exists or not
Optional<ComponentInstanceProperty> instanceProperty = originalComponentInstProps.stream()
- .filter(p -> p.getUniqueId().equals(property.getUniqueId())).findAny();
+ .filter(p -> p.getUniqueId().equals(property.getUniqueId())).findAny();
if (instanceProperty.isPresent()) {
status = updateComponentInstanceProperty(containerComponent, componentInstanceId, property);
} else {
@@ -1597,15 +1684,35 @@ public class ToscaOperationFacade {
return status;
}
- public StorageOperationStatus updateInstanceCapabilityProperty(Component containerComponent, String componentInstanceId,
+ private StorageOperationStatus updateOrAddComponentInstanceAttribute(Component containerComponent,
+ String componentInstanceId,
+ List<ComponentInstanceAttribute> originalComponentInstProps,
+ ComponentInstanceAttribute property) {
+ StorageOperationStatus status;
+ // check if the property already exists or not
+ Optional<ComponentInstanceAttribute> instanceProperty = originalComponentInstProps.stream()
+ .filter(p -> p.getUniqueId().equals(property.getUniqueId())).findAny();
+ if (instanceProperty.isPresent()) {
+ status = updateComponentInstanceAttribute(containerComponent, componentInstanceId, property);
+ } else {
+ status = addComponentInstanceAttribute(containerComponent, componentInstanceId, property);
+ }
+ if (status != StorageOperationStatus.OK) {
+ log.debug("Failed to update instance property {} for instance {} error {} ",
+ property, componentInstanceId, status);
+ }
+ return status;
+ }
+
+ public StorageOperationStatus updateInstanceCapabilityProperty(Component containerComponent, String componentInstanceId,
ComponentInstanceProperty property,
CapabilityDefinition capabilityDefinition) {
Optional<ComponentInstance> fetchedCIOptional = containerComponent.getComponentInstanceById(componentInstanceId);
- if(!fetchedCIOptional.isPresent()) {
+ if (!fetchedCIOptional.isPresent()) {
return StorageOperationStatus.GENERAL_ERROR;
}
Either<Component, StorageOperationStatus> getComponentRes =
- getToscaFullElement(fetchedCIOptional.get().getComponentUid());
+ getToscaFullElement(fetchedCIOptional.get().getComponentUid());
if(getComponentRes.isRight()) {
return StorageOperationStatus.GENERAL_ERROR;
}
@@ -2034,12 +2141,7 @@ public class ToscaOperationFacade {
log.debug("failed to get vertex from graph with property normalizedName: {}", normalizedName);
return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(vertexEither.right().value()));
}
- List<GraphVertex> vertexList = vertexEither.isLeft() ? vertexEither.left().value() : null;
- if (vertexList != null && !vertexList.isEmpty()) {
- return Either.left(false);
- } else {
- return Either.left(true);
- }
+ return Either.left(CollectionUtils.isEmpty(vertexEither.isLeft() ? vertexEither.left().value() : null));
}
private void fillNodeTypePropsMap(final Map<GraphPropertyEnum, Object> hasProps,
@@ -2650,6 +2752,10 @@ public class ToscaOperationFacade {
return getToscaElementOperation(resource).deleteToscaDataElement(resource.getUniqueId(), EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, inputName, JsonPresentationFields.NAME);
}
+ public StorageOperationStatus deleteOutputOfResource(final Component resource, final String outputName) {
+ return getToscaElementOperation(resource).deleteToscaDataElement(resource.getUniqueId(), EdgeLabelEnum.OUTPUTS, VertexTypeEnum.OUTPUTS, outputName, JsonPresentationFields.NAME);
+ }
+
/**
* Deletes a data type from a component.
* @param component the container which has the data type
@@ -2682,21 +2788,60 @@ public class ToscaOperationFacade {
}
}
if (result == null) {
- Optional<PropertyDefinition> newProperty = (getUpdatedComponentRes.left().value())
- .getProperties().stream().filter(p -> p.getName().equals(newPropertyDefinition.getName())).findAny();
- if (newProperty.isPresent()) {
- result = Either.left(newProperty.get());
- } else {
+ Optional<PropertyDefinition> newProperty = (getUpdatedComponentRes.left().value())
+ .getProperties().stream().filter(p -> p.getName().equals(newPropertyDefinition.getName())).findAny();
+ if (newProperty.isPresent()) {
+ result = Either.left(newProperty.get());
+ } else {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
FAILED_TO_FIND_RECENTLY_ADDED_PROPERTY_ON_THE_RESOURCE_STATUS_IS, newPropertyDefinition.getName(),
component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
result = Either.right(StorageOperationStatus.NOT_FOUND);
}
- }
- return result;
- }
+ }
+ return result;
+ }
- public Either<AttributeDefinition, StorageOperationStatus> addAttributeOfResource(Component component, AttributeDefinition newAttributeDef) {
+ public Either<AttributeDefinition, StorageOperationStatus> updateAttributeOfComponent(Component component,
+ AttributeDefinition newPropertyDefinition) {
+
+ Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
+ Either<AttributeDefinition, StorageOperationStatus> result = null;
+ StorageOperationStatus status = getToscaElementOperation(component)
+ .updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES,
+ newPropertyDefinition, JsonPresentationFields.NAME);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS,
+ newPropertyDefinition.getName(), component.getName(), status);
+ result = Either.right(status);
+ }
+ if (result == null) {
+ ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreProperties(false);
+ getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
+ if (getUpdatedComponentRes.isRight()) {
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_UPDATED_RESOURCE_STATUS_IS,
+ component.getUniqueId(), getUpdatedComponentRes.right().value());
+ result = Either.right(status);
+ }
+ }
+ if (result == null) {
+ Optional<AttributeDefinition> newProperty = (getUpdatedComponentRes.left().value())
+ .getAttributes().stream().filter(p -> p.getName().equals(newPropertyDefinition.getName())).findAny();
+ if (newProperty.isPresent()) {
+ result = Either.left(newProperty.get());
+ } else {
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
+ FAILED_TO_FIND_RECENTLY_ADDED_PROPERTY_ON_THE_RESOURCE_STATUS_IS, newPropertyDefinition.getName(),
+ component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+ result = Either.right(StorageOperationStatus.NOT_FOUND);
+ }
+ }
+ return result;
+ }
+
+ public Either<AttributeDefinition, StorageOperationStatus> addAttributeOfResource(Component component,
+ AttributeDefinition newAttributeDef) {
Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
Either<AttributeDefinition, StorageOperationStatus> result = null;
@@ -2706,7 +2851,9 @@ public class ToscaOperationFacade {
newAttributeDef.setOwnerId(component.getUniqueId());
}
- StorageOperationStatus status = getToscaElementOperation(component).addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef, JsonPresentationFields.NAME);
+ StorageOperationStatus status = getToscaElementOperation(component)
+ .addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef,
+ JsonPresentationFields.NAME);
if (status != StorageOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newAttributeDef.getName(), component.getName(), status);
result = Either.right(status);
@@ -2847,31 +2994,58 @@ public class ToscaOperationFacade {
return nodeTemplateOperation.updateComponentInstanceProperties(containerComponent, componentInstanceId, properties);
}
+ public StorageOperationStatus updateComponentInstanceAttributes(final Component containerComponent,
+ final String componentInstanceId,
+ final List<ComponentInstanceAttribute> attributes) {
+ return nodeTemplateOperation.updateComponentInstanceAttributes(containerComponent, componentInstanceId, attributes);
+ }
- public StorageOperationStatus addComponentInstanceProperty(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property) {
+ public StorageOperationStatus addComponentInstanceProperty(Component containerComponent, String componentInstanceId,
+ ComponentInstanceProperty property) {
return nodeTemplateOperation.addComponentInstanceProperty(containerComponent, componentInstanceId, property);
}
- public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute property){
- return nodeTemplateOperation.updateComponentInstanceAttribute(containerComponent, componentInstanceId, property);
+ public StorageOperationStatus updateComponentInstanceAttribute(final Component containerComponent,
+ final String componentInstanceId,
+ final ComponentInstanceAttribute attribute) {
+ return nodeTemplateOperation.updateComponentInstanceAttribute(containerComponent, componentInstanceId, attribute);
}
- public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute attribute){
+ public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId,
+ ComponentInstanceAttribute attribute) {
return nodeTemplateOperation.addComponentInstanceAttribute(containerComponent, componentInstanceId, attribute);
}
- public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) {
+ public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId,
+ ComponentInstanceInput property) {
return nodeTemplateOperation.updateComponentInstanceInput(containerComponent, componentInstanceId, property);
}
- public StorageOperationStatus updateComponentInstanceInputs(Component containerComponent, String componentInstanceId, List<ComponentInstanceInput> instanceInputs) {
+ public StorageOperationStatus updateComponentInstanceOutput(Component containerComponent, String componentInstanceId,
+ ComponentInstanceOutput property) {
+ return nodeTemplateOperation.updateComponentInstanceOutput(containerComponent, componentInstanceId, property);
+ }
+
+ public StorageOperationStatus updateComponentInstanceInputs(Component containerComponent, String componentInstanceId,
+ List<ComponentInstanceInput> instanceInputs) {
return nodeTemplateOperation.updateComponentInstanceInputs(containerComponent, componentInstanceId, instanceInputs);
}
- public StorageOperationStatus addComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) {
+ public StorageOperationStatus updateComponentInstanceOutputs(Component containerComponent, String componentInstanceId,
+ List<ComponentInstanceOutput> instanceInputs) {
+ return nodeTemplateOperation.updateComponentInstanceOutputs(containerComponent, componentInstanceId, instanceInputs);
+ }
+
+ public StorageOperationStatus addComponentInstanceInput(Component containerComponent, String componentInstanceId,
+ ComponentInstanceInput property) {
return nodeTemplateOperation.addComponentInstanceInput(containerComponent, componentInstanceId, property);
}
+ public StorageOperationStatus addComponentInstanceOutput(Component containerComponent, String componentInstanceId,
+ ComponentInstanceOutput property) {
+ return nodeTemplateOperation.addComponentInstanceOutput(containerComponent, componentInstanceId, property);
+ }
+
public void setNodeTypeOperation(NodeTypeOperation nodeTypeOperation) {
this.nodeTypeOperation = nodeTypeOperation;
}
@@ -2880,17 +3054,24 @@ public class ToscaOperationFacade {
this.topologyTemplateOperation = topologyTemplateOperation;
}
- public StorageOperationStatus deleteComponentInstanceInputsFromTopologyTemplate(Component containerComponent, List<InputDefinition> inputsToDelete) {
- return topologyTemplateOperation.deleteToscaDataElements(containerComponent.getUniqueId(), EdgeLabelEnum.INPUTS, inputsToDelete.stream().map(PropertyDataDefinition::getName).collect(Collectors.toList()));
+ public StorageOperationStatus deleteComponentInstanceInputsFromTopologyTemplate(Component containerComponent,
+ List<InputDefinition> inputsToDelete) {
+ return topologyTemplateOperation.deleteToscaDataElements(containerComponent.getUniqueId(), EdgeLabelEnum.INPUTS,
+ inputsToDelete.stream().map(PropertyDataDefinition::getName).collect(Collectors.toList()));
}
- public StorageOperationStatus updateComponentInstanceCapabiltyProperty(Component containerComponent, String componentInstanceUniqueId, String capabilityPropertyKey, ComponentInstanceProperty property) {
- return nodeTemplateOperation.updateComponentInstanceCapabilityProperty(containerComponent, componentInstanceUniqueId, capabilityPropertyKey, property);
+ public StorageOperationStatus updateComponentInstanceCapabiltyProperty(Component containerComponent, String componentInstanceUniqueId,
+ String capabilityPropertyKey,
+ ComponentInstanceProperty property) {
+ return nodeTemplateOperation
+ .updateComponentInstanceCapabilityProperty(containerComponent, componentInstanceUniqueId, capabilityPropertyKey, property);
}
- public StorageOperationStatus updateComponentInstanceCapabilityProperties(Component containerComponent, String componentInstanceUniqueId) {
+ public StorageOperationStatus updateComponentInstanceCapabilityProperties(Component containerComponent,
+ String componentInstanceUniqueId) {
return convertComponentInstanceProperties(containerComponent, componentInstanceUniqueId)
- .map(instanceCapProps -> topologyTemplateOperation.updateComponentInstanceCapabilityProperties(containerComponent, componentInstanceUniqueId, instanceCapProps))
+ .map(instanceCapProps -> topologyTemplateOperation
+ .updateComponentInstanceCapabilityProperties(containerComponent, componentInstanceUniqueId, instanceCapProps))
.orElse(StorageOperationStatus.NOT_FOUND);
}
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 db6a8e100f..08f672b4c8 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
@@ -94,6 +94,7 @@ import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceInterface;
+import org.openecomp.sdc.be.model.ComponentInstanceOutput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
@@ -102,6 +103,7 @@ import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.MapInterfaceInstanceDataDefinition;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RelationshipImpl;
@@ -204,6 +206,8 @@ public class ModelConverter {
convertInputs(topologyTemplate, service);
+ convertOutputs(topologyTemplate, service);
+
convertProperties(topologyTemplate, service);
convertPolicies(topologyTemplate, service);
@@ -282,6 +286,7 @@ public class ModelConverter {
convertComponentInstances(topologyTemplate, resource);
convertRelations(topologyTemplate, resource);
convertInputs(topologyTemplate, resource);
+ convertOutputs(topologyTemplate, resource);
convertGroups(topologyTemplate, resource);
setCapabilitiesToComponentAndGroups(topologyTemplate, resource);
convertPolicies(topologyTemplate, resource);
@@ -355,6 +360,8 @@ public class ModelConverter {
setComponentInstancesInputsToComponent(topologyTemplate, component);
+ setComponentInstancesOutputsToComponent(topologyTemplate, component);
+
setComponentInstancesToComponent(topologyTemplate, component);
setComponentInstancesCapabilitiesToComponentAndCI(topologyTemplate, component);
@@ -1347,6 +1354,18 @@ public class ModelConverter {
}
}
+ private static void convertOutputs(final TopologyTemplate topologyTemplate, final Component component) {
+ final Map<String, AttributeDataDefinition> outputsMap = topologyTemplate.getOutputs();
+ if (MapUtils.isEmpty(outputsMap)) {
+ return;
+ }
+ final List<OutputDefinition> outputList = outputsMap.values()
+ .stream()
+ .map(OutputDefinition::new)
+ .collect(Collectors.toList());
+ component.setOutputs(outputList);
+ }
+
private static void convertProperties(Component component, TopologyTemplate topologyTemplate) {
List<PropertyDefinition> propertiesList = component.getProperties();
if (propertiesList != null && !propertiesList.isEmpty()) {
@@ -1573,6 +1592,21 @@ public class ModelConverter {
}
}
+ private static void setComponentInstancesOutputsToComponent(final TopologyTemplate topologyTemplate, final Component component) {
+ if (topologyTemplate.getInstOutputs() != null) {
+ final Map<String, List<ComponentInstanceOutput>> outputs = new HashMap<>();
+ for (final Entry<String, MapAttributesDataDefinition> entry : topologyTemplate.getInstOutputs().entrySet()) {
+ if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) {
+ final String key = entry.getKey();
+ final List<ComponentInstanceOutput> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream()
+ .map(e -> new ComponentInstanceOutput(e.getValue())).collect(Collectors.toList());
+ outputs.put(key, componentInstanceAttributes);
+ }
+ }
+ component.setComponentInstancesOutputs(outputs);
+ }
+ }
+
private static void setComponentInstancesPropertiesToComponent(TopologyTemplate topologyTemplate, Component component) {
if (topologyTemplate.getInstProperties() != null) {
Map<String, List<ComponentInstanceProperty>> properties = new HashMap<>();
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 1d1c8cd9dc..c7e34fcbfa 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
@@ -40,6 +40,7 @@ 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.OutputDefinition;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
@@ -70,6 +71,7 @@ public class UiComponentDataTransfer {
private List<PolicyDefinition> policies;
private Map<String, List<RequirementDefinition>> requirements;
private List<InputDefinition> inputs;
+ private List<OutputDefinition> outputs;
private List<GroupDefinition> groups;
private Map<String, InterfaceDefinition> interfaces;
@@ -82,7 +84,4 @@ public class UiComponentDataTransfer {
private List<AttributeDefinition> attributes;
private Map<String, List<ComponentInstanceInterface>> componentInstancesInterfaces;
- public UiComponentDataTransfer() {
- }
-
}