<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="HLS_WS_REQUESTS" defaultOrderBy="request_date desc,status_date,responsed_date asc">
    <bm:fields>
        <bm:field name="request_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REQUEST_ID" prompt="HLS_WS_REQUESTS.REQUEST_ID"/>
        <bm:field name="request_date" databaseType="DATE" datatype="java.util.Date" physicalName="REQUEST_DATE" prompt="HLS_WS_REQUESTS.REQUEST_DATE"/>
        <bm:field name="request_wsdl_url" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REQUEST_WSDL_URL" prompt="HLS_WS_REQUESTS.REQUEST_WSDL_URL"/>
        <bm:field name="function_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FUNCTION_NAME" prompt="HLS_WS_REQUESTS.FUNCTION_NAME"/>
        <bm:field name="status_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STATUS_CODE" prompt="HLS_WS_REQUESTS.STATUS_CODE"/>
        <bm:field name="status_date" databaseType="DATE" datatype="java.util.Date" physicalName="STATUS_DATE" prompt="HLS_WS_REQUESTS.STATUS_DATE"/>
        <bm:field name="return_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RETURN_STATUS" prompt="HLS_WS_REQUESTS.RETURN_STATUS"/>
        <bm:field name="responsed_date" databaseType="DATE" datatype="java.util.Date" physicalName="RESPONSED_DATE" prompt="HLS_WS_REQUESTS.RESPONSED_DATE"/>
        <bm:field name="request_xml" databaseType="VARCHAR2" expression="dbms_lob.substr(xmltype.getclobval(t1.request_xml),3800,1)" forInsert="false" forUpdate="false" physicalName="REQUEST_XML" prompt="HLS_WS_REQUESTS.REQUEST_XML"/>
        <bm:field name="response_xml" databaseType="VARCHAR2" expression="dbms_lob.substr(xmltype.getclobval(t1.response_xml),3800,1)" forInsert="false" forUpdate="false" physicalName="RESPONSE_XML" prompt="HLS_WS_REQUESTS.RESPONSE_XML"/>
        <bm:field name="resend_flag" databaseType="VARCHAR2" expression="case when t1.status_code = 2 and t1.return_status  = &apos;S&apos; then 1 else 0 end" forInsert="false" forUpdate="false" physicalName="RESPONSE_XML"/>
    </bm:fields>
    <bm:primary-key>
        <bm:pk-field name="request_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
          SELECT t1.REQUEST_ID,
       t1.REQUEST_DATE,
       t1.REQUEST_WSDL_URL,
       t1.FUNCTION_NAME,
       t1.STATUS_CODE,
       t1.STATUS_DATE,
       t1.RETURN_STATUS,
       t1.RESPONSED_DATE,
       decode(t1.parameter_type,'json',t1.request_json,xmltype.getclobval(t1.request_xml)) AS request_xml,
       decode(t1.parameter_type,'json',t1.response_json,xmltype.getclobval(t1.response_xml)) AS response_xml,
       null resend_flag
  FROM HLS_WS_REQUESTS t1 #WHERE_CLAUSE# 
  ORDER BY request_date desc, status_date, responsed_date asc
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="request_id" queryOperator="like"/>
        <bm:query-field field="function_name" queryOperator="like"/>
        <bm:query-field name="request_date_start" queryExpression="trunc(t1.request_date) &gt;= to_date(${@request_date_start},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="request_date_end" queryExpression="trunc(t1.request_date) &lt;= to_date(${@request_date_end},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field field="status_code" queryOperator="="/>
        <bm:query-field field="return_status" queryOperator="="/>
    </bm:query-fields>
</bm:model>
