org.tigris.scarab.tools
Class ScarabGlobalTool

java.lang.Object
  extended byorg.tigris.scarab.tools.ScarabGlobalTool
All Implemented Interfaces:
org.apache.turbine.services.pull.ApplicationTool

public class ScarabGlobalTool
extends java.lang.Object
implements org.apache.turbine.services.pull.ApplicationTool

This scope is an object that is made available as a global object within the system. This object must be thread safe as multiple requests may access it at the same time. The object is made available in the context as: $scarabG

The design goals of the Scarab*API is to enable a pull based methodology to be implemented.

Version:
$Id: ScarabGlobalTool.java 10257 2006-08-07 22:43:30Z jorgeuriarte $
Author:
Jon S. Stevens, Douglas B. Robertson

Constructor Summary
ScarabGlobalTool()
          Constructor does initialization stuff
 
Method Summary
 java.util.Date addApproxOneHour(java.util.Date date)
           
 java.lang.String getActivityTypeLabelResource(java.lang.String code)
          Remap Activity code to resource id.
 java.util.List getAllAttributes()
          Gets a List of all of the data (non-user) Attribute objects.
 java.util.List getAllAttributes(java.lang.String attributeType, boolean includeDeleted, java.lang.String sortColumn, java.lang.String sortPolarity)
          Gets a List of all of the data (non-user) Attribute objects.
 java.util.List getAllAttributes(java.lang.String sortColumn, java.lang.String sortPolarity)
          Gets a List of all of the data (non-user) Attribute objects.
 java.util.List getAllIssueTypes()
           
 java.util.List getAllIssueTypes(boolean deleted)
          gets a list of all Issue Types
 java.util.List getAllIssueTypes(boolean deleted, java.lang.String sortColumn, java.lang.String sortPolarity)
          Gets a List of all of the Attribute objects.
 java.util.List getAllNotificationTypeCodes()
          Get the list of available activityType codes.
 java.util.List getAllPermissions()
          Returns a list of all the permissions in use by scarab.
 java.util.List getAttributes(java.lang.String attributeType)
          Gets a List of all of the Attribute objects by type.
 java.util.List getAttributes(java.lang.String attributeType, boolean includeDeleted, java.lang.String sortColumn, java.lang.String sortPolarity)
          Gets a List of all of user Attribute objects.
 java.lang.String getBuildVersion()
          returns Scarab's build version.
 int getCALENDAR_DAY_FIELD()
           
 int getCALENDAR_HOUR_FIELD()
           
 int getCALENDAR_MONTH_FIELD()
           
 int getCALENDAR_YEAR_FIELD()
           
 SkipFiltering getCommentText(java.lang.String text, ScarabLink link, Module currentModule)
           
 org.apache.velocity.app.FieldMethodizer getConstant()
          holds the Scarab constants. it will be available to the template system as $scarabG.Constant.CONSTANT_NAME.
 java.util.List getCustomization(java.lang.Object moduleId, java.lang.Object userId, java.lang.Object activityCode)
          Return the list of available NotificationFilters for the given user in the given module
 int getInt(java.lang.Object obj)
          Returns an int representation of the given Object whose toString method should be a valid integer.
 MITListManager getMITListManager()
           
static int getModuleCodeLength()
           
static int getModuleCodeLengthPadded()
           
 java.util.List getModulesFromIssueList(java.util.List issues)
          Create a list of Modules from the given list of issues.
static NotificationFilter getNotificationFilter(java.lang.Integer moduleId, java.lang.Integer userId, java.lang.String activityCode)
           
 java.util.Date getNow()
          Get a new Date object initialized to the current time.
 GlobalParameterManager getParameter()
           
 org.apache.velocity.app.FieldMethodizer getParameterName()
          holds the names of parameters that are configurable through the ui.
 org.apache.velocity.app.FieldMethodizer getPermission()
          holds the Scarab permission constants.
 int getPublicModulesDisplayCount()
          Provides the maximum number of public modules to be shown on the login screen. the number is stored in the property scarab.public.modules.display.count If no number is specified, this method returns -1
 java.util.List getSearchUsers(java.lang.String searchField, java.lang.String searchCriteria)
          Returns a List of users based on the given search criteria.
 java.util.List getSearchUsers(java.lang.String searchField, java.lang.String searchCriteria, java.lang.String orderByField, java.lang.String ascOrDesc)
          Describe getSearchUsers method here.
 java.lang.String getSiteLogo()
          Provides the site logo for the top banner.
 java.lang.String getSiteName()
          Provides the site name for the top banner.
 org.apache.commons.configuration.Configuration getTurbineConfiguration()
           
 java.util.List getUserAttributes()
          Gets a List of all of user Attributes.
 java.util.List getUserAttributes(boolean includeDeleted, java.lang.String sortColumn, java.lang.String sortPolarity)
          Gets a List of all of the Attribute objects.
 java.util.List getUserAttributes(java.lang.String sortColumn, java.lang.String sortPolarity)
          Gets a List of all of the Attribute objects.
