2 * Copyright © 2018-2019 AT&T Intellectual Property.
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.
17 package org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db
19 import org.springframework.data.domain.Pageable
20 import org.springframework.data.jpa.repository.JpaRepository
21 import org.springframework.data.jpa.repository.Modifying
22 import org.springframework.data.jpa.repository.Query
23 import org.springframework.stereotype.Repository
24 import org.springframework.transaction.annotation.Transactional
28 @Transactional(readOnly = true)
29 interface PrioritizationMessageRepository : JpaRepository<MessagePrioritization, String> {
31 @Query("FROM MessagePrioritization pm WHERE pm.group = :group ORDER BY pm.createdDate asc")
32 fun findByGroup(group: String, count: Pageable): List<MessagePrioritization>?
34 @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
35 "ORDER BY pm.createdDate asc")
36 fun findByGroupAndStateIn(group: String, states: List<String>, count: Pageable): List<MessagePrioritization>?
38 @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
39 "ORDER BY pm.updatedDate asc")
40 fun findByGroupAndStateInOrderByUpdatedDate(group: String, states: List<String>, count: Pageable)
41 : List<MessagePrioritization>?
43 @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
44 "AND pm.expiryDate > :expiryCheckDate ORDER BY pm.createdDate asc")
45 fun findByGroupAndStateInAndNotExpiredDate(group: String, states: List<String>, expiryCheckDate: Date,
46 count: Pageable): List<MessagePrioritization>?
48 @Query("FROM MessagePrioritization pm WHERE pm.state in :states " +
49 "AND pm.expiryDate < :expiryCheckDate ORDER BY pm.createdDate asc")
50 fun findByStateInAndExpiredDate(states: List<String>, expiryCheckDate: Date,
51 count: Pageable): List<MessagePrioritization>?
53 @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
54 "AND pm.expiryDate < :expiryCheckDate ORDER BY pm.createdDate asc")
55 fun findByGroupAndStateInAndExpiredDate(group: String, states: List<String>, expiryCheckDate: Date,
56 count: Pageable): List<MessagePrioritization>?
58 @Query("FROM MessagePrioritization pm WHERE pm.group = :group " +
59 "AND pm.expiryDate < :expiryCheckDate ORDER BY pm.createdDate asc")
60 fun findByByGroupAndExpiredDate(group: String, expiryCheckDate: Date, count: Pageable): List<MessagePrioritization>?
62 @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
63 "AND pm.correlationId = :correlationId ORDER BY pm.createdDate asc")
64 fun findByGroupAndCorrelationId(group: String, states: List<String>, correlationId: String)
65 : List<MessagePrioritization>?
67 @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
68 "AND pm.type in :types AND pm.correlationId = :correlationId ORDER BY pm.createdDate asc")
69 fun findByGroupAndTypesAndCorrelationId(group: String, states: List<String>, types: List<String>,
70 correlationId: String): List<MessagePrioritization>?
74 @Query("UPDATE MessagePrioritization pm SET pm.state = :state WHERE pm.id = :id")
75 fun setStatusForMessageId(id: String, state: String): Int
79 @Query("UPDATE MessagePrioritization pm SET pm.state = :state WHERE pm.id IN :ids")
80 fun setStatusForMessageIds(ids: List<String>, state: String): Int
84 @Query("UPDATE MessagePrioritization pm SET pm.aggregatedMessageIds = :aggregatedMessageIds " +
86 fun setAggregatedMessageIds(id: String, aggregatedMessageIds: String): Int
90 @Query("DELETE FROM MessagePrioritization pm WHERE pm.group = :group")
91 fun deleteGroup(group: String)
95 @Query("DELETE FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state IN :states")
96 fun deleteGroupAndStateIn(group: String, states: List<String>)