<?xml version="1.0" encoding="UTF-8"?>

<action-sequence>
  <name>territory.waqr.xaction</name>
  <version>1</version>
  <title>territory</title>
  <documentation>
    <author>joe</author>
    <description>Territory Report</description>
    <icon>PentahoReporting.png</icon>
    <help>Auto-generated action-sequence for WAQR.</help>
    <result-type>report</result-type>
  </documentation>
  <inputs>
    <output-type type="string">
      <default-value>html</default-value>
      <sources>
        <request>type</request>
      </sources>
    </output-type>
  </inputs>
  <outputs>
    <report type="content">
      <destinations>
        <response>content</response>
      </destinations>
    </report>
  </outputs>
  <resources>
    <report-definition>
      <xml>
        <location>
          <report bottommargin="10" topmargin="10" rightmargin="10" leftmargin="10" pageformat="LETTER" orientation="landscape" name="territory.waqr.xreportspec">
            <parser-config>
              <property name="reportheader">Territory Report Header</property>
              <property name="reportfooter">Territory Report Footer</property>
              <property name="pageheader">Territory Page Header</property>
              <property name="pagefooter">Territory Page Footer</property>
            </parser-config>
            <reportheader color="#ff7d17" fontname="Arial" fontsize="16">
              <message-field alignment="left" height="18" vertical-alignment="middle" width="100%" x="0%" y="0">${reportheader}</message-field>
            </reportheader>
            <reportfooter color="#ff7d17" fontname="Arial" fontsize="16">
              <message-field alignment="center" height="18" vertical-alignment="top" width="100%" x="0%" y="0">${reportfooter}</message-field>
            </reportfooter>
            <pageheader color="#c0c0c0" fontname="Arial" fontsize="8">
              <message-field alignment="left" height="18" vertical-alignment="middle" width="50%" x="0%" y="0">${pageheader}</message-field>
              <message-field alignment="right" height="18" width="50%" x="50%" y="0">$(report.date, date, MMMM dd, yyyy @ hh:mm )</message-field>
              <line color="#9eaa36" height="3" weight="1" width="100%" x1="0%" x2="100%" y1="18" y2="18"/>
            </pageheader>
            <pagefooter color="#c0c0c0" fontname="Arial" fontsize="8">
              <line color="#9eaa36" height="3" weight="1" width="100%" x1="0%" x2="100%" y1="0" y2="0"/>
              <message-field alignment="left" height="18" width="50%" x="0" y="0">${pagefooter}</message-field>
              <message-field alignment="right" height="18" width="50%" x="50%" y="0">Page $(PageofPages)</message-field>
            </pagefooter>
            <functions>
              <property-ref name="report.date"/>
              <function class="org.jfree.report.function.PageOfPagesFunction" name="PageofPages"/>
              <function name="backgroundTrigger" class="org.jfree.report.function.ElementVisibilitySwitchFunction">
                <properties>
                  <property name="element">rowBandingElement</property>
                  <property name="numberOfElements">1</property>
                  <property name="initialState">true</property>
                </properties>
              </function>
              <expression class="org.jfree.report.function.HideElementIfDataAvailableExpression" name="noDataLabelElementHideIfNullTrigger">
                <properties>
                  <property name="element">noDataLabelElement</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ShowElementIfDataAvailableExpression" name="dummyGroupFooterHideIfNullTrigger">
                <properties>
                  <property name="element">dummyGroupFooter</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ItemAvgFunction" name="Summary_BC_ORDERDETAILS_PRICEEACHExpression">
                <properties>
                  <property name="field">BC_ORDERDETAILS_PRICEEACH</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ItemSumFunction" name="Summary_BC_ORDERDETAILS_QUANTITYORDEREDExpression">
                <properties>
                  <property name="field">BC_ORDERDETAILS_QUANTITYORDERED</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ItemSumFunction" name="Summary_BC_ORDERDETAILS_TOTALExpression">
                <properties>
                  <property name="field">BC_ORDERDETAILS_TOTAL</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ShowElementIfDataAvailableExpression" name="BC_CUSTOMER_W_TER_TERRITORYGroupHeaderHideIfNullTrigger">
                <properties>
                  <property name="element">BC_CUSTOMER_W_TER_TERRITORYGroupHeader</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ShowElementIfDataAvailableExpression" name="BC_CUSTOMER_W_TER_TERRITORYGroupFooterHideIfNullTrigger">
                <properties>
                  <property name="element">BC_CUSTOMER_W_TER_TERRITORYGroupFooter</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ItemAvgFunction" name="BC_CUSTOMER_W_TER_TERRITORYBC_ORDERDETAILS_PRICEEACHExpression">
                <properties>
                  <property name="field">BC_ORDERDETAILS_PRICEEACH</property>
                  <property name="group">BC_CUSTOMER_W_TER_TERRITORY</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ItemSumFunction" name="BC_CUSTOMER_W_TER_TERRITORYBC_ORDERDETAILS_QUANTITYORDEREDExpression">
                <properties>
                  <property name="field">BC_ORDERDETAILS_QUANTITYORDERED</property>
                  <property name="group">BC_CUSTOMER_W_TER_TERRITORY</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ItemSumFunction" name="BC_CUSTOMER_W_TER_TERRITORYBC_ORDERDETAILS_TOTALExpression">
                <properties>
                  <property name="field">BC_ORDERDETAILS_TOTAL</property>
                  <property name="group">BC_CUSTOMER_W_TER_TERRITORY</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ShowElementIfDataAvailableExpression" name="BC_CUSTOMER_W_TER_CUSTOMERNAMEGroupHeaderHideIfNullTrigger">
                <properties>
                  <property name="element">BC_CUSTOMER_W_TER_CUSTOMERNAMEGroupHeader</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ShowElementIfDataAvailableExpression" name="BC_CUSTOMER_W_TER_CUSTOMERNAMEGroupFooterHideIfNullTrigger">
                <properties>
                  <property name="element">BC_CUSTOMER_W_TER_CUSTOMERNAMEGroupFooter</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ItemAvgFunction" name="BC_CUSTOMER_W_TER_CUSTOMERNAMEBC_ORDERDETAILS_PRICEEACHExpression">
                <properties>
                  <property name="field">BC_ORDERDETAILS_PRICEEACH</property>
                  <property name="group">BC_CUSTOMER_W_TER_CUSTOMERNAME</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ItemSumFunction" name="BC_CUSTOMER_W_TER_CUSTOMERNAMEBC_ORDERDETAILS_QUANTITYORDEREDExpression">
                <properties>
                  <property name="field">BC_ORDERDETAILS_QUANTITYORDERED</property>
                  <property name="group">BC_CUSTOMER_W_TER_CUSTOMERNAME</property>
                </properties>
              </expression>
              <expression class="org.jfree.report.function.ItemSumFunction" name="BC_CUSTOMER_W_TER_CUSTOMERNAMEBC_ORDERDETAILS_TOTALExpression">
                <properties>
                  <property name="field">BC_ORDERDETAILS_TOTAL</property>
                  <property name="group">BC_CUSTOMER_W_TER_CUSTOMERNAME</property>
                </properties>
              </expression>
            </functions>
            <items color="#000000" fontname="Arial" fontsize="9" fontstyle="plain">
              <rectangle name="rowBandingElement" color="#e7e7e7" draw="false" fill="true" height="11" x="0%" width="100%" y="0"/>
              <string-field name="BC_PRODUCTS_PRODUCTNAMEElement" nullstring="-" fieldname="BC_PRODUCTS_PRODUCTNAME" vertical-alignment="middle" alignment="left" width="25.0%" x="0.0%" y="0" height="11" color="#000000" fontname="Arial" fontsize="9"/>
              <number-field name="BC_ORDERDETAILS_PRICEEACHElement" nullstring="-" fieldname="BC_ORDERDETAILS_PRICEEACH" format="$#,###.##" vertical-alignment="middle" alignment="left" width="25.0%" x="25.0%" y="0" height="11" color="#000000" fontname="Arial" fontsize="10" fontstyle="plain"/>
              <number-field name="BC_ORDERDETAILS_QUANTITYORDEREDElement" nullstring="-" fieldname="BC_ORDERDETAILS_QUANTITYORDERED" format="#,###.##" vertical-alignment="middle" alignment="left" width="25.0%" x="50.0%" y="0" height="11" color="#000000" fontname="Arial" fontsize="10" fontstyle="plain"/>
              <number-field name="BC_ORDERDETAILS_TOTALElement" nullstring="-" fieldname="BC_ORDERDETAILS_TOTAL" format="$#,###.##" vertical-alignment="middle" alignment="left" width="25.0%" x="75.0%" y="0" height="11" color="#000000" fontname="Arial" fontsize="10" fontstyle="plain"/>
              <line color="#c0c0c0" weight=".5" x1="0.0%" y1="0" x2="0.0%" y2="11"/>
              <line color="#c0c0c0" weight=".5" x1="25.0%" y1="0" x2="25.0%" y2="11"/>
              <line color="#c0c0c0" weight=".5" x1="50.0%" y1="0" x2="50.0%" y2="11"/>
              <line color="#c0c0c0" weight=".5" x1="75.0%" y1="0" x2="75.0%" y2="11"/>
              <line color="#c0c0c0" weight=".5" x1="100%" y1="0" x2="100%" y2="11"/>
              <line color="#c0c0c0" weight=".5" x1="0%" y1="0" x2="100%" y2="0"/>
              <line color="#c0c0c0" weight=".5" x1="0%" y1="11" x2="100%" y2="11"/>
            </items>
            <groups>
              <group name="dummy">
                <groupheader name="dummyGroupHeader" color="#767676" fontname="Arial" fontsize="12" fontstyle="bold" repeat="false">
                  <label name="noDataLabelElement" height="11" vertical-alignment="middle" alignment="left" width="100%" x="0%" y="0" visible="false">No Data Available</label>
                </groupheader>
                <groupfooter name="dummyGroupFooter" color="#ff7d17" fontname="Arial" fontsize="12" fontstyle="bold">
                  <rectangle color="#e0d0c0" draw="false" fill="true" height="17" width="100%" y="1" x="0%"/>
                  <number-field fieldname="Summary_BC_ORDERDETAILS_PRICEEACHExpression" height="16" vertical-alignment="middle" alignment="left" width="25.0%" x="25.0%" y="2" format="$#,###.##"/>
                  <number-field fieldname="Summary_BC_ORDERDETAILS_QUANTITYORDEREDExpression" height="16" vertical-alignment="middle" alignment="left" width="25.0%" x="50.0%" y="2" format="#,###.##"/>
                  <number-field fieldname="Summary_BC_ORDERDETAILS_TOTALExpression" height="16" vertical-alignment="middle" alignment="left" width="25.0%" x="75.0%" y="2" format="$#,###.##"/>
                  <message-field height="16" x="0%" width="25.0%" y="2" alignment="left" vertical-alignment="middle">Grand Total</message-field>
                </groupfooter>
              </group>
              <group name="BC_CUSTOMER_W_TER_TERRITORY">
                <fields>
                  <field>BC_CUSTOMER_W_TER_TERRITORY</field>
                </fields>
                <groupheader name="BC_CUSTOMER_W_TER_TERRITORYGroupHeader" repeat="false" pagebreak-before-print="false" pagebreak-after-print="false" color="#767676" fontname="Arial" fontsize="12" fontstyle="bold">
                  <message-field height="17" vertical-alignment="top" alignment="left" width="100%" x="0%" y="0" nullstring="-">&amp;&lt;</message-field>
                  <rectangle color="#FFFFFF" draw="false" fill="false" height="17" width="100%" x="0%" y="17"/>
                  <message-field height="17" vertical-alignment="top" alignment="left" width="100%" x="0%" y="17" nullstring="-">Territory: $(BC_CUSTOMER_W_TER_TERRITORY)</message-field>
                </groupheader>
                <groupfooter name="BC_CUSTOMER_W_TER_TERRITORYGroupFooter" color="#ff7d17" fontname="Arial" fontsize="12" fontstyle="bold" pagebreak-before-print="false" pagebreak-after-print="false">
                  <rectangle color="#c0d0e0" draw="false" fill="true" height="17" width="100%" y="1" x="0%"/>
                  <number-field fieldname="BC_CUSTOMER_W_TER_TERRITORYBC_ORDERDETAILS_PRICEEACHExpression" height="16" vertical-alignment="middle" alignment="left" width="25.0%" x="25.0%" y="2" format="$#,###.##"/>
                  <number-field fieldname="BC_CUSTOMER_W_TER_TERRITORYBC_ORDERDETAILS_QUANTITYORDEREDExpression" height="16" vertical-alignment="middle" alignment="left" width="25.0%" x="50.0%" y="2" format="#,###.##"/>
                  <number-field fieldname="BC_CUSTOMER_W_TER_TERRITORYBC_ORDERDETAILS_TOTALExpression" height="16" vertical-alignment="middle" alignment="left" width="25.0%" x="75.0%" y="2" format="$#,###.##"/>
                  <message-field height="16" x="0%" width="25.0%" y="2" alignment="left" vertical-alignment="middle">My Total $(BC_CUSTOMER_W_TER_TERRITORY)</message-field>
                </groupfooter>
              </group>
              <group name="BC_CUSTOMER_W_TER_CUSTOMERNAME">
                <fields>
                  <field>BC_CUSTOMER_W_TER_TERRITORY</field>
                  <field>BC_CUSTOMER_W_TER_CUSTOMERNAME</field>
                </fields>
                <groupheader name="BC_CUSTOMER_W_TER_CUSTOMERNAMEGroupHeader" repeat="false" pagebreak-before-print="false" pagebreak-after-print="false" color="#767676" fontname="Arial" fontsize="12" fontstyle="bold" height="38">
                  <rectangle color="#FFFFFF" draw="false" fill="false" height="17" width="100%" x="0%" y="0"/>
                  <message-field height="17" vertical-alignment="top" alignment="left" width="100%" x="0%" y="0" nullstring="-">Customername: $(BC_CUSTOMER_W_TER_CUSTOMERNAME)</message-field>
                  <rectangle color="#9eaa36" draw="false" fill="true" height="18" width="100%" x="0%" y="19"/>
                  <rectangle draw="false" fill="false" height="2" width="100%" x="0%" y="17"/>
                  <label color="#ffffff" fontname="Arial" fontsize="10" fontstyle="plain" height="18" vertical-alignment="middle" alignment="left" width="25.0%" x="0.0%" y="19">Product Name</label>
                  <label color="#ffffff" fontname="Arial" fontsize="10" fontstyle="plain" height="18" vertical-alignment="middle" alignment="left" width="25.0%" x="25.0%" y="19">Price Sold</label>
                  <label color="#ffffff" fontname="Arial" fontsize="10" fontstyle="plain" height="18" vertical-alignment="middle" alignment="left" width="25.0%" x="50.0%" y="19">Quantity Ordered</label>
                  <label color="#ffffff" fontname="Arial" fontsize="10" fontstyle="plain" height="18" vertical-alignment="middle" alignment="left" width="25.0%" x="75.0%" y="19">Total</label>
                </groupheader>
                <groupfooter name="BC_CUSTOMER_W_TER_CUSTOMERNAMEGroupFooter" color="#ff7d17" fontname="Arial" fontsize="12" fontstyle="bold" pagebreak-before-print="false" pagebreak-after-print="false">
                  <rectangle color="#c0d0e0" draw="false" fill="true" height="17" width="100%" y="1" x="0%"/>
                  <number-field fieldname="BC_CUSTOMER_W_TER_CUSTOMERNAMEBC_ORDERDETAILS_PRICEEACHExpression" height="16" vertical-alignment="middle" alignment="left" width="25.0%" x="25.0%" y="2" format="$#,###.##"/>
                  <number-field fieldname="BC_CUSTOMER_W_TER_CUSTOMERNAMEBC_ORDERDETAILS_QUANTITYORDEREDExpression" height="16" vertical-alignment="middle" alignment="left" width="25.0%" x="50.0%" y="2" format="#,###.##"/>
                  <number-field fieldname="BC_CUSTOMER_W_TER_CUSTOMERNAMEBC_ORDERDETAILS_TOTALExpression" height="16" vertical-alignment="middle" alignment="left" width="25.0%" x="75.0%" y="2" format="$#,###.##"/>
                  <message-field height="16" x="0%" width="25.0%" y="2" alignment="left" vertical-alignment="middle">My Other Total $(BC_CUSTOMER_W_TER_CUSTOMERNAME)</message-field>
                </groupfooter>
              </group>
            </groups>
          </report>
        </location>
        <mime-type>text/xml</mime-type>
      </xml>
    </report-definition>
  </resources>
  <actions>
    <action-definition>
      <action-outputs>
        <rule-result type="result-set"/>
      </action-outputs>
      <component-name>MQLRelationalDataComponent</component-name>
      <action-type>rule</action-type>
      <component-definition>
        <mql> 
          <domain_type>relational</domain_type>  
          <domain_id><![CDATA[samples]]></domain_id>
          <model_id><![CDATA[BV_ORDERS]]></model_id>  
          <options> 
            <disable_distinct>false</disable_distinct> 
          </options>  
          <selections> 
            <selection>
              <view>BC_CUSTOMER_W_TER_</view>
              <column>BC_CUSTOMER_W_TER_TERRITORY</column>
            </selection>  
            <selection>
              <view>BC_CUSTOMER_W_TER_</view>
              <column>BC_CUSTOMER_W_TER_CUSTOMERNAME</column>
            </selection>  
            <selection>
              <view>CAT_PRODUCTS</view>
              <column>BC_PRODUCTS_PRODUCTNAME</column>
            </selection>  
            <selection>
              <view>CAT_ORDERS</view>
              <column>BC_ORDERDETAILS_PRICEEACH</column>
            </selection>  
            <selection>
              <view>CAT_ORDERS</view>
              <column>BC_ORDERDETAILS_QUANTITYORDERED</column>
            </selection>  
            <selection>
              <view>CAT_ORDERS</view>
              <column>BC_ORDERDETAILS_TOTAL</column>
            </selection> 
          </selections>  
          <constraints> 
            <constraint>
              <operator><![CDATA[AND]]></operator>
              <condition><![CDATA[LIKE( [BC_CUSTOMER_W_TER_.BC_CUSTOMER_W_TER_CUSTOMERNAME];"%orn%")]]></condition>
            </constraint>  
            <constraint>
              <operator><![CDATA[AND]]></operator>
              <condition><![CDATA[[CAT_ORDERS.BC_ORDERS_STATUS] = "Shipped"]]></condition>
            </constraint> 
          </constraints>  
          <orders> 
            <order>
              <direction>asc</direction>
              <view_id>BC_CUSTOMER_W_TER_</view_id>
              <column_id>BC_CUSTOMER_W_TER_TERRITORY</column_id>
            </order>  
            <order>
              <direction>desc</direction>
              <view_id>BC_CUSTOMER_W_TER_</view_id>
              <column_id>BC_CUSTOMER_W_TER_CUSTOMERNAME</column_id>
            </order>  
            <order>
              <direction>desc</direction>
              <view_id>CAT_ORDERS</view_id>
              <column_id>BC_ORDERDETAILS_QUANTITYORDERED</column_id>
            </order> 
          </orders> 
        </mql>
        <live>true</live>
        <display-names>false</display-names>
      </component-definition>
    </action-definition>
    <action-definition>
      <action-outputs>
        <report type="content"/>
      </action-outputs>
      <action-inputs>
        <output-type type="string"/>
        <data type="result-set" mapping="rule-result"/>
      </action-inputs>
      <action-resources>
        <report-definition type="resource"/>
      </action-resources>
      <component-name>JFreeReportComponent</component-name>
      <action-type>report</action-type>
      <component-definition>
        <output-type>html</output-type>
      </component-definition>
    </action-definition>
  </actions>
</action-sequence>