<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:ns2="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="execute">
            <bm:parameters>
                <bm:parameter name="session_id" dataType="java.lang.Long" output="true" outputPath="/session/@session_id"/>
                <bm:parameter name="encryted_session_id" dataType="java.lang.String" input="false" output="true" outputPath="/parameter/@encryted_session_id"/>
                <bm:parameter name="message" dataType="java.lang.String" input="false" output="true" outputPath="/parameter/@message"/>
                <bm:parameter name="user_id" dataType="java.lang.Long" input="false" output="true" outputPath="/session/@user_id"/>
                <bm:parameter name="is_ipad" output="true" outputPath="/session/@is_ipad"/>
                <bm:parameter name="sid" dataType="java.lang.String" input="false" output="true" outputPath="/parameter/@sid"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
                declare
                   vsid 		number;
                   v_user_id 	number;
                begin
                    sys_login_pkg.login(
                        p_user_name           =>${@user_name},
                        p_password            =>${@user_password},
                        p_language            =>${@user_language},
                        p_ip                  =>${/request/@address},
                        p_session_id          =>vsid,
                        p_encryted_session_id =>${@encryted_session_id},
                        p_error_message       =>${@message}
                    );
                    if vsid != -1 then
                        select user_id, vsid,${/parameter/@is_ipad} 
                        into   v_user_id, ${@session_id},${@is_ipad}
                        from   sys_session
                        where  session_id = vsid;
                    end if;
                    sys_auto_login_pkg.create_auto_login(p_user_id   	=>v_user_id,
				    									 p_auto_code	=>${@sid});
					select v_user_id into ${@user_id} from dual;
                end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