static Workflow getWorkflow()
          Makes the workflow tool accessible.
 void init(java.lang.Object data)
           
 boolean isString(java.lang.Object obj)
           
 java.util.List linkIssueIds(Module module, java.lang.String text)
           
 void log(java.lang.String s)
          Logs a message at the debug level.
 void log(java.lang.String category, java.lang.String s)
          Logs a message at the debug level.
 void print(java.lang.String s)
          Prints a message to standard out.
 void refresh()
           
 java.lang.String replace(java.lang.String text, java.lang.String a, java.lang.String b)
           
 java.util.List reverse(java.util.List a)
          Creates a new List with elements reversed from the given List.
 java.lang.Object[] reverse(java.lang.Object[] a)
          Creates a new array with elements reversed from the given array.
 int sizeOfArray(java.lang.Object[] obj)
          Velocity has no way of getting the size of an Object[] easily.
 java.util.List subset(java.util.List a, java.lang.Integer fromIndex, java.lang.Integer toIndex)
          Creates a view of the portion of the given List between the specified fromIndex, inclusive, and toIndex, exclusive.
 java.lang.Object[] subset(java.lang.Object[] a, java.lang.Integer fromIndex, java.lang.Integer toIndex)
          Creates a new array with a view of the portion of the given array between the specified fromIndex, inclusive, and toIndex, exclusive
 boolean templateExists(java.lang.String template)
          Delegates to Velocity's templateExists() method.
 SkipFiltering textToHTML(java.lang.String text, ScarabLink link, Module currentModule)
          Converts a text string to HTML by: replacing reserved characters with equivalent HTML entities adding hyperlinks for URLs adding hyperlinks for issue references
 java.util.Enumeration tokenize(java.lang.String text, java.lang.String delimiters)
          Breaks text into a list of Strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScarabGlobalTool

public ScarabGlobalTool()
Constructor does initialization stuff

Method Detail

init

public void init(java.lang.Object data)
Specified by:
init in interface org.apache.turbine.services.pull.ApplicationTool

refresh

public void refresh()
Specified by:
refresh in interface org.apache.turbine.services.pull.ApplicationTool

getBuildVersion

public java.lang.String getBuildVersion()
returns Scarab's build version.


getConstant

public org.apache.velocity.app.FieldMethodizer getConstant()
holds the Scarab constants. it will be available to the template system as $scarabG.Constant.CONSTANT_NAME.


getPermission

public org.apache.velocity.app.FieldMethodizer getPermission()
holds the Scarab permission constants. It will be available to the template system as $scarabG.PERMISSION_NAME.


getParameterName

public org.apache.velocity.app.FieldMethodizer getParameterName()
holds the names of parameters that are configurable through the ui.


replace

public java.lang.String replace(java.lang.String text,
                                java.lang.String a,
                                java.lang.String b)

getParameter

public GlobalParameterManager getParameter()

getAllPermissions

public java.util.List getAllPermissions()
Returns a list of all the permissions in use by scarab.

Returns:
a List of Strings

getAllAttributes

public java.util.List getAllAttributes()
                                throws java.lang.Exception
Gets a List of all of the data (non-user) Attribute objects.

Throws:
java.lang.Exception

getAttributes

public java.util.List getAttributes(java.lang.String attributeType)
                             throws java.lang.Exception
Gets a List of all of the Attribute objects by type.

Throws:
java.lang.Exception

getAllAttributes

public java.util.List getAllAttributes(java.lang.String attributeType,
                                       boolean includeDeleted,
                                       java.lang.String sortColumn,
                                       java.lang.String sortPolarity)
                                throws java.lang.Exception
Gets a List of all of the data (non-user) Attribute objects. Passes in sort criteria.

Throws:
java.lang.Exception

getAllAttributes

public java.util.List getAllAttributes(java.lang.String sortColumn,
                                       java.lang.String sortPolarity)
                                throws java.lang.Exception
