aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/main
diff options
context:
space:
mode:
authorRamesh Murugan Iyer <ramesh.murugan.iyer@est.tech>2022-11-15 12:37:49 +0000
committerGerrit Code Review <gerrit@onap.org>2022-11-15 12:37:49 +0000
commitaf8ef619877bfe7ab17b8e3f1d9cacc6a3f9ca67 (patch)
tree5e588798d2aa117c8a88f9adf169a3f216437f19 /models/src/main
parent5353ee0e99762e3b37c4cc491faa3c16936ebf92 (diff)
parentc32d7926409b4c164e2a5097e7ba1bc4d766bd5b (diff)
Merge "Remove redundant endpoints in ACM"
Diffstat (limited to 'models/src/main')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java53
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java80
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java29
3 files changed, 2 insertions, 160 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
index 760613026..5ee7d02f6 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
@@ -22,9 +22,7 @@
package org.onap.policy.clamp.models.acm.persistence.provider;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
import javax.persistence.EntityNotFoundException;
import javax.ws.rs.core.Response;
@@ -35,15 +33,12 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition;
import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository;
import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplateRepository;
-import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplatesRepository;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
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.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -57,7 +52,6 @@ public class AutomationCompositionProvider {
private final AutomationCompositionRepository automationCompositionRepository;
private final ToscaNodeTemplateRepository toscaNodeTemplateRepository;
- private final ToscaNodeTemplatesRepository toscaNodeTemplatesRepository;
/**
* Get automation composition.
@@ -136,10 +130,9 @@ public class AutomationCompositionProvider {
* Get all automation compositions.
*
* @return all automation compositions found
- * @throws PfModelException on errors getting automation compositions
*/
@Transactional(readOnly = true)
- public List<AutomationComposition> getAutomationCompositions() throws PfModelException {
+ public List<AutomationComposition> getAutomationCompositions() {
return ProviderUtils.asEntityList(automationCompositionRepository.findAll());
}
@@ -150,11 +143,9 @@ public class AutomationCompositionProvider {
* @param name the name of the automation composition to get, null to get all automation compositions
* @param version the version of the automation composition to get, null to get all automation compositions
* @return the automation compositions found
- * @throws PfModelException on errors getting automation compositions
*/
@Transactional(readOnly = true)
- public List<AutomationComposition> getAutomationCompositions(final String name, final String version)
- throws PfModelException {
+ public List<AutomationComposition> getAutomationCompositions(final String name, final String version) {
return ProviderUtils
.asEntityList(automationCompositionRepository.getFiltered(JpaAutomationComposition.class, name, version));
@@ -182,24 +173,6 @@ public class AutomationCompositionProvider {
}
/**
- * Saves Instance Properties to the database.
- *
- * @param serviceTemplate the service template
- * @return a Map of tosca node templates
- */
- public Map<String, ToscaNodeTemplate> saveInstanceProperties(ToscaServiceTemplate serviceTemplate) {
- Map<String, ToscaNodeTemplate> savedNodeTemplates = new HashMap<>();
-
- var jpaToscaNodeTemplates = new JpaToscaNodeTemplates();
- jpaToscaNodeTemplates.fromAuthorative(List.of(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates()));
-
- toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates);
- serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach(savedNodeTemplates::put);
-
- return savedNodeTemplates;
- }
-
- /**
* Delete a automation composition.
*
* @param name the name of the automation composition to delete
@@ -225,31 +198,9 @@ public class AutomationCompositionProvider {
}
/**
- * 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(List.of(filteredToscaNodeTemplateMap));
-
- toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates);
-
- filteredToscaNodeTemplateList.forEach(template -> {
- var jpaToscaNodeTemplate = new JpaToscaNodeTemplate(template);
-
- toscaNodeTemplateRepository.delete(jpaToscaNodeTemplate);
- });
- }
-
- /**
* Get All Node Templates.
*
* @return the list of node templates found
- * @throws PfModelException on errors getting node templates
*/
@Transactional(readOnly = true)
public List<ToscaNodeTemplate> getAllNodeTemplates() {
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 942fe8d46..4661c74c7 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
@@ -29,7 +29,6 @@ import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.models.acm.persistence.repository.ToscaServiceTemplateRepository;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -214,56 +213,6 @@ 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
@@ -278,33 +227,4 @@ public class ServiceTemplateProvider {
return this.getFinalNodeTypesMap(serviceTemplate.getNodeTypes(), tempNodeTypesMap);
}
-
- /**
- * Get node templates with appropriate common or instance properties added.
- *
- * @param initialNodeTemplates map of all the node templates in the specified template
- * @param nodeTypeProps map of all the node types that have common or instance properties including children
- * @return all node templates with appropriate common or instance properties added
- * @throws PfModelException on errors getting map of node templates with common or instance properties added
- */
- public Map<String, ToscaNodeTemplate> getDerivedCommonOrInstanceNodeTemplates(
- Map<String, ToscaNodeTemplate> initialNodeTemplates, Map<String, ToscaNodeType> nodeTypeProps) {
-
- var finalNodeTemplatesMap = new HashMap<String, ToscaNodeTemplate>();
-
- initialNodeTemplates.forEach((templateKey, template) -> {
- if (nodeTypeProps.containsKey(template.getType())) {
- var finalMergedProps = new HashMap<String, Object>();
-
- nodeTypeProps.get(template.getType()).getProperties().forEach(finalMergedProps::putIfAbsent);
-
- template.setProperties(finalMergedProps);
-
- finalNodeTemplatesMap.put(templateKey, template);
- } else {
- return;
- }
- });
- return finalNodeTemplatesMap;
- }
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java
deleted file mode 100644
index f0ab40bf7..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.persistence.repository;
-
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-public interface ToscaNodeTemplatesRepository extends JpaRepository<JpaToscaNodeTemplates, PfConceptKey> {
-
-}