<?xml version="1.0" encoding="UTF-8"?>
<process
    name="ProductionProcess"
    targetNamespace="http://enterprise.netbeans.org/bpel/SCA_BPEL_Production/ProductionProcess"
    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:sxt="http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/Trace" 
    xmlns:sxed="http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/Editor"
    xmlns:sxeh="http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/ErrorHandling"
    xmlns:tns="http://enterprise.netbeans.org/bpel/SCA_BPEL_Production/ProductionProcess" xmlns:ns0="http://com.sap.research/ProductionConfiguration" xmlns:ns1="http://api.roboter/" xmlns:ns2="http://api.milling/">
   
    <import namespace="http://enterprise.netbeans.org/bpel/millingWrapper" location="millingWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://api.milling/" location="milling.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://enterprise.netbeans.org/bpel/prodconfWrapper" location="prodconfWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://xquery/" location="prodconf.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://enterprise.netbeans.org/bpel/RoboterWrapper" location="RoboterWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://api.roboter/" location="Roboter.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" location="ProductionProcess.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <partnerLinks>
        <partnerLink name="prodconfPL" xmlns:tns="http://enterprise.netbeans.org/bpel/prodconfWrapper" partnerLinkType="tns:ProductionConfigurationLinkType" partnerRole="ProductionConfigurationRole"/>
        <partnerLink name="RoboterPL" xmlns:tns="http://enterprise.netbeans.org/bpel/RoboterWrapper" partnerLinkType="tns:IRoboterLinkType" partnerRole="IRoboterRole"/>
        <partnerLink name="MillingPL" xmlns:tns="http://enterprise.netbeans.org/bpel/millingWrapper" partnerLinkType="tns:IMillingLinkType" partnerRole="IMillingRole"/>
        <partnerLink name="PartnerLink1" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" partnerLinkType="tns:ProductionProcess" myRole="ProductionProcessPortTypeRole"/>
    </partnerLinks>
    <variables>
        <!--<variable name="StartProductionProcessIn" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" messageType="tns:StartProductionProcessRequest"/>
        <variable name="StartProductionProcessOut" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" messageType="tns:StartProductionProcessResponse"/>
        <variable name="StartProductionProcessIn" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" messageType="tns:StartProductionProcessRequest"/>-->
        <variable name="StartProductionProcessOut" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" messageType="tns:StartProductionProcessResponse"/>
        <variable name="StartProductionProcessIn" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" messageType="tns:StartProductionProcessRequest"/>
        <variable name="ConnectMilling" messageType="ns2:connect"/>
        <variable name="connectRobot" messageType="ns1:connect"/>
        <!--<variable name="StartProductionProcessOut" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" messageType="tns:StartProductionProcessResponse"/>-->
        <variable name="StartProgOut2" xmlns:tns="http://api.roboter/" messageType="tns:startProgResponse"/>
        <variable name="StartProgIn2" xmlns:tns="http://api.roboter/" messageType="tns:startProg"/>
        <variable name="StartProgOut1" xmlns:tns="http://api.milling/" messageType="tns:startProgResponse"/>
        <variable name="StartProgIn1" xmlns:tns="http://api.milling/" messageType="tns:startProg"/>
        <variable name="ConnectOut1" xmlns:tns="http://api.milling/" messageType="tns:connectResponse"/>
        <variable name="ConnectIn1" xmlns:tns="http://api.milling/" messageType="tns:connect"/>
        <variable name="StartProgOut" xmlns:tns="http://api.roboter/" messageType="tns:startProgResponse"/>
        <variable name="StartProgIn" xmlns:tns="http://api.roboter/" messageType="tns:startProg"/>
        <variable name="ConnectIn" xmlns:tns="http://api.roboter/" messageType="tns:connect"/>
        <variable name="ConnectOut" xmlns:tns="http://api.roboter/" messageType="tns:connectResponse"/>
        <variable name="GetConfigurationIn" xmlns:tns="http://xquery/" messageType="tns:getConfiguration"/>
        <!--<variable name="StartProductionProcessIn" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" messageType="tns:StartProductionProcessRequest"/>-->
        <variable name="GetConfigurationOut" xmlns:tns="http://xquery/" messageType="tns:getConfigurationResponse"/>
    </variables>
    <sequence>
        <receive name="Receive1" createInstance="yes" partnerLink="PartnerLink1" operation="StartProductionProcess" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" portType="tns:ProductionProcessPortType" variable="StartProductionProcessIn"/>
        <assign name="AssignInput">
            <copy>
                <from>
                    <literal/>
                </from>
                <to variable="ConnectMilling" part="connect"/>
            </copy>
            <copy>
                <from>
                    <literal/>
                </from>
                <to variable="connectRobot" part="connect"/>
            </copy>
            <copy>
                <from>$StartProductionProcessIn.params/configuration</from>
                <to>$GetConfigurationIn.getConfiguration/arg0</to>
            </copy>
            <copy>
                <from>$StartProductionProcessIn.params/order_id</from>
                <to>$StartProductionProcessOut.params/order_id</to>
            </copy>
        </assign>
        <invoke name="getConfiguration" partnerLink="prodconfPL" operation="getConfiguration" xmlns:tns="http://xquery/" portType="tns:ProductionConfiguration" outputVariable="GetConfigurationOut" inputVariable="GetConfigurationIn"/>
        <assign name="AssignConnection">
            <copy>
                <from variable="connectRobot" part="connect"/>
                <to variable="ConnectIn" part="connect"/>
            </copy>
        </assign>
        <invoke name="connect2Roboter" partnerLink="RoboterPL" operation="connect" xmlns:tns="http://api.roboter/" portType="tns:IRoboter" outputVariable="ConnectOut" inputVariable="ConnectIn"/>
        <if name="IF_Robot_Connected">
            <condition>$ConnectOut.connectResponse/return==true</condition>
            <sequence name="Sequence1">
                <assign name="Assign1">
                    <copy>
                        <from>'MOVE'</from>
                        <to>$StartProgIn.startProg/arg0</to>
                    </copy>
                    <copy>
                        <from>$GetConfigurationOut.getConfigurationResponse/return/ns0:getMaterial/ns0:move/ns0:start</from>
                        <to>$StartProgIn.startProg/arg1</to>
                    </copy>
                    <copy>
                        <from>$GetConfigurationOut.getConfigurationResponse/return/ns0:getMaterial/ns0:move/ns0:end</from>
                        <to>$StartProgIn.startProg/arg2</to>
                    </copy>
                    <copy>
                        <from>10000</from>
                        <to>$StartProgIn.startProg/arg4</to>
                    </copy>
                    <copy>
                        <from>0</from>
                        <to>$StartProgIn.startProg/arg3</to>
                    </copy>
                </assign>
                <invoke name="Invoke2" partnerLink="RoboterPL" operation="startProg" xmlns:tns="http://api.roboter/" portType="tns:IRoboter" inputVariable="StartProgIn" outputVariable="StartProgOut"/>
            </sequence>
        </if>
        <assign name="AssignConnectMilling">
            <copy>
                <from variable="ConnectMilling" part="connect"/>
                <to variable="ConnectIn1" part="connect"/>
            </copy>
        </assign>
        <invoke name="Invoke3" partnerLink="MillingPL" operation="connect" xmlns:tns="http://api.milling/" portType="tns:IMilling" inputVariable="ConnectIn1" outputVariable="ConnectOut1"/>
        <assign name="Assign2">
            <copy>
                <from>$GetConfigurationOut.getConfigurationResponse/return/ns0:mill/ns0:program</from>
                <to>$StartProgIn1.startProg/arg0</to>
            </copy>
            <copy>
                <from>10000</from>
                <to>$StartProgIn1.startProg/arg1</to>
            </copy>
        </assign>
        <invoke name="Invoke4" partnerLink="MillingPL" operation="startProg" xmlns:tns="http://api.milling/" portType="tns:IMilling" inputVariable="StartProgIn1" outputVariable="StartProgOut1"/>
        <assign name="Assign3">
            <copy>
                <from>'MOVE'</from>
                <to>$StartProgIn2.startProg/arg0</to>
            </copy>
            <copy>
                <from>$GetConfigurationOut.getConfigurationResponse/return/ns0:getProduct/ns0:move/ns0:start</from>
                <to>$StartProgIn2.startProg/arg1</to>
            </copy>
            <copy>
                <from>$GetConfigurationOut.getConfigurationResponse/return/ns0:getProduct/ns0:move/ns0:end</from>
                <to>$StartProgIn2.startProg/arg2</to>
            </copy>
            <copy>
                <from>0</from>
                <to>$StartProgIn2.startProg/arg3</to>
            </copy>
            <copy>
                <from>10000</from>
                <to>$StartProgIn2.startProg/arg4</to>
            </copy>
        </assign>
        <invoke name="Invoke5" partnerLink="RoboterPL" operation="startProg" xmlns:tns="http://api.roboter/" portType="tns:IRoboter" inputVariable="StartProgIn2" outputVariable="StartProgOut2"/>
        <assign name="Assign4">
            <copy>
                <from>$StartProductionProcessIn.params/order_id</from>
                <to>$StartProductionProcessOut.params/order_id</to>
            </copy>
            <copy>
                <from>true()</from>
                <to>$StartProductionProcessOut.params/success</to>
            </copy>
        </assign>
        <reply name="Reply1" partnerLink="PartnerLink1" operation="StartProductionProcess" xmlns:tns="http://j2ee.netbeans.org/wsdl/SCA_BPEL_Production/ProductionProcess" portType="tns:ProductionProcessPortType" variable="StartProductionProcessOut"/>
    </sequence>
</process>
