All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.webank.wedatasphere.dss.server.dao.impl.projectMapper.xml Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
<?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.dss.server.dao.ProjectMapper">

    <sql id="project_main">
        id,`name`,`source`,`description`,`org_id`,`visibility`,`is_transfer`,`initial_org_id`,`user_id`,`create_time`,`create_by`,`product`,`application_area`,`business`
    </sql>

    <sql id="project_version">
        id,`project_id`,`version`,`comment`,`update_time`,`updator_id`,`lock`
    </sql>

    <sql id="project_publish">
        id,`project_version_id`,`create_time`,`creator_id`,`update_time`,`comment`,`state`,`version_path`,`expire_time`
    </sql>

    <select id="selectProjectByID" resultType="com.webank.wedatasphere.dss.common.entity.project.DWSProject">
        SELECT
            p.*, MIN(ISNULL(pph.id)) AS 'is_not_publish'
        FROM
            dss_project p
        LEFT JOIN dss_project_version pv ON p.id = pv.project_id
        LEFT JOIN dss_project_publish_history pph ON pv.id = pph.project_version_id
        WHERE
            p.id = #{id}
    </select>

    <select id="selectLatestVersionByProjectID" resultType="com.webank.wedatasphere.dss.common.entity.project.DWSProjectVersion">
        SELECT * FROM dss_project_version WHERE project_id = #{projectID} ORDER BY id DESC LIMIT 1
    </select>
    
    <select id="selectProjectByVersionID" resultType="com.webank.wedatasphere.dss.common.entity.project.DWSProject">
        SELECT
            wp.*
        FROM
            dss_project_version wpv
        LEFT JOIN dss_project wp ON wpv.project_id = wp.id
        WHERE
            wpv.id = #{projrctVersionID}
    </select>

    <insert id="addProject" useGeneratedKeys="true" keyProperty="id"  parameterType="com.webank.wedatasphere.dss.common.entity.project.DWSProject">
        INSERT INTO dss_project (<include refid = "project_main" />)
        VALUES
        (#{id},#{name},#{source},#{description},#{orgID},#{visibility},#{isTransfer},#{initialOrgID},#{userID},#{createTime},#{createBy},#{product},#{applicationArea},#{business})
    </insert>

    <insert id="addProjectVersion" useGeneratedKeys="true" keyProperty="id" parameterType="com.webank.wedatasphere.dss.common.entity.project.DWSProjectVersion" >
        INSERT INTO dss_project_version (<include refid = "project_version" />)
        VALUES
        (#{id},#{projectID},#{version},#{comment},#{updateTime},#{updatorID},#{lock})
    </insert>

    <update id="updateDescription">
        UPDATE dss_project
        SET description = #{description},product = #{product},application_area = #{applicationArea},business = #{business}
        WHERE id = #{projectID}
    </update>

<!--    <select id="listProjectVersionsByProjectID" resultType="com.webank.bdp.dataworkcloud.wtss.entity.DWSProjectVersion">
        SELECT * from dss_project_version WHERE project_id = #{projectID} ORDER BY version DESC
    </select>-->

    <select id="listProjectVersionsByProjectID" resultType="com.webank.wedatasphere.dss.common.entity.project.DWSProjectVersion">
        SELECT
            pv.*, u.`name` AS 'updator',
            (
                ISNULL(pph.id) || pph.state != 2
            ) AS 'is_not_publish'
        FROM
            dss_project_version pv
        LEFT JOIN dss_user u ON pv.updator_id = u.id
        LEFT JOIN dss_project_publish_history pph ON pph.project_version_id = pv.id
        WHERE
            pv.project_id = #{projectID}
        ORDER BY
            pv.id DESC
    </select>

    <select id="noPublished" resultType="Boolean">
        SELECT
            (
                ISNULL(wpvh.id) || wpvh.state != 2
            ) AS 'no_published'
        FROM
            dss_project wp
        LEFT JOIN dss_project_version wpv ON wp.id = wpv.project_id
        LEFT JOIN dss_project_publish_history wpvh ON wpv.id = wpvh.project_version_id
        WHERE
            wp.id = #{projectID}
        LIMIT 1
    </select>

    <delete id="deleteProjectVersions">
        DELETE
        FROM
            dss_project_version
        WHERE
            project_id = #{projectID}
    </delete>

    <delete id="deleteProjectBaseInfo">
        DELETE
        FROM
        dss_project
        WHERE
        id = #{projectID}
    </delete>

    <select id="selectProjectVersionByID" resultType="com.webank.wedatasphere.dss.common.entity.project.DWSProjectVersion">
        SELECT * from dss_project_version WHERE id = #{id}
    </select>

    <select id="selectProjectVersionByProjectIDAndVersionID" resultType="com.webank.wedatasphere.dss.common.entity.project.DWSProjectVersion">
        SELECT *  from dss_project_version WHERE project_id = #{projectID} and version = #{version}
    </select>

    <update id="updateLock">
      UPDATE `dss_project_version` set `lock` = `lock` +1  WHERE id= #{projectVersionID} AND `lock` = #{lock}
    </update>

    <select id="selectProjectPublishHistoryByProjectVersionID" resultType="com.webank.wedatasphere.dss.common.entity.project.DWSProjectPublishHistory">
        SELECT
            pph.*, u.`name` as 'creator'
        FROM
            `dss_project_publish_history` pph
        LEFT JOIN dss_user u ON pph.creator_id = u.id
        WHERE
            pph.project_version_id = #{projectVersionID}
    </select>

    <insert id="insertPublishHistory" useGeneratedKeys="true" keyProperty="id" parameterType="com.webank.wedatasphere.dss.common.entity.project.DWSProjectPublishHistory">
        INSERT INTO dss_project_publish_history (<include refid = "project_publish" />)
        VALUES
        (#{id},#{projectVersionID},#{createTime},#{createID},#{updateTime},#{comment},#{state},#{versionPath},#{expireTime})
    </insert>

    <update id="updatePublishHistoryState">
        UPDATE `dss_project_publish_history`
        SET state = #{status}
        WHERE
            project_version_id = #{projectVersionID}
    </update>

    <insert id="addAccessProjectRelation">
        INSERT INTO dss_project_applications_project
        ( `project_id`,`application_id`,`application_project_id`)
        VALUES
        <foreach collection="appjointProjectIDAndAppID" index="key" item="item"  separator="," >
            (#{projectID},#{key},#{item})
        </foreach>
    </insert>

    <select id="getAppjointProjectID" resultType="Long">
        SELECT application_project_id  FROM dss_project_applications_project WHERE project_id = #{projectID} AND application_id = #{applicationID}
    </select>

</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy