aboutsummaryrefslogtreecommitdiffstats
path: root/models-provider/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'models-provider/src/main/java/org')
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java80
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java52
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java38
3 files changed, 42 insertions, 128 deletions
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
index 12c72d714..cf40a57f9 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
@@ -25,14 +25,16 @@ import java.util.Map;
import lombok.NonNull;
-import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
+import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
@@ -76,22 +78,24 @@ public interface PolicyModelsProvider extends AutoCloseable {
public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
/**
- * Get latest policy types.
+ * Get filtered policy types.
*
- * @param name the name of the policy type to get, set to null to get all policy types
+ * @param filter the filter for the policy types to get
* @return the policy types found
* @throws PfModelException on errors getting policy types
*/
- public ToscaServiceTemplate getLatestPolicyTypes(final String name) throws PfModelException;
+ public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaPolicyTypeFilter filter)
+ throws PfModelException;
/**
- * Get latest policy types.
+ * Get filtered policy types.
*
- * @param name the name of the policy type to get, set to null to get all policy types
+ * @param filter the filter for the policy types to get
* @return the policy types found
* @throws PfModelException on errors getting policy types
*/
- public List<ToscaPolicyType> getLatestPolicyTypeList(final String name) throws PfModelException;
+ public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaPolicyTypeFilter filter)
+ throws PfModelException;
/**
* Create policy types.
@@ -145,46 +149,22 @@ public interface PolicyModelsProvider extends AutoCloseable {
public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
/**
- * Get policies for a policy type name.
- *
- * @param policyTypeName the name of the policy type for which to get policies
- * @param policyTypeVersion the version of the policy type, null returns all versions of deployed policies for
- * policy types
- * @return the policies found
- * @throws PfModelException on errors getting policies
- */
- public ToscaServiceTemplate getPolicies4PolicyType(@NonNull final String policyTypeName,
- final String policyTypeVersion) throws PfModelException;
-
- /**
- * Get policies for a policy type name.
- *
- * @param policyTypeName the name of the policy type for which to get policies
- * @param policyTypeVersion the version of the policy type, null returns all versions of deployed policies for
- * policy types
- * @return the policies found
- * @throws PfModelException on errors getting policies
- */
- public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final String policyTypeName,
- final String policyTypeVersion) throws PfModelException;
-
- /**
- * Get latest policies.
+ * Get filtered policies.
*
- * @param name the name of the policy to get, null to get all policies
+ * @param filter the filter for the policies to get
* @return the policies found
* @throws PfModelException on errors getting policies
*/
- public ToscaServiceTemplate getLatestPolicies(final String name) throws PfModelException;
+ public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
/**
- * Get latest policies.
+ * Get filtered policies.
*
- * @param name the name of the policy to get, null to get all policies
+ * @param filter the filter for the policies to get
* @return the policies found
* @throws PfModelException on errors getting policies
*/
- public List<ToscaPolicy> getLatestPolicyList(final String name) throws PfModelException;
+ public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
/**
* Create policies.
@@ -305,23 +285,13 @@ public interface PolicyModelsProvider extends AutoCloseable {
public List<PdpGroup> getPdpGroups(final String name, final String version) throws PfModelException;
/**
- * Get latest PDP Groups, returns PDP groups in all states.
+ * Get filtered PDP groups.
*
- * @param name the name of the PDP group to get, null to get all PDP groups
+ * @param filter the filter for the PDP groups to get
* @return the PDP groups found
* @throws PfModelException on errors getting policies
*/
- public List<PdpGroup> getLatestPdpGroups(final String name) throws PfModelException;
-
- /**
- * Get a filtered list of PDP groups, returns only active PDP groups.
- *
- * @param pdpType The PDP type filter for the returned PDP groups, null to get policy types across PDP subgroups
- * @param supportedPolicyTypes a list of policy type name/version pairs that the PDP groups must support.
- * @return the PDP groups found
- */
- public List<PdpGroup> getFilteredPdpGroups(final String pdpType,
- @NonNull final List<Pair<String, String>> supportedPolicyTypes);
+ public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
/**
* Creates PDP groups.
@@ -396,14 +366,4 @@ public interface PolicyModelsProvider extends AutoCloseable {
public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
@NonNull final String pdpType, @NonNull final String pdpInstanceId,
@NonNull final PdpStatistics pdppStatistics) throws PfModelException;
-
- /**
- * Get deployed policies.
- *
- * @param name the name of the policy to get, null to get all policies
- * @return the policies deployed as a map of policy lists keyed by PDP group name and version
- * @throws PfModelException on errors getting policies
- */
- public Map<Pair<String, String>, List<ToscaPolicy>> getDeployedPolicyList(final String name)
- throws PfModelException;
}
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
index 51b7d2f68..2fe52e935 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
@@ -30,7 +30,6 @@ import javax.ws.rs.core.Response;
import lombok.NonNull;
-import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.dao.DaoParameters;
@@ -39,13 +38,16 @@ import org.onap.policy.models.dao.PfDaoFactory;
import org.onap.policy.models.dao.impl.DefaultPfDao;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
+import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.persistence.provider.PdpProvider;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.provider.AuthorativeToscaProvider;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
@@ -162,15 +164,16 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getLatestPolicyTypes(final String name) throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull ToscaPolicyTypeFilter filter) throws PfModelException {
assertInitilized();
- return new AuthorativeToscaProvider().getLatestPolicyTypes(pfDao, name);
+ return new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, filter);
}
@Override
- public List<ToscaPolicyType> getLatestPolicyTypeList(final String name) throws PfModelException {
+ public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull ToscaPolicyTypeFilter filter)
+ throws PfModelException {
assertInitilized();
- return new AuthorativeToscaProvider().getLatestPolicyTypeList(pfDao, name);
+ return new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao, filter);
}
@Override
@@ -207,30 +210,17 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getPolicies4PolicyType(@NonNull String policyTypeName, String policyTypeVersion)
- throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicies(@NonNull ToscaPolicyFilter filter) throws PfModelException {
assertInitilized();
- return new AuthorativeToscaProvider().getPolicies4PolicyType(pfDao, policyTypeName, policyTypeVersion);
+ return new AuthorativeToscaProvider().getFilteredPolicies(pfDao, filter);
}
@Override
- public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final String policyTypeName,
- final String policyTypeVersion) throws PfModelException {
+ public List<ToscaPolicy> getFilteredPolicyList(@NonNull ToscaPolicyFilter filter) throws PfModelException {
assertInitilized();
- return new AuthorativeToscaProvider().getPolicyList4PolicyType(pfDao, policyTypeName, policyTypeVersion);
+ return new AuthorativeToscaProvider().getFilteredPolicyList(pfDao, filter);
}
- @Override
- public ToscaServiceTemplate getLatestPolicies(final String name) throws PfModelException {
- assertInitilized();
- return new AuthorativeToscaProvider().getLatestPolicies(pfDao, name);
- }
-
- @Override
- public List<ToscaPolicy> getLatestPolicyList(final String name) throws PfModelException {
- assertInitilized();
- return new AuthorativeToscaProvider().getLatestPolicyList(pfDao, name);
- }
@Override
public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
@@ -313,16 +303,9 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public List<PdpGroup> getLatestPdpGroups(final String name) throws PfModelException {
+ public List<PdpGroup> getFilteredPdpGroups(@NonNull PdpGroupFilter filter) throws PfModelException {
assertInitilized();
- return new PdpProvider().getLatestPdpGroups(pfDao, name);
- }
-
- @Override
- public List<PdpGroup> getFilteredPdpGroups(final String pdpType,
- @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
- assertInitilized();
- return new PdpProvider().getFilteredPdpGroups(pfDao, pdpType, supportedPolicyTypes);
+ return new PdpProvider().getFilteredPdpGroups(pfDao, filter);
}
@Override
@@ -371,13 +354,6 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
pdppStatistics);
}
- @Override
- public Map<Pair<String, String>, List<ToscaPolicy>> getDeployedPolicyList(final String name)
- throws PfModelException {
- assertInitilized();
- return new PdpProvider().getDeployedPolicyList(pfDao, name);
- }
-
/**
* Check if the model provider is initialized.
*/
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
index 52929ab5a..0bf529730 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
@@ -29,19 +29,21 @@ import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.NonNull;
-import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
+import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
@@ -82,12 +84,12 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getLatestPolicyTypes(final String name) throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull ToscaPolicyTypeFilter filter) throws PfModelException {
return null;
}
@Override
- public List<ToscaPolicyType> getLatestPolicyTypeList(final String name) throws PfModelException {
+ public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull ToscaPolicyTypeFilter filter) {
return new ArrayList<>();
}
@@ -120,24 +122,12 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getPolicies4PolicyType(@NonNull String policyTypeName, String policyTypeVersion)
- throws PfModelException {
- return null;
- }
-
- @Override
- public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final String policyTypeName,
- final String policyTypeVersion) throws PfModelException {
- return new ArrayList<>();
- }
-
- @Override
- public ToscaServiceTemplate getLatestPolicies(final String name) throws PfModelException {
+ public ToscaServiceTemplate getFilteredPolicies(@NonNull ToscaPolicyFilter filter) throws PfModelException {
return null;
}
@Override
- public List<ToscaPolicy> getLatestPolicyList(final String name) throws PfModelException {
+ public List<ToscaPolicy> getFilteredPolicyList(@NonNull ToscaPolicyFilter filter) throws PfModelException {
return new ArrayList<>();
}
@@ -211,13 +201,7 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public List<PdpGroup> getLatestPdpGroups(final String name) throws PfModelException {
- return new ArrayList<>();
- }
-
- @Override
- public List<PdpGroup> getFilteredPdpGroups(final String pdpType,
- @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
+ public List<PdpGroup> getFilteredPdpGroups(@NonNull PdpGroupFilter filter) throws PfModelException {
return new ArrayList<>();
}
@@ -260,12 +244,6 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
// Not implemented
}
- @Override
- public Map<Pair<String, String>, List<ToscaPolicy>> getDeployedPolicyList(final String name)
- throws PfModelException {
- return null;
- }
-
/**
* Return a ToscaServicetemplate dummy response.
*