<process type="asynchronous" pof-object-type="pt_expense" name="" id="P1164743269594" xmlns:aws="http://www.adobe.com/2004/AWSTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://adobe.com/workflow/template/support" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <description xsi:nil="true"/>
  <variables>
    <variable pof-attribute="id" type="xs:long" required="true" in="false" out="false" name="id" id="V1165954107392"/>
    <variable pof-attribute="create_time" type="xs:dateTime" required="true" in="false" out="false" name="create_time" id="V1165954107390"/>
    <variable pof-attribute="update_time" type="xs:dateTime" required="true" in="false" out="false" name="update_time" id="V1165954107394"/>
    <variable pof-attribute="creator_id" type="xs:string" required="true" in="false" out="false" name="creator_id" id="V1165954107391">
      <property readonly="false" dependent-property="" editor="" description="number of characters" name="length" id="VP1165954107468">100</property>
    </variable>
    <variable pof-attribute="status" type="xs:string" required="true" in="false" out="false" name="status" id="V1165954107393">
      <property readonly="false" dependent-property="" editor="" description="number of characters" name="length" id="VP1165954107469">100</property>
    </variable>
    <variable pof-attribute="expensereportform" type="aws:form" required="false" in="true" out="false" name="expensereportform" id="V1165954107395">
      <property readonly="false" dependent-property="schema rootnode" editor="com.adobe.workflow.tools.processdesigner.JTemplateUrlCellEditor" description="URL pointer to the form template associated with this variable." name="template-url" id="VP1165954107470">/Forms/Accounting/ExpenseReport1.xdp</property>
      <property readonly="false" dependent-property="" editor="com.adobe.workflow.tools.processdesigner.JXDPTextAreaCellEditor" description="Default XML document for form data." name="data" id="VP1165954107471"/>
      <property readonly="true" dependent-property="" editor="" description="name of data node (as specified by the form schema, or &quot;default&quot; if no schema is found)" name="schema rootnode" id="VP1165954107472">fields</property>
    </variable>
    <variable pof-attribute="pagecount" type="xs:int" required="false" in="false" out="false" name="pagecount" id="V1165954107396"/>
    <variable pof-attribute="pagenumber" type="xs:int" required="false" in="false" out="false" name="pagenumber" id="V1165954107397"/>
    <variable pof-attribute="expensereportdoc" type="aws:document" required="false" in="false" out="false" name="expensereportdoc" id="V1165954107398"/>
    <variable pof-attribute="originatoremail" type="xs:string" required="false" in="false" out="false" name="originatoremail" id="V1165954107399">
      <property readonly="false" dependent-property="" editor="" description="number of characters" name="length" id="VP1165954107473">100</property>
    </variable>
    <variable pof-attribute="accountantemail" type="xs:string" required="false" in="false" out="false" name="accountantemail" id="V1165954107400">
      <property readonly="false" dependent-property="" editor="" description="number of characters" name="length" id="VP1165954107474">100</property>
    </variable>
    <variable pof-attribute="grandtotal" type="xs:string" required="false" in="false" out="false" name="grandtotal" id="V1165954107401">
      <property readonly="false" dependent-property="" editor="" description="number of characters" name="length" id="VP1165954107475">100</property>
    </variable>
    <variable pof-attribute="employee" type="xs:string" required="false" in="false" out="false" name="employee" id="V1165954107402">
      <property readonly="false" dependent-property="" editor="" description="number of characters" name="length" id="VP1165954107476">100</property>
    </variable>
  </variables>
  <branch start-action="Set Variables" type="synchronous" y-position="0" x-position="0" name="main-branch" id="B1164743269688">
    <description xsi:nil="true"/>
    <actions>
      <execute component-id="User" color="" y-position="392" x-position="129" name="Accountant Review" id="A1164912646039">
        <description/>
        <routes>
          <route destination="Originator Review" to-port="INPUT" from-port="OUTPUT" y-offset="0" x-offset="55" link-type="normal" connective="and" name="Reject" id="R1164912646054">
            <description xsi:nil="true"/>
          </route>
          <route destination="Accounts Payable Review" to-port="INPUT" from-port="OUTPUT" y-offset="0" x-offset="55" link-type="normal" connective="and" name="Accept" id="R1165452578359">
            <description xsi:nil="true"/>
          </route>
        </routes>
        <input><![CDATA[<pat-action>
    <formdata-input-variable>expensereportform</formdata-input-variable>
    <formdata-output-variable>expensereportform</formdata-output-variable>
    <use-inputform-for-formurl>true</use-inputform-for-formurl>
    <formurl/>
    <dataTypeIn>FORM_VARIABLE</dataTypeIn>
    <dataTypeOut>FORM_VARIABLE</dataTypeOut>
    <instructions>Review the expense report for any errrors. Rejecting it will send the form back to the employee.</instructions>
    <type>4</type>
    <path/>
    <individual-cn/>
    <individual-dn/>
    <group-cn>cn=accounting,ou=groups,dc=etech,dc=adobe,dc=com</group-cn>
    <group-dn>SunOne</group-dn>
    <group-select-type>GROUP_QUEUE</group-select-type>
    <escalation-type>2</escalation-type>
    <escalation-days/>
    <escalation-hours/>
    <escalation-minutes/>
    <escalation-path/>
    <escalation-individual-cn/>
    <escalation-individual-dn/>
    <escalation-group-cn/>
    <escalation-group-dn/>
    <escalation-select-group-type>GROUP_QUEUE</escalation-select-group-type>
    <escalation-after-start>false</escalation-after-start>
    <use-first-reminder>false</use-first-reminder>
    <first-reminder-days/>
    <first-reminder-hours/>
    <first-reminder-minutes/>
    <use-repeat-reminder>false</use-repeat-reminder>
    <repeat-reminder-days/>
    <repeat-reminder-hours/>
    <repeat-reminder-minutes/>
    <reminder-override-instructions>false</reminder-override-instructions>
    <reminder-instructions/>
    <use-deadline>false</use-deadline>
    <deadline-days/>
    <deadline-hours/>
    <deadline-minutes/>
    <use-deadline-action>false</use-deadline-action>
    <deadline-action/>
    <deadline-override-instructions>false</deadline-override-instructions>
    <deadline-instructions/>
    <map-route-to-actions>true</map-route-to-actions>
    <is-action-required>false</is-action-required>
    <copy-attachments>true</copy-attachments>
    <show-attachments>false</show-attachments>
    <task-completed-by-mapping/>
    <task-id-mapping/>
</pat-action>]]></input>
      </execute>
      <execute component-id="User" color="" y-position="520" x-position="302" name="Originator Review" id="A1164912646042">
        <description/>
        <routes>
          <route destination="Set Variables" to-port="INPUT" from-port="OUTPUT" y-offset="0" x-offset="0" link-type="normal" connective="and" name=">>" id="R1165260666098">
            <description xsi:nil="true"/>
          </route>
        </routes>
        <input><![CDATA[<pat-action>
    <formdata-input-variable>expensereportform</formdata-input-variable>
    <formdata-output-variable>expensereportform</formdata-output-variable>
    <use-inputform-for-formurl>true</use-inputform-for-formurl>
    <formurl/>
    <dataTypeIn>FORM_VARIABLE</dataTypeIn>
    <dataTypeOut>FORM_VARIABLE</dataTypeOut>
    <instructions>The expense report you submitted was rejected, please correct it and re-submit it.</instructions>
    <type>3</type>
    <path/>
    <individual-cn/>
    <individual-dn/>
    <group-cn/>
    <group-dn/>
    <group-select-type>GROUP_QUEUE</group-select-type>
    <escalation-type>2</escalation-type>
    <escalation-days/>
    <escalation-hours/>
    <escalation-minutes/>
    <escalation-path/>
    <escalation-individual-cn/>
    <escalation-individual-dn/>
    <escalation-group-cn/>
    <escalation-group-dn/>
    <escalation-select-group-type>GROUP_QUEUE</escalation-select-group-type>
    <escalation-after-start>false</escalation-after-start>
    <use-first-reminder>false</use-first-reminder>
    <first-reminder-days/>
    <first-reminder-hours/>
    <first-reminder-minutes/>
    <use-repeat-reminder>false</use-repeat-reminder>
    <repeat-reminder-days/>
    <repeat-reminder-hours/>
    <repeat-reminder-minutes/>
    <reminder-override-instructions>false</reminder-override-instructions>
    <reminder-instructions/>
    <use-deadline>false</use-deadline>
    <deadline-days/>
    <deadline-hours/>
    <deadline-minutes/>
    <use-deadline-action>false</use-deadline-action>
    <deadline-action/>
    <deadline-override-instructions>false</deadline-override-instructions>
    <deadline-instructions/>
    <map-route-to-actions>false</map-route-to-actions>
    <is-action-required>false</is-action-required>
    <copy-attachments>false</copy-attachments>
    <show-attachments>false</show-attachments>
    <task-completed-by-mapping/>
    <task-id-mapping/>
</pat-action>]]></input>
      </execute>
      <execute component-id="SetValue" color="" y-position="555" x-position="4" name="Set Variables" id="A1165260666050">
        <description/>
        <routes>
          <route destination="Accountant Review" to-port="INPUT" from-port="OUTPUT" y-offset="1" x-offset="3" link-type="normal" connective="and" name=">>" id="R1165260666097">
            <description xsi:nil="true"/>
          </route>
        </routes>
        <input>&lt;mappings>&lt;mapping value="/process_data/expensereportform/form-data/data/xdp/datasets/data/fields/employee" location="/process_data/@employee"/>&lt;mapping value="/process_data/expensereportform/form-data/data/xdp/datasets/data/fields/grandTotal" location="/process_data/@grandtotal"/>&lt;/mappings></input>
      </execute>
      <execute component-id="User" color="" y-position="269" x-position="279" name="Accounts Payable Review" id="A1165452578344">
        <description/>
        <routes>
          <route destination="Complete" to-port="INPUT" from-port="OUTPUT" y-offset="0" x-offset="0" link-type="normal" connective="and" name=">>" id="R1165452578360">
            <description xsi:nil="true"/>
          </route>
        </routes>
        <input><![CDATA[<pat-action>
    <formdata-input-variable>expensereportform</formdata-input-variable>
    <formdata-output-variable>expensereportform</formdata-output-variable>
    <use-inputform-for-formurl>true</use-inputform-for-formurl>
    <formurl/>
    <dataTypeIn>FORM_VARIABLE</dataTypeIn>
    <dataTypeOut>FORM_VARIABLE</dataTypeOut>
    <instructions>Write a cheque to the employee for the total amount and record the cheque number used on the form</instructions>
    <type>4</type>
    <path/>
    <individual-cn/>
    <individual-dn/>
    <group-cn>cn=accounts payable,ou=groups,dc=etech,dc=adobe,dc=com</group-cn>
    <group-dn>SunOne</group-dn>
    <group-select-type>GROUP_QUEUE</group-select-type>
    <escalation-type>2</escalation-type>
    <escalation-days/>
    <escalation-hours/>
    <escalation-minutes/>
    <escalation-path/>
    <escalation-individual-cn/>
    <escalation-individual-dn/>
    <escalation-group-cn/>
    <escalation-group-dn/>
    <escalation-select-group-type>GROUP_QUEUE</escalation-select-group-type>
    <escalation-after-start>false</escalation-after-start>
    <use-first-reminder>false</use-first-reminder>
    <first-reminder-days/>
    <first-reminder-hours/>
    <first-reminder-minutes/>
    <use-repeat-reminder>false</use-repeat-reminder>
    <repeat-reminder-days/>
    <repeat-reminder-hours/>
    <repeat-reminder-minutes/>
    <reminder-override-instructions>false</reminder-override-instructions>
    <reminder-instructions/>
    <use-deadline>false</use-deadline>
    <deadline-days/>
    <deadline-hours/>
    <deadline-minutes/>
    <use-deadline-action>false</use-deadline-action>
    <deadline-action/>
    <deadline-override-instructions>false</deadline-override-instructions>
    <deadline-instructions/>
    <map-route-to-actions>false</map-route-to-actions>
    <is-action-required>false</is-action-required>
    <copy-attachments>false</copy-attachments>
    <show-attachments>false</show-attachments>
    <task-completed-by-mapping/>
    <task-id-mapping/>
</pat-action>]]></input>
      </execute>
      <split y-position="197" x-position="443" join-type="and" color="" name="Complete" id="A1164912646047">
        <description/>
        <branches>
          <branch start-action="Archive to DB" type="synchronous" y-position="223" x-position="646" name="Archive" id="B1164912646040">
            <description/>
            <actions>
              <execute component-id="SQL" color="" y-position="249" x-position="656" name="Archive to DB" id="A1164912646050">
                <description/>
                <input>&lt;pat-action>
    &lt;sql_statement>INSERT INTO expenseReportArchive (id, date, submitter, amount, data) VALUES (
'{$string(/process_data/@id)$}',
'{$string(/process_data/@create_time)$}',
'{$string(/process_data/@creator_id)$}',
'{$string(/process_data/@grandtotal)$}',
'{$serialize(/process_data/expensereportform/form-data/data/*, false) $}');&lt;/sql_statement>
    &lt;statement_type>INSERT&lt;/statement_type>
    &lt;data_map/>
