summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model/src/main')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java211
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java13
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java28
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java53
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceInstanceDefinition.java39
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/MapInterfaceDataDefinition.java42
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/MapInterfaceInstanceDataDefinition.java43
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/OperationInstance.java63
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java33
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java41
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java300
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java232
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/StorageOperationStatus.java3
14 files changed, 798 insertions, 308 deletions
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 7c5368887b..24386bc42e 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
@@ -25,17 +25,19 @@ import com.google.common.collect.Maps;
import org.apache.commons.collections.MapUtils;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.utils.MapUtil;
+import org.openecomp.sdc.be.datatypes.elements.*;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
-import static java.util.Collections.emptyList;
-import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
-import java.util.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -45,37 +47,38 @@ import static java.util.stream.Collectors.toMap;
import static org.apache.commons.collections.CollectionUtils.isEmpty;
import static org.apache.commons.collections.MapUtils.isEmpty;
-public abstract class Component {
-
- private ComponentMetadataDefinition componentMetadataDefinition;
- private Map<String, ArtifactDefinition> artifacts;
- private Map<String, ArtifactDefinition> deploymentArtifacts;
- private Map<String, ArtifactDefinition> toscaArtifacts;
- private List<CategoryDefinition> categories;
- private List<ComponentInstance> componentInstances;
- private List<RequirementCapabilityRelDef> componentInstancesRelations;
- private Map<String, List<ComponentInstanceInput>> componentInstancesInputs;
- private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties;
- private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes;
- private Map<String, List<CapabilityDefinition>> capabilities;
- private Map<String, List<RequirementDefinition>> requirements;
- private List<InputDefinition> inputs;
- private List<GroupDefinition> groups;
- private Map<String, PolicyDefinition> policies;
- private String derivedFromGenericType;
- private String derivedFromGenericVersion;
- private String toscaType;
- protected List<AdditionalInformationDefinition> additionalInformation;
- protected List<PropertyDefinition> properties;
- private Map<String, InterfaceDefinition> interfaces;
-
- public Map<String, InterfaceDefinition> getInterfaces() {
- return interfaces;
- }
-
- public void setInterfaces(Map<String, InterfaceDefinition> interfaces) {
- this.interfaces = interfaces;
- }
+public abstract class Component implements PropertiesOwner {
+
+ private ComponentMetadataDefinition componentMetadataDefinition;
+ private Map<String, ArtifactDefinition> artifacts;
+ private Map<String, ArtifactDefinition> deploymentArtifacts;
+ private Map<String, ArtifactDefinition> toscaArtifacts;
+ private List<CategoryDefinition> categories;
+ private List<ComponentInstance> componentInstances;
+ private List<RequirementCapabilityRelDef> componentInstancesRelations;
+ private Map<String, List<ComponentInstanceInput>> componentInstancesInputs;
+ private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties;
+ private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes;
+ private Map<String, List<CapabilityDefinition>> capabilities;
+ private Map<String, List<RequirementDefinition>> requirements;
+ private Map<String, List<ComponentInstanceInterface>> componentInstancesInterfaces;
+ private List<InputDefinition> inputs;
+ private List<GroupDefinition> groups;
+ private Map<String, PolicyDefinition> policies;
+ private String derivedFromGenericType;
+ private String derivedFromGenericVersion;
+ private String toscaType;
+ protected List<AdditionalInformationDefinition> additionalInformation;
+ protected List<PropertyDefinition> properties;
+ private Map<String, InterfaceDefinition> interfaces;
+
+ public Map<String, InterfaceDefinition> getInterfaces() {
+ return interfaces;
+ }
+
+ public void setInterfaces(Map<String, InterfaceDefinition> interfaces) {
+ this.interfaces = interfaces;
+ }
public Component(ComponentMetadataDefinition componentMetadataDefinition) {
this.componentMetadataDefinition = componentMetadataDefinition;
@@ -119,9 +122,10 @@ public abstract class Component {
this.toscaArtifacts = toscaArtifacts;
}
- public String getUniqueId() {
- return componentMetadataDefinition.getMetadataDataDefinition().getUniqueId();
- }
+ @Override
+ public String getUniqueId() {
+ return componentMetadataDefinition.getMetadataDataDefinition().getUniqueId();
+ }
public void setUniqueId(String uniqueId) {
componentMetadataDefinition.getMetadataDataDefinition().setUniqueId(uniqueId);
@@ -203,9 +207,10 @@ public abstract class Component {
this.componentMetadataDefinition.getMetadataDataDefinition().setLastUpdaterFullName(lastUpdaterFullName);
}
- public String getName() {
- return componentMetadataDefinition.getMetadataDataDefinition().getName();
- }
+ @Override
+ public String getName() {
+ return componentMetadataDefinition.getMetadataDataDefinition().getName();
+ }
public String getVersion() {
return componentMetadataDefinition.getMetadataDataDefinition().getVersion();
@@ -317,9 +322,10 @@ public abstract class Component {
this.categories = categories;
}
- public String getNormalizedName() {
- return componentMetadataDefinition.getMetadataDataDefinition().getNormalizedName();
- }
+ @Override
+ public String getNormalizedName() {
+ return componentMetadataDefinition.getMetadataDataDefinition().getNormalizedName();
+ }
public void setNormalizedName(String normalizedName) {
componentMetadataDefinition.getMetadataDataDefinition().setNormalizedName(normalizedName);
@@ -355,7 +361,7 @@ public abstract class Component {
public List<ComponentInstance> getComponentInstances() {
return componentInstances;
}
-
+
public List<ComponentInstance> safeGetComponentInstances() {
if(componentInstances != null) {
return componentInstances;
@@ -418,10 +424,14 @@ public abstract class Component {
return this.safeGetComponentInstanceEntity(comptInstanceId, this.componentInstancesInputs);
}
- public void setComponentInstancesProperties(
- Map<String, List<ComponentInstanceProperty>> resourceInstancesProperties) {
- this.componentInstancesProperties = resourceInstancesProperties;
- }
+ public List<ComponentInstanceInterface> safeGetComponentInstanceInterfaces(String cmptInstacneId) {
+ return this.safeGetComponentInstanceEntity(cmptInstacneId, this.componentInstancesInterfaces);
+ }
+
+ public void setComponentInstancesProperties(
+ Map<String, List<ComponentInstanceProperty>> resourceInstancesProperties) {
+ this.componentInstancesProperties = resourceInstancesProperties;
+ }
public Boolean getIsDeleted() {
return componentMetadataDefinition.getMetadataDataDefinition().isDeleted();
@@ -515,58 +525,69 @@ public abstract class Component {
.findAny();
}
- public void setGroups(List<GroupDefinition> groups) {
- this.groups = groups;
- }
+ public Map<String, List<ComponentInstanceInterface>> getComponentInstancesInterfaces() {
+ return componentInstancesInterfaces;
+ }
- public void addGroups(List<GroupDefinition> groupsToAdd) {
- if (groups == null) {
- groups = new ArrayList<>();
- }
- groups.addAll(groupsToAdd);
- }
+ public void setComponentInstancesInterfaces(Map<String, List<ComponentInstanceInterface>> componentInstancesInterfaces) {
+ this.componentInstancesInterfaces = componentInstancesInterfaces;
+ }
- public Map<String, PolicyDefinition> getPolicies() {
- return policies;
- }
+ public void setGroups(List<GroupDefinition> groups) {
+ this.groups = groups;
+ }
- public void setPolicies(Map<String, PolicyDefinition> policies) {
- this.policies = policies;
+ public void addGroups(List<GroupDefinition> groupsToAdd) {
+ if (groups == null) {
+ groups = new ArrayList<>();
}
+ groups.addAll(groupsToAdd);
+ }
- public List<PropertyDefinition> getProperties() {
- return properties;
- }
+ public Map<String, PolicyDefinition> getPolicies() {
+ return policies;
+ }
- public void setProperties(List<PropertyDefinition> properties) {
- this.properties = properties;
+ public void setPolicies(Map<String, PolicyDefinition> policies) {
+ this.policies = policies;
}
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((artifacts == null) ? 0 : artifacts.hashCode());
- result = prime * result + ((categories == null) ? 0 : categories.hashCode());
- result = prime * result + ((componentMetadataDefinition == null) ? 0 : componentMetadataDefinition.hashCode());
- result = prime * result + ((deploymentArtifacts == null) ? 0 : deploymentArtifacts.hashCode());
- result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode());
- result = prime * result + ((requirements == null) ? 0 : requirements.hashCode());
- result = prime * result + ((componentInstances == null) ? 0 : componentInstances.hashCode());
- result = prime * result
- + ((componentInstancesProperties == null) ? 0 : componentInstancesProperties.hashCode());
- result = prime * result
- + ((componentInstancesAttributes == null) ? 0 : componentInstancesAttributes.hashCode());
- result = prime * result + ((componentInstancesInputs == null) ? 0 : componentInstancesInputs.hashCode());
- result = prime * result + ((componentInstancesRelations == null) ? 0 : componentInstancesRelations.hashCode());
- result = prime * result + ((groups == null) ? 0 : groups.hashCode());
- result = prime * result + ((policies == null) ? 0 : policies.hashCode());
- result = prime * result + ((derivedFromGenericType == null) ? 0 : derivedFromGenericType.hashCode());
- result = prime * result + ((derivedFromGenericVersion == null) ? 0 : derivedFromGenericVersion.hashCode());
- result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode());
- result = prime * result + ((properties == null) ? 0 : properties.hashCode());
- return result;
- }
+ public List<PropertyDefinition> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List<PropertyDefinition> properties) {
+ this.properties = properties;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((artifacts == null) ? 0 : artifacts.hashCode());
+ result = prime * result + ((categories == null) ? 0 : categories.hashCode());
+ result = prime * result + ((componentMetadataDefinition == null) ? 0 : componentMetadataDefinition.hashCode());
+// result = prime * result + ((creatorUserId == null) ? 0 : creatorUserId.hashCode());
+// result = prime * result + ((creatorFullName == null) ? 0 : creatorFullName.hashCode());
+ result = prime * result + ((deploymentArtifacts == null) ? 0 : deploymentArtifacts.hashCode());
+// result = prime * result + ((lastUpdaterUserId == null) ? 0 : lastUpdaterUserId.hashCode());
+// result = prime * result + ((lastUpdaterFullName == null) ? 0 : lastUpdaterFullName.hashCode());
+ result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode());
+ result = prime * result + ((requirements == null) ? 0 : requirements.hashCode());
+ result = prime * result + ((componentInstances == null) ? 0 : componentInstances.hashCode());
+ result = prime * result
+ + ((componentInstancesProperties == null) ? 0 : componentInstancesProperties.hashCode());
+ result = prime * result
+ + ((componentInstancesAttributes == null) ? 0 : componentInstancesAttributes.hashCode());
+ result = prime * result + ((componentInstancesInputs == null) ? 0 : componentInstancesInputs.hashCode());
+ result = prime * result + ((componentInstancesRelations == null) ? 0 : componentInstancesRelations.hashCode());
+ result = prime * result + ((groups == null) ? 0 : groups.hashCode());
+ result = prime * result + ((policies == null) ? 0 : policies.hashCode());
+ result = prime * result + ((derivedFromGenericType == null) ? 0 : derivedFromGenericType.hashCode());
+ result = prime * result + ((derivedFromGenericVersion == null) ? 0 : derivedFromGenericVersion.hashCode());
+ result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode());
+ return result;
+ }
@Override
public boolean equals(Object obj) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java
index 306992d2fc..9d0877d8f9 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java
@@ -31,6 +31,7 @@ public class ComponentInstInputsMap {
private Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap;
private Map<String, List<ComponentInstancePropInput>> componentInstanceProperties;
+ private Map<String, List<ComponentInstancePropInput>> serviceProperties;
private Map<String, List<ComponentInstancePropInput>> policyProperties;
private Map<String, List<ComponentInstancePropInput>> groupProperties;
@@ -44,6 +45,9 @@ public class ComponentInstInputsMap {
if (isNotEmpty(policyProperties)) {
return singleMapEntry(policyProperties);
}
+ if(isNotEmpty(serviceProperties)) {
+ return singleMapEntry(serviceProperties);
+ }
if (isNotEmpty(groupProperties)) {
return singleMapEntry(groupProperties);
}
@@ -79,6 +83,15 @@ public class ComponentInstInputsMap {
this.policyProperties = policyProperties;
}
+ public Map<String, List<ComponentInstancePropInput>> getServiceProperties() {
+ return serviceProperties;
+ }
+
+ public void setServiceProperties(
+ Map<String, List<ComponentInstancePropInput>> serviceProperties) {
+ this.serviceProperties = serviceProperties;
+ }
+
public Map<String, List<ComponentInstancePropInput>> getGroupProperties() {
return groupProperties;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java
index ef9b409735..0d18676acc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java
@@ -20,12 +20,14 @@
package org.openecomp.sdc.be.model;
+import org.apache.commons.collections.MapUtils;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertiesOwner;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -36,6 +38,8 @@ public class ComponentInstance extends ComponentInstanceDataDefinition implement
private Map<String, ArtifactDefinition> deploymentArtifacts;
private Map<String, ArtifactDefinition> artifacts;
private List<GroupInstance> groupInstances;
+ private Map<String, Object> interfaces;
+ private List<PropertyDefinition> properties;
private CINodeFilterDataDefinition nodeFilter;
public ComponentInstance() {
@@ -109,6 +113,30 @@ public class ComponentInstance extends ComponentInstanceDataDefinition implement
return safeGetInformationalArtifacts().get(artifactLabel) != null;
}
+ public Map<String, Object> getInterfaces() {
+ return interfaces;
+ }
+
+ public void setInterfaces(Map<String, Object> interfaces) {
+ this.interfaces = interfaces;
+ }
+
+ public void addInterface(String interfaceName, Object interfaceDefinition) {
+ if(MapUtils.isEmpty(this.interfaces)) {
+ this.interfaces = new HashMap<>();
+ }
+
+ this.interfaces.put(interfaceName, interfaceDefinition);
+ }
+
+ public List<PropertyDefinition> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List<PropertyDefinition> properties) {
+ this.properties = properties;
+ }
+
public CINodeFilterDataDefinition getNodeFilter() {
return nodeFilter;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java
new file mode 100644
index 0000000000..5482a51d7a
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdc.be.model;
+
+import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition;
+
+public class ComponentInstanceInterface extends InterfaceDefinition {
+ private String interfaceId;
+ private InterfaceInstanceDataDefinition interfaceInstanceDataDefinition;
+
+ public ComponentInstanceInterface(String interfaceId,
+ InterfaceInstanceDataDefinition interfaceInstanceDataDefinition) {
+ this.interfaceId = interfaceId;
+ this.interfaceInstanceDataDefinition = interfaceInstanceDataDefinition;
+ }
+
+ public ComponentInstanceInterface(String interfaceId, InterfaceDataDefinition interfaceDataDefinition) {
+ super(interfaceDataDefinition);
+ this.interfaceId = interfaceId;
+ }
+
+ public String getInterfaceId() {
+ return interfaceId;
+ }
+
+ public void setInterfaceId(String interfaceId) {
+ this.interfaceId = interfaceId;
+ }
+
+ public InterfaceInstanceDataDefinition getInterfaceInstanceDataDefinition() {
+ return interfaceInstanceDataDefinition;
+ }
+
+ public void setInterfaceInstanceDataDefinition(
+ InterfaceInstanceDataDefinition interfaceInstanceDataDefinition) {
+ this.interfaceInstanceDataDefinition = interfaceInstanceDataDefinition;
+ }
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceInstanceDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceInstanceDefinition.java
new file mode 100644
index 0000000000..d16370d151
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceInstanceDefinition.java
@@ -0,0 +1,39 @@
+package org.openecomp.sdc.be.model;
+
+import org.apache.commons.collections.MapUtils;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationInstance;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+public class InterfaceInstanceDefinition extends InterfaceInstanceDataDefinition {
+
+ public InterfaceInstanceDefinition(InterfaceInstanceDataDefinition inter) {
+ super(inter);
+ }
+
+ public InterfaceInstanceDefinition(){}
+
+ public Map<String, Object> getInputs() {
+ return this.inputs;
+ }
+
+ public void setInputs(
+ Map<String, Object> inputs) {
+ this.inputs = inputs;
+ }
+
+ public Map<String, OperationInstance> getOperations() {
+ return operations;
+ }
+
+ public void addInstanceOperation(String operationName, OperationInstance operation) {
+ if(MapUtils.isEmpty(this.operations)) {
+ this.operations = new HashMap<>();
+ }
+
+ this.operations.put(operationName, operation);
+ }
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/MapInterfaceDataDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/MapInterfaceDataDefinition.java
new file mode 100644
index 0000000000..c58131f542
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/MapInterfaceDataDefinition.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdc.be.model;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
+
+import java.util.Map;
+
+public class MapInterfaceDataDefinition extends MapDataDefinition<InterfaceDataDefinition> {
+
+ public MapInterfaceDataDefinition() {
+
+ }
+
+ @JsonCreator
+ public MapInterfaceDataDefinition(Map<String, InterfaceDataDefinition > mapToscaDataDefinition) {
+ super(mapToscaDataDefinition);
+ }
+
+ @JsonValue
+ @Override
+ public Map<String, InterfaceDataDefinition> getMapToscaDataDefinition() {
+ return mapToscaDataDefinition;
+ }
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/MapInterfaceInstanceDataDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/MapInterfaceInstanceDataDefinition.java
new file mode 100644
index 0000000000..6efa0ed404
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/MapInterfaceInstanceDataDefinition.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdc.be.model;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
+
+import java.util.Map;
+
+public class MapInterfaceInstanceDataDefinition extends
+ MapDataDefinition<InterfaceInstanceDataDefinition> {
+
+ public MapInterfaceInstanceDataDefinition() {
+
+ }
+
+ @JsonCreator
+ public MapInterfaceInstanceDataDefinition(Map<String, InterfaceInstanceDataDefinition> mapToscaDataDefinition) {
+ super(mapToscaDataDefinition);
+ }
+
+ @JsonValue
+ @Override
+ public Map<String, InterfaceInstanceDataDefinition> getMapToscaDataDefinition() {
+ return mapToscaDataDefinition;
+ }
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/OperationInstance.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/OperationInstance.java
new file mode 100644
index 0000000000..fb958eb7b6
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/OperationInstance.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdc.be.model;
+
+import org.openecomp.sdc.be.datatypes.elements.OperationImplementation;
+
+import java.util.Map;
+import java.util.Objects;
+
+public class OperationInstance/* extends Operation*/ {
+ private OperationImplementation implementation;
+ private Map<String, Object> inputs;
+
+
+ public OperationImplementation getImplementation() {
+ return implementation;
+ }
+
+ public void setImplementation(OperationImplementation implementation) {
+ this.implementation = implementation;
+ }
+
+ public Map<String, Object> getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(Map<String, Object> inputs) {
+ this.inputs = inputs;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof OperationInstance)) {
+ return false;
+ }
+ OperationInstance that = (OperationInstance) o;
+ return Objects.equals(implementation, that.implementation) &&
+ Objects.equals(inputs, that.inputs);
+ }
+
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(implementation, inputs);
+ }
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
index f3996ed42b..0603538833 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
@@ -42,12 +42,15 @@ public class Resource extends Component {
private List<PropertyDefinition> attributes;
- private List<String> defaultCapabilities;
-
- public Resource() {
- super(new ResourceMetadataDefinition());
- this.getComponentMetadataDefinition().getMetadataDataDefinition().setComponentType(ComponentTypeEnum.RESOURCE);
- }
+ private Map<String, InterfaceInstanceDefinition> instInterfaces;
+
+ private List<String> defaultCapabilities;
+
+ public Resource() {
+ super(new ResourceMetadataDefinition());
+ this.getComponentMetadataDefinition().getMetadataDataDefinition()
+ .setComponentType(ComponentTypeEnum.RESOURCE);
+ }
public Resource(ComponentMetadataDefinition componentMetadataDefinition) {
super(componentMetadataDefinition);
@@ -101,10 +104,20 @@ public class Resource extends Component {
this.attributes = attributes;
}
- public Boolean isAbstract() {
- return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
- .isAbstract();
- }
+ public Map<String, InterfaceInstanceDefinition> getInstInterfaces() {
+ return instInterfaces;
+ }
+
+ public void setInstInterfaces(
+ Map<String, InterfaceInstanceDefinition> instInterfaces) {
+ this.instInterfaces = instInterfaces;
+ }
+
+ public Boolean isAbstract() {
+ return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition()
+ .getMetadataDataDefinition())
+ .isAbstract();
+ }
public void setAbstract(Boolean isAbstract) {
((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java
index 823ababcc0..3c1ca26879 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java
@@ -22,6 +22,10 @@ package org.openecomp.sdc.be.model;
import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -51,7 +55,6 @@ public class Service extends Component {
private Map<String, ArtifactDefinition> serviceApiArtifacts;
private Map<String, ForwardingPathDataDefinition> forwardingPaths;
-
public Map<String, ArtifactDefinition> getServiceApiArtifacts() {
return serviceApiArtifacts;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java
index 0d7b14abd1..ac9f196a92 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java
@@ -25,6 +25,8 @@ import org.openecomp.sdc.be.datatypes.elements.*;
import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.MapInterfaceDataDefinition;
+import org.openecomp.sdc.be.model.MapInterfaceInstanceDataDefinition;
import org.openecomp.sdc.be.model.jsontitan.enums.JsonConstantKeysEnum;
import java.util.HashMap;
@@ -54,6 +56,8 @@ public class TopologyTemplate extends ToscaElement{
private Map<String, MapArtifactDataDefinition> instDeploymentArtifacts;
private Map<String, MapArtifactDataDefinition> instanceArtifacts;
private Map<String, InterfaceDataDefinition> interfaces;
+ private Map<String, MapInterfaceInstanceDataDefinition> instInterfaces;
+ private Map<String, MapInterfaceDataDefinition> componentInstInterfaces;
//Component Instances External References (instanceId -> ExternalRefsMap)
//-----------------------------------------------------------------------
@@ -76,6 +80,43 @@ public class TopologyTemplate extends ToscaElement{
this.interfaces = interfaces;
}
+ public Map<String, MapInterfaceInstanceDataDefinition> getInstInterfaces() {
+ return instInterfaces;
+ }
+
+ public void setInstInterfaces(
+ Map<String, MapInterfaceInstanceDataDefinition> instInterfaces) {
+ this.instInterfaces = instInterfaces;
+ }
+
+ public void addInstInterface(String compId, MapInterfaceInstanceDataDefinition
+ mapInterfaceInstanceDataDefinition) {
+ if(MapUtils.isEmpty(this.instInterfaces)) {
+ this.instInterfaces = new HashMap<>();
+ }
+
+ this.instInterfaces.put(compId, mapInterfaceInstanceDataDefinition);
+ }
+
+ public Map<String, MapInterfaceDataDefinition> getComponentInstInterfaces() {
+ return componentInstInterfaces;
+ }
+
+ public void setComponentInstInterfaces(
+ Map<String, MapInterfaceDataDefinition> componentInstInterfaces) {
+ this.componentInstInterfaces = componentInstInterfaces;
+ }
+
+ public void addComponentInstanceInterfaceMap(String componentInstanceId, MapInterfaceDataDefinition
+ mapInterfaceDataDefinition) {
+ if(MapUtils.isEmpty(this.componentInstInterfaces)) {
+ this.componentInstInterfaces = new HashMap<>();
+ }
+
+ this.componentInstInterfaces.put(componentInstanceId, mapInterfaceDataDefinition);
+ }
+
+
public Map<String, PropertyDataDefinition> getInputs() {
return inputs;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
index 5c06e97bf3..d8a4fc4af1 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
@@ -25,6 +25,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
@@ -35,8 +36,6 @@ import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.*;
import org.openecomp.sdc.be.datatypes.enums.*;
import org.openecomp.sdc.be.model.*;
-import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
-import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
import org.openecomp.sdc.be.model.catalog.CatalogComponent;
import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
@@ -971,7 +970,35 @@ public class ToscaOperationFacade {
}
- public Either<List<InputDefinition>, StorageOperationStatus> updateInputsToComponent(List<InputDefinition> inputs, String componentId) {
+ public Either<List<InputDefinition>, StorageOperationStatus> getComponentInputs(String componentId) {
+
+ Either<GraphVertex, TitanOperationStatus> getVertexEither = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
+ if (getVertexEither.isRight()) {
+ log.debug("Couldn't fetch component with and unique id {}, error: {}", componentId, getVertexEither.right().value());
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVertexEither.right().value()));
+
+ }
+
+ Either<ToscaElement, StorageOperationStatus> toscaElement =
+ topologyTemplateOperation.getToscaElement(componentId);
+ if(toscaElement.isRight()) {
+ return Either.right(toscaElement.right().value());
+ }
+
+ TopologyTemplate topologyTemplate = (TopologyTemplate) toscaElement.left().value();
+
+ Map<String, PropertyDataDefinition> inputsMap = topologyTemplate.getInputs();
+
+ List<InputDefinition> inputs = new ArrayList<>();
+ if(MapUtils.isNotEmpty(inputsMap)) {
+ inputs =
+ inputsMap.values().stream().map(p -> new InputDefinition(p)).collect(Collectors.toList());
+ }
+
+ return Either.left(inputs);
+ }
+
+ public Either<List<InputDefinition>, StorageOperationStatus> updateInputsToComponent(List<InputDefinition> inputs, String componentId) {
Either<GraphVertex, TitanOperationStatus> getVertexEither = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
if (getVertexEither.isRight()) {
@@ -1135,7 +1162,7 @@ public class ToscaOperationFacade {
}
return Either.left(instProperties);
}
-
+
public Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addComponentInstancePropertiesToComponent(Component containerComponent, Map<String, List<ComponentInstanceProperty>> instProperties) {
requireNonNull(instProperties);
StorageOperationStatus status;
@@ -1984,91 +2011,97 @@ public class ToscaOperationFacade {
return nodeTemplateOperation.generateCustomizationUUIDOnInstanceGroup(componentId, instanceId, groupInstances);
}
- /*
- * adds property to a resource
- * @warn this method has SIDE EFFECT on ownerId ,use it with caution
- * */
- public Either<PropertyDefinition, StorageOperationStatus> addPropertyToResource(String propertyName, PropertyDefinition newPropertyDefinition, Resource resource) {
-
- Either<PropertyDefinition, StorageOperationStatus> result = null;
- Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
- newPropertyDefinition.setName(propertyName);
- StorageOperationStatus status = getToscaElementOperation(resource).addToscaDataToToscaElement(resource.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, newPropertyDefinition, JsonPresentationFields.NAME);
- if (status != StorageOperationStatus.OK) {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, propertyName, resource.getName(), status);
- result = Either.right(status);
- }
- if (result == null) {
- ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreProperties(false);
- getUpdatedComponentRes = getToscaElement(resource.getUniqueId(), filter);
- if (getUpdatedComponentRes.isRight()) {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_UPDATED_RESOURCE_STATUS_IS, resource.getUniqueId(), getUpdatedComponentRes.right().value());
- result = Either.right(status);
- }
- }
- if (result == null) {
- PropertyDefinition newProperty = null;
- List<PropertyDefinition> properties = ((Resource) getUpdatedComponentRes.left().value()).getProperties();
- if (CollectionUtils.isNotEmpty(properties)) {
- Optional<PropertyDefinition> newPropertyOptional = properties.stream().filter(p -> p.getName().equals(propertyName)).findAny();
- if (newPropertyOptional.isPresent()) {
- newProperty = newPropertyOptional.get();
- }
- }
- if (newProperty == null) {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_FIND_RECENTLY_ADDED_PROPERTY_ON_THE_RESOURCE_STATUS_IS, propertyName, resource.getUniqueId(), StorageOperationStatus.NOT_FOUND);
- result = Either.right(StorageOperationStatus.NOT_FOUND);
- } else {
- result = Either.left(newProperty);
- }
- }
- return result;
- }
-
- public StorageOperationStatus deletePropertyOfResource(Resource resource, String propertyName) {
- return getToscaElementOperation(resource).deleteToscaDataElement(resource.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, propertyName, JsonPresentationFields.NAME);
- }
-
- public StorageOperationStatus deleteAttributeOfResource(Component component, String attributeName) {
- return getToscaElementOperation(component).deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, attributeName, JsonPresentationFields.NAME);
- }
+ public Either<PropertyDefinition, StorageOperationStatus> addPropertyToComponent(String propertyName,
+ PropertyDefinition newPropertyDefinition,
+ Component component) {
+
+ Either<PropertyDefinition, StorageOperationStatus> result = null;
+ Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
+ newPropertyDefinition.setName(propertyName);
+
+ StorageOperationStatus status = getToscaElementOperation(component)
+ .addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, newPropertyDefinition, JsonPresentationFields.NAME);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the property {} to the component {}. Status is {}. ", propertyName, component.getName(), status);
+ result = Either.right(status);
+ }
+ if (result == null) {
+ ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreProperties(false);
+ filter.setIgnoreInputs(false);
+ getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
+ if (getUpdatedComponentRes.isRight()) {
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get updated component {}. Status is {}. ", component.getUniqueId(), getUpdatedComponentRes.right().value());
+ result = Either.right(status);
+ }
+ }
+ if (result == null) {
+ PropertyDefinition newProperty = null;
+ List<PropertyDefinition> properties =
+ (getUpdatedComponentRes.left().value()).getProperties();
+ if (CollectionUtils.isNotEmpty(properties)) {
+ Optional<PropertyDefinition> propertyOptional = properties.stream().filter(
+ propertyEntry -> propertyEntry.getName().equals(propertyName)).findAny();
+ if (propertyOptional.isPresent()) {
+ newProperty = propertyOptional.get();
+ }
+ }
+ if (newProperty == null) {
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to find recently added property {} on the component {}. Status is {}. ", propertyName, component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+ result = Either.right(StorageOperationStatus.NOT_FOUND);
+ } else {
+ result = Either.left(newProperty);
+ }
+ }
+ return result;
+ }
+ public StorageOperationStatus deletePropertyOfComponent(Component component, String propertyName) {
+ return getToscaElementOperation(component).deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, propertyName, JsonPresentationFields.NAME);
+ }
+
+ public StorageOperationStatus deleteAttributeOfResource(Component component, String attributeName) {
+ return getToscaElementOperation(component).deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, attributeName, JsonPresentationFields.NAME);
+ }
public StorageOperationStatus deleteInputOfResource(Component resource, String inputName) {
return getToscaElementOperation(resource).deleteToscaDataElement(resource.getUniqueId(), EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, inputName, JsonPresentationFields.NAME);
}
- public Either<PropertyDefinition, StorageOperationStatus> updatePropertyOfResource(Resource resource, PropertyDefinition newPropertyDefinition) {
-
- Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
- Either<PropertyDefinition, StorageOperationStatus> result = null;
- StorageOperationStatus status = getToscaElementOperation(resource).updateToscaDataOfToscaElement(resource.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, newPropertyDefinition, JsonPresentationFields.NAME);
- if (status != StorageOperationStatus.OK) {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newPropertyDefinition.getName(), resource.getName(), status);
- result = Either.right(status);
- }
- if (result == null) {
- ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreProperties(false);
- getUpdatedComponentRes = getToscaElement(resource.getUniqueId(), filter);
- if (getUpdatedComponentRes.isRight()) {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_UPDATED_RESOURCE_STATUS_IS, resource.getUniqueId(), getUpdatedComponentRes.right().value());
- result = Either.right(status);
- }
- }
- if (result == null) {
- Optional<PropertyDefinition> newProperty = ((Resource) 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(), resource.getUniqueId(), StorageOperationStatus.NOT_FOUND);
- result = Either.right(StorageOperationStatus.NOT_FOUND);
- }
- }
- return result;
- }
-
- public Either<PropertyDefinition, StorageOperationStatus> addAttributeOfResource(Component component, PropertyDefinition newAttributeDef) {
+ public Either<PropertyDefinition, StorageOperationStatus> updatePropertyOfComponent(Component component,
+ PropertyDefinition newPropertyDefinition) {
+
+ Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
+ Either<PropertyDefinition, StorageOperationStatus> result = null;
+ StorageOperationStatus status = getToscaElementOperation(component).updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, 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<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;
+ }
+
+
+
+ public Either<PropertyDefinition, StorageOperationStatus> addAttributeOfResource(Component component, PropertyDefinition newAttributeDef) {
Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
Either<PropertyDefinition, StorageOperationStatus> result = null;
@@ -2263,10 +2296,11 @@ public class ToscaOperationFacade {
.orElse(StorageOperationStatus.NOT_FOUND);
}
- public StorageOperationStatus updateComponentCalculatedCapabilitiesProperties(Component containerComponent) {
- Map<String, MapCapabilityProperty> MapCapabilityPropertyMap = convertComponentCapabilitiesProperties(containerComponent);
- return nodeTemplateOperation.overrideComponentCapabilitiesProperties(containerComponent, MapCapabilityPropertyMap);
- }
+ public StorageOperationStatus updateComponentCalculatedCapabilitiesProperties(Component containerComponent) {
+ Map<String, MapCapabilityProperty> mapCapabiltyPropertyMap =
+ convertComponentCapabilitiesProperties(containerComponent);
+ return nodeTemplateOperation.overrideComponentCapabilitiesProperties(containerComponent, mapCapabiltyPropertyMap);
+ }
public StorageOperationStatus deleteAllCalculatedCapabilitiesRequirements(String topologyTemplateId) {
StorageOperationStatus status = topologyTemplateOperation.removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAPABILITIES, VertexTypeEnum.CALCULATED_CAPABILITIES);
@@ -2309,11 +2343,24 @@ public class ToscaOperationFacade {
return topologyTemplateOperation.getComponentInstanceCapabilityProperties(componentId, instanceId, capabilityName, capabilityType, ownerId);
}
- private Map<String, MapCapabilityProperty> convertComponentCapabilitiesProperties(Component currComponent) {
- Map<String, MapCapabilityProperty> map = ModelConverter.extractCapabilityPropertiesFromGroups(currComponent.getGroups(), true);
- map.putAll(ModelConverter.extractCapabilityProperteisFromInstances(currComponent.getComponentInstances(), true));
- return map;
- }
+ private MapInterfaceDataDefinition convertComponentInstanceInterfaces(Component currComponent,
+ String componentInstanceId) {
+ MapInterfaceDataDefinition mapInterfaceDataDefinition = new MapInterfaceDataDefinition();
+ List<ComponentInstanceInterface> componentInterface = currComponent.getComponentInstancesInterfaces().get(componentInstanceId);
+
+ if(CollectionUtils.isNotEmpty(componentInterface)) {
+ componentInterface.stream().forEach(interfaceDef -> mapInterfaceDataDefinition.put
+ (interfaceDef.getUniqueId(), interfaceDef));
+ }
+
+ return mapInterfaceDataDefinition;
+ }
+
+ private Map<String, MapCapabilityProperty> convertComponentCapabilitiesProperties(Component currComponent) {
+ Map<String, MapCapabilityProperty> map = ModelConverter.extractCapabilityPropertiesFromGroups(currComponent.getGroups(), true);
+ map.putAll(ModelConverter.extractCapabilityProperteisFromInstances(currComponent.getComponentInstances(), true));
+ return map;
+ }
private Optional<MapCapabilityProperty> convertComponentInstanceProperties(Component component, String instanceId) {
return component.fetchInstanceById(instanceId)
@@ -2433,4 +2480,71 @@ public class ToscaOperationFacade {
throw new StorageException(status);
}
+ public Either<Boolean, StorageOperationStatus> isComponentInUse(String componentId) {
+ final List<EdgeLabelEnum> forbiddenEdgeLabelEnums = Arrays.asList(EdgeLabelEnum.INSTANCE_OF, EdgeLabelEnum.PROXY_OF, EdgeLabelEnum.ALLOTTED_OF);
+ Either<GraphVertex, TitanOperationStatus> vertexById = titanDao.getVertexById(componentId);
+ if (vertexById.isLeft()) {
+ for (EdgeLabelEnum edgeLabelEnum : forbiddenEdgeLabelEnums) {
+ Iterator<Edge> edgeItr = vertexById.left().value().getVertex().edges(Direction.IN, edgeLabelEnum.name());
+ if(edgeItr != null && edgeItr.hasNext()){
+ return Either.left(true);
+ }
+ }
+ }
+ return Either.left(false);
+ }
+
+ public Either<List<Component>, StorageOperationStatus> getComponentListByInvariantUuid
+ (String componentInvariantUuid, Map<GraphPropertyEnum, Object> additionalPropertiesToMatch) {
+
+ Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ if (MapUtils.isNotEmpty(additionalPropertiesToMatch)) {
+ propertiesToMatch.putAll(additionalPropertiesToMatch);
+ }
+ propertiesToMatch.put(GraphPropertyEnum.INVARIANT_UUID, componentInvariantUuid);
+
+ Either<List<GraphVertex>, TitanOperationStatus> vertexEither = titanDao.getByCriteria(null, propertiesToMatch, JsonParseFlagEnum.ParseMetadata);
+
+ if (vertexEither.isRight()) {
+ log.debug("Couldn't fetch metadata for component with type {} and invariantUUId {}, error: {}", componentInvariantUuid, vertexEither.right().value());
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(vertexEither.right().value()));
+ }
+ List<GraphVertex> vertexList = vertexEither.isLeft() ? vertexEither.left().value() : null;
+
+ if (vertexList == null || vertexList.isEmpty()) {
+ log.debug("Component with invariantUUId {} was not found", componentInvariantUuid);
+ return Either.right(StorageOperationStatus.NOT_FOUND);
+ }
+
+ ArrayList<Component> components = new ArrayList<>();
+ for (GraphVertex vertex : vertexList) {
+ Either<Component, StorageOperationStatus> toscaElementByOperation = getToscaElementByOperation(vertex);
+ if (toscaElementByOperation.isRight()) {
+ log.debug("Could not fetch the following Component by Invariant UUID {}", vertex.getUniqueId());
+ return Either.right(toscaElementByOperation.right().value());
+ }
+ components.add(toscaElementByOperation.left().value());
+ }
+
+ return Either.left(components);
+ }
+
+ public Either<List<Component>, StorageOperationStatus> getParentComponents(String componentId) {
+ List<Component> parentComponents = new ArrayList<>();
+ final List<EdgeLabelEnum> relationEdgeLabelEnums = Arrays.asList(EdgeLabelEnum.INSTANCE_OF, EdgeLabelEnum.PROXY_OF);
+ Either<GraphVertex, TitanOperationStatus> vertexById = titanDao.getVertexById(componentId);
+ if (vertexById.isLeft()) {
+ for (EdgeLabelEnum edgeLabelEnum : relationEdgeLabelEnums) {
+ Either<GraphVertex, TitanOperationStatus> parentVertexEither = titanDao.getParentVertex(vertexById.left().value(), edgeLabelEnum, JsonParseFlagEnum.ParseJson);
+ if(parentVertexEither.isLeft()){
+ Either<Component, StorageOperationStatus> componentEither = getToscaElement(parentVertexEither.left().value().getUniqueId());
+ if(componentEither.isLeft()){
+ parentComponents.add(componentEither.left().value());
+ }
+ }
+ }
+ }
+ return Either.left(parentComponents);
+ }
+
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
index 569491cef6..6a49509d6f 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
@@ -22,68 +22,17 @@ package org.openecomp.sdc.be.model.jsontitan.utils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
-import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.*;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.AdditionalInformationDefinition;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceInput;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.DistributionStatusEnum;
-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.InterfaceDefinition;
-import org.openecomp.sdc.be.model.PolicyDefinition;
-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.Resource;
-import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.jsontitan.datamodel.NodeType;
import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
@@ -95,6 +44,11 @@ import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
import org.openecomp.sdc.be.resources.data.ServiceMetadataData;
import org.openecomp.sdc.common.log.wrappers.Logger;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
public class ModelConverter {
public static final String CAP_PROP_DELIM = "#";
private static final Logger log = Logger.getLogger(ModelConverter.class);
@@ -171,7 +125,11 @@ public class ModelConverter {
convertComponentInstances(topologyTemplate, service);
- convertInputs(topologyTemplate, service);
+ convertInputs(topologyTemplate, service);
+
+ convertProperties(topologyTemplate, service);
+
+ convertPolicies(topologyTemplate, service);
convertGroups(topologyTemplate, service);
@@ -591,8 +549,14 @@ public class ModelConverter {
component.setDerivedFromGenericType(toscaElement.getDerivedFromGenericType());
component.setDerivedFromGenericVersion(toscaElement.getDerivedFromGenericVersion());
- //archive
- component.setArchived(toscaElement.isArchived() == null ? false : toscaElement.isArchived());
+ Map<String, PropertyDataDefinition> properties = toscaElement.getProperties();
+ if(MapUtils.isNotEmpty(properties)) {
+ List<PropertyDefinition> propertiesMap = properties.values().stream().map(x -> new PropertyDefinition(x)).collect(Collectors.toList());
+ component.setProperties(propertiesMap);
+ }
+
+ //archive
+ component.setArchived(toscaElement.isArchived() == null ? false : toscaElement.isArchived());
//component.setArchiveTime(toscaElement.getArchiveTime() == null ? 0L : toscaElement.getArchiveTime());
@@ -632,14 +596,6 @@ public class ModelConverter {
component.setContactId((String) toscaElement.getMetadataValue(JsonPresentationFields.CONTACT_ID));
component.setUUID((String) toscaElement.getMetadataValue(JsonPresentationFields.UUID));
component.setIsDeleted((Boolean) toscaElement.getMetadataValue(JsonPresentationFields.IS_DELETED));
-
-
- Map<String, PropertyDataDefinition> properties = toscaElement.getProperties();
- if (properties != null && !properties.isEmpty()) {
- List<PropertyDefinition> propertiesMap = properties.values().stream().map(PropertyDefinition::new).collect(Collectors.toList());
- ((Resource) component).setProperties(propertiesMap);
- }
-
component.setToscaType(toscaElement.getToscaType().getValue());
}
@@ -944,34 +900,35 @@ public class ModelConverter {
ComponentTypeEnum componentType = component.getComponentType();
topologyTemplate = new TopologyTemplate();
- if (componentType == ComponentTypeEnum.RESOURCE) {
- Resource resource = (Resource) component;
- topologyTemplate.setResourceType(resource.getResourceType());
- topologyTemplate.setMetadataValue(JsonPresentationFields.CSAR_UUID, resource.getCsarUUID());
- topologyTemplate.setMetadataValue(JsonPresentationFields.CSAR_VERSION, resource.getCsarVersion());
- topologyTemplate.setMetadataValue(JsonPresentationFields.IMPORTED_TOSCA_CHECKSUM, resource.getImportedToscaChecksum());
- convertInterfaces(resource, topologyTemplate);
- }
- if (componentType == ComponentTypeEnum.SERVICE) {
- convertServiceSpecificEntities((Service) component, topologyTemplate);
- }
- convertCommonToscaData(component, topologyTemplate);
- convertArtifacts(component, topologyTemplate);
+ if (componentType == ComponentTypeEnum.RESOURCE) {
+ Resource resource = (Resource) component;
+ topologyTemplate.setResourceType(resource.getResourceType());
+ topologyTemplate.setMetadataValue(JsonPresentationFields.CSAR_UUID, resource.getCsarUUID());
+ topologyTemplate.setMetadataValue(JsonPresentationFields.CSAR_VERSION, resource.getCsarVersion());
+ topologyTemplate.setMetadataValue(JsonPresentationFields.IMPORTED_TOSCA_CHECKSUM, resource.getImportedToscaChecksum());
+ convertTopologyTemplateInterfaces(resource, topologyTemplate);
+ }
+ if (componentType == ComponentTypeEnum.SERVICE) {
+ convertServiceSpecificEntities((Service) component, topologyTemplate);
+ }
+ convertCommonToscaData(component, topologyTemplate);
+ convertArtifacts(component, topologyTemplate);
convertAdditionalInformation(component, topologyTemplate);
convertComponentInstances(component, topologyTemplate);
- convertInputs(component, topologyTemplate);
- convertCapabilities(component, topologyTemplate);
- convertGroups(component, topologyTemplate);
- convertPolicies(component, topologyTemplate);
- convertRequirements(component, topologyTemplate);
- convertRelationsToComposition(component, topologyTemplate);
+ convertInputs(component, topologyTemplate);
+ convertProperties(component, topologyTemplate);
+ convertCapabilities(component, topologyTemplate);
+ convertGroups(component, topologyTemplate);
+ convertPolicies(component, topologyTemplate);
+ convertRequirements(component, topologyTemplate);
+ convertRelationsToComposition(component, topologyTemplate);
return topologyTemplate;
}
- private static void convertInterfaces(Resource resource, TopologyTemplate topologyTemplate) {
+ private static void convertTopologyTemplateInterfaces(Resource resource, TopologyTemplate topologyTemplate) {
Map<String, InterfaceDefinition> interfaces = resource.getInterfaces();
if (interfaces != null && !interfaces.isEmpty()) {
Map<String, InterfaceDataDefinition> copy = interfaces.entrySet().stream()
@@ -1047,17 +1004,36 @@ public class ModelConverter {
}
- private static void convertInputs(TopologyTemplate topologyTemplate, Component component) {
- Map<String, PropertyDataDefinition> inputsMap = topologyTemplate.getInputs();
- if (inputsMap != null && !inputsMap.isEmpty()) {
- List<InputDefinition> inputsList = inputsMap.values()
- .stream()
- .map(InputDefinition::new)
- .collect(Collectors.toList());
- component.setInputs(inputsList);
- }
+ private static void convertInputs(TopologyTemplate topologyTemplate, Component component) {
+ Map<String, PropertyDataDefinition> inputsMap = topologyTemplate.getInputs();
+ if (inputsMap != null && !inputsMap.isEmpty()) {
+ List<InputDefinition> inputsList = inputsMap.values()
+ .stream()
+ .map(InputDefinition::new)
+ .collect(Collectors.toList());
+ component.setInputs(inputsList);
+ }
+ }
+
+ private static void convertProperties(Component component, TopologyTemplate topologyTemplate) {
+ List<PropertyDefinition> propertiesList = component.getProperties();
+ if (propertiesList != null && !propertiesList.isEmpty()) {
+ Map<String, PropertyDataDefinition> propertiesMap = propertiesList.stream().map(i -> new PropertyDataDefinition(i)).collect(Collectors.toMap(i -> i.getName(), i -> i));
+ topologyTemplate.setProperties(propertiesMap);
+ }
+
+ }
+
+ private static void convertProperties(TopologyTemplate topologyTemplate, Component component) {
+ Map<String, PropertyDataDefinition> proeprtiesMap = topologyTemplate.getProperties();
+ if (proeprtiesMap != null && !proeprtiesMap.isEmpty()) {
+ Map<String, PropertyDefinition> copy = proeprtiesMap.entrySet().stream()
+ .collect(Collectors.toMap(entry -> entry.getKey(), entry -> new PropertyDefinition
+ (entry.getValue())));
+ component.setProperties(new ArrayList<>(copy.values()));
+ }
+ }
- }
private static void convertCommonToscaData(Component component, ToscaElement toscaElement) {
toscaElement.setUUID(component.getUUID());
@@ -1131,6 +1107,14 @@ public class ModelConverter {
List<GroupInstance> groupInstances = topologyTemplate.getInstGroups().get(key).getMapToscaDataDefinition().entrySet().stream().map(e -> new GroupInstance(e.getValue())).collect(Collectors.toList());
currComponentInstance.setGroupInstances(groupInstances);
}
+ if(topologyTemplate.getInstProperties() != null && topologyTemplate.getInstProperties().containsKey(key) && topologyTemplate.getInstProperties().get(key) != null ){
+ List<PropertyDefinition> instanceProps = topologyTemplate.getInstProperties().get(key).getMapToscaDataDefinition().entrySet().stream().map(e -> new PropertyDefinition(e.getValue())).collect(Collectors.toList());
+ currComponentInstance.setProperties(instanceProps);
+ }
+ if(topologyTemplate.getComponentInstInterfaces() != null && topologyTemplate.getComponentInstInterfaces().containsKey(key) && topologyTemplate.getComponentInstInterfaces().get(key) != null ){
+ Map<String, Object> interfacesMap = topologyTemplate.getComponentInstInterfaces().get(key).getMapToscaDataDefinition().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ currComponentInstance.setInterfaces(interfacesMap);
+ }
componentInstances.add(currComponentInstance);
}
component.setComponentInstances(componentInstances);
@@ -1165,20 +1149,52 @@ public class ModelConverter {
}
}
- private static void setComponentInstancesAttributesToComponent(TopologyTemplate topologyTemplate, Component component) {
- if (topologyTemplate.getInstAttributes() != null) {
- Map<String, List<ComponentInstanceProperty>> attributes = new HashMap<>();
- for (Map.Entry<String, MapPropertiesDataDefinition> entry : topologyTemplate.getInstAttributes().entrySet()) {
- if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) {
- String key = entry.getKey();
- List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue())))
- .collect(Collectors.toList());
- attributes.put(key, componentInstanceAttributes);
- }
- }
- component.setComponentInstancesAttributes(attributes);
- }
- }
+ private static void setComponentInstancesInterfacesToComponent(TopologyTemplate topologyTemplate, Component component) {
+ if (topologyTemplate.getInstInterfaces() != null) {
+ Map<String, List<ComponentInstanceInterface>> interfaces = new HashMap<>();
+ for (Entry<String, MapInterfaceInstanceDataDefinition> entry : topologyTemplate.getInstInterfaces().entrySet()) {
+ if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) {
+ String key = entry.getKey();
+ List<ComponentInstanceInterface> componentInstanceInterfaces = entry.getValue()
+ .getMapToscaDataDefinition().entrySet().stream().map(e -> new
+ ComponentInstanceInterface(e.getKey(), e.getValue()))
+ .collect(Collectors.toList());
+ interfaces.put(key, componentInstanceInterfaces);
+ }
+ }
+ component.setComponentInstancesInterfaces(interfaces);
+ }
+ else if (topologyTemplate.getComponentInstInterfaces() != null) {
+ Map<String, List<ComponentInstanceInterface>> interfaces = new HashMap<>();
+ for (Entry<String, MapInterfaceDataDefinition> entry : topologyTemplate.getComponentInstInterfaces().entrySet()) {
+ if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) {
+ String key = entry.getKey();
+ List<ComponentInstanceInterface> componentInstanceInterfaces = entry.getValue()
+ .getMapToscaDataDefinition().entrySet().stream().map(e -> new
+ ComponentInstanceInterface(e.getKey(), e.getValue()))
+ .collect(Collectors.toList());
+ interfaces.put(key, componentInstanceInterfaces);
+ }
+ }
+ component.setComponentInstancesInterfaces(interfaces);
+ }
+
+ }
+
+ private static void setComponentInstancesAttributesToComponent(TopologyTemplate topologyTemplate, Component component) {
+ if (topologyTemplate.getInstAttributes() != null) {
+ Map<String, List<ComponentInstanceProperty>> attributes = new HashMap<>();
+ for (Map.Entry<String, MapPropertiesDataDefinition> entry : topologyTemplate.getInstAttributes().entrySet()) {
+ if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) {
+ String key = entry.getKey();
+ List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue())))
+ .collect(Collectors.toList());
+ attributes.put(key, componentInstanceAttributes);
+ }
+ }
+ component.setComponentInstancesAttributes(attributes);
+ }
+ }
private static void setComponentInstancesRequirementsToComponent(TopologyTemplate topologyTemplate, Component component) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/StorageOperationStatus.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/StorageOperationStatus.java
index ca700b03d5..bb1096a900 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/StorageOperationStatus.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/StorageOperationStatus.java
@@ -62,6 +62,7 @@ public enum StorageOperationStatus {
CANNOT_UPDATE_EXISTING_ENTITY,
PROPERTY_NAME_ALREADY_EXISTS,
INVALID_PROPERTY,
- COMPONENT_IS_ARCHIVED;
+ COMPONENT_IS_ARCHIVED,
+ DECLARED_INPUT_USED_BY_OPERATION;
}