When a filter specifies a name (and possibly version), those can
be used to speed DB searches. Modified the code to use the keys
rather than always retrieving every record before applying the
filter.
Change-Id: I6b48d9e6880ab7e8132d5d8f770394720031b9b5
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
public List<PdpGroup> getFilteredPdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroupFilter filter) {
*/
public List<PdpGroup> getFilteredPdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroupFilter filter) {
- List<JpaPdpGroup> jpaPdpGroupList = dao.getAll(JpaPdpGroup.class);
-
- return filter.filter(asPdpGroupList(jpaPdpGroupList));
+ return filter.filter(
+ asPdpGroupList(dao.getFiltered(JpaPdpGroup.class, filter.getName(), PfKey.NULL_KEY_VERSION)));
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public ToscaServiceTemplate getFilteredPolicies(@NonNull final PfDao dao, @NonNull final ToscaPolicyFilter filter)
throws PfModelException {
public ToscaServiceTemplate getFilteredPolicies(@NonNull final PfDao dao, @NonNull final ToscaPolicyFilter filter)
throws PfModelException {
- ToscaServiceTemplate serviceTemplate = new SimpleToscaProvider().getPolicies(dao, null, null).toAuthorative();
+ String version = ToscaPolicyFilter.LATEST_VERSION.equals(filter.getVersion()) ? null : filter.getVersion();
+
+ ToscaServiceTemplate serviceTemplate =
+ new SimpleToscaProvider().getPolicies(dao, filter.getName(), version).toAuthorative();
List<ToscaPolicy> filteredPolicies = asConceptList(serviceTemplate.getToscaTopologyTemplate().getPolicies());
filteredPolicies = filter.filter(filteredPolicies);
List<ToscaPolicy> filteredPolicies = asConceptList(serviceTemplate.getToscaTopologyTemplate().getPolicies());
filteredPolicies = filter.filter(filteredPolicies);
public List<ToscaPolicy> getFilteredPolicyList(@NonNull final PfDao dao, @NonNull final ToscaPolicyFilter filter)
throws PfModelException {
public List<ToscaPolicy> getFilteredPolicyList(@NonNull final PfDao dao, @NonNull final ToscaPolicyFilter filter)
throws PfModelException {
- return filter.filter(getPolicyList(dao, null, null));
+ String version = ToscaPolicyFilter.LATEST_VERSION.equals(filter.getVersion()) ? null : filter.getVersion();
+ return filter.filter(getPolicyList(dao, filter.getName(), version));