<!-- approval BPEL Process [Generated by the Eclipse BPEL Designer] -->
<!-- Date: Thu Aug 06 16:47:38 CEST 2009 -->
<bpel:process name="approval"
         targetNamespace="http://orchestra.ow2.org/loanApproval/approval"
         suppressJoinFailure="yes"
         xmlns:tns="http://orchestra.ow2.org/loanApproval/approval"
         xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
         xmlns:ns="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://orchestra.ow2.org/loanApproval/common">
         
    <!-- ================================================================= -->         
    <!-- PARTNERLINKS                                                      -->
    <!-- List of services participating in this BPEL process               -->
    <!-- ================================================================= -->         
    <bpel:import namespace="http://orchestra.ow2.org/loanApproval/common" location="../common.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"></bpel:import>
    <bpel:import namespace="http://orchestra.ow2.org/loanApproval/approval" location="approval.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"></bpel:import>
    <bpel:partnerLinks>       
        <bpel:partnerLink name="ApprovalPLNK" partnerLinkType="tns:approvalLT" myRole="approver"></bpel:partnerLink>
    </bpel:partnerLinks>
  
    <!-- ================================================================= -->         
    <!-- VARIABLES                                                         -->
    <!-- List of messages and XML documents used within this BPEL process  -->
    <!-- ================================================================= -->         
    <bpel:variables>
        <bpel:variable name="firstName" type="ns:string"></bpel:variable>
        <bpel:variable name="name" type="ns:string"></bpel:variable>
        <bpel:variable name="amount" type="ns:integer"></bpel:variable>
        <bpel:variable name="result" type="ns:string"></bpel:variable>
        <bpel:variable name="ApprovalPLNKResponse" messageType="ns0:approvalMessage"></bpel:variable>
    </bpel:variables>

    <!-- ================================================================= -->         
    <!-- ORCHESTRATION LOGIC                                               -->
    <!-- Set of activities coordinating the flow of messages across the    -->
    <!-- services integrated within this business process                  -->
    <!-- ================================================================= -->         
    <bpel:sequence>
        <bpel:receive name="ReceiveRequest" partnerLink="ApprovalPLNK" operation="approve" portType="tns:approvalPT" createInstance="yes">
            <bpel:fromParts>
                <bpel:fromPart part="firstName" toVariable="firstName"></bpel:fromPart>
                <bpel:fromPart part="name" toVariable="name"></bpel:fromPart>
                <bpel:fromPart part="amount" toVariable="amount"></bpel:fromPart>
            </bpel:fromParts>
        </bpel:receive>
        <bpel:if name="If">
            <bpel:condition><![CDATA[$name='Dupont' or $name='McDonalds']]></bpel:condition>
            <bpel:if name="If1">
                <bpel:condition><![CDATA[$amount < 30000]]></bpel:condition>
                <bpel:assign validate="no" name="Assign">
                    <bpel:copy>
                        <bpel:from>
                            <bpel:literal>yes</bpel:literal>
                        </bpel:from>
                        <bpel:to variable="result"></bpel:to>
                    </bpel:copy>
                </bpel:assign>
                <bpel:else>
                    <bpel:assign validate="no" name="Assign">
                    <bpel:copy>
                        <bpel:from>
                            <bpel:literal>no</bpel:literal>
                        </bpel:from>
                        <bpel:to variable="result"></bpel:to>
                    </bpel:copy>
                  </bpel:assign>
                </bpel:else>
            </bpel:if>
        <bpel:elseif>
                <bpel:condition><![CDATA[$name='Kent' or $name='Martin']]></bpel:condition>
                <bpel:if name="If2">
                  <bpel:condition><![CDATA[$amount < 10000]]></bpel:condition>
                  <bpel:assign validate="no" name="Assign">
                      <bpel:copy>
                          <bpel:from>
                              <bpel:literal>yes</bpel:literal>
                          </bpel:from>
                          <bpel:to variable="result"></bpel:to>
                      </bpel:copy>
                  </bpel:assign>
                <bpel:else>
                  <bpel:assign validate="no" name="Assign">
                    <bpel:copy>
                        <bpel:from>
                            <bpel:literal>no</bpel:literal>
                        </bpel:from>
                        <bpel:to variable="result"></bpel:to>
                    </bpel:copy>
                  </bpel:assign>
                </bpel:else>
                </bpel:if>
            </bpel:elseif>
            <bpel:elseif>
                <bpel:condition><![CDATA[$amount < 50000]]></bpel:condition>
                <bpel:assign validate="no" name="Assign"><bpel:copy>
                        <bpel:from>
                            <bpel:literal>yes</bpel:literal>
                        </bpel:from>
                        <bpel:to variable="result"></bpel:to>
                    </bpel:copy>
                </bpel:assign>
            </bpel:elseif>
            <bpel:else>
                <bpel:assign validate="no" name="Assign">
                    <bpel:copy>
                        <bpel:from>
                            <bpel:literal>no</bpel:literal>
                        </bpel:from>
                        <bpel:to variable="result"></bpel:to>
                    </bpel:copy>
                </bpel:assign>
            </bpel:else>
        </bpel:if>
        <bpel:reply name="Reply" partnerLink="ApprovalPLNK" operation="approve">
            <bpel:toParts>
                <bpel:toPart part="accept" fromVariable="result"></bpel:toPart>
            </bpel:toParts>
        </bpel:reply>
    </bpel:sequence>    
</bpel:process>

