summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorbrunomilitzer <bruno.militzer@est.tech>2022-05-05 15:20:30 +0100
committerbrunomilitzer <bruno.militzer@est.tech>2022-05-25 15:01:02 +0100
commitf35587328e1bd99882ed8a4df85d01660d54c007 (patch)
tree668b2e35b88a24dbf60ce84d62c21c463e2c0449 /models
parentb77b61847ddd169da9a71b05742ed51bc826f5f6 (diff)
Added Edit Instance Properties Functionality
Issue-ID: POLICY-4094 Change-Id: Id52dba3c0912486fa551697be170c05542a0ee22 Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
Diffstat (limited to 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java53
1 files changed, 51 insertions, 2 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java
index 0de5f480a..942fe8d46 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -133,7 +133,6 @@ public class ServiceTemplateProvider {
* @param fullNodeTypes map of all the node types in the specified template
* @param common boolean to indicate whether common or instance properties are required
* @return node types map that only has common properties
- * @throws PfModelException on errors getting node type with common properties
*/
private Map<String, ToscaNodeType> getInitialNodeTypesMap(Map<String, ToscaNodeType> fullNodeTypes,
boolean common) {
@@ -215,6 +214,56 @@ public class ServiceTemplateProvider {
}
/**
+ * Get the node types derived from those that have been saved by instantiation.
+ *
+ * @param initialNodeTypes map of all the node types in the specified template
+ * @param filteredNodeTypes map of all the node types that have common or instance properties
+ * @param instanceName automation composition name
+ * @return all node types that have common properties including their children
+ */
+ private Map<String, ToscaNodeType> getFinalSavedInstanceNodeTypesMap(
+ Map<String, ToscaNodeType> initialNodeTypes,
+ Map<String, ToscaNodeType> filteredNodeTypes, String instanceName) {
+
+ for (var i = 0; i < initialNodeTypes.size(); i++) {
+ initialNodeTypes.forEach((key, nodeType) -> {
+ var tempToscaNodeType = new ToscaNodeType();
+ tempToscaNodeType.setName(key);
+
+ if (filteredNodeTypes.get(nodeType.getDerivedFrom()) != null) {
+ tempToscaNodeType.setName(key);
+
+ var finalProps = new HashMap<String, ToscaProperty>(
+ filteredNodeTypes.get(nodeType.getDerivedFrom()).getProperties());
+
+ tempToscaNodeType.setProperties(finalProps);
+ } else {
+ return;
+ }
+ filteredNodeTypes.putIfAbsent(key, tempToscaNodeType);
+
+ });
+ }
+ return filteredNodeTypes;
+ }
+
+ /**
+ * Get the requested node types by automation composition.
+ *
+ * @param instanceName automation composition name
+ * @param serviceTemplate the ToscaServiceTemplate
+ * @return the node types with common or instance properties
+ */
+ public Map<String, ToscaNodeType> getSavedInstanceInstancePropertiesFromNodeTypes(
+ String instanceName, ToscaServiceTemplate serviceTemplate) {
+ var tempNodeTypesMap =
+ this.getInitialNodeTypesMap(serviceTemplate.getNodeTypes(), false);
+
+ return this.getFinalSavedInstanceNodeTypesMap(serviceTemplate.getNodeTypes(), tempNodeTypesMap, instanceName);
+
+ }
+
+ /**
* Get the requested node types with common or instance properties.
*
* @param common boolean indicating common or instance properties