2 * Copyright (C) 2019 Bell Canada.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db
18 import org.springframework.data.jpa.repository.JpaRepository
19 import org.springframework.data.jpa.repository.Query
20 import org.springframework.data.repository.query.Param
21 import org.springframework.stereotype.Repository
22 import javax.transaction.Transactional
25 interface ResourceResolutionRepository : JpaRepository<ResourceResolution, String> {
28 value = "SELECT * FROM RESOURCE_RESOLUTION WHERE resolution_key = :key AND blueprint_name = :blueprintName AND blueprint_version = :blueprintVersion AND artifact_name = :artifactName AND name = :name ORDER BY occurrence DESC, creation_date DESC LIMIT 1",
31 fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(
32 @Param("key")key: String,
33 @Param("blueprintName")blueprintName: String,
34 @Param("blueprintVersion")blueprintVersion: String,
35 @Param("artifactName")artifactName: String,
36 @Param("name")name: String
37 ): ResourceResolution?
40 value = "SELECT max(occurrence) FROM RESOURCE_RESOLUTION WHERE resolution_key = :key AND blueprint_name = :blueprintName AND blueprint_version = :blueprintVersion AND artifact_name = :artifactName ",
43 fun findMaxOccurrenceByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
44 @Param("key")key: String,
45 @Param("blueprintName")blueprintName: String,
46 @Param("blueprintVersion")blueprintVersion: String,
47 @Param("artifactName")artifactName: String
51 value = "SELECT max(occurrence) FROM RESOURCE_RESOLUTION WHERE blueprint_name = :blueprintName AND blueprint_version = :blueprintVersion AND resource_id = :resourceId AND resource_type = :resourceType ",
54 fun findMaxOccurrenceByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(
55 @Param("blueprintName")blueprintName: String,
56 @Param("blueprintVersion")blueprintVersion: String,
57 @Param("resourceId")resourceId: String,
58 @Param("resourceType")resourceType: String
61 fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
62 resolutionKey: String,
63 blueprintName: String,
64 blueprintVersion: String,
65 artifactPrefix: String
66 ): List<ResourceResolution>
68 fun findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(
69 blueprintName: String,
70 blueprintVersion: String,
73 ): List<ResourceResolution>
75 fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
76 blueprintName: String?,
77 blueprintVersion: String?,
79 resolutionKey: String,
81 ): List<ResourceResolution>
83 fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
84 blueprintName: String?,
85 blueprintVersion: String?,
90 ): List<ResourceResolution>
93 fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(
94 blueprintName: String?,
95 blueprintVersion: String?,