com.waveset.report
Class BaseReportTask

java.lang.Object
  extended bycom.waveset.task.Executor
      extended bycom.waveset.report.BaseReportTask

public abstract class BaseReportTask
extends Executor


Field Summary
protected  java.util.Map _conditions
          list of attribute conditions used by a report when requesting objects
protected  TaskContext _ctx
          Context of the report task
protected  boolean _emailReport
          flag to indicate if this report should be emailed after generated
 boolean _reportsProgress
          Flag to indicate if progress updates should be written.
protected  boolean _storesResults
           
protected  Subject _subject
          Subject who is running the task, used for Locale, where necessary
protected  TaskInstance _task
          TaskInstance for this report task
 int _updateInterval
          How often to write progress to the repository.
protected static java.lang.String COL_END
           
protected static java.lang.String COL_START
           
static int DEFAULT_MAX_ROW_SIZE
           
protected static java.lang.String ROW_END
           
protected static java.lang.String ROW_START
           
static java.lang.String VAR_DATE_RANGE
           
static java.lang.String VAR_DESCRIPTION
           
static java.lang.String VAR_EMAIL_ADDRESSES
           
static java.lang.String VAR_EMAIL_TEMPLATE
           
static java.lang.String VAR_END_DATE
           
static java.lang.String VAR_EXCLUDE_ALL
           
static java.lang.String VAR_ORG_SCOPE
           
static java.lang.String VAR_SEND_EMAIL
           
static java.lang.String VAR_START_DATE
           
static java.lang.String VAR_TIMELINE
           
static java.lang.String VAR_TITLE
           
static java.lang.String XML_HEADER
           
 
Fields inherited from class com.waveset.task.Executor
_monitor, _suspendRequested, _terminateRequested, trace
 
Constructor Summary
BaseReportTask()
           
 
Method Summary
 void addCondition(AttributeCondition cond)
          Add an attribute condition to this reports conditions.
 void addCondition(java.lang.Object attr, java.lang.Object attrValue, AttributeCondition.Operator op)
          Build an attribute condition to this reports conditions.
 void addCondition(java.lang.Object attr, java.lang.Object attrValue, AttributeCondition.Operator op, boolean useId)
           
 void addKeyedCondition(Attribute attr, java.lang.Object val)
          Add in a keyed attribute condition, this if for things like objectType, action and status for audit reports.
protected  java.lang.String buildRow(java.lang.Object attrName, java.lang.Object value)
           
 void checkForTermination()
           
abstract  WavesetResult createReports()
          Abstract method createReports, which is the method that will generate the Report object(s) and place them in a waveset result.
static void emailReport(RepositoryResult extendedResults, TaskInstance task, LighthouseContext ctx, java.lang.String templateName, java.util.Locale locale)
          Email a result that contains one or more report objects.
 void execute(TaskContext ctx, TaskInstance task)
          Execute the task.
protected  java.lang.String formatEventDateTimeForQuery(java.util.Date date)
           
 java.util.List getAttributeConditionsList()
          Get an array of AttributeConditions for use when calling session/repo.
protected  java.lang.String getDbKey(Attribute attr, java.lang.String value)
          For things that use ObjectType, Action and Status as a db key convert the mask to the corresponding DB key for the query.
 Message getDescription()
          Get the report description.
 java.util.Date getEndDate()
           
protected  java.util.Locale getLocale()
          Returns the current locale setting.
protected static java.util.Locale getLocale(Subject subject)
          Returns the locale based on the subject.
static boolean getPdfFontIsEmbedded(TaskInstance task)
          Return whether or not to embed the font in PDF documents.
static java.lang.String getPdfFontName(TaskInstance task)
          Return the font name to use in the PDF document.
 java.util.Date getStartDate()
           
protected  boolean getStoresExtendedResults()
           
 Message getTitle()
          Get the report title.
protected  RepositoryResult listExtendedResults(TaskContext ctx, TaskInstance task)
          Returns the extended report for use in email results.
protected  java.lang.String mapActionDbKeyToMessageKey(java.lang.String dbKey)
           
protected  java.lang.String mapObjectTypeDbKeyToMessageKey(java.lang.String dbKey)
           
protected  java.lang.String mapStatusDbKeyToMessageKey(java.lang.String dbKey)
           
