aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/main/java/org
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-01-17 10:54:33 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2023-01-17 11:06:12 +0000
commita991c1a124824e9976aecfc52c34148bf1cd9e11 (patch)
treeafaeff39b2b240a36f13b6f199b1572ed0ad169b /models/src/main/java/org
parentadfe6d2d2e5b11a24208b3bce5383f1c38cec61e (diff)
Remove FilterRepository in ACM
As part of participantId refactoring, FilterRepository and related implementation could be removed. Issue-ID: POLICY-4522 Change-Id: Idb078989871f1f65615a7df90aea69f7cd822dae Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/main/java/org')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java21
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java40
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java45
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java4
4 files changed, 6 insertions, 104 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java
index 91766807f..fa8979d58 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java
@@ -46,19 +46,6 @@ public class ParticipantProvider {
private final ParticipantRepository participantRepository;
/**
- * Get participants.
- *
- * @param name the name of the participant to get, null to get all participants
- * @param version the version of the participant to get, null to get all participants
- * @return the participants found
- */
- @Transactional(readOnly = true)
- public List<Participant> getParticipants(final String name, final String version) {
-
- return ProviderUtils.asEntityList(participantRepository.getFiltered(JpaParticipant.class, name, version));
- }
-
- /**
* Get all participants.
*
* @return the participants found
@@ -76,8 +63,8 @@ public class ParticipantProvider {
* @throws PfModelException on errors getting participant
*/
@Transactional(readOnly = true)
- public Participant getParticipantById(String participantId) {
- var participant = participantRepository.findByParticipantId(participantId);
+ public Participant getParticipantById(UUID participantId) {
+ var participant = participantRepository.findByParticipantId(participantId.toString());
if (participant.isEmpty()) {
throw new PfModelRuntimeException(Status.NOT_FOUND,
"Participant Not Found with ID: " + participantId);
@@ -132,8 +119,8 @@ public class ParticipantProvider {
* @param participantId the Id of the participant to delete
* @return the participant deleted
*/
- public Participant deleteParticipant(@NonNull final ToscaConceptIdentifier participantId) {
- var jpaDeleteParticipantOpt = participantRepository.findById(participantId.asConceptKey());
+ public Participant deleteParticipant(@NonNull final UUID participantId) {
+ var jpaDeleteParticipantOpt = participantRepository.findByParticipantId(participantId.toString());
if (jpaDeleteParticipantOpt.isEmpty()) {
String errorMessage =
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java
deleted file mode 100644
index fb4c0bc48..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 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.clamp.models.acm.persistence.repository;
-
-import java.util.List;
-import org.onap.policy.models.base.PfConcept;
-
-public interface FilterRepository {
-
- /**
- * Get an object from the database, referred to by concept key.
- *
- * @param <T> the type of the object to get, a subclass of {@link PfConcept}
- * @param someClass the class of the object to get, a subclass of {@link PfConcept}, if name is null, all concepts
- * of type T are returned, if name is not null and version is null, all versions of that concept matching the
- * name are returned.
- * @param name the name of the object to get, null returns all objects
- * @param version the version the object to get, null returns all objects for a specified name
- * @return the objects that was retrieved from the database
- */
- <T extends PfConcept> List<T> getFiltered(Class<T> someClass, String name, String version);
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java
deleted file mode 100644
index 470f05379..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 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.clamp.models.acm.persistence.repository;
-
-import java.util.List;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import org.onap.policy.models.base.PfConcept;
-import org.onap.policy.models.dao.PfDao;
-import org.onap.policy.models.dao.impl.ProxyDao;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class FilterRepositoryImpl implements FilterRepository {
-
- @PersistenceContext
- private EntityManager entityManager;
-
- protected PfDao getPfDao() {
- return new ProxyDao(entityManager);
- }
-
- @Override
- public <T extends PfConcept> List<T> getFiltered(Class<T> someClass, String name, String version) {
- return getPfDao().getFiltered(someClass, name, version);
- }
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java
index 67ea18870..b448731ba 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java
@@ -27,7 +27,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface ParticipantRepository extends JpaRepository<JpaParticipant, PfConceptKey>, FilterRepository {
+public interface ParticipantRepository extends JpaRepository<JpaParticipant, PfConceptKey> {
- Optional<JpaParticipant> findByParticipantId(String compositionId);
+ Optional<JpaParticipant> findByParticipantId(String participantId);
}