&lt;/pat-action></input>
              </execute>
            </actions>
          </branch>
          <branch start-action="Lookup creator e-mail in DB" type="synchronous" y-position="365" x-position="545" name="Notify" id="B1164912646041">
            <description/>
            <actions>
              <execute component-id="Email with Attachments" color="" y-position="391" x-position="746" name="E-mail Originator" id="A1164912646051">
                <description/>
                <input><![CDATA[<pat-action>
    <subject>Expense Report Approved</subject>
    <from_address>livecycle</from_address>
    <smtp_requires_auth>true</smtp_requires_auth>
    <smtp_loginname>livecycle@sandbox.adobe.com</smtp_loginname>
    <smtp_password>password</smtp_password>
    <email_address>{$/process_data/@originatoremail$}</email_address>
    <cc_email_address/>
    <bcc_email_address/>
    <message_format>text</message_format>
    <message_text>{$/process_data/@employee$}

Your expense report has been approved. You will be receiving a cheque for ${$/process_data/@grandtotal$}.
</message_text>
    <attachments/>
</pat-action>]]></input>
              </execute>
              <execute component-id="SQL" color="" y-position="391" x-position="555" name="Lookup creator e-mail in DB" id="A1165260666049">
                <description/>
                <routes>
                  <route destination="E-mail Originator" to-port="INPUT" from-port="OUTPUT" y-offset="-10" x-offset="-12" link-type="normal" connective="and" name=">>" id="R1165260666095">
                    <description xsi:nil="true"/>
                  </route>
                </routes>
                <input><![CDATA[<pat-action>
    <sql_statement>SELECT email from edcprincipalentity where id='{$/process_data/@creator_id$}'</sql_statement>
    <statement_type>SELECT</statement_type>
    <data_map>email=/process_data/@originatoremail|</data_map>
</pat-action>]]></input>
              </execute>
            </actions>
          </branch>
          <branch start-action="Convert From to PDF" type="synchronous" y-position="522" x-position="546" name="Save" id="B1164912646042">
            <description/>
            <actions>
              <execute component-id="Script" color="" y-position="548" x-position="730" name="Save Copy to Disk" id="A1164912646052">
                <description/>
                <input>&lt;pat-action>
    &lt;interactive>false&lt;/interactive>
    &lt;test-data>
        &lt;value variable="originatoremail"/>
        &lt;value variable="create_time"/>
        &lt;value variable="accountantemail"/>
        &lt;value variable="update_time"/>
        &lt;value variable="pagenumber"/>
        &lt;value variable="reviewtaskid"/>
        &lt;value variable="creator_id"/>
        &lt;value variable="expensereportdoc"/>
        &lt;value variable="expensereportform"/>
        &lt;value variable="status"/>
        &lt;value variable="pagecount"/>
        &lt;value variable="id"/>
    &lt;/test-data>
    &lt;script>import com.adobe.idp.*;