Gets a List of all of the data (non-user) Attribute objects. Passes in sort criteria.

Throws:
java.lang.Exception

getUserAttributes

public java.util.List getUserAttributes()
                                 throws java.lang.Exception
Gets a List of all of user Attributes.

Throws:
java.lang.Exception

getUserAttributes

public java.util.List getUserAttributes(java.lang.String sortColumn,
                                        java.lang.String sortPolarity)
                                 throws java.lang.Exception
Gets a List of all of the Attribute objects.

Throws:
java.lang.Exception

getUserAttributes

public java.util.List getUserAttributes(boolean includeDeleted,
                                        java.lang.String sortColumn,
                                        java.lang.String sortPolarity)
                                 throws java.lang.Exception
Gets a List of all of the Attribute objects.

Throws:
java.lang.Exception

getAttributes

public java.util.List getAttributes(java.lang.String attributeType,
                                    boolean includeDeleted,
                                    java.lang.String sortColumn,
                                    java.lang.String sortPolarity)
                             throws java.lang.Exception
Gets a List of all of user Attribute objects.

Throws:
java.lang.Exception

getAllIssueTypes

public java.util.List getAllIssueTypes()
                                throws java.lang.Exception
Throws:
java.lang.Exception

getAllIssueTypes

public java.util.List getAllIssueTypes(boolean deleted)
                                throws java.lang.Exception
gets a list of all Issue Types

Throws:
java.lang.Exception

getAllIssueTypes

public java.util.List getAllIssueTypes(boolean deleted,
                                       java.lang.String sortColumn,
                                       java.lang.String sortPolarity)
                                throws java.lang.Exception
Gets a List of all of the Attribute objects.

Throws:
java.lang.Exception

getAllNotificationTypeCodes

public java.util.List getAllNotificationTypeCodes()
Get the list of available activityType codes.

Returns:

getActivityTypeLabelResource

public java.lang.String getActivityTypeLabelResource(java.lang.String code)
Remap Activity code to resource id. Necessary due to incompatible name conventions.

Parameters:
code -
Returns:

getCustomization

public java.util.List getCustomization(java.lang.Object moduleId,
                                       java.lang.Object userId,
                                       java.lang.Object activityCode)
                                throws org.apache.torque.TorqueException
Return the list of available NotificationFilters for the given user in the given module

Parameters:
moduleId -
userId -
activityCode -
Returns:
Throws:
org.apache.torque.TorqueException

getNotificationFilter

public static NotificationFilter getNotificationFilter(java.lang.Integer moduleId,
                                                       java.lang.Integer userId,
                                                       java.lang.String activityCode)
                                                throws ScarabException
Throws:
ScarabException

getWorkflow

public static Workflow getWorkflow()
                            throws ScarabException
Makes the workflow tool accessible.

Throws:
ScarabException

getSearchUsers

public java.util.List getSearchUsers(java.lang.String searchField,
                                     java.lang.String searchCriteria)
                              throws java.lang.Exception
Returns a List of users based on the given search criteria. This method is an overloaded function which returns an unsorted list of users.

Parameters:
searchField - the name of the database attribute to search on
searchCriteria - the search criteria to use within the LIKE command
Returns:
a List of users matching the specifed criteria
Throws:
java.lang.Exception

getSearchUsers

public java.util.List getSearchUsers(java.lang.String searchField,
                                     java.lang.String searchCriteria,
                                     java.lang.String orderByField,
                                     java.lang.String ascOrDesc)
                              throws java.lang.Exception
Describe getSearchUsers method here.

Parameters:
searchField - a String value
searchCriteria - a String value
orderByField - a String value
ascOrDesc - a String value
Returns:
a List value
Throws:
java.lang.Exception - if an error occurs

getModulesFromIssueList

public java.util.List getModulesFromIssueList(java.util.List issues)
                                       throws org.apache.torque.TorqueException
Create a list of Modules from the given list of issues. Each Module in the list of issues will only occur once in the list of Modules.

Throws:
org.apache.torque.TorqueException

getMITListManager

public MITListManager getMITListManager()

getNow

public java.util.Date getNow()
Get a new Date object initialized to the current time.

Returns:
a Date value

reverse

public java.lang.Object[] reverse(java.lang.Object[] a)
Creates a new array with elements reversed from the given array.

Parameters:
a - the orginal Object[]
Returns:
a new Object[] with values reversed from the original

reverse

public java.util.List reverse(java.util.List a)
Creates a new List with elements reversed from the given List.

