Improve unit-test coverage
[vfc/nfvo/driver/vnfm/svnfm.git] / nokia / vnfmdriver / vfcadaptorservice / vfcadaptor / src / main / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / db / mapper / VnfmJobExecutionMapper.java
1 /*
2  * Copyright 2016-2017, Nokia Corporation
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  
17 package org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper;
18
19 import java.util.List;
20
21 import org.apache.ibatis.annotations.Delete;
22 import org.apache.ibatis.annotations.Insert;
23 import org.apache.ibatis.annotations.Mapper;
24 import org.apache.ibatis.annotations.Result;
25 import org.apache.ibatis.annotations.Results;
26 import org.apache.ibatis.annotations.Select;
27 import org.apache.ibatis.annotations.Update;
28 import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo;
29
30 @Mapper
31 public interface VnfmJobExecutionMapper {
32         @Select("SELECT * FROM vnfm_job_execution_info")
33     @Results({
34         @Result(property = "jobId",  column = "job_id"),
35         @Result(property = "vnfmExecutionId", column = "vnfm_execution_id"),
36         @Result(property = "vnfInstanceId", column = "vnf_instance_id"),
37         @Result(property = "vnfmInterfceName", column = "vnfm_interface_name"),
38         @Result(property = "status", column = "status"),
39         @Result(property = "operateStartTime", column = "operate_start_time"),
40         @Result(property = "operateEndTime", column = "operate_end_time")
41     })
42     List<VnfmJobExecutionInfo> getAll();
43
44     @Select("SELECT * FROM vnfm_job_execution_info WHERE job_id = #{jobId}")
45     @Results({
46         @Result(property = "jobId",  column = "job_id"),
47         @Result(property = "vnfmExecutionId", column = "vnfm_execution_id"),
48         @Result(property = "vnfInstanceId", column = "vnf_instance_id"),
49         @Result(property = "vnfmInterfceName", column = "vnfm_interface_name"),
50         @Result(property = "status", column = "status"),
51         @Result(property = "operateStartTime", column = "operate_start_time"),
52         @Result(property = "operateEndTime", column = "operate_end_time")
53     })
54     VnfmJobExecutionInfo findOne(Long jobId);
55
56     @Insert("INSERT INTO vnfm_job_execution_info(vnfm_execution_id,vnf_instance_id,vnfm_interface_name,status,operate_start_time, operate_end_time) VALUES(#{vnfmExecutionId}, #{vnfInstanceId}, #{vnfmInterfceName}, #{status}, #{operateStartTime}, #{operateEndTime})")
57     void insert(VnfmJobExecutionInfo user);
58
59     @Update("UPDATE vnfm_job_execution_info SET vnfm_execution_id=#{vnfmExecutionId},vnf_instance_id=#{vnfInstanceId},vnfm_interface_name=#{vnfmInterfceName},status=#{status},operate_start_time=#{operateStartTime}, operate_end_time=#{operateEndTime} WHERE job_id =#{jobId}")
60     void update(VnfmJobExecutionInfo user);
61
62     @Delete("DELETE FROM vnfm_job_execution_info WHERE id =#{id}")
63     void delete(Long id);
64     
65     @Select("select * from vnfm_job_execution_info where job_id = (select max(job_id) from vnfm_job_execution_info)")
66     @Results({
67         @Result(property = "jobId",  column = "job_id"),
68         @Result(property = "vnfmExecutionId", column = "vnfm_execution_id"),
69         @Result(property = "vnfInstanceId", column = "vnf_instance_id"),
70         @Result(property = "vnfmInterfceName", column = "vnfm_interface_name"),
71         @Result(property = "status", column = "status"),
72         @Result(property = "operateStartTime", column = "operate_start_time"),
73         @Result(property = "operateEndTime", column = "operate_end_time")
74     })
75     VnfmJobExecutionInfo findNewestJobInfo();
76 }