<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang
    $Date: 2013-4-15 下午01:13:07
    $Revision: 1.0
    $Purpose:
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HLS_BP_MASTER_V" needAccessControl="false">
    <bm:fields>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID" prompt="HLS_BP_MASTER_V.BP_ID"/>
        <bm:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="80" forDisplay="true" forQuery="true" physicalName="BP_CODE" prompt="HLS.BP_TITLE"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="160" forDisplay="true" forQuery="true" physicalName="BP_NAME" prompt="HLS.BP_NAME_SHORT"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="HLS_BP_MASTER_V.COMPANY_ID"/>
        <bm:field name="company_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_CODE" prompt="HLS_BP_MASTER_V.COMPANY_CODE"/>
        <bm:field name="company_short_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_SHORT_NAME" prompt="HLS_BP_MASTER_V.COMPANY_SHORT_NAME"/>
        <bm:field name="company_full_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_FULL_NAME" prompt="HLS_BP_MASTER_V.COMPANY_FULL_NAME"/>
        <bm:field name="bp_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CATEGORY"/>
        <bm:field name="bp_category_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CATEGORY_NAME" prompt="商业伙伴类型"/>
        <bm:field name="bp_class" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS"/>
        <bm:field name="bp_class_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS_NAME"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG"/>
        <!--<bm:field name="id_card_no" displayWidth="200" forDisplay="true" prompt="身份证"/>-->
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <s:bm-script><![CDATA[
            var cx = Packages.leaf.javascript.Context.getCurrentContext();
            Packages.leaf.plugin.script.engine.ScriptImportor.defineExternScript(cx, this, $ctx.getData(), "aut_authority_bm_validate.js");
        ]]></s:bm-script>
    </bm:features>
    <bm:query-fields>
        <bm:query-field field="bp_id" queryOperator="="/>
        <bm:query-field field="bp_code" queryOperator="like"/>
        <bm:query-field field="bp_name" queryExpression="t1.bp_name like &apos;%&apos;||${@bp_name}||&apos;%&apos;"/>
        <!-- <bm:query-field field="bp_category" queryOperator="="/> -->
        <bm:query-field field="bp_category" queryExpression="(t1.bp_category = ${@bp_category} or exists(select 1 from hls_bp_master_role br where br.bp_id = t1.bp_id     and br.bp_category = ${@bp_category} and br.bp_type = ${@bp_category}))"/>
        <bm:query-field field="bp_category_name" queryExpression="(t1.bp_category_name like &apos;%&apos;||${@bp_category_name}||&apos;%&apos;)"/>
        <!-- <bm:query-field name="contract_bp_flag" queryExpression="(exists (select 1           from con_contract_bp b          where b.contract_id in (${:@contract_id})            and b.bp_id = t1.bp_id            and b.bp_category in (&apos;VENDER&apos;,&apos;TENANT&apos;,&apos;TENANT_SEC&apos;)            )or nvl(${@contract_bp_flag},&apos;N&apos;) != &apos;Y&apos; )"/> -->
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="query" expression="(t1.company_id=${/session/@company_id})"/>
        <bm:data-filter name="query" expression="(t1.enabled_flag=&apos;Y&apos;)"/>
		<bm:data-filter name="query" expression="(t1.bp_category in ('TENANT','AGENT','VENDER','RENTER','MAN_FACTURER') or exists(select 1 from hls_bp_master_role br where br.bp_id = t1.bp_id  and br.enabled_flag = 'Y'   and br.bp_category in('TENANT','AGENT','VENDER','RENTER','MAN_FACTURER') and br.bp_type in('TENANT','AGENT','VENDER','RENTER','MAN_FACTURER')))"/>
        <!--<bm:data-filter name="query" expression="(exists (select 1 from con_contract_bp bp, con_contract cc  where bp.contract_id = cc.contract_id and bp.bp_id = t1.bp_id and cc.data_class = 'NORMAL' ))"/>-->
       <bm:data-filter name="query" expression="(t1.sbo_bp_status=&apos;Y&apos;)"/>
    </bm:data-filters>
</bm:model>
