aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca
diff options
context:
space:
mode:
Diffstat (limited to 'models-tosca')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java116
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java4
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java8
3 files changed, 112 insertions, 16 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
index 0201bbea2..e9e92d361 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
@@ -20,11 +20,16 @@
package org.onap.policy.models.tosca.authorative.provider;
+import java.util.ArrayList;
+import java.util.List;
+
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.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider;
@@ -44,13 +49,53 @@ public class AuthorativeToscaProvider {
* @return the policy types found
* @throws PfModelException on errors getting policy types
*/
- public ToscaServiceTemplate getPolicyTypes(@NonNull final PfDao dao, @NonNull final String name,
- @NonNull final String version) throws PfModelException {
+ public ToscaServiceTemplate getPolicyTypes(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
return new SimpleToscaProvider().getPolicyTypes(dao, new PfConceptKey(name, version)).toAuthorative();
}
/**
+ * Get policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @param version the version of the policy type to get, set to null to get all versions
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getPolicyTypeList(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Get latest policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public ToscaServiceTemplate getLatestPolicyTypes(@NonNull final PfDao dao, final String name)
+ throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Get latest policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getLatestPolicyTypeList(@NonNull final PfDao dao, final String name)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
* Create policy types.
*
* @param dao the DAO to use to access the database
@@ -81,18 +126,18 @@ public class AuthorativeToscaProvider {
}
/**
- * Delete policy types.
+ * Delete policy type.
*
* @param dao the DAO to use to access the database
* @param name the name of the policy type to delete.
* @param version the version of the policy type to delete.
- * @return the TOSCA service template containing the policy types that were deleted
+ * @return the TOSCA service template containing the policy type that was deleted
* @throws PfModelException on errors deleting policy types
*/
- public ToscaServiceTemplate deletePolicyTypes(@NonNull final PfDao dao, @NonNull final String name,
+ public ToscaServiceTemplate deletePolicyType(@NonNull final PfDao dao, @NonNull final String name,
@NonNull final String version) throws PfModelException {
- return new SimpleToscaProvider().deletePolicyTypes(dao, new PfConceptKey(name, version)).toAuthorative();
+ return new SimpleToscaProvider().deletePolicyType(dao, new PfConceptKey(name, version)).toAuthorative();
}
/**
@@ -111,6 +156,57 @@ public class AuthorativeToscaProvider {
}
/**
+ * Get policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @param version the version of the policy to get, null to get all versions of a policy
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Get policies for a policy type name.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyTypeName the name of the policy type for which to get policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final PfDao dao, @NonNull final String policyTypeName)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Get latest policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public ToscaServiceTemplate getLatestPolicies(@NonNull final PfDao dao, final String name) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Get latest policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getLatestPolicyList(@NonNull final PfDao dao, final String name) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
* Create policies.
*
* @param dao the DAO to use to access the database
@@ -141,17 +237,17 @@ public class AuthorativeToscaProvider {
}
/**
- * Delete policies.
+ * Delete policy.
*
* @param dao the DAO to use to access the database
* @param name the name of the policy to delete.
* @param version the version of the policy to delete.
- * @return the TOSCA service template containing the policies that were deleted
+ * @return the TOSCA service template containing the policy that weas deleted
* @throws PfModelException on errors deleting policies
*/
- public ToscaServiceTemplate deletePolicies(@NonNull final PfDao dao, @NonNull final String name,
+ public ToscaServiceTemplate deletePolicy(@NonNull final PfDao dao, @NonNull final String name,
@NonNull final String version) throws PfModelException {
- return new SimpleToscaProvider().deletePolicies(dao, new PfConceptKey(name, version)).toAuthorative();
+ return new SimpleToscaProvider().deletePolicy(dao, new PfConceptKey(name, version)).toAuthorative();
}
}
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
index 6e356d0ab..e7e81603a 100644
--- 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
@@ -143,7 +143,7 @@ public class SimpleToscaProvider {
* @return the TOSCA service template containing the policy types that were deleted
* @throws PfModelException on errors deleting policy types
*/
- public JpaToscaServiceTemplate deletePolicyTypes(@NonNull final PfDao dao,
+ public JpaToscaServiceTemplate deletePolicyType(@NonNull final PfDao dao,
@NonNull final PfConceptKey policyTypeKey)
throws PfModelException {
@@ -251,7 +251,7 @@ public class SimpleToscaProvider {
* @return the TOSCA service template containing the policies that were deleted
* @throws PfModelException on errors deleting policies
*/
- public JpaToscaServiceTemplate deletePolicies(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
+ public JpaToscaServiceTemplate deletePolicy(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
throws PfModelException {
JpaToscaServiceTemplate serviceTemplate = getPolicies(dao, policyKey);
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
index ebbebce1c..0d486e3ea 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
@@ -213,21 +213,21 @@ public class SimpleToscaProviderTest {
@Test
public void testPoliciesDelete() throws Exception {
try {
- new SimpleToscaProvider().deletePolicies(null, null);
+ new SimpleToscaProvider().deletePolicy(null, null);
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("dao is marked @NonNull but is null", exc.getMessage());
}
try {
- new SimpleToscaProvider().deletePolicies(null, new PfConceptKey());
+ new SimpleToscaProvider().deletePolicy(null, new PfConceptKey());
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("dao is marked @NonNull but is null", exc.getMessage());
}
try {
- new SimpleToscaProvider().deletePolicies(pfDao, null);
+ new SimpleToscaProvider().deletePolicy(pfDao, null);
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("policyKey is marked @NonNull but is null", exc.getMessage());
@@ -249,7 +249,7 @@ public class SimpleToscaProviderTest {
PfConceptKey policyKey = new PfConceptKey("onap.restart.tca:1.0.0");
JpaToscaServiceTemplate deletedServiceTemplate =
- new SimpleToscaProvider().deletePolicies(pfDao, new PfConceptKey(policyKey));
+ new SimpleToscaProvider().deletePolicy(pfDao, new PfConceptKey(policyKey));
assertEquals(originalServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey),
deletedServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey));