2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package com.onap.sdnc.vnfbackupservice.dao;
22 import java.sql.Timestamp;
23 import java.util.List;
25 import javax.transaction.Transactional;
27 import org.springframework.data.jpa.repository.JpaRepository;
28 import org.springframework.data.jpa.repository.Modifying;
29 import org.springframework.data.jpa.repository.Query;
30 import org.springframework.data.repository.query.Param;
31 import org.springframework.stereotype.Repository;
34 import com.onap.sdnc.vnfbackupservice.model.VnfConfigDetailsDB;
37 public interface VnfBackupServiceRepo extends JpaRepository<VnfConfigDetailsDB, Long> {
39 @Query(value = "Select * from vnfconfigdetails where vnfid = :vnfid", nativeQuery = true)
40 List<VnfConfigDetailsDB> getVnfDetails(@Param("vnfid") String vnfid);
42 @Query(value = "Select * from vnfconfigdetails where vnfid = :vnfid ORDER BY vnfversion DESC LIMIT 1", nativeQuery = true)
43 VnfConfigDetailsDB getVnfDetail(@Param("vnfid") String vnfid);
46 @Query(value = "insert into vnfconfigdetails (configinfo,creationdate,lastupdated,status,vnfid,vnfname,vnfversion) VALUES (:configinfo,:creationdate,:lastupdated,:status,:vnfid,:vnfname,:vnfversion)", nativeQuery = true)
48 void saveVnfDetails(@Param("configinfo") String configinfo, @Param("creationdate") Timestamp creationDate,
49 @Param("lastupdated") Timestamp lastupdated, @Param("status") int status, @Param("vnfid") String vnfid,
50 @Param("vnfname") String vnfname,@Param("vnfversion") String vnfversion);
52 @Query(value = "Select configinfo && vnfversion from vnfconfigdetails where vnfid = :vnfid", nativeQuery = true)
53 List<VnfConfigDetailsDB> getVnfDetailhavingAllVersion(@Param("vnfid") String vnfid);
55 @Query(value = "Select backuptime from vnfschedulertime where id=1", nativeQuery = true)
56 String getvnfschedulertime();
59 @Query(value = "insert into vnfschedulertime(id, backuptime) VALUES (:id, :backuptime)", nativeQuery = true)
61 void insertSchedulerTime(@Param("id") int id, @Param("backuptime") String backuptime);
64 @Query(value = "UPDATE vnfschedulertime SET backuptime =:formatDateTime WHERE id = 1", nativeQuery = true)
66 void updateSchedulerTime(@Param("formatDateTime") String formatDateTime);