invent_subscribe.xaction 12.4 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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
<?xml version="1.0" encoding="UTF-8"?>
<action-sequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
  <title>%title</title>
  <version>1</version>
  <logging-level>ERROR</logging-level>
  <documentation> 
    <author>Michael D'Amour</author>  
    <description>%description</description>  
    <icon>inventory.png</icon>  
    <help/>  
    <result-type>report</result-type> 
  </documentation>

  <inputs> 
    <reportType type="string"> 
      <default-value>pdf</default-value>  
      <sources> 
        <request>reportType</request> 
      </sources> 
    </reportType>  
    <productLine type="string"> 
      <sources> 
        <request>productLine</request> 
      </sources>  
      <default-value/> 
    </productLine>  
    <reportTypeList type="property-map-list"> 
      <sources> 
        <request>reportTypeList</request> 
      </sources>  
      <default-value type="property-map-list"> 
        <property-map> 
          <entry key="reportTypeDesc">Send as PDF</entry>  
          <entry key="reportTypeId">pdf</entry> 
        </property-map>  
        <property-map> 
          <entry key="reportTypeDesc">Send as Excel</entry>  
          <entry key="reportTypeId">xls</entry> 
        </property-map>  
        <property-map> 
          <entry key="reportTypeDesc">View in Browser</entry>  
          <entry key="reportTypeId">html</entry> 
        </property-map> 
      </default-value> 
    </reportTypeList>  
    <emailAddress type="string"> 
      <sources> 
        <request>emailAddress</request> 
      </sources>  
      <default-value>empty</default-value>
    </emailAddress>  
    <SUB_SCHEDULED_EXECUTE type="string"> 
      <sources> 
        <request>SUB_SCHEDULED_EXECUTE</request> 
      </sources>  
      <default-value>false</default-value> 
    </SUB_SCHEDULED_EXECUTE>  
    <SUB_EXECUTE_TIME type="string"> 
      <sources> 
        <request>SUB_EXECUTE_TIME</request> 
      </sources>  
      <default-value>NO VALUE</default-value> 
    </SUB_EXECUTE_TIME>  
    <SUB_SCHEDULE_NAME type="string"> 
      <sources> 
        <request>SUB_SCHEDULE_NAME</request> 
      </sources>  
      <default-value>NO VALUE</default-value> 
    </SUB_SCHEDULE_NAME>  
    <SUB_NAME type="string"> 
      <sources> 
        <request>SUB_NAME</request> 
      </sources>  
      <default-value>NO VALUE</default-value> 
    </SUB_NAME>  
    <SUB_ID type="string"> 
      <sources> 
        <request>SUB_ID</request> 
      </sources>  
      <default-value>NO VALUE</default-value> 
    </SUB_ID> 
  </inputs>

  <outputs> 
    <!-- an output stream will be provided by default -->  
    <ConfMessage type="content"> 
      <destinations> 
        <response>content</response> 
      </destinations> 
    </ConfMessage> 
  </outputs>

  <resources> 
    <!-- use this section to identify any files that the component needs to execute the report -->  
    <report-definition> 
      <solution-file> 
        <location>Inventory List.xml</location>  
        <mime-type>text/xml</mime-type> 
      </solution-file> 
    </report-definition> 
  </resources>
  
  <actions> 
    <action-definition> 
      <component-name>SQLLookupRule</component-name>
      <action-type>Get List of Product Lines</action-type>
      <action-outputs> 
        <PRODUCTLINE type="string"/>  
        <query-result type="result-set" mapping="productLineList"/> 
      </action-outputs>
      <component-definition> 
        <jndi>SampleData</jndi>  
        <query><![CDATA[SELECT DISTINCT (PRODUCTLINE) FROM PRODUCTS ORDER BY PRODUCTLINE ASC]]></query> 
      </component-definition> 
    </action-definition>
  
    <action-definition> 
      <component-name>SecureFilterComponent</component-name>
      <action-type>Prompt for Product Line and Report Type</action-type>
      <action-inputs> 
        <productLine type="string"/>  
        <productLineList type="result-set"/>  
        <reportType type="string"/>  
        <reportTypeList type="property-map-list"/>  
        <emailAddress type="string"/> 
      </action-inputs>
      <component-definition> 
        <selections> 
          <productLine style="list-multi"> 
            <title>Product Line</title>  
            <filter value-col-name="PRODUCTLINE" display-col-name="PRODUCTLINE">productLineList</filter> 
          </productLine>  
          <reportType style="radio"> 
            <title>Report Type</title>  
            <filter value-col-name="reportTypeId" display-col-name="reportTypeDesc">reportTypeList</filter> 
          </reportType>  
          <emailAddress filter="none" optional="true"> 
            <title>Enter Email Address, if choosing Send.</title> 
          </emailAddress> 
        </selections> 
      </component-definition> 
    </action-definition>
  
    <action-definition> 
      <component-name>SQLLookupRule</component-name>
      <action-type>Run Data Query</action-type>
      <action-inputs> 
        <productLine type="string"/> 
      </action-inputs>
      <action-outputs> 
        <query-result type="result-set" mapping="data_source_result"/> 
      </action-outputs>
      <component-definition> 
        <jndi>SampleData</jndi>  
        <query><![CDATA[SELECT PRODUCTLINE, PRODUCTVENDOR, PRODUCTCODE, PRODUCTNAME,PRODUCTSCALE, PRODUCTDESCRIPTION, QUANTITYINSTOCK, BUYPRICE, MSRP FROM PRODUCTS WHERE  PRODUCTLINE IN ({PREPARE:productLine}) ORDER BY PRODUCTLINE ASC, PRODUCTVENDOR ASC, PRODUCTCODE ASC]]></query> 
      </component-definition> 
    </action-definition>
  
    <actions> 
      <condition><![CDATA[reportType == "html"]]></condition>  
      <action-definition> 
        <component-name>JFreeReportComponent</component-name>
        <action-type>View with Browser</action-type>
        <action-inputs> 
          <data type="result-set" mapping="data_source_result"/> 
        </action-inputs>
        <action-resources> 
          <report-definition type="resource"/> 
        </action-resources>
        <component-definition> 
          <output-type>html</output-type> 
        </component-definition> 
      </action-definition>
 
    </actions>
  
    <actions> 
      <condition><![CDATA[reportType != "html"]]></condition>  
      <action-definition> 
        <component-name>UtilityComponent</component-name>
        <action-type>Create Attachment Name</action-type>
        <action-inputs> 
          <reportType type="string"/> 
        </action-inputs>
        <action-outputs> 
          <formatted_msg type="string" mapping="attach_name"/> 
        </action-outputs>
        <component-definition> 
          <format> 
            <return>formatted_msg</return>  
            <format-string>"Inventory.{0}"</format-string>  
            <arg>reportType</arg> 
          </format> 
        </component-definition> 
      </action-definition>
  
      <action-definition> 
        <component-name>UtilityComponent</component-name>
        <action-type>Create Subject Line</action-type>
        <action-inputs/>
        <action-outputs> 
          <formatted_msg type="string" mapping="subject"/> 
        </action-outputs>
        <component-definition> 
          <format> 
            <format-string>"Inventory Report"</format-string>  
            <return>formatted_msg</return> 
          </format> 
        </component-definition> 
      </action-definition>
  
      <action-definition> 
        <component-name>UtilityComponent</component-name>
        <action-type>Create Message</action-type>
        <action-inputs/>
        <action-outputs> 
          <formatted_msg type="string" mapping="message_text"/> 
        </action-outputs>
        <component-definition> 
          <format> 
            <format-string>"Attached is the Inventory Report."</format-string>  
            <return>formatted_msg</return> 
          </format> 
        </component-definition> 
      </action-definition>
  
      <action-definition> 
        <component-name>JFreeReportComponent</component-name>
        <action-type>Run Report</action-type>
        <action-inputs> 
          <output-type type="string" mapping="reportType"/>  
          <data type="result-set" mapping="data_source_result"/> 
        </action-inputs>
        <action-resources> 
          <report-definition type="resource"/> 
        </action-resources>
        <action-outputs> 
          <report-output type="content" mapping="report_output"/> 
        </action-outputs>
        <component-definition/> 
      </action-definition>
  
      <actions> 
        <condition><![CDATA[SUB_SCHEDULED_EXECUTE]]></condition>  
        <action-definition> 
          <component-name>JavascriptRule</component-name>
          <action-type>Build Message for Subscription</action-type>
          <action-inputs> 
            <SUB_EXECUTE_TIME type="string"/>  
            <SUB_SCHEDULE_NAME type="string"/>  
            <SUB_NAME type="string"/>  
            <SUB_ID type="string"/>  
            <productLine type="string"/>  
            <data_source_result type="result-set"/> 
          </action-inputs>
          <action-outputs> 
            <emailSubject type="string"/>  
            <resultMessage type="string"/> 
          </action-outputs>
          <component-definition> 
            <script><![CDATA[resultMessage = "Attached is your Inventory Report for Product Lines: " + "{productLine}" + ".\n";
resultMessage += "\nSubscription Name: " + SUB_NAME;
resultMessage += "\nExecuted on: " + SUB_EXECUTE_TIME;
resultMessage += "\nSchedule Name: " + SUB_SCHEDULE_NAME;
resultMessage += "\n\nSent by the Pentaho BI Platform - Pro Edition\n";

emailSubject = "Subscription Error for id: " + SUB_ID;

if ( data_source_result.getRowCount() > 0 ) {
  emailSubject = "Inventory Report for: " + "{productLine}";
}]]></script> 
          </component-definition> 
        </action-definition>
  
        <action-definition> 
          <component-name>EmailComponent</component-name>
          <action-type>Email PDF or Excel</action-type>
          <action-inputs> 
            <message-plain type="string" mapping="resultMessage"/>  
            <report_output type="content"/>  
            <subject type="string" mapping="emailSubject"/>  
            <to type="string" mapping="emailAddress"/>  
            <attach_name type="string"/> 
          </action-inputs>
          <component-definition> 
            <from>pentaho-server@pentaho.org</from>  
            <attachment-ref name-param="attach_name" input-param="report_output"/> 
          </component-definition> 
        </action-definition>
  
        <action-definition> 
          <component-name>TemplateComponent</component-name>
          <action-type>Confirmation Message</action-type>
          <action-inputs> 
            <emailAddress type="string"/>  
            <productLine type="string"/> 
          </action-inputs>
          <action-outputs> 
            <output-message type="string" mapping="ConfMessage"/> 
          </action-outputs>
          <component-definition> 
            <template><![CDATA[The report was sent to {emailAddress}.  Selections are: {productLine}]]></template> 
          </component-definition> emailAddress
        </action-definition>
 
      </actions>
  
      <actions> 
        <condition><![CDATA[SUB_SCHEDULED_EXECUTE == "false"]]></condition>  
        <action-definition> 
          <component-name>EmailComponent</component-name>
          <action-type>Email PDF or Excel</action-type>
          <action-inputs> 
            <message-plain type="string" mapping="message_text"/>  
            <report_output type="content"/>  
            <subject type="string"/>  
            <to type="string" mapping="emailAddress"/>  
            <attach_name type="string"/> 
          </action-inputs>
          <component-definition> 
            <from>pentaho-server@pentaho.org</from>  
            <attachment-ref name-param="attach_name" input-param="report_output"/> 
          </component-definition> 
        </action-definition>
  
        <action-definition> 
          <component-name>TemplateComponent</component-name>
          <action-type>Confirmation Message</action-type>
          <action-inputs> 
            <emailAddress type="string"/>  
            <productLine type="string"/> 
          </action-inputs>
          <action-outputs> 
            <output-message type="content" mapping="ConfMessage"/> 
          </action-outputs>
          <component-definition> 
            <template><![CDATA[The report was sent to {emailAddress}.  Selections are: {productLine}]]></template> 
          </component-definition> 
        </action-definition>
 
      </actions>
 
    </actions>
 
  </actions> 
</action-sequence>