diff options
Diffstat (limited to 'models')
2 files changed, 62 insertions, 0 deletions
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 4e502c64c..71407916d 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 @@ -22,12 +22,15 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provide import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import javax.ws.rs.core.Response; import lombok.NonNull; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop; +import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse; import org.onap.policy.models.base.PfAuthorative; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; @@ -38,6 +41,7 @@ import org.onap.policy.models.provider.impl.AbstractModelsProvider; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; 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.springframework.stereotype.Component; @@ -184,6 +188,26 @@ public class ControlLoopProvider extends AbstractModelsProvider { } /** + * 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<>(); + + serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, template) -> { + JpaToscaNodeTemplate jpaToscaNodeTemplate = new JpaToscaNodeTemplate(template); + + getPfDao().create(jpaToscaNodeTemplate); + + savedNodeTemplates.put(key, template); + }); + + return savedNodeTemplates; + } + + /** * Get Node Templates. * * @param name the name of the node template to get, null to get all node templates @@ -220,4 +244,5 @@ public class ControlLoopProvider extends AbstractModelsProvider { private <T extends ToscaEntity, J extends PfAuthorative<T>> List<T> asEntityList(List<J> jpaEntityList) { return jpaEntityList.stream().map(J::toAuthorative).collect(Collectors.toList()); } + } 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 new file mode 100644 index 000000000..eed339447 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java @@ -0,0 +1,37 @@ +/* + * ============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.controlloop.models.messages.rest.instantiation; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Response to Instance Properties requests that affect a change. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class InstancePropertiesResponse extends SimpleResponse { + private List<ToscaConceptIdentifier> affectedInstanceProperties; +} |