protected  void parseAttributeConditions()
          Allow a report form to specify queries with the following format: queryAttr.attr.enabled ( ui controlled checkbox ) queryAttr.attr.value ( can be list, String ) queryAttr.attr.condition ( EQUALS, STARTS WITH, ENDS WITH, CONTAINS, etc queryAttr.attr.useId(value needs to be resovled to an id before query) Where attr is the string name of a com.waveset.object.Type i.e The following example would add an Attribute condition which described querying a given object for specified value.
protected  void processCommonArguments()
          Process those arguments that are common among all the reporting tasks.
 void removeCondition(java.lang.String name)
          Generic remove condition by name function.
 AttributeCondition.Operator resolveOperator(java.lang.String operator)
           
 void setDescription(Message description)
          Set the report description.
 void setEndDateCondition(java.util.Date date)
           
protected  void setReportsProgress(boolean reportsProgress)
           
 void setStartDateCondition(java.util.Date date)
           
protected  void setStoresExtendedResults(boolean does)
           
 void setTitle(Message title)
          Set the report title.
protected  void setUpdateInterval(int interval)
           
protected static java.util.Date translateInterval(java.lang.String intervalString)
           
 void updateProgress(Message progress)
          Update the progress string on the task instance.
protected  void updateProgress(Message progress, boolean force)
          Update the progress string on the task instance.
protected static void validateDates(java.util.Date startDate, java.util.Date endDate)
           
 
Methods inherited from class com.waveset.task.Executor
addExtendedResult, delete, doRealWork, getExtendedResult, getPool, isSuspendRequested, isTerminateRequested, println, processEvent, setPool, setSuspendRequested, setTerminateRequested
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_HEADER

public static final java.lang.String XML_HEADER
See Also:
Constant Field Values

VAR_EXCLUDE_ALL

public static final java.lang.String VAR_EXCLUDE_ALL
See Also:
Constant Field Values

VAR_TITLE

public static final java.lang.String VAR_TITLE
See Also:
Constant Field Values

VAR_DESCRIPTION

public static final java.lang.String VAR_DESCRIPTION
See Also:
Constant Field Values

VAR_ORG_SCOPE

public static final java.lang.String VAR_ORG_SCOPE
See Also:
Constant Field Values

VAR_DATE_RANGE

public static final java.lang.String VAR_DATE_RANGE
See Also:
Constant Field Values

VAR_START_DATE

public static final java.lang.String VAR_START_DATE
See Also:
Constant Field Values

VAR_END_DATE

public static final java.lang.String VAR_END_DATE
See Also:
Constant Field Values

VAR_TIMELINE

public static final java.lang.String VAR_TIMELINE
See Also:
Constant Field Values

VAR_SEND_EMAIL

public static final java.lang.String VAR_SEND_EMAIL
See Also:
Constant Field Values

VAR_EMAIL_ADDRESSES

public static final java.lang.String VAR_EMAIL_ADDRESSES
See Also:
Constant Field Values

VAR_EMAIL_TEMPLATE

public static final java.lang.String VAR_EMAIL_TEMPLATE
See Also:
Constant Field Values

DEFAULT_MAX_ROW_SIZE

public static final int DEFAULT_MAX_ROW_SIZE
See Also:
Constant Field Values

_storesResults

protected boolean _storesResults

COL_START

protected static final java.lang.String COL_START
See Also:
Constant Field Values

COL_END

protected static final java.lang.String COL_END
See Also:
Constant Field Values

ROW_START

protected static final java.lang.String ROW_START
See Also:
Constant Field Values

ROW_END

protected static final java.lang.String ROW_END
See Also:
Constant Field Values

_conditions

protected java.util.Map _conditions
list of attribute conditions used by a report when requesting objects


_ctx

protected TaskContext _ctx
Context of the report task


_emailReport

protected boolean _emailReport
flag to indicate if this report should be emailed after generated


_task

protected TaskInstance _task
TaskInstance for this report task


_subject

protected Subject _subject
Subject who is running the task, used for Locale, where necessary


_reportsProgress

public boolean _reportsProgress
Flag to indicate if progress updates should be written. This property set from the underlying task definition.


_updateInterval

public int _updateInterval
How often to write progress to the repository. Only applicable if the task definition specifies it reports progress. Property set from the underlying task definition.

Constructor Detail

BaseReportTask

public BaseReportTask()
Method Detail

execute

public void execute(TaskContext ctx,
                    TaskInstance task)
Description copied from class: Executor
Execute the task. System resources are supplied through the context object. Task options and persistent task state is supplied through the task object. This method provides shell execution logic as a default. A subclass must feel perfectly free to override this logic if any part of the structure seems inappropriate. However, if satisfied with this structure, a subclass need only implement the abstract method doRealWork().

Overrides:
execute in class Executor
See Also:
Executor.doRealWork(TaskContext, TaskInstance)

listExtendedResults

protected RepositoryResult listExtendedResults(TaskContext ctx,
                                               TaskInstance task)
Returns the extended report for use in email results.


processCommonArguments

protected void processCommonArguments()
                               throws WavesetException
Process those arguments that are common among all the reporting tasks. Arguments like title, description, date range, and the email flag.

Throws:
WavesetException

createReports

public abstract WavesetResult createReports()
                                     throws WavesetException
Abstract method createReports, which is the method that will generate the Report object(s) and place them in a waveset result.

Throws:
WavesetException

updateProgress

public void updateProgress(Message progress)
Update the progress string on the task instance. This progress string is for use in the task status applet. The progress will only be updated (in the repository) at the defined interval. ( see get/setUpdateInterval() ) NOTE: this method is expensive so be careful.


updateProgress

protected void updateProgress(Message progress,
                              boolean force)
Update the progress string on the task instance. This progress string is for use in the task status applet. The progress will only be updated (in the repository) at the defined interval. ( see get/setUpdateInterval() ) NOTE: this method is db expensive so be careful.


getLocale

protected java.util.Locale getLocale()
Returns the current locale setting.


getLocale

protected static java.util.Locale getLocale(Subject subject)
Returns the locale based on the subject.


getStoresExtendedResults

protected boolean getStoresExtendedResults()

getDescription

public Message getDescription()
Get the report description.


getTitle

public Message getTitle()
                 throws WavesetException
Get the report title.

Throws:
WavesetException

setTitle

public void setTitle(Message title)
Set the report title.


setStoresExtendedResults

protected void setStoresExtendedResults(boolean does)

setDescription

public void setDescription(Message description)
Set the report description.


getStartDate

public java.util.Date getStartDate()

getEndDate

public java.util.Date getEndDate()

getAttributeConditionsList

public java.util.List getAttributeConditionsList()
                                          throws WavesetException
Get an array of AttributeConditions for use when calling session/repo.

Throws:
WavesetException

parseAttributeConditions

protected void parseAttributeConditions()
                                 throws WavesetException
Allow a report form to specify queries with the following format: queryAttr.attr.enabled ( ui controlled checkbox ) queryAttr.attr.value ( can be list, String ) queryAttr.attr.condition ( EQUALS, STARTS WITH, ENDS WITH, CONTAINS, etc queryAttr.attr.useId(value needs to be resovled to an id before query) Where attr is the string name of a com.waveset.object.Type i.e The following example would add an Attribute condition which described querying a given object for specified value.

Throws:
WavesetException

resolveOperator

public AttributeCondition.Operator resolveOperator(java.lang.String operator)

setStartDateCondition

public void setStartDateCondition(java.util.Date date)
                           throws WavesetException
Throws:
WavesetException

setEndDateCondition

public void setEndDateCondition(java.util.Date date)
                         throws WavesetException
Throws:
WavesetException

addKeyedCondition

public void addKeyedCondition(Attribute attr,
                              java.lang.Object val)
Add in a keyed attribute condition, this if for things like objectType, action and status for audit reports.


addCondition

public void addCondition(java.lang.Object attr,
                         java.lang.Object attrValue,
                         AttributeCondition.Operator op)
                  throws WavesetException
Build an attribute condition to this reports conditions. Get the complete query list from getAttributeConditions().

Throws:
WavesetException

addCondition

public void addCondition(java.lang.Object attr,
                         java.lang.Object attrValue,
                         AttributeCondition.Operator op,
                         boolean useId)
                  throws WavesetException
Throws:
WavesetException

addCondition

public void addCondition(AttributeCondition cond)
Add an attribute condition to this reports conditions. Get the complete query list from getAttributeConditions().


removeCondition

public void removeCondition(java.lang.String name)
Generic remove condition by name function. Removes it from the its stored hashmap.


translateInterval

protected static java.util.Date translateInterval(java.lang.String intervalString)

checkForTermination

public void checkForTermination()
                         throws ReportTerminated
Throws:
ReportTerminated

emailReport

public static void emailReport(RepositoryResult extendedResults,
                               TaskInstance task,
                               LighthouseContext ctx,
                               java.lang.String templateName,
                               java.util.Locale locale)
Email a result that contains one or more report objects. This is static so I can use it from the various reporting classes, like Risk Analysis and Auditing. Locale is used to resolve any embedded Message objects included in a report.


getPdfFontName

public static java.lang.String getPdfFontName(TaskInstance task)
Return the font name to use in the PDF document. This first looks in task for an override, but then falls back to the global reports configuration object. null might be returned by this method.


getPdfFontIsEmbedded

public static boolean getPdfFontIsEmbedded(TaskInstance task)
Return whether or not to embed the font in PDF documents. This first looks in task for an override, but then falls back to the global reports configuration object.


getDbKey

protected java.lang.String getDbKey(Attribute attr,
                                    java.lang.String value)
For things that use ObjectType, Action and Status as a db key convert the mask to the corresponding DB key for the query.


mapStatusDbKeyToMessageKey

protected java.lang.String mapStatusDbKeyToMessageKey(java.lang.String dbKey)

mapObjectTypeDbKeyToMessageKey

protected java.lang.String mapObjectTypeDbKeyToMessageKey(java.lang.String dbKey)

mapActionDbKeyToMessageKey

protected java.lang.String mapActionDbKeyToMessageKey(java.lang.String dbKey)

setUpdateInterval

protected void setUpdateInterval(int interval)

setReportsProgress

protected void setReportsProgress(boolean reportsProgress)

validateDates

protected static void validateDates(java.util.Date startDate,
                                    java.util.Date endDate)
                             throws WavesetException
Throws:
WavesetException

formatEventDateTimeForQuery

protected java.lang.String formatEventDateTimeForQuery(java.util.Date date)
                                                throws WavesetException
Throws:
WavesetException

buildRow

protected java.lang.String buildRow(java.lang.Object attrName,
                                    java.lang.Object value)