<?xml version="1.0" encoding="UTF-8"?>
<process
    name="ManageCodes"
    targetNamespace="http://enterprise.netbeans.org/bpel/FR7_FR9_ManageCodes/ManageCodes"
    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://enterprise.netbeans.org/bpel/FR7_FR9_ManageCodes/ManageCodes"
    xmlns:ns0="http://xml.netbeans.org/schema/ManageCodes"
    xmlns:ns1="http://xml.netbeans.org/schema/Authen_Autho" 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">
   <import namespace="http://j2ee.netbeans.org/wsdl/ManageCodes" location="ManageCodes.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
   <import namespace="http://j2ee.netbeans.org/wsdl/Authen_Autho" location="Partners/Authen_Autho/Authen_Autho.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
   <import namespace="http://enterprise.netbeans.org/bpel/CodeClassificationManagerWrapper" location="Partners/CodeClassificationManagerService/CodeClassificationManagerWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
   <import namespace="http://CodeClassificationManagerService.webservice.ellectra.org/" location="Partners/CodeClassificationManagerService/CodeClassificationManager.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
   <partnerLinks>
      <partnerLink name="WS_CodeClassificationManager" xmlns:tns="http://enterprise.netbeans.org/bpel/CodeClassificationManagerWrapper" partnerLinkType="tns:CodeClassificationManagerLinkType" partnerRole="CodeClassificationManagerRole"/>
      <partnerLink name="BPEL_Authorisation" xmlns:tns="http://j2ee.netbeans.org/wsdl/Authen_Autho" partnerLinkType="tns:Authen_Autho1" partnerRole="Authen_AuthoPortTypeRole"/>
      <partnerLink name="BPEL_ManageCodes" xmlns:tns="http://j2ee.netbeans.org/wsdl/ManageCodes" partnerLinkType="tns:ManageCodes1" myRole="ManageCodesPortTypeRole"/>
   </partnerLinks>
   <variables>
      <variable name="outputCounter" type="xsd:int"/>
      <variable name="recordCounter" type="xsd:int"/>
      <variable name="QueryCodeClassificationFilesFindAllOut" xmlns:tns="http://CodeClassificationManagerService.webservice.ellectra.org/" messageType="tns:queryCodeClassificationFilesFindAllResponse"/>
      <variable name="QueryCodeClassificationFilesFindAllIn" xmlns:tns="http://CodeClassificationManagerService.webservice.ellectra.org/" messageType="tns:queryCodeClassificationFilesFindAll"/>
      <variable name="DeleteCodeClassificationFilesOut" xmlns:tns="http://CodeClassificationManagerService.webservice.ellectra.org/" messageType="tns:deleteCodeClassificationFilesResponse"/>
      <variable name="DeleteCodeClassificationFilesIn" xmlns:tns="http://CodeClassificationManagerService.webservice.ellectra.org/" messageType="tns:deleteCodeClassificationFiles"/>
      <variable name="CreateCodeClassificationFilesOut" xmlns:tns="http://CodeClassificationManagerService.webservice.ellectra.org/" messageType="tns:createCodeClassificationFilesResponse"/>
      <variable name="CreateCodeClassificationFilesIn" xmlns:tns="http://CodeClassificationManagerService.webservice.ellectra.org/" messageType="tns:createCodeClassificationFiles"/>
      <variable name="Authen_AuthoOperationOut" xmlns:tns="http://j2ee.netbeans.org/wsdl/Authen_Autho" messageType="tns:Authen_AuthoOperationReply"/>
      <variable name="Authen_AuthoOperationIn" xmlns:tns="http://j2ee.netbeans.org/wsdl/Authen_Autho" messageType="tns:Authen_AuthoOperationRequest"/>
      <variable name="BPEL_ManageCodesOperationOut" xmlns:tns="http://j2ee.netbeans.org/wsdl/ManageCodes" messageType="tns:ManageCodesOperationReply"/>
      <variable name="BPEL_ManageCodesOperationIn" xmlns:tns="http://j2ee.netbeans.org/wsdl/ManageCodes" messageType="tns:ManageCodesOperationRequest"/>
   </variables>
   <sequence>
      <receive name="Receive1" createInstance="yes" partnerLink="BPEL_ManageCodes" operation="ManageCodesOperation" xmlns:tns="http://j2ee.netbeans.org/wsdl/ManageCodes" portType="tns:ManageCodesPortType" variable="BPEL_ManageCodesOperationIn"/>
      <assign name="prepareAuthorisation">
         <copy>
            <from>
               <literal>FR4_Authorise</literal>
            </from>
            <to>$Authen_AuthoOperationIn.part1/ns1:action</to>
         </copy>
         <copy>
            <from>$BPEL_ManageCodesOperationIn.part1/ns0:actorSignature</from>
            <to>$Authen_AuthoOperationIn.part1/ns1:signature</to>
         </copy>
         <copy>
            <from>
               <literal>FR7_FR9_ManageCodes</literal>
            </from>
            <to>$Authen_AuthoOperationIn.part1/ns1:operation</to>
         </copy>
      </assign>
      <invoke name="authoriseUser" partnerLink="BPEL_Authorisation" operation="Authen_AuthoOperation" xmlns:tns="http://j2ee.netbeans.org/wsdl/Authen_Autho" portType="tns:Authen_AuthoPortType" inputVariable="Authen_AuthoOperationIn" outputVariable="Authen_AuthoOperationOut"/>
      <if name="ifUserAuthorised">
          <condition>$Authen_AuthoOperationOut.part1/ns1:return and $Authen_AuthoOperationOut.part1/ns1:hasAccess</condition>
         <sequence name="startManaging">
            <if name="addNew">
               <condition>$BPEL_ManageCodesOperationIn.part1/ns0:action = 'Add'</condition>
               <sequence name="SequenceAddFile">
                  <if name="checkDocStatusEnum">
                     <condition>string-length($BPEL_ManageCodesOperationIn.part1/ns0:documentStatus) &lt; 1</condition>
                        <assign name="AssigndocStatusNull">
                           <copy>
                                 <from>
                                       <literal>NULL</literal>
                                    </from>
                                    <to>$CreateCodeClassificationFilesIn.parameters/documentStatus</to>
                              </copy>
                        </assign>
                     <else>
                        <assign name="AssignDocStatus">
                           <copy>
                              <from>$BPEL_ManageCodesOperationIn.part1/ns0:documentStatus</from>
                              <to>$CreateCodeClassificationFilesIn.parameters/documentStatus</to>
                           </copy>
                        </assign>
                     </else>
                  </if>
                  <if name="checkMimeTypeEnum">
                     <condition>string-length($BPEL_ManageCodesOperationIn.part1/ns0:mimeType) &lt; 1</condition>
                        <assign name="AssignMimeTypeNull">
                           <copy>
                                 <from>
                                       <literal>NULL</literal>
                                    </from>
                                    <to>$CreateCodeClassificationFilesIn.parameters/mimeType</to>
                              </copy>
                        </assign>
                     <else>
                        <assign name="AssignMimeType">
                           <copy>
                              <from>$BPEL_ManageCodesOperationIn.part1/ns0:mimeType</from>
                              <to>$CreateCodeClassificationFilesIn.parameters/mimeType</to>
                           </copy>
                        </assign>
                     </else>
                  </if>
                  <assign name="passCreateIn">
                     <copy>
                        <from>$BPEL_ManageCodesOperationIn.part1/ns0:filename</from>
                        <to>$CreateCodeClassificationFilesIn.parameters/filename</to>
                     </copy>
                     <copy>
                        <from>$BPEL_ManageCodesOperationIn.part1/ns0:language</from>
                        <to>$CreateCodeClassificationFilesIn.parameters/language</to>
                     </copy>
                     <copy>
                        <from>$BPEL_ManageCodesOperationIn.part1/ns0:description</from>
                        <to>$CreateCodeClassificationFilesIn.parameters/description</to>
                     </copy>
                     <copy>
                        <from>$BPEL_ManageCodesOperationIn.part1/ns0:documentType</from>
                        <to>$CreateCodeClassificationFilesIn.parameters/documentType</to>
                     </copy>
                     <copy>
                        <from>$BPEL_ManageCodesOperationIn.part1/ns0:timeStamp</from>
                        <to>$CreateCodeClassificationFilesIn.parameters/timeStamp</to>
                     </copy>
                  </assign>
                  <invoke name="createFileReference" partnerLink="WS_CodeClassificationManager" operation="createCodeClassificationFiles" xmlns:tns="http://CodeClassificationManagerService.webservice.ellectra.org/" portType="tns:CodeClassificationManager" inputVariable="CreateCodeClassificationFilesIn" outputVariable="CreateCodeClassificationFilesOut"/>
                  <if name="ifCreated">
                      <condition>$CreateCodeClassificationFilesOut.parameters/return != ''</condition>
                     <assign name="AssignCreateOut">
                            <copy>
                               <from>
                                     <literal>Success - a Code Classification file has been created</literal>
                                  </from>
                                  <to>$BPEL_ManageCodesOperationOut.part1/ns0:returnMessage</to>
                            </copy>
                            <copy>
                               <from>true()</from>
                                  <to>$BPEL_ManageCodesOperationOut.part1/ns0:return</to>
                            </copy>
                     </assign>
                     <else>
                        <assign name="ErrorCreation">
                            <copy>
                               <from>
                                     <literal>Error - could not create Code Classification file</literal>
                                  </from>
                                  <to>$BPEL_ManageCodesOperationOut.part1/ns0:returnMessage</to>
                            </copy>
                            <copy>
                               <from>false()</from>
                                  <to>$BPEL_ManageCodesOperationOut.part1/ns0:return</to>
                            </copy>
                      </assign>
                     </else>
                  </if>
               </sequence>
               <else>
                  <if name="deleteFile">
                     <condition>$BPEL_ManageCodesOperationIn.part1/ns0:action = 'Delete'</condition>
                     <sequence name="SequenceDeleteFile">
                        <assign name="passFileID">
                           <copy>
                              <from>$BPEL_ManageCodesOperationIn.part1/ns0:fileID</from>
                              <to>$DeleteCodeClassificationFilesIn.parameters/arg0</to>
                           </copy>
                        </assign>
                        <invoke name="deleteFileReference" partnerLink="WS_CodeClassificationManager" operation="deleteCodeClassificationFiles" xmlns:tns="http://CodeClassificationManagerService.webservice.ellectra.org/" portType="tns:CodeClassificationManager" inputVariable="DeleteCodeClassificationFilesIn" outputVariable="DeleteCodeClassificationFilesOut"/>
                        <if name="ifDeleted">
                           <condition>$DeleteCodeClassificationFilesOut.parameters/return</condition>
                           <assign name="AssignDeleteOut">
                                <copy>
                                   <from>
                                         <literal>Success - a Code Classification file has been deleted</literal>
                                      </from>
                                      <to>$BPEL_ManageCodesOperationOut.part1/ns0:returnMessage</to>
                                </copy>
                                <copy>
                                   <from>true()</from>
                                      <to>$BPEL_ManageCodesOperationOut.part1/ns0:return</to>
                                </copy>
                           </assign>
                           <else>
                              <assign name="ErrorDelete">
                                  <copy>
                                       <from>
                                             <literal>Error - Code Classification file could not be deleted</literal>
                                          </from>
                                          <to>$BPEL_ManageCodesOperationOut.part1/ns0:returnMessage</to>
                                    </copy>
                                    <copy>
                                       <from>false()</from>
                                          <to>$BPEL_ManageCodesOperationOut.part1/ns0:return</to>
                                    </copy>
                              </assign>
                           </else>
                        </if>
                     </sequence>
                     <else>
                        <if name="queryFiles">
                           <condition>$BPEL_ManageCodesOperationIn.part1/ns0:action = 'Query'</condition>
                           <sequence name="SequenceQueryFiles">
                              <assign name="initFields3">
                                   <copy>
                                      <from>1</from>
                                      <to variable="recordCounter"/>
                                   </copy>
                                   <copy>
                                      <from>1</from>
                                      <to variable="outputCounter"/>
                                   </copy>
                                    <copy>
                                        <from>
                                            <literal></literal>
                                        </from>
                                        <to part="parameters" variable="QueryCodeClassificationFilesFindAllIn"/>
                                    </copy>
                                </assign>
                              <invoke name="queryAllFiles" partnerLink="WS_CodeClassificationManager" operation="queryCodeClassificationFilesFindAll" xmlns:tns="http://CodeClassificationManagerService.webservice.ellectra.org/" portType="tns:CodeClassificationManager" inputVariable="QueryCodeClassificationFilesFindAllIn" outputVariable="QueryCodeClassificationFilesFindAllOut"/>
                              <while name="forEachFile">
                                 <condition>$recordCounter &lt;= count($QueryCodeClassificationFilesFindAllOut.parameters/return)</condition>
                                 <sequence name="Sequence5">
                                    <if name="ifClassificationFile">
                                       <condition>contains($QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/documentType, 'CODEFILE')</condition>
                                       <sequence name="Sequence6">
                                          <if name="checkDocStatus">
                                            <condition>string-length($QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/documentStatus) &gt; 0</condition>
                                            <assign name="writeDocStatus">
                                                 <copy>
                                                     <from>$QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/documentStatus</from>
                                                    <to>$BPEL_ManageCodesOperationOut.part1/ns0:classificationFile[$outputCounter]/ns0:documentStatus</to>
                                                </copy>
                                            </assign>
                                        </if>
                                        <if name="checkDescription">
                                            <condition>string-length($QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/description) &gt; 0</condition>
                                            <assign name="writeDescription">
                                                 <copy>
                                                     <from>$QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/description</from>
                                                    <to>$BPEL_ManageCodesOperationOut.part1/ns0:classificationFile[$outputCounter]/ns0:description</to>
                                                </copy>
                                            </assign>
                                        </if>
                                        <if name="checkLanguage">
                                            <condition>string-length($QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/language) &gt; 0</condition>
                                            <assign name="writeLanguage">
                                                 <copy>
                                                     <from>$QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/language</from>
                                                    <to>$BPEL_ManageCodesOperationOut.part1/ns0:classificationFile[$outputCounter]/ns0:language</to>
                                                </copy>
                                            </assign>
                                        </if>
                                        <if name="checkMimeType">
                                            <condition>string-length($QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/mimeType) &gt; 0</condition>
                                            <assign name="writeMimeType">
                                                 <copy>
                                                     <from>$QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/mimeType</from>
                                                    <to>$BPEL_ManageCodesOperationOut.part1/ns0:classificationFile[$outputCounter]/ns0:mimeType</to>
                                                </copy>
                                            </assign>
                                        </if>
                                        <if name="checkTimeStamp">
                                            <condition>string-length($QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/timeStamp) &gt; 0</condition>
                                            <assign name="writeTimeStamp">
                                                 <copy>
                                                     <from>$QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/timeStamp</from>
                                                    <to>$BPEL_ManageCodesOperationOut.part1/ns0:classificationFile[$outputCounter]/ns0:timeStamp</to>
                                                </copy>
                                            </assign>
                                        </if>
                                        <assign name="WriteRest">
                                             <copy>
                                                     <from>$QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/id</from>
                                                    <to>$BPEL_ManageCodesOperationOut.part1/ns0:classificationFile[$outputCounter]/ns0:fileID</to>
                                                </copy>
                                                <copy>
                                                     <from>$QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/documentType</from>
                                                    <to>$BPEL_ManageCodesOperationOut.part1/ns0:classificationFile[$outputCounter]/ns0:documentType</to>
                                                </copy>
                                                <copy>
                                                     <from>$QueryCodeClassificationFilesFindAllOut.parameters/return[$recordCounter]/filename</from>
                                                    <to>$BPEL_ManageCodesOperationOut.part1/ns0:classificationFile[$outputCounter]/ns0:filename</to>
                                                </copy>
                                         </assign>
                                         <assign name="increaseOut">
                                             <copy>
                                                   <from>$outputCounter + 1</from>
                                                      <to variable="outputCounter"/>
                                                </copy>
                                         </assign>
                                       </sequence>
                                    </if>
                                    <assign name="getNextRecord">
                                       <copy>
                                             <from>$recordCounter + 1</from>
                                                <to variable="recordCounter"/>
                                          </copy>
                                    </assign>
                                 </sequence>
                              </while>
                              <if name="ifCfpsFound">
                                 <condition>     $outputCounter &gt; 1     </condition>
                                 <assign name="AssignQueryOutput">
                                    <copy>
                                          <from>true()</from>
                                             <to>$BPEL_ManageCodesOperationOut.part1/ns0:return</to>
                                       </copy>
                                       <copy>
                                          <from>
                                                <literal>Success - Code Classification files have retrieved successfully</literal>
                                             </from>
                                             <to>$BPEL_ManageCodesOperationOut.part1/ns0:returnMessage</to>
                                       </copy>
                                 </assign>
                                 <else>
                                    <assign name="NotFound">
                                       <copy>
                                          <from>false()</from>
                                          <to>$BPEL_ManageCodesOperationOut.part1/ns0:return</to>
                                       </copy>
                                       <copy>
                                          <from>
                                             <literal>Result - not found Code Classification files</literal>
                                          </from>
                                          <to>$BPEL_ManageCodesOperationOut.part1/ns0:returnMessage</to>
                                       </copy>
                                    </assign>
                                 </else>
                              </if>
                           </sequence>
                        </if>
                     </else>
                  </if>
               </else>
            </if>
         </sequence>
         <else>
            <assign name="AssignAuthorisationError">
               <copy>
                  <from>$Authen_AuthoOperationOut.part1/ns1:returnMessage</from>
                  <to>$BPEL_ManageCodesOperationOut.part1/ns0:returnMessage</to>
               </copy>
               <copy>
                  <from>$Authen_AuthoOperationOut.part1/ns1:return</from>
                  <to>$BPEL_ManageCodesOperationOut.part1/ns0:return</to>
               </copy>
            </assign>
         </else>
      </if>
      <reply name="Reply1" partnerLink="BPEL_ManageCodes" operation="ManageCodesOperation" xmlns:tns="http://j2ee.netbeans.org/wsdl/ManageCodes" portType="tns:ManageCodesPortType" variable="BPEL_ManageCodesOperationOut"/>
   </sequence>
</process>
