<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Search">
   <statement id="selectList" parameterClass="java.util.HashMap" resultClass="java.util.LinkedHashMap" >
      SELECT substr(interfaceName,1,LENGTH(interfaceName)-2) as "interfaceName", interfaceDesc as "interfaceDesc", resourceType as "resourceType", author as "userId"
      , resourceApp as "resourceApp", resourceName||'.txt' as "resourceName", resourceDesc as "resourceDesc", '$serviceType$/'||resourcePath as "resourcePath"
      , serviceName as "serviceName"
      FROM (
      SELECT txid as serviceName, EAISVCNAME AS interfaceName , EAISVCDESC AS interfaceDesc, 'interface' resourceType , '1' orderType , AUTHOR ,EAIBZWKDSTCD AS resourceApp , EAISVCNAME AS resourceName, EAISVCDESC AS resourceDesc , EAIBZWKDSTCD ||'/'||'interface'||'/' AS resourcePath
      FROM $schemaId$.tseaihe01
      UNION all
      SELECT he01.txid as serviceName, he01.EAISVCNAME , he01.EAISVCDESC , 'transform' resourceType , '2' orderType, tr01.AUTHOR , substr(tr01.CNVSNNAME,11,3) AS resourceApp , he02.transform AS resourceName, tr01.CNVSNDESC AS resourceDesc , substr(tr01.CNVSNNAME,11,3) ||'/'||'transform'||'/' AS resourcePath
      FROM $schemaId$.tseaihe01 he01, $schemaId$.tseaitr01 tr01,
      (
      SELECT EAISVCNAME , 'S' AS TYPE, CHNGMSGIDNAME           AS TRANSFORM FROM $schemaId$.TSEAIHE02 WHERE SVCPRCSSNO = 1 AND CHNGEONOT = '1'          AND CHNGMSGIDNAME IS NOT null
      UNION
      SELECT EAISVCNAME , 'R' AS TYPE, BASCRSPNSCHNGMSGIDNAME AS TRANSFORM FROM $schemaId$.TSEAIHE02 WHERE SVCPRCSSNO = 1 AND BASCRSPNSCHNGEONOT = '1' AND BASCRSPNSCHNGMSGIDNAME IS NOT null
      UNION
      SELECT EAISVCNAME , 'E' AS TYPE, ERRRSPNSCHNGMSGIDNAME  AS TRANSFORM FROM $schemaId$.TSEAIHE02 WHERE SVCPRCSSNO = 1 AND ERRRSPNSCHNGEONOT = '1'  AND ERRRSPNSCHNGMSGIDNAME IS NOT null
      ) he02
      WHERE he01.EAISVCNAME = he02.eaisvcname
      AND tr01.CNVSNNAME = he02.TRANSFORM
      UNION all
      SELECT he01.txid as serviceName, he01.EAISVCNAME , he01.EAISVCDESC , 'layout' resourceType , '3' orderType, tr07.AUTHOR ,substr(tr07.LOUTNAME ,1,3) AS resourceApp , tr07.LOUTNAME AS resourceName, tr07.LOUTDESC AS resourceDesc , substr(tr07.LOUTNAME ,1,3) ||'/'||'layout'||'/' AS resourcePath
      FROM $schemaId$.tseaihe01 he01, $schemaId$.tseaitr02 tr02, $schemaId$.tseaitr07 tr07,
      (
      SELECT EAISVCNAME , 'S' AS TYPE, CHNGMSGIDNAME           AS TRANSFORM FROM $schemaId$.TSEAIHE02 WHERE SVCPRCSSNO = 1 AND CHNGEONOT = '1'          AND CHNGMSGIDNAME IS NOT null
      UNION
      SELECT EAISVCNAME , 'R' AS TYPE, BASCRSPNSCHNGMSGIDNAME AS TRANSFORM FROM $schemaId$.TSEAIHE02 WHERE SVCPRCSSNO = 1 AND BASCRSPNSCHNGEONOT = '1' AND BASCRSPNSCHNGMSGIDNAME IS NOT null
      UNION
      SELECT EAISVCNAME , 'E' AS TYPE, ERRRSPNSCHNGMSGIDNAME  AS TRANSFORM FROM $schemaId$.TSEAIHE02 WHERE SVCPRCSSNO = 1 AND ERRRSPNSCHNGEONOT = '1'  AND ERRRSPNSCHNGMSGIDNAME IS NOT null
      ) he02
      WHERE he01.EAISVCNAME = he02.eaisvcname
      AND tr02.CNVSNNAME = he02.TRANSFORM
      AND tr02.LOUTNAME = tr07.LOUTNAME
      ) rst
      <dynamic prepend="WHERE">
         <isNotEmpty prepend="AND" property="searchUserId">
            AUTHOR = #searchUserId#
         </isNotEmpty>
         <isNotEmpty prepend="AND" property="searchResourceApp">
            resourceApp = #searchResourceApp#
         </isNotEmpty>
         <isNotEmpty prepend="AND" property="searchResourceType">
            resourceType = #searchResourceType#
         </isNotEmpty>
         <isNotEmpty prepend="AND" property="searchInterfaceName">
            interfaceName like '%'||#searchInterfaceName#||'%'
         </isNotEmpty>
         <isNotEmpty prepend="AND" property="searchInterfaceDesc">
            interfaceDesc like '%'||#searchInterfaceDesc#||'%'
         </isNotEmpty>
         <isNotEmpty prepend="AND" property="searchResourceName">
            resourceName like '%'||#searchResourceName#||'%'
         </isNotEmpty>
         <isNotEmpty prepend="AND" property="searchResourceDesc">
            resourceDesc like '%'||#searchResourceDesc#||'%'
         </isNotEmpty>
         <isNotEmpty prepend="AND" property="searchServiceName">
            serviceName like '%'||#searchServiceName#||'%'
         </isNotEmpty>
      </dynamic>

      ORDER BY 1, 5
   </statement>

</sqlMap>