2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.tosca.simple.provider;
23 import lombok.NonNull;
25 import org.onap.policy.models.base.PfConceptKey;
26 import org.onap.policy.models.base.PfModelException;
27 import org.onap.policy.models.dao.PfDao;
28 import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
31 * This class provides the provision of information on TOSCA concepts in the database to callers.
33 * @author Liam Fallon (liam.fallon@est.tech)
35 public class SimpleToscaProvider {
39 * @param dao the DAO to use to access the database
40 * @param policyTypeKey the policy type key for the policy types to be retrieved. A null key name returns all policy
41 * types. A null key version returns all versions of the policy type name specified in the key.
42 * @return the policy types found
43 * @throws PfModelException on errors getting policy types
45 public ToscaServiceTemplate getPolicyTypes(@NonNull final PfDao dao, @NonNull final PfConceptKey policyTypeKey)
46 throws PfModelException {
51 * Create policy types.
53 * @param dao the DAO to use to access the database
54 * @param serviceTemplate the service template containing the definition of the policy types to be created
55 * @return the TOSCA service template containing the created policy types
56 * @throws PfModelException on errors creating policy types
58 public ToscaServiceTemplate createPolicyTypes(@NonNull final PfDao dao,
59 @NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException {
64 * Create policy types.
66 * @param dao the DAO to use to access the database
67 * @param serviceTemplate the service template containing the definition of the policy types to be modified
68 * @return the TOSCA service template containing the modified policy types
69 * @throws PfModelException on errors updating policy types
71 public ToscaServiceTemplate updatePolicyTypes(@NonNull final PfDao dao,
72 @NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException {
77 * Delete policy types.
79 * @param dao the DAO to use to access the database
80 * @param policyTypeKey the policy type key for the policy types to be deleted, if the version of the key is null,
81 * all versions of the policy type are deleted.
82 * @return the TOSCA service template containing the policy types that were deleted
83 * @throws PfModelException on errors deleting policy types
85 public ToscaServiceTemplate deletePolicyTypes(@NonNull final PfDao dao, @NonNull final PfConceptKey policyTypeKey)
86 throws PfModelException {
93 * @param dao the DAO to use to access the database
94 * @param policyKey the policy key for the policies to be retrieved. The parent name and version must be specified.
95 * A null local name returns all policies for a parent policy type.
96 * @return the policies found
97 * @throws PfModelException on errors getting policies
99 public ToscaServiceTemplate getPolicies(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
100 throws PfModelException {
107 * @param dao the DAO to use to access the database
108 * @param serviceTemplate the service template containing the definitions of the new policies to be created.
109 * @return the TOSCA service template containing the policy types that were created
110 * @throws PfModelException on errors creating policies
112 public ToscaServiceTemplate createPolicies(@NonNull final PfDao dao,
113 @NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException {
120 * @param dao the DAO to use to access the database
121 * @param serviceTemplate the service template containing the definitions of the policies to be updated.
122 * @return the TOSCA service template containing the policies that were updated
123 * @throws PfModelException on errors updating policies
125 public ToscaServiceTemplate updatePolicies(@NonNull final PfDao dao,
126 @NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException {
133 * @param dao the DAO to use to access the database
134 * @param policyKey the policy key
135 * @return the TOSCA service template containing the policy types that were deleted
136 * @throws PfModelException on errors deleting policies
138 public ToscaServiceTemplate deletePolicies(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
139 throws PfModelException {