6806ad665b761c83c7dcbc729184f31c4c135e7b
[ccsdk/cds.git] /
1 /*
2  * Copyright (C) 2019 Bell Canada.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db
17
18 import org.springframework.data.jpa.repository.JpaRepository
19 import org.springframework.stereotype.Repository
20 import javax.transaction.Transactional
21
22 /**
23  * JPA repository managing the underlying ResourceConfigSnapshot table.
24  *
25  * @author Serge Simard
26  * @version 1.0
27  */
28 @Repository
29 interface ResourceConfigSnapshotRepository : JpaRepository<ResourceConfigSnapshot, String> {
30
31     fun findByResourceIdAndResourceTypeAndStatus(
32         resourceId: String,
33         resourceType: String,
34         status: ResourceConfigSnapshot.Status
35     ): ResourceConfigSnapshot?
36
37     @Transactional
38     fun deleteByResourceIdAndResourceTypeAndStatus(
39         resourceId: String,
40         resourceType: String,
41         status: ResourceConfigSnapshot.Status
42     )
43
44     /**
45      * Finds all ResourceConfigSnapshot for a given resourceId and status as search criterias,
46      * ordering the resulting list in reverse chronological order.
47      *
48      * @param resourceId a resource identifier, e.g. CLLI1234555
49      * @param status RUNNING or CANDIDATE
50      *
51      * @return A list of entries are found returns a list of ConfigSnapshot.
52      * If no entries are found, this method returns an empty list.
53      */
54     fun findByResourceIdAndStatusOrderByCreatedDateDesc(
55         resourceId: String,
56         status: ResourceConfigSnapshot.Status
57     ): List<ResourceConfigSnapshot>?
58
59     /**
60      * Finds all ResourceConfigSnapshot for a given resourceId,
61      * ordering the resulting list in reverse chronological order.
62      *
63      * @param resourceId a resource identifier, e.g. CLLI1234555
64      *
65      * @return A list of entries are found returns a list of ConfigSnapshot.
66      * If no entries are found, this method returns an empty list.
67      */
68     fun findByResourceIdOrderByCreatedDateDesc(
69         resourceId: String
70     ): List<ResourceConfigSnapshot>?
71
72     /**
73      * Finds all ResourceConfigSnapshot for a given resourceType and status as search criterias,
74      * ordering the resulting list in reverse chronological order.
75      *
76      * @param resourceType a resource type name, e.g full_config
77      * @param status RUNNING or CANDIDATE
78      *
79      * @return A list of entries are found returns a list of ConfigSnapshot.
80      * If no entries are found, this method returns an empty list.
81      */
82     fun findByResourceTypeAndStatusOrderByCreatedDateDesc(
83         resourceType: String,
84         status: ResourceConfigSnapshot.Status
85     ): List<ResourceConfigSnapshot>?
86
87     /**
88      * Finds all ResourceConfigSnapshot for a given resourceType,
89      * ordering the resulting list in reverse chronological order.
90      *
91      * @param resourceType a resource type name, e.g full_config
92      *
93      * @return A list of entries are found returns a list of ConfigSnapshot.
94      * If no entries are found, this method returns an empty list.
95      */
96     fun findByResourceTypeOrderByCreatedDateDesc(
97         resourceType: String
98     ): List<ResourceConfigSnapshot>?
99 }