aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/main/java/org
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2021-11-10 14:11:51 +0000
committerFrancescoFioraEst <francesco.fiora@est.tech>2021-11-19 09:54:38 +0000
commit0574c7df7944828a7e8a03c1eacf93605c43b154 (patch)
tree3f33ce0c0784361198ff83f2738a7f84f85a7032 /models/src/main/java/org
parentb421ff09244107ab6172f72076466c6be8616c5b (diff)
Add support transaction in ParticipantProvider
Issue-ID: POLICY-3800 Change-Id: I938c2731a30013b5f8e11a23a86d117300c95bff 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/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java5
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java156
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java8
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java39
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java31
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java31
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java30
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java29
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java30
10 files changed, 267 insertions, 96 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
index bdb0d4d9b..867c34aad 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
@@ -59,7 +59,7 @@ public class ClElementStatisticsProvider {
@NonNull final List<ClElementStatistics> clElementStatisticsList) throws PfModelException {
try {
- var jpaClElementStatisticsList = ProviderUtils.getJpaAndValidate(clElementStatisticsList,
+ var jpaClElementStatisticsList = ProviderUtils.getJpaAndValidateList(clElementStatisticsList,
JpaClElementStatistics::new, "control loop element statistics");
var jpaClElementStatisticsSaved = clElementStatisticsRepository.saveAll(jpaClElementStatisticsList);
@@ -67,8 +67,7 @@ public class ClElementStatisticsProvider {
// Return the saved control loop element statistics
return asClElementStatisticsList(jpaClElementStatisticsSaved);
} catch (IllegalArgumentException e) {
- throw new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error in save control loop element statistics",
- e);
+ throw new PfModelException(Status.BAD_REQUEST, "Error in save control loop element statistics", e);
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
index b4f99a51e..a61b97fa8 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
@@ -125,7 +125,7 @@ public class ControlLoopProvider extends AbstractModelsProvider {
public List<ControlLoop> createControlLoops(@NonNull final List<ControlLoop> controlLoops) throws PfModelException {
List<JpaControlLoop> jpaControlLoopList =
- ProviderUtils.getJpaAndValidate(controlLoops, JpaControlLoop::new, "control loop");
+ ProviderUtils.getJpaAndValidateList(controlLoops, JpaControlLoop::new, "control loop");
jpaControlLoopList.forEach(jpaControlLoop -> getPfDao().create(jpaControlLoop));
@@ -151,7 +151,7 @@ public class ControlLoopProvider extends AbstractModelsProvider {
public List<ControlLoop> updateControlLoops(@NonNull final List<ControlLoop> controlLoops) throws PfModelException {
List<JpaControlLoop> jpaControlLoopList =
- ProviderUtils.getJpaAndValidate(controlLoops, JpaControlLoop::new, "control loop");
+ ProviderUtils.getJpaAndValidateList(controlLoops, JpaControlLoop::new, "control loop");
// Return the created control loops
List<ControlLoop> returnControlLoops = new ArrayList<>(controlLoops.size());
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
index dd669a6d8..2a6f21c07 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
@@ -20,36 +20,30 @@
package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider;
-import java.util.ArrayList;
import java.util.List;
-import java.util.stream.Collectors;
-import javax.ws.rs.core.Response;
+import java.util.Optional;
+import javax.ws.rs.core.Response.Status;
+import lombok.AllArgsConstructor;
import lombok.NonNull;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ParticipantRepository;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-import org.onap.policy.models.provider.impl.AbstractModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
/**
* This class provides information on participant concepts in the database to callers.
*/
+@Transactional
+@AllArgsConstructor
@Component
-public class ParticipantProvider extends AbstractModelsProvider {
- /**
- * Create a provider for participants.
- *
- * @param parameters the parameters for database access
- * @throws PfModelException on initiation errors
- */
- public ParticipantProvider(@NonNull PolicyModelsProviderParameters parameters) throws PfModelException {
- super(parameters);
- this.init();
- }
+public class ParticipantProvider {
+
+ private ParticipantRepository participantRepository;
/**
* Get participants.
@@ -59,74 +53,73 @@ public class ParticipantProvider extends AbstractModelsProvider {
* @return the participants found
* @throws PfModelException on errors getting participants
*/
+ @Transactional(readOnly = true)
public List<Participant> getParticipants(final String name, final String version) throws PfModelException {
- return asParticipantList(getPfDao().getFiltered(JpaParticipant.class, name, version));
+ return ProviderUtils.asEntityList(participantRepository.getFiltered(JpaParticipant.class, name, version));
}
/**
- * Get filtered participants.
+ * Get all participants.
*
- * @param filter the filter for the participants to get
* @return the participants found
* @throws PfModelException on errors getting policies
*/
- public List<Participant> getFilteredParticipants(@NonNull final ToscaTypedEntityFilter<Participant> filter) {
-
- return filter.filter(
- asParticipantList(getPfDao().getFiltered(JpaParticipant.class, filter.getName(), filter.getVersion())));
+ @Transactional(readOnly = true)
+ public List<Participant> getParticipants() throws PfModelException {
+ return ProviderUtils.asEntityList(participantRepository.findAll());
}
/**
- * Creates participants.
+ * Get participant.
*
- * @param participants a specification of the participants to create
- * @return the participants created
- * @throws PfModelException on errors creating participants
+ * @param name the name of the participant to get
+ * @param version the version of the participant to get
+ * @return the participant found
+ * @throws PfModelException on errors getting participant
*/
- public List<Participant> createParticipants(@NonNull final List<Participant> participants) throws PfModelException {
-
- List<JpaParticipant> jpaParticipantList =
- ProviderUtils.getJpaAndValidate(participants, JpaParticipant::new, "participant");
-
- jpaParticipantList.forEach(jpaParticipant -> getPfDao().create(jpaParticipant));
-
- // Return the created participants
- List<Participant> returnParticipants = new ArrayList<>(participants.size());
-
- for (Participant participant : participants) {
- var jpaParticipant = getPfDao().get(JpaParticipant.class,
- new PfConceptKey(participant.getName(), participant.getVersion()));
- returnParticipants.add(jpaParticipant.toAuthorative());
+ @Transactional(readOnly = true)
+ public Optional<Participant> findParticipant(@NonNull final String name, @NonNull final String version)
+ throws PfModelException {
+ try {
+ return participantRepository.findById(new PfConceptKey(name, version)).map(JpaParticipant::toAuthorative);
+ } catch (IllegalArgumentException e) {
+ throw new PfModelException(Status.BAD_REQUEST, "Error in find Participant", e);
}
-
- return returnParticipants;
}
/**
- * Updates participants.
+ * Get filtered participants.
*
- * @param participants a specification of the participants to update
- * @return the participants updated
- * @throws PfModelException on errors updating participants
+ * @param filter the filter for the participants to get
+ * @return the participants found
+ * @throws PfModelException on errors getting policies
*/
- public List<Participant> updateParticipants(@NonNull final List<Participant> participants) throws PfModelException {
+ @Transactional(readOnly = true)
+ public List<Participant> getFilteredParticipants(@NonNull final ToscaTypedEntityFilter<Participant> filter)
+ throws PfModelException {
- List<JpaParticipant> jpaParticipantList =
- ProviderUtils.getJpaAndValidate(participants, JpaParticipant::new, "participant");
-
- jpaParticipantList.forEach(jpaParticipant -> getPfDao().update(jpaParticipant));
-
- // Return the created participants
- List<Participant> returnParticipants = new ArrayList<>(participants.size());
+ return filter.filter(ProviderUtils.asEntityList(
+ participantRepository.getFiltered(JpaParticipant.class, filter.getName(), filter.getVersion())));
+ }
- for (Participant participant : participants) {
- var jpaParticipant = getPfDao().get(JpaParticipant.class,
- new PfConceptKey(participant.getName(), participant.getVersion()));
- returnParticipants.add(jpaParticipant.toAuthorative());
+ /**
+ * Saves participant.
+ *
+ * @param participant participant to save
+ * @return the participant created
+ * @throws PfModelException on errors creating participants
+ */
+ public Participant saveParticipant(@NonNull final Participant participant) throws PfModelException {
+ try {
+ var result = participantRepository
+ .save(ProviderUtils.getJpaAndValidate(participant, JpaParticipant::new, "participant"));
+
+ // Return the saved participant
+ return result.toAuthorative();
+ } catch (IllegalArgumentException e) {
+ throw new PfModelException(Status.BAD_REQUEST, "Error in save Participant", e);
}
-
- return returnParticipants;
}
/**
@@ -137,30 +130,23 @@ public class ParticipantProvider extends AbstractModelsProvider {
* @return the participant deleted
* @throws PfModelRuntimeException on errors deleting participants
*/
- public Participant deleteParticipant(@NonNull final String name, @NonNull final String version) {
-
- var participantKey = new PfConceptKey(name, version);
-
- JpaParticipant jpaDeleteParticipant = getPfDao().get(JpaParticipant.class, participantKey);
-
- if (jpaDeleteParticipant == null) {
- String errorMessage =
- "delete of participant \"" + participantKey.getId() + "\" failed, participant does not exist";
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
+ public Participant deleteParticipant(@NonNull final String name, @NonNull final String version)
+ throws PfModelException {
+ try {
+ var participantKey = new PfConceptKey(name, version);
+
+ var jpaDeleteParticipantOpt = participantRepository.findById(participantKey);
+
+ if (jpaDeleteParticipantOpt.isEmpty()) {
+ String errorMessage =
+ "delete of participant \"" + participantKey.getId() + "\" failed, participant does not exist";
+ throw new PfModelRuntimeException(Status.BAD_REQUEST, errorMessage);
+ }
+ participantRepository.delete(jpaDeleteParticipantOpt.get());
+
+ return jpaDeleteParticipantOpt.get().toAuthorative();
+ } catch (IllegalArgumentException e) {
+ throw new PfModelException(Status.BAD_REQUEST, "Error in delete Participant", e);
}
-
- getPfDao().delete(jpaDeleteParticipant);
-
- return jpaDeleteParticipant.toAuthorative();
- }
-
- /**
- * Convert JPA participant list to an authorative participant list.
- *
- * @param jpaParticipantList the list to convert
- * @return the authorative list
- */
- private List<Participant> asParticipantList(List<JpaParticipant> jpaParticipantList) {
- return jpaParticipantList.stream().map(JpaParticipant::toAuthorative).collect(Collectors.toList());
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
index 06c7a11f8..811412205 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
@@ -57,15 +57,13 @@ public class ParticipantStatisticsProvider {
@Transactional(readOnly = true)
public List<ParticipantStatistics> getParticipantStatistics(final String name, final String version,
final Instant timestamp) {
-
if (name != null && version != null && timestamp != null) {
return asParticipantStatisticsList(
participantStatisticsRepository.findAllById(List.of(new PfTimestampKey(name, version, timestamp))));
} else if (name != null) {
return getFilteredParticipantStatistics(name, version, timestamp, null, null, "DESC", 0);
- } else {
- return asParticipantStatisticsList(participantStatisticsRepository.findAll());
}
+ return asParticipantStatisticsList(participantStatisticsRepository.findAll());
}
/**
@@ -113,7 +111,7 @@ public class ParticipantStatisticsProvider {
@NonNull final List<ParticipantStatistics> participantStatisticsList) throws PfModelException {
try {
- var jpaParticipantStatisticsList = ProviderUtils.getJpaAndValidate(participantStatisticsList,
+ var jpaParticipantStatisticsList = ProviderUtils.getJpaAndValidateList(participantStatisticsList,
JpaParticipantStatistics::new, "Participant Statistics");
var jpaParticipantStatisticsSaved = participantStatisticsRepository.saveAll(jpaParticipantStatisticsList);
@@ -121,7 +119,7 @@ public class ParticipantStatisticsProvider {
// Return the saved participant statistics
return asParticipantStatisticsList(jpaParticipantStatisticsSaved);
} catch (IllegalArgumentException e) {
- throw new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error in save participant statistics", e);
+ throw new PfModelException(Status.BAD_REQUEST, "Error in save participant statistics", e);
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java
index 3cce9c55c..3b0400b4f 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provide
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
+import java.util.stream.Collectors;
import javax.ws.rs.core.Response;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -30,11 +31,20 @@ import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.models.base.PfAuthorative;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ProviderUtils {
- protected static <A, J extends PfConcept & PfAuthorative<A>> List<J> getJpaAndValidate(
+ /**
+ * Convert a list of concepts to a list of Jpa objects.
+ *
+ * @param authorativeConceptList the list of concepts
+ * @param jpaSupplier the Jpa Supplier
+ * @param conceptDescription the description used for validation result
+ * @return the list of Jpa objects
+ */
+ public static <A, J extends PfConcept & PfAuthorative<A>> List<J> getJpaAndValidateList(
List<A> authorativeConceptList, Supplier<J> jpaSupplier, String conceptDescription) {
var validationResult = new BeanValidationResult(conceptDescription + " List", authorativeConceptList);
@@ -53,4 +63,31 @@ public final class ProviderUtils {
}
return jpaConceptList;
}
+
+ protected static <A, J extends PfConcept & PfAuthorative<A>> J getJpaAndValidate(A authorativeConcept,
+ Supplier<J> jpaSupplier, String conceptDescription) {
+ var validationResult = new BeanValidationResult(conceptDescription, authorativeConcept);
+
+ var jpaConcept = jpaSupplier.get();
+ jpaConcept.fromAuthorative(authorativeConcept);
+
+ validationResult.addResult(jpaConcept.validate(conceptDescription));
+
+ if (!validationResult.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
+ return jpaConcept;
+ }
+
+ /**
+ * Convert JPA control loop list to an authorative control loop list.
+ *
+ * @param <T> the type of TOSCA entity
+ * @param <J> the type of JPA TOSCA entity
+ * @param jpaEntityList the list to convert
+ * @return the authorative list
+ */
+ public static <T extends ToscaEntity, J extends PfAuthorative<T>> List<T> asEntityList(List<J> jpaEntityList) {
+ return jpaEntityList.stream().map(J::toAuthorative).collect(Collectors.toList());
+ }
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java
new file mode 100644
index 000000000..1a5fd5a56
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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.controlloop.models.controlloop.persistence.repository;
+
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop;
+import org.onap.policy.models.base.PfConceptKey;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ControlLoopRepository extends JpaRepository<JpaControlLoop, PfConceptKey>, FilterRepository {
+
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java
new file mode 100644
index 000000000..671d23bbe
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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.controlloop.models.controlloop.persistence.repository;
+
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant;
+import org.onap.policy.models.base.PfConceptKey;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ParticipantRepository extends JpaRepository<JpaParticipant, PfConceptKey>, FilterRepository {
+
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java
new file mode 100644
index 000000000..a8f830fed
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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.controlloop.models.controlloop.persistence.repository;
+
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface ToscaNodeTemplateRepository
+ extends JpaRepository<JpaToscaNodeTemplate, PfConceptKey>, FilterRepository {
+
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java
new file mode 100644
index 000000000..7bd7d1013
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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.controlloop.models.controlloop.persistence.repository;
+
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface ToscaNodeTemplatesRepository extends JpaRepository<JpaToscaNodeTemplates, PfConceptKey> {
+
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java
new file mode 100644
index 000000000..a5d5fe766
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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.controlloop.models.controlloop.persistence.repository;
+
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface ToscaServiceTemplateRepository
+ extends JpaRepository<JpaToscaServiceTemplate, PfConceptKey>, FilterRepository {
+
+}