summaryrefslogtreecommitdiffstats
path: root/models/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'models/src/main')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java34
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java3
3 files changed, 32 insertions, 8 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java
index 691ce95db..4ab406f3b 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java
@@ -18,6 +18,7 @@
package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
+import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@@ -34,7 +35,7 @@ import org.onap.policy.models.base.PfUtils;
@AllArgsConstructor
@EqualsAndHashCode
public class ControlLoops {
- private List<ControlLoop> controlLoopList;
+ private List<ControlLoop> controlLoopList = new ArrayList<>();
/**
* Copy constructor, does a deep copy.
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
index 762b927ab..b4f99a51e 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
@@ -45,6 +45,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates;
import org.springframework.stereotype.Component;
/**
@@ -197,18 +198,39 @@ public class ControlLoopProvider extends AbstractModelsProvider {
Map<String, ToscaNodeTemplate> savedNodeTemplates = new HashMap<>();
- serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, template) -> {
- var jpaToscaNodeTemplate = new JpaToscaNodeTemplate(template);
-
- getPfDao().create(jpaToscaNodeTemplate);
+ var jpaToscaNodeTemplates = new JpaToscaNodeTemplates();
+ jpaToscaNodeTemplates.fromAuthorative(Collections.singletonList(serviceTemplate.getToscaTopologyTemplate()
+ .getNodeTemplates()));
- savedNodeTemplates.put(key, template);
- });
+ getPfDao().create(jpaToscaNodeTemplates);
+ serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach(savedNodeTemplates::put);
return savedNodeTemplates;
}
/**
+ * Deletes Instance Properties on the database.
+ *
+ * @param filteredToscaNodeTemplateMap filtered node templates map to delete
+ * @param filteredToscaNodeTemplateList filtered node template list to delete
+ */
+ public void deleteInstanceProperties(
+ Map<String, ToscaNodeTemplate> filteredToscaNodeTemplateMap,
+ List<ToscaNodeTemplate> filteredToscaNodeTemplateList) {
+
+ var jpaToscaNodeTemplates = new JpaToscaNodeTemplates();
+ jpaToscaNodeTemplates.fromAuthorative(Collections.singletonList(filteredToscaNodeTemplateMap));
+
+ getPfDao().create(jpaToscaNodeTemplates);
+
+ filteredToscaNodeTemplateList.forEach(template -> {
+ var jpaToscaNodeTemplate = new JpaToscaNodeTemplate(template);
+
+ getPfDao().delete(jpaToscaNodeTemplate);
+ });
+ }
+
+ /**
* Get Node Templates.
*
* @param name the name of the node template to get, null to get all node templates
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java
index eed339447..d8974d6e3 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java
@@ -19,6 +19,7 @@
package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation;
+import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
@@ -33,5 +34,5 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@Setter
@ToString(callSuper = true)
public class InstancePropertiesResponse extends SimpleResponse {
- private List<ToscaConceptIdentifier> affectedInstanceProperties;
+ private List<ToscaConceptIdentifier> affectedInstanceProperties = new ArrayList<>();
}