Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="eu.unicore.xuudb.server.db.UudbPoolMapper">
<select id="getAliveMapping" resultType="eu.unicore.xuudb.server.db.MappingBean">
select id, entry from UUDB_POOL_ENTRIES
where pool = #{pool} AND poolKey = #{key} AND freezeTime IS NULL
</select>
<select id="getFrozenMappings" resultType="eu.unicore.xuudb.server.db.MappingBean">
select id, entry from UUDB_POOL_ENTRIES
where pool = #{pool} AND poolKey = #{key} AND freezeTime IS NOT NULL
</select>
<update id="updateAccessTime">
UPDATE UUDB_POOL_ENTRIES SET lastAccess = NOW()
WHERE id = #{id}
</update>
<select id="getFreeMapping" resultType="eu.unicore.xuudb.server.db.MappingBean">
select id, entry from UUDB_POOL_ENTRIES
WHERE pool = #{pool} AND poolKey IS NULL
LIMIT 1
</select>
<update id="addMapping">
UPDATE UUDB_POOL_ENTRIES SET poolKey = #{key}, lastAccess = NOW()
WHERE id = #{id}
</update>
<select id="getInactiveMappings" resultType="eu.unicore.xuudb.server.db.MappingBean">
SELECT id, entry, lastAccess FROM UUDB_POOL_ENTRIES
WHERE freezeTime IS NULL AND pool= #{pool} AND lastAccess < #{since} AND poolKey IS NOT NULL
</select>
<update id="freezeMapping">
UPDATE UUDB_POOL_ENTRIES SET freezeTime = NOW()
WHERE id = #{id}
</update>
<select id="getOldMappings" resultType="eu.unicore.xuudb.server.db.MappingBean">
SELECT id, entry, freezeTime FROM UUDB_POOL_ENTRIES
WHERE freezeTime IS NOT NULL AND pool= #{pool} AND freezeTime < #{since} AND poolKey IS NOT NULL
</select>
<update id="removeMapping">
UPDATE UUDB_POOL_ENTRIES SET freezeTime = NULL, lastAccess = NULL, poolKey = NULL
WHERE id = #{id}
</update>
<select id="countOccupiedMappings" resultType="long">
SELECT COUNT(*) FROM UUDB_POOL_ENTRIES
WHERE pool = #{pool} and poolKey IS NOT NULL
</select>
<select id="getMappings" resultType="eu.unicore.xuudb.server.db.MappingBean">
<include refid="getMappingsSelect"/>
<where>
<if test="status != null && status == 'live'"> UUDB_POOL_ENTRIES.freezeTime IS NULL </if>
<if test="status != null && status == 'frozen'"> UUDB_POOL_ENTRIES.freezeTime IS NOT NULL </if>
<if test="pool != null"> AND UUDB_POOL_ENTRIES.pool = #{pool} </if>
AND UUDB_POOL_ENTRIES.pool = UUDB_POOLS.id
AND UUDB_POOL_ENTRIES.poolKey IS NOT NULL
</where>
</select>
<select id="findMappingsByValue" resultType="eu.unicore.xuudb.server.db.MappingBean">
<include refid="getMappingsSelect"/>
WHERE
UUDB_POOL_ENTRIES.entry = #{value} AND
UUDB_POOL_ENTRIES.pool = UUDB_POOLS.id AND
UUDB_POOLS.valueType = #{valueType}
</select>
<select id="findMappingsByKey" resultType="eu.unicore.xuudb.server.db.MappingBean">
<include refid="getMappingsSelect"/>
WHERE
UUDB_POOLS.keyType = #{keyType} AND
UUDB_POOL_ENTRIES.poolKey = #{key} AND
UUDB_POOL_ENTRIES.pool = UUDB_POOLS.id
</select>
<insert id="populatePool" useGeneratedKeys="true">
INSERT INTO UUDB_POOL_ENTRIES (pool, entry, lastAccess)
VALUES (#{pool}, #{entry}, NOW())
</insert>
<insert id="createPool" parameterType="eu.unicore.xuudb.server.db.MappingBean"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO UUDB_POOLS (name, keyType, valueType)
VALUES (#{poolName}, #{mappingKeyType}, #{mappingValueType})
</insert>
<delete id="removePool">
DELETE FROM UUDB_POOLS WHERE name = #{poolName}
</delete>
<select id="checkPoolExistence" resultType="eu.unicore.xuudb.server.db.MappingBean">
select id, keyType AS mappingKeyType, valueType AS mappingValueType from UUDB_POOLS where name = #{pool}
</select>
<select id="listPools" resultType="eu.unicore.xuudb.server.db.PoolInfoBean">
SELECT a.NAME AS poolName, a.keyType AS poolKeyType, a.valueType AS poolType, ALIVEMAPPINGS, FROZENMAPPINGS, FREESLOTS
FROM UUDB_POOLS a
LEFT OUTER JOIN
(SELECT POOL, COUNT(*) AS ALIVEMAPPINGS FROM UUDB_POOL_ENTRIES WHERE FREEZETIME IS NULL AND POOLKEY IS NOT NULL GROUP BY POOL) b
ON b.pool = a.id
LEFT OUTER JOIN
(SELECT POOL, COUNT(*) AS FROZENMAPPINGS FROM UUDB_POOL_ENTRIES WHERE FREEZETIME IS NOT NULL GROUP BY POOL) c
ON c.pool = a.id
LEFT OUTER JOIN
(SELECT POOL, COUNT(*) AS FREESLOTS FROM UUDB_POOL_ENTRIES WHERE POOLKEY IS NULL GROUP BY POOL) d
ON d.pool = a.id
</select>
<!-- reusable -->
<sql id="getMappingsSelect">
SELECT UUDB_POOL_ENTRIES.id, UUDB_POOL_ENTRIES.entry, UUDB_POOL_ENTRIES.freezeTime,
UUDB_POOL_ENTRIES.lastAccess, UUDB_POOL_ENTRIES.poolKey AS mappingKey,
UUDB_POOLS.name AS poolName, UUDB_POOLS.keyType AS mappingKeyType
FROM UUDB_POOL_ENTRIES, UUDB_POOLS
</sql>
</mapper>