Mass_CRON_Scheduler.xaction 3.71 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
<?xml version="1.0" encoding="UTF-8"?>
<action-sequence>
  <name>Mass_CRON_Scheduler.xaction</name>
  <version>1</version>
  <title>Mass CRON Scheduler</title>
  <logging-level>debug</logging-level>
  <documentation>
    <author>William E. Seyler</author>
    <description>Creates a set of crons based on two file inputs.  One file is a list of action sequences to schedule.  The other is a list of crons to schedule those action sequences against.</description>
    <help>TBD</help>
    <result-type>rule</result-type>
  </documentation>
  <inputs>
    <c-string type="string">
      <default-value type="string">name</default-value>
    </c-string>
    <jobAction type="string">
      <default-value>startJob</default-value>
    <sources><request>jobAction</request></sources></jobAction>
    <triggerType type="string">
      <default-value>cron</default-value> 
    </triggerType>
  </inputs>
  <outputs>
            <solution type="string"/>
            <path type="string"/>
            <action type="string"/>
            <cron type="string"/>
  </outputs>
  <resources/>
  <actions>
        <action-definition><action-type>JavaScript</action-type><action-inputs/>
        <action-outputs><rule-result type="list"/></action-outputs>
        <component-name>org.pentaho.component.JavascriptRule</component-name>
        <component-definition><script><![CDATA[ 
    function run( ) {
      var cronList = new Array('0 40 16 * * ?', '0 40 18 * * ?');
      var actionList = new Array( 
         new Array ('test', 'email', 'text_only_email.xaction' ),
         new Array ('test', 'email', 'text_html_attach_email.xaction' )  );

      var results = new JavaScriptResultSet();
      results.setColumnHeaders( new Array( 'solution', 'path', 'action', 'cron' ) );
      for( i=0; i<actionList.length; i++ ) {
        for( j=0; j<cronList.length; j++ ) {
        results.addRow( new Array( actionList[i][0],actionList[i][1],actionList[i][2], cronList[j] ) );
}
      }

      return results;

      }
    run(); 
    ]]> </script></component-definition></action-definition>


    <actions loop-on="rule-result">
        <action-definition>
          <action-type>Formatted Message</action-type>
          <action-inputs>
            <action type="string"/>
            <cron type="string"/>
          </action-inputs>
          <action-outputs>
            <jobName type="string"/>
          </action-outputs>
          <component-name>UtilityComponent</component-name>
          
        <component-definition><format> 
  <format-string>"{0}{1}"</format-string>  
  <arg>action</arg>  
  <arg>cron</arg>  
  <return>jobName</return> 
</format></component-definition></action-definition>
        <action-definition>
          <action-type>Formatted Message</action-type>
          <action-inputs>
            <jobName type="string"/>
          </action-inputs>
          <action-outputs/>
          <component-name>UtilityComponent</component-name>
          <component-definition>
            <print>
              <delimiter>"-"</delimiter> 
              <arg>jobName</arg>
            </print>
          </component-definition>
        </action-definition>
        <action-definition>
          <action-type>Start Job</action-type>
          <action-inputs>
            <jobAction type="string"/>
            <jobName type="string"/>
            <solution type="string"/>
            <path type="string"/>
            <action type="string"/>
            <triggerType type="string"/>
            <triggerName type="string" mapping="jobName"/>
          <cronString type="string" mapping="cronList"/>
          </action-inputs>
          <action-outputs/>
          <component-name>JobSchedulerComponent</component-name>
        </action-definition>
      </actions>
  </actions>
</action-sequence>