Parameters:
a - the orginal List
Returns:
a new List with values reversed from the original

subset

public java.util.List subset(java.util.List a,
                             java.lang.Integer fromIndex,
                             java.lang.Integer toIndex)
Creates a view of the portion of the given List between the specified fromIndex, inclusive, and toIndex, exclusive. The list returned by this method is backed by the original, so changes to either affect the other.

Parameters:
a - the orginal List
fromIndex - the start index of the returned subset
toIndex - the end index of the returned subset
Returns:
a derived List with a view of the original

subset

public java.lang.Object[] subset(java.lang.Object[] a,
                                 java.lang.Integer fromIndex,
                                 java.lang.Integer toIndex)
Creates a new array with a view of the portion of the given array between the specified fromIndex, inclusive, and toIndex, exclusive

Parameters:
a - the orginal Object[]
fromIndex - the start index of the returned subset
toIndex - the end index of the returned subset
Returns:
a new Object[] with a view of the original

sizeOfArray

public int sizeOfArray(java.lang.Object[] obj)
Velocity has no way of getting the size of an Object[] easily. Usually this would be done by calling obj.length but this doesn't work in Velocity.

Parameters:
obj - the Object[]
Returns:
the number of objects in the Object[] or -1 if obj is null

isString

public boolean isString(java.lang.Object obj)

tokenize

public java.util.Enumeration tokenize(java.lang.String text,
                                      java.lang.String delimiters)
Breaks text into a list of Strings. Text is separated into tokens at characters given in delimiters. The delimiters are not part of the resulting tokens. if delimiters is empty or null, "\n" is used.

Parameters:
text - a String value
delimiters - a String value
Returns:
a List value

linkIssueIds

public java.util.List linkIssueIds(Module module,
                                   java.lang.String text)

getCommentText

public SkipFiltering getCommentText(java.lang.String text,
                                    ScarabLink link,
                                    Module currentModule)

textToHTML

public SkipFiltering textToHTML(java.lang.String text,
                                ScarabLink link,
                                Module currentModule)

Converts a text string to HTML by:

Parameters:
text - The text string to convert.
link -
currentModule - The active module.
Returns:
A SkipFiltering object which contains the generated HTML.

log

public void log(java.lang.String s)
Logs a message at the debug level. Useful for "I am here" type messages. The category is "org.tigris.scarab".

Parameters:
s - message to log

log

public void log(java.lang.String category,
                java.lang.String s)
Logs a message at the debug level. Useful for "I am here" type messages. The category in which to log is also specified.

Parameters:
category - log4j Category
s - message to log

print

public void print(java.lang.String s)
Prints a message to standard out. Useful for "I am here" type messages.

Parameters:
s - message to log

getSiteName

public java.lang.String getSiteName()
Provides the site name for the top banner.

Returns:
the configured site name

getSiteLogo

public java.lang.String getSiteLogo()
Provides the site logo for the top banner.

Returns:
the configured site logo

getPublicModulesDisplayCount

public int getPublicModulesDisplayCount()
Provides the maximum number of public modules to be shown on the login screen. the number is stored in the property scarab.public.modules.display.count If no number is specified, this method returns -1

Returns:
the number specified in scarab.public.modules.display.count

getInt

public int getInt(java.lang.Object obj)
Returns an int representation of the given Object whose toString method should be a valid integer. If the String cannot be parsed 0 is returned.

Parameters:
obj - the object
Returns:
the int representation of the Object if possible or 0.

getCALENDAR_YEAR_FIELD

public int getCALENDAR_YEAR_FIELD()

getCALENDAR_MONTH_FIELD

public int getCALENDAR_MONTH_FIELD()

getCALENDAR_DAY_FIELD

public int getCALENDAR_DAY_FIELD()

getCALENDAR_HOUR_FIELD

public int getCALENDAR_HOUR_FIELD()

addApproxOneHour

public java.util.Date addApproxOneHour(java.util.Date date)

templateExists

public boolean templateExists(java.lang.String template)
Delegates to Velocity's templateExists() method.


getModuleCodeLength

public static int getModuleCodeLength()
Returns:

getModuleCodeLengthPadded

public static int getModuleCodeLengthPadded()
Returns:

getTurbineConfiguration

public org.apache.commons.configuration.Configuration getTurbineConfiguration()
Returns:
Return the current turbine configuration with all keys included


Copyright © 2000-2004 Tigris.org. All Rights Reserved.