Files
alfresco-community-repo/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/query-authorities-common-SqlMap.xml
2013-08-20 17:17:31 +00:00

85 lines
4.2 KiB
XML

<?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">
<!--
Queries related to authorities
-->
<mapper namespace="alfresco.query.authorities">
<!-- -->
<!-- Result Maps -->
<!-- -->
<resultMap id="result_AuthorityInfo" type="AuthorityInfo">
<id property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="authorityDisplayName" column="authority_display_name" jdbcType="VARCHAR" javaType="java.lang.String"/>
<result property="authorityName" column="authority_name" jdbcType="VARCHAR" javaType="java.lang.String"/>
</resultMap>
<resultMap id="result_AuthorityBridgeLink" type="AuthorityBridgeLink">
<result property="childName" column="child_name" jdbcType="VARCHAR" javaType="java.lang.String"/>
<result property="parentName" column="parent_name" jdbcType="VARCHAR" javaType="java.lang.String"/>
</resultMap>
<!-- -->
<!-- Parameter Maps -->
<!-- -->
<!-- -->
<!-- Statements -->
<!-- -->
<!-- Count authorities: PEOPLE -->
<select id="select_AuthorityCount_People" parameterType="ids" resultType="long">
select count(type_qname_id) from alf_node where type_qname_id = #{idOne}
</select>
<!-- Count authorities: GROUPS -->
<select id="select_AuthorityCount_Groups" resultType="long">
select count(type_qname_id) from alf_node where type_qname_id = #{idOne}
</select>
<!-- GetAuthorities - note: take advantage of fact that authority name is also on child assoc (including "username" for users, eg. getAllAuthoritiesInZone) -->
<select id="select_GetAuthoritiesCannedQuery" parameterType="AuthorityInfo" resultMap="result_AuthorityInfo" fetchSize="-2147483648">
select
childNode.id as id,
adn.string_value as authority_display_name,
assoc.qname_localname as authority_name <!-- see note -->
from
alf_child_assoc assoc
join alf_node childNode on (childNode.id = assoc.child_node_id)
left join alf_node_properties adn on (adn.node_id = childNode.id and adn.qname_id = #{authorityDisplayNameQNameId})
where
assoc.parent_node_id = #{parentNodeId}
</select>
<!-- Get all relationships between authorities -->
<select id="select_GetAuthorityBridgeEntries" parameterType="AuthorityBridgeParameters" resultMap="result_AuthorityBridgeLink" fetchSize="-2147483648">
select
ca.qname_localname as child_name,
parentName.string_value as parent_name
from
alf_child_assoc ca
join alf_node childNode on ((childNode.id = ca.child_node_id) and (childNode.type_qname_id = #{typeQNameId} )and (childNode.store_id = #{storeId}))
join alf_node parentNode on ((parentNode.id = ca.parent_node_id) and (parentNode.type_qname_id = #{typeQNameId}) and (parentNode.store_id = #{storeId}))
join alf_node_properties parentName on (parentName.node_id = parentNode.id and parentName.qname_id = #{authorityNameQNameId})
where
ca.type_qname_id = #{childAssocTypeQNameId}
</select>
<!-- Get direct parent authorities -->
<select id="select_GetDirectAuthoritiesForUser" parameterType="AuthorityBridgeParameters" resultMap="result_AuthorityBridgeLink" fetchSize="-2147483648">
select
'' as child_name,
parentName.string_value as parent_name
from
alf_child_assoc ca
join alf_node childNode on ((childNode.id = ca.child_node_id) and (childNode.store_id = #{storeId}))
join alf_node parentNode on ((parentNode.id = ca.parent_node_id) and (parentNode.type_qname_id = #{typeQNameId}) and (parentNode.store_id = #{storeId}))
join alf_node_properties parentName on (parentName.node_id = parentNode.id and parentName.qname_id = #{authorityNameQNameId})
where
ca.type_qname_id = #{childAssocTypeQNameId}
and childNode.id = #{nodeId}
</select>
</mapper>