com.raritantechnologies.searchApp.alert
Class EmailAlertProcessor

java.lang.Object
  extended bycom.raritantechnologies.searchApp.alert.EmailAlertProcessor
All Implemented Interfaces:
IConfigurable, IGatewayOutputProcessor, IResultSetProcessor

public class EmailAlertProcessor
extends java.lang.Object
implements IResultSetProcessor, IGatewayOutputProcessor

Implementation of IResultSetProcessor/IGatewayOutputProcessor that collects results and sends emails to recipient. The EMailAlertProcessor collects and collates a set of results for each user (identified by an eMail address) and user-specified category(ies) based on a set of "category" objects (or category metadata). The category metadata can be attached to the content result using a DocumentClassifier. A category can be for example, a saved query.

Uses two IDisplayFormRenderers to transform an IResult into an email message, one to render the set of results assigned to a category and the other to compose a set of categories into the final email output.

XML Configuration Template:
   <OutputProcessor class="com.raritantechnologies.searchApp.alert.EmailAlertProcessor"
            emailAddressField="[ result field that contains the email Address ]"
            userKeyField="[ (optional) result field that contains the user key (if not using email Address as the key ) ]"
            categoryField="[ result field that contains the category ]"
            emailFormatField="[ result field specifying result renderer to invoke - maps to 'emailFormat' attribute of EMailRenderer tag ]"
            scoreField="[ result field that contains the sorting score within a category ]"
            maxResultsPerCategory="[ optional limit on the maximum number of results per category to send in the email ]"
            multipleEmails="[ true|false(default) - if true, send out one email for each category, if false put all categories in a single email ]"
            contentRendererField="[ maps to field in the CategoryRenderer DisplayFormRenderer that renders the output of the ContentRenderer  (default='Content') ]"
            categoryRendererField="[ maps to field in the CategoryRenderer DisplayFormRenderer that renders the category header (default='Category') ]"
            categoryContentField="[ maps rendered data to a template output field ]"
            countRendererField="[ maps to number of content items in a category  ]" 
            emailSubject="[ Optional subject heading of eMail ]" 
            emailSubjectField="[ Optional field name of formatted eMail subject heading of eMail ]" >
            debug="[ true | false (default) | one or more of code|output|local; Optional debug flag, debug flag set to local turns off mail transmission to test when mailServer is unavailable]"
            mailServerConnected="[ true(default)|false; Optional debug flag to turn off mail transmission when mailServer is unavailable ]"
            nestedResultField = "[ name of nested result field that contains user and category information ]"
            categoryToContentFields="[ fields that should be copied from category result to content result for each user ]" >
   
        <EMailer class="[ class of com.raritantechnologies.utils.email.IMailer ]" >
                name="[unique name for the mail server]"
                mailServer="[IP Address of mail server]"
                mailServerPort="[Port of mail server (default is 25)]"
                userID="[User ID for mail server authentication]"
                password="[Password for mail server authentication]"
                authenticationRequired="true (default)|false">

            <!-- One or more Message Templates: these can be used to provide header, footer -->
            <MessageTemplates>
                <MessageTemplate name="[ name of the message template ]" 
                                    templateType="[file(default)|embedded; Optional use of a template; template is either located in a file or it is embedded: contained in the text of this tag]">
                MessageTemplate contents: if file type - put the filename here, if embedded, put the template text here.
                </MessageTemplate>
            </MessageTemplates>

        </EMailer>

        <!-- Optional Map of emailFormatField values to emailFormat: Use this if there is more than one EMailRenderer -->
        <!-- And if the field values of the incoming category results need to be mapped to the supported email formats -->
        <EMailFormatMap>
          <Value resultValue="[ value in result emailFormatField - e.g. 'WebFormat' ]" emailFormat="[ maps to email Format - e.g. 'HTML' ]" />
          <!-- etc. . . -->
        </EMailFormatMap>

        <!-- Set of Content result fields that will be needed for email output -->
        <ContentOutputFields>
          <Field ID="[ result field ID ]" />
          <!-- etc... -->
        </ContentOutputFields>

        <!-- Set of additional Category result fields that will be needed for email output -->
        <CategoryOutputFields>
          <Field ID="[ result field ID ]" />
          <!-- etc... -->
        </CategoryOutputFields>

        <!-- Optional IFieldFormatters that will be used to format the Category results (created from the CategoryOutputFields) -->
        <CategoryFormatters>
          <!-- One or more FieldFormatter tags ... -->
          <FieldFormatter class="[ class of com.raritantechnologies.searchApp.IFieldFormatter ]" >

          </FieldFormatter>

          <!-- etc... -->

        </CategoryFormatters>

        <!-- Optional ISorter that will be used to sort the results in each category before display -->
        <ResultSorter class="[ class of com.raritantechnologies.searchApp.ISorter ]" >

        </ResultSorter>

        <ResultSetFilter class="[ class of com.raritantechnologies.searchApp.IResultSetFilter ]" >

        </ResultSetFilter>

        <!-- One or more pairs of ContentRenderer and CategoryRenderer. The ContentRenderer renders the collected results -->
        <!-- per category, the CategoryRenderer renders the group of content sets. -->
        <EMailRenderer emailFormat="[ email format (e.g. 'HTML' or 'TEXT') that this is used for - maps to emailFormatField ]"
                          messageTemplate="[ IMailer message template to put on top of email body ]" >

            <!-- Renders the entire email page: for each category (contained in the categoryRendererField),  -->
            <!-- for each category: renders the contents for that category (contained in the contentRendererField) -->
            <CategoryRenderer rendererClass="[ class of com.raritantechnologies.searchApp.taglibrary.IResultRenderer ]" >            

            </CategoryRenderer>

            <!-- Renders the collected set of documents that match this category -->
            <ContentRenderer rendererClass="[ class of com.raritantechnologies.searchApp.taglibrary.IDisplayFormRenderer ]" >            

            </ContentRenderer>

        </EMailRenderer>

        <!-- Alternatively can use a System DisplayForm for the Category and/or Content renderers -->
        <EMailRenderer emailFormat="[ email format (e.g. 'HTML' or 'TEXT') that this is used for - maps to emailFormatField ]" >
            <CategoryRenderer formName="[ name of System DisplayForm to use for category group rendering ]" />  
            <ContentRenderer formName="[ name of System DisplayForm to use for content rendering ]" />
        </EMailRenderer>

        <!-- optional OutputProcessor for debugging email output -->
        <OutputProcessor class="com.raritantechnologies.searchApp.dataCollection.IGatewayOutputProcessor" >

        </OutputProcessor>
   </OutputProcessor>
 

