<?xml version="1.0" encoding="UTF-8"?>
<process xmlns:blue="http://www.e-marson.com/bluelemon">

  <descriptor>
    <name>com/emarson/lemonade/examples/mobank/_deployment/InstallerPIN</name>
    <version>1.0</version>
    <description>
      This process is used to create an installer 
      to be processed in the moBank MIDlet.
      It will install the functionality that will
      allow user to set a PIN number for the moBank application.
    </description>
    <vendor>E-MARSON</vendor>
  </descriptor>

  <path>
    
    <!-- ASSOCIATIONS --->

    <!-- association to Screen in mobank/pin --->
    <action name="action for 'Setting a PIN'">
      <type>general/bluelemon/code</type>
      <definition resultTo="goToScreen">
        <blue:call node="com/emarson/lemonade/examples/mobank/pin/Screen"
                         location="@com/emarson/lemonade/examples/mobank/pin"/>

      </definition>
    </action>


    <!-- PACKAGES INSTALLATION ---> 

    <subprocess name="mocheers">
      <source>com/emarson/lemonade/examples/mobank/_deployment/PackagePIN</source>
      <resultTo>package</resultTo>
    </subprocess> 


    <!-- 'PERMANENT' AND 'SESSION' UPDATES ---> 

    <!-- Update MenuOptions node in permanent location  --->
    <action name="add a row to the main menu">
      <type>general/bluelemon/code</type>
      <definition resultTo="addNewMenuRow">

        <!-- get a dataset with menu options --->
        <blue:get node="com/emarson/lemonade/examples/mobank/MenuOptions"
                  location="permanent" toVariable="menuOptions"/>

                  
        <!-- append the new row --->
        <blue:call manager="UtilsManager" method="appendFirst"
                   toVariable="menuOptions">

          <blue:argument type="variable" name="menuOptions"/>
          <blue:argument type="dataset">
            <blue:descriptor>
              <blue:field type="String"/>
              <blue:field type="byteArr"/>
            </blue:descriptor>
            <blue:row>
              <blue:field value="Setting a PIN"/>
              <blue:field contextKey="goToScreen"/>
            </blue:row>
          </blue:argument>
        </blue:call>

        <!-- and save the changes --->
        <blue:set node="com/emarson/lemonade/examples/mobank/MenuOptions"
                  location="permanent">

          <blue:argument type="variable" name="menuOptions"/>
        </blue:set>

      </definition>
    </action>
    
    
    <!-- POST-INSTALL INSTRUCTION ---> 
    
    <!-- Call AddUpdateInfo node --->
    <subprocess name="add update info">
      <source>com/emarson/lemonade/examples/mobank/_deployment/AddUpdateInfo</source>
      <arguments>
        <argument key="text">
          "To enhance your security, please open 'Setting a PIN' " +
          "from your main menu now."
        </argument>
      </arguments>
      <resultTo>updateInfoCode</resultTo>
    </subprocess>


    <finish name="done">
      <return>package + addNewMenuRow + updateInfoCode</return>
    </finish>

  </path>

</process>