import com.adobe.workflow.pat.service.*;
import com.adobe.service.DataBuffer;
import java.io.*;

Document myDoc = patExecContext.getProcessDataDocumentValue("/process_data/@expensereportdoc");
DataBuffer buf = myDoc.getDataBuffer();
byte[] attBytes = buf.getBytes(0, buf.getBufLength());

String timestamp = patExecContext.getProcessDataStringValue("/process_data/@update_time");
timestamp = timestamp.replaceAll("T", "-");
timestamp = timestamp.replaceFirst(":", "h");
timestamp = timestamp.replaceFirst(":", "m");
timestamp = timestamp.replaceAll("Z", "-GMT");

String filename = patExecContext.getProcessDataStringValue("/process_data/expensereportform/form-data/templateURI");

filename = filename.substring(filename.lastIndexOf('/'), filename.lastIndexOf('.'));
filename += "-";
filename += timestamp;
filename += ".pdf";
File tempFile = new File("C:\\tmp" + filename);
FileOutputStream targetFile = new FileOutputStream(tempFile);
targetFile.write(attBytes);
targetFile.close();&lt;/script>
&lt;/pat-action></input>
              </execute>
              <execute component-id="Form Server Render Form" color="" y-position="548" x-position="556" name="Convert From to PDF" id="A1165452578343">
                <description/>
                <routes>
                  <route destination="Save Copy to Disk" to-port="INPUT" from-port="OUTPUT" y-offset="-21" x-offset="-6" link-type="normal" connective="and" name=">>" id="R1165452578358">
                    <description xsi:nil="true"/>
                  </route>
                </routes>
                <input><![CDATA[<pat-action>
    <FormQuery>ExpenseReport1.xdp</FormQuery>
    <FormPreference>PDF</FormPreference>
    <Options/>
    <UserAgent/>
    <ApplicationWebRoot/>
    <InputXML>{$ serialize(/process_data/expensereportform/form-data/data/*, false) $}</InputXML>
    <TargetURL/>
    <ContentRootURI>file:///c:/forms</ContentRootURI>
    <BaseURL/>
    <Username/>
    <Password/>
    <Document>/process_data/@expensereportdoc</Document>
    <PageCount>/process_data/@pagecount</PageCount>
    <PageNumber>/process_data/@pagenumber</PageNumber>
    <xmlTemplate/>
</pat-action>]]></input>
              </execute>
            </actions>
          </branch>
        </branches>
      </split>
    </actions>
  </branch>
  <init-forms>
    <init-form data-type-out="Form" data-rootnode-name="fields" template-url="/Forms/Accounting/ExpenseReport1.xdp" name="ExpenseReport" id="IF1165954107718">
      <action-list>submit, cancel</action-list>
    </init-form>
  </init-forms>
</process>