Developed by Raritan Technologies Inc..

Author:
Pat Crabtree, Ted Sullivan

Constructor Summary
EmailAlertProcessor()
           
 
Method Summary
 void dataComplete()
          Data feed is complete.
 java.lang.String getConfigurationXML()
           
 void initialize(org.w3c.dom.Element elem)
          Initialize the from XML Element.
 void initialize(org.w3c.dom.Element outputProcElem, ISearchFieldMap sfMap)
          Initialize the GatewayOutputProcessor from XML Configuration Element.
 void initialize(java.util.Map initParams)
          Dynamic initialization.
 java.lang.String processData(IResultSet data)
          returns name of XML File created/appended.
 void processResultSet(java.lang.String sessionID, IResultSet data)
          processes the IResultSet (somehow)
protected  java.lang.String sendToOutput(IResultSet filteredData)
           
 void setDEBUG(java.lang.String debugSt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmailAlertProcessor

public EmailAlertProcessor()
Method Detail

processData

public java.lang.String processData(IResultSet data)
Description copied from interface: IGatewayOutputProcessor
returns name of XML File created/appended.

Specified by:
processData in interface IGatewayOutputProcessor

processResultSet

public void processResultSet(java.lang.String sessionID,
                             IResultSet data)
Description copied from interface: IResultSetProcessor
processes the IResultSet (somehow)

Specified by:
processResultSet in interface IResultSetProcessor

dataComplete

public void dataComplete()
Description copied from interface: IResultSetProcessor
Data feed is complete.

Specified by:
dataComplete in interface IResultSetProcessor

initialize

public void initialize(java.util.Map initParams)
Description copied from interface: IResultSetProcessor
Dynamic initialization.

Specified by:
initialize in interface IResultSetProcessor

initialize

public void initialize(org.w3c.dom.Element outputProcElem,
                       ISearchFieldMap sfMap)
Description copied from interface: IGatewayOutputProcessor
Initialize the GatewayOutputProcessor from XML Configuration Element.

Specified by:
initialize in interface IGatewayOutputProcessor

initialize

public void initialize(org.w3c.dom.Element elem)
Description copied from interface: IResultSetProcessor
Initialize the from XML Element.

Specified by:
initialize in interface IResultSetProcessor

sendToOutput

protected java.lang.String sendToOutput(IResultSet filteredData)

getConfigurationXML

public java.lang.String getConfigurationXML()
Specified by:
getConfigurationXML in interface IGatewayOutputProcessor

setDEBUG

public void setDEBUG(java.lang.String debugSt)