| <?xml version="1.0" encoding="UTF-8" ?> |
| <!-- |
| ~ Copyright 2019 WeBank |
| ~ |
| ~ Licensed under the Apache License, Version 2.0 (the "License"); |
| ~ you may not use this file except in compliance with the License. |
| ~ You may obtain a copy of the License at |
| ~ |
| ~ http://www.apache.org/licenses/LICENSE-2.0 |
| ~ |
| ~ Unless required by applicable law or agreed to in writing, software |
| ~ distributed under the License is distributed on an "AS IS" BASIS, |
| ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| ~ See the License for the specific language governing permissions and |
| ~ limitations under the License. |
| --> |
| |
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| |
| |
| <mapper namespace="com.webank.wedatasphere.linkis.jobhistory.dao.TaskMapper"> |
| |
| <resultMap id="taskMapper" type="com.webank.wedatasphere.linkis.jobhistory.entity.QueryTask"> |
| <id column="id" property="taskID" jdbcType="BIGINT"/> |
| <result column="params" property="paramsJson" jdbcType="LONGVARCHAR"/> |
| <result column="script_path" property="sourceJson" jdbcType="LONGVARCHAR"/> |
| </resultMap> |
| |
| <sql id="task_List"> |
| id, `instance`, `exec_id`, `um_user`, `execution_code`, `progress`,`log_path`, |
| `result_location`,`status`,`created_time`,`updated_time`,`run_type`,`err_code`,`err_desc`,`execute_application_name`,`request_application_name`,`script_path`,`params`,`engine_instance`, |
| `engine_start_time` |
| </sql> |
| |
| <insert id="insertTask" useGeneratedKeys="true" keyProperty="taskID" parameterType="com.webank.wedatasphere.linkis.jobhistory.entity.QueryTask"> |
| INSERT INTO linkis_task(<include refid="task_List"/>) |
| VALUES (#{taskID},#{instance},#{execId}, |
| #{umUser},#{executionCode},#{progress}, |
| #{logPath},#{resultLocation},#{status}, |
| #{createdTime},#{updatedTime},#{runType}, |
| #{errCode},#{errDesc},#{executeApplicationName}, |
| #{requestApplicationName},#{sourceJson},#{paramsJson}, |
| #{engineInstance},#{engineStartTime}) |
| </insert> |
| |
| <select id="selectTask" resultMap="taskMapper" parameterType="com.webank.wedatasphere.linkis.jobhistory.entity.QueryTask"> |
| SELECT * from linkis_task |
| <where> |
| <if test="taskID != null">id = #{taskID}</if> |
| <if test="instance != null">and instance = #{instance}</if> |
| <if test="execId != null">and exec_id = #{execId}</if> |
| <if test="umUser != null">and um_user = #{umUser}</if> |
| <if test="engineInstance != null">and engine_instance = #{engineInstance}</if> |
| <if test="executionCode != null">and execution_code = #{executionCode}</if> |
| <if test="progress != null">and progress = #{progress}</if> |
| <if test="logPath != null">and log_path = #{logPath}</if> |
| <if test="resultLocation != null">and result_location = #{resultLocation}</if> |
| <if test="status != null">and status = #{status}</if> |
| <if test="createdTime != null">and created_time = #{createdTime}</if> |
| <if test="updatedTime != null">and updated_time = #{updatedTime}</if> |
| <if test="runType != null">and run_type = #{runType}</if> |
| <if test="errCode != null">and err_code = #{errCode}</if> |
| <if test="errDesc != null">and err_desc = #{errDesc}</if> |
| <if test="executeApplicationName != null">and execute_application_name = #{executeApplicationName}</if> |
| <if test="requestApplicationName != null">and request_application_name = #{requestApplicationName}</if> |
| <if test="sourceJson != null">and script_path = #{sourceJson}</if> |
| <if test="paramsJson != null">and params = #{paramsJson}</if> |
| <if test="engineStartTime != null">and engine_start_time = #{engineStartTime}</if> |
| </where> |
| </select> |
| |
| |
| <select id="search" resultMap="taskMapper" > |
| SELECT * from linkis_task |
| <where> |
| <if test="taskID != null">id = #{taskID}</if> |
| <if test="umUser != null">and um_user = #{umUser}</if> |
| <if test="executeApplicationName != null">and execute_application_name = #{executeApplicationName}</if> |
| <if test="startDate != null">and created_time BETWEEN #{startDate} AND #{endDate}</if> |
| <if test="status != null">and <foreach collection="status" item="element" close=")" separator="," open="status in (">#{element}</foreach></if> |
| </where> |
| ORDER BY linkis_task.created_time DESC |
| </select> |
| |
| <update id="updateTask" parameterType="com.webank.wedatasphere.linkis.jobhistory.entity.QueryTask"> |
| UPDATE linkis_task |
| <trim prefix="set" suffixOverrides=","> |
| <if test="instance != null">instance=#{instance},</if> |
| <if test="execId != null">exec_id=#{execId},</if> |
| <if test="umUser != null">um_user=#{umUser},</if> |
| <if test="executionCode != null">execution_code=#{executionCode},</if> |
| <if test="progress != null">progress=#{progress},</if> |
| <if test="logPath != null">log_path=#{logPath},</if> |
| <if test="resultLocation != null">result_location=#{resultLocation},</if> |
| <if test="status != null">status=#{status},</if> |
| <if test="createdTime != null">created_time=#{createdTime},</if> |
| <if test="updatedTime != null">updated_time=#{updatedTime},</if> |
| <if test="runType != null">run_type=#{runType},</if> |
| <if test="errCode != null">err_code=#{errCode},</if> |
| <if test="errDesc != null">err_desc=#{errDesc},</if> |
| <if test="executeApplicationName != null">execute_application_name=#{executeApplicationName},</if> |
| <if test="requestApplicationName != null">request_application_name=#{requestApplicationName},</if> |
| <if test="sourceJson != null"> script_path = #{sourceJson},</if> |
| <if test="paramsJson != null"> params = #{paramsJson},</if> |
| <if test="engineInstance != null"> engine_instance = #{engineInstance},</if> |
| <if test="engineStartTime != null"> engine_start_time = #{engineStartTime},</if> |
| </trim> |
| WHERE id =#{taskID} |
| </update> |
| |
| <select id="selectTaskStatusForUpdate" resultType="String"> |
| SELECT |
| bdt.`status` |
| FROM |
| `linkis_task` bdt |
| WHERE |
| id = #{taskID} FOR UPDATE |
| </select> |
| </mapper> |