Version change for security fix
[dcaegen2/services/son-handler.git] / src / main / java / org / onap / dcaegen2 / services / sonhms / dao / ClusterDetailsRepository.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  son-handler
4  *  ================================================================================
5  *   Copyright (C) 2019 Wipro Limited.
6  *   ==============================================================================
7  *     Licensed under the Apache License, Version 2.0 (the "License");
8  *     you may not use this file except in compliance with the License.
9  *     You may obtain a copy of the License at
10  *  
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *  
13  *     Unless required by applicable law or agreed to in writing, software
14  *     distributed under the License is distributed on an "AS IS" BASIS,
15  *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *     See the License for the specific language governing permissions and
17  *     limitations under the License.
18  *     ============LICENSE_END=========================================================
19  *  
20  *******************************************************************************/
21
22 package org.onap.dcaegen2.services.sonhms.dao;
23
24 import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails;
25
26 import java.util.List;
27
28 import org.springframework.data.jpa.repository.Modifying;
29 import org.springframework.data.jpa.repository.Query;
30 import org.springframework.data.repository.CrudRepository;
31 import org.springframework.stereotype.Repository;
32 import org.springframework.transaction.annotation.Transactional;
33
34
35 @Repository
36 @Transactional
37 public interface ClusterDetailsRepository extends CrudRepository<ClusterDetails, String> {
38
39     @Modifying
40     @Query(nativeQuery = true, value = "UPDATE CLUSTER_DETAILS SET cluster_info=?1  WHERE cluster_id = ?2")
41     public void updateCluster(String clusterInfo, String clusterId);
42
43     @Query(nativeQuery = true, value = "SELECT * FROM cluster_details")
44     public List<ClusterDetails> getAllClusterDetails();
45
46     @Query(nativeQuery = true, value = "SELECT child_thread_id FROM cluster_details WHERE cluster_id = ?1")
47     public long getChildThreadForCluster(String clusterId);
48
49     @Query(nativeQuery = true, value = "SELECT cluster_id FROM cluster_details WHERE child_thread_id = ?1")
50     public String getClusterIdForChildThread(long childThreadId);
51
52     @Modifying
53     @Query(nativeQuery = true, value = "DELETE FROM cluster_details WHERE child_thread_id = ?1")
54     public void deleteByChildThreadId(Long threadId);
55
56     @Modifying
57     @Query(nativeQuery = true, value = "UPDATE cluster_details SET child_thread_id = ?2 WHERE cluster_id = ?1")
58     public void updateThreadId(String clusterId, Long threadId);
59
60 }