aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-03-22 15:59:21 +0000
committerliamfallon <liam.fallon@est.tech>2019-03-22 15:59:21 +0000
commitc61eebfa4f17e30e3be000d4c59bc74e75b880a1 (patch)
tree88c83888740038476579d32b838b75dc5595ec25 /models-tosca/src
parent834851e6c460ef8a28f356a64fe7b85d8bbf9a55 (diff)
Implement Database provider
This review brings in the structure of the database provider with complete unit test coverage. The provider delegates the details of each database interactino to the appropriate package in the model. Resolved merge conflict. Issue-ID: POLICY-1195 Change-Id: I9d01146415531d18bc9648dcf232b425bc09578d Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java6
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyToscaProvider.java139
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java142
3 files changed, 284 insertions, 3 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java
index 2c0d5084d..2f87020be 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java
@@ -52,20 +52,20 @@ public class LegacyOperationalPolicyMapper
// TODO: Find out how to parse the PolicyType from the content
// TODO: Check if this is the correct way to set the policy type version
- toscaPolicy.setType(new PfConceptKey("SomeDerivedPolicyType", "1.0.0"));
+ toscaPolicy.setType(new PfConceptKey("SomeDerivedPolicyType", "1.0.1"));
Map<String, String> propertyMap = new HashMap<>();
toscaPolicy.setProperties(propertyMap);
toscaPolicy.getProperties().put("Content", legacyOperationalPolicy.getContent());
- PfConceptKey serviceTemplateKey = new PfConceptKey("ServiceTemplate", "1.0.0");
+ PfConceptKey serviceTemplateKey = new PfConceptKey("ServiceTemplate", "1.0.2");
ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(serviceTemplateKey);
serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_0");
PfReferenceKey topologyTemplateKey = new PfReferenceKey(serviceTemplateKey, "TopolocyTemplate");
serviceTemplate.setTopologyTemplate(new ToscaTopologyTemplate(topologyTemplateKey));
- PfConceptKey policiesKey = new PfConceptKey("Policies", "1.0.0");
+ PfConceptKey policiesKey = new PfConceptKey("Policies", "1.0.3");
serviceTemplate.getTopologyTemplate().setPolicies(new ToscaPolicies(policiesKey));
serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(policyKey, toscaPolicy);
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyToscaProvider.java
new file mode 100644
index 000000000..da9d929df
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyToscaProvider.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.models.tosca.legacy.provider;
+
+import lombok.NonNull;
+
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.dao.PfDao;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicy;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
+
+/**
+ * This class provides the provision of information on TOSCA concepts in the database to callers in legacy formats.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class LegacyToscaProvider {
+ /**
+ * Get legacy operational policy.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyId ID of the policy.
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public LegacyOperationalPolicy getOperationalPolicy(@NonNull final PfDao dao, @NonNull final String policyId)
+ throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Create legacy operational policy.
+ *
+ * @param dao the DAO to use to access the database
+ * @param legacyOperationalPolicy the definition of the policy to be created.
+ * @return the created policy
+ * @throws PfModelException on errors creating policies
+ */
+ public LegacyOperationalPolicy createOperationalPolicy(@NonNull final PfDao dao,
+ @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Update legacy operational policy.
+ *
+ * @param dao the DAO to use to access the database
+ * @param legacyOperationalPolicy the definition of the policy to be updated
+ * @return the updated policy
+ * @throws PfModelException on errors updating policies
+ */
+ public LegacyOperationalPolicy updateOperationalPolicy(@NonNull final PfDao dao,
+ @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Delete legacy operational policy.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyId ID of the policy.
+ * @return the deleted policy
+ * @throws PfModelException on errors deleting policies
+ */
+ public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final PfDao dao, @NonNull final String policyId)
+ throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Get legacy guard policy.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyId ID of the policy.
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public LegacyGuardPolicy getGuardPolicy(@NonNull final PfDao dao, @NonNull final String policyId)
+ throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Create legacy guard policy.
+ *
+ * @param dao the DAO to use to access the database
+ * @param legacyGuardPolicy the definition of the policy to be created.
+ * @return the created policy
+ * @throws PfModelException on errors creating policies
+ */
+ public LegacyGuardPolicy createGuardPolicy(@NonNull final PfDao dao,
+ @NonNull final LegacyGuardPolicy legacyGuardPolicy) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Update legacy guard policy.
+ *
+ * @param dao the DAO to use to access the database
+ * @param legacyGuardPolicy the definition of the policy to be updated
+ * @return the updated policy
+ * @throws PfModelException on errors updating policies
+ */
+ public LegacyGuardPolicy updateGuardPolicy(@NonNull final PfDao dao,
+ @NonNull final LegacyGuardPolicy legacyGuardPolicy) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Delete legacy guard policy.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyId ID of the policy.
+ * @return the deleted policy
+ * @throws PfModelException on errors deleting policies
+ */
+ public LegacyGuardPolicy deleteGuardPolicy(@NonNull final PfDao dao, @NonNull final String policyId)
+ throws PfModelException {
+ return null;
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
new file mode 100644
index 000000000..3d563a1cc
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.models.tosca.simple.provider;
+
+import lombok.NonNull;
+
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.dao.PfDao;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+
+/**
+ * This class provides the provision of information on TOSCA concepts in the database to callers.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class SimpleToscaProvider {
+ /**
+ * Get policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyTypeKey the policy type key for the policy types to be retrieved. A null key name returns all policy
+ * types. A null key version returns all versions of the policy type name specified in the key.
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public ToscaServiceTemplate getPolicyTypes(@NonNull final PfDao dao, @NonNull final PfConceptKey policyTypeKey)
+ throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Create policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param serviceTemplate the service template containing the definition of the policy types to be created
+ * @return the TOSCA service template containing the created policy types
+ * @throws PfModelException on errors creating policy types
+ */
+ public ToscaServiceTemplate createPolicyTypes(@NonNull final PfDao dao,
+ @NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Create policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param serviceTemplate the service template containing the definition of the policy types to be modified
+ * @return the TOSCA service template containing the modified policy types
+ * @throws PfModelException on errors updating policy types
+ */
+ public ToscaServiceTemplate updatePolicyTypes(@NonNull final PfDao dao,
+ @NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Delete policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyTypeKey the policy type key for the policy types to be deleted, if the version of the key is null,
+ * all versions of the policy type are deleted.
+ * @return the TOSCA service template containing the policy types that were deleted
+ * @throws PfModelException on errors deleting policy types
+ */
+ public ToscaServiceTemplate deletePolicyTypes(@NonNull final PfDao dao, @NonNull final PfConceptKey policyTypeKey)
+ throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Get policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyKey the policy key for the policies to be retrieved. The parent name and version must be specified.
+ * A null local name returns all policies for a parent policy type.
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public ToscaServiceTemplate getPolicies(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
+ throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Create policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param serviceTemplate the service template containing the definitions of the new policies to be created.
+ * @return the TOSCA service template containing the policy types that were created
+ * @throws PfModelException on errors creating policies
+ */
+ public ToscaServiceTemplate createPolicies(@NonNull final PfDao dao,
+ @NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Update policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param serviceTemplate the service template containing the definitions of the policies to be updated.
+ * @return the TOSCA service template containing the policies that were updated
+ * @throws PfModelException on errors updating policies
+ */
+ public ToscaServiceTemplate updatePolicies(@NonNull final PfDao dao,
+ @NonNull final ToscaServiceTemplate serviceTemplate) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Delete policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyKey the policy key
+ * @return the TOSCA service template containing the policy types that were deleted
+ * @throws PfModelException on errors deleting policies
+ */
+ public ToscaServiceTemplate deletePolicies(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
+ throws PfModelException {
+ return null;
+ }
+}