org.itracker.services.implementations
Class ConfigurationServiceImpl

java.lang.Object
  extended by org.itracker.services.implementations.ConfigurationServiceImpl
All Implemented Interfaces:
ConfigurationService

public class ConfigurationServiceImpl
extends Object
implements ConfigurationService

Implementation of the ConfigurationService Interface.

See Also:
ConfigurationService

Field Summary
 
Fields inherited from interface org.itracker.services.ConfigurationService
PNAME_SYSTEM_BASE_URL
 
Constructor Summary
ConfigurationServiceImpl(Properties configurationProperties, ConfigurationDAO configurationDAO, CustomFieldDAO customFieldDAO, CustomFieldValueDAO customFieldValueDAO, LanguageDAO languageDAO, ProjectScriptDAO projectScriptDAO, WorkflowScriptDAO workflowScriptDAO)
          Creates a new instance using the given configuration.
 
Method Summary
 boolean configurationItemExists(Configuration configuration)
           
 boolean configurationItemUpToDate(Configuration configuration)
           
 Configuration createConfigurationItem(Configuration configuration)
          Creates a Configuration.
 CustomField createCustomField(CustomField customField)
          Creates a custom field
 CustomFieldValue createCustomFieldValue(CustomFieldValue customFieldValue)
          This method will create a new CustomFieldValue for persistance in the database.
 ProjectScript createProjectScript(ProjectScript projectScript)
          This method will create a new project script for persistance in the database.
 WorkflowScript createWorkflowScript(WorkflowScript workflowScript)
          Creates a workflow script.
 HashMap<String,List<String>> getAvailableLanguages()
           
 boolean getBooleanProperty(String name, boolean defaultValue)
           
 ConfigurationDAO getConfigurationDAO()
           
 Configuration getConfigurationItem(Integer id)
           
 List<Configuration> getConfigurationItemsByType(int type)
          Returns all the configuration items of a particular type.
 List<Configuration> getConfigurationItemsByType(int type, Locale locale)
          Returns all the configuration items of a particular type.
 CustomField getCustomField(Integer id)
          This method will return the requested custom field.
 CustomFieldDAO getCustomFieldDAO()
           
 List<CustomField> getCustomFields()
          This method will return all the custom fields defined in the system.
 List<CustomField> getCustomFields(Locale locale)
          This method will return all the custom fields defined in the system.
 CustomFieldValue getCustomFieldValue(Integer id)
          Gets a CustomFieldValue by primary key
 CustomFieldValueDAO getCustomFieldValueDAO()
           
 HashMap<String,String> getDefinedKeys(String locale)
           
 List<NameValuePair> getDefinedKeysAsArray(String locale)
           
 int getIntegerProperty(String name, int defaultValue)
           
 List<Language> getLanguage(Locale locale)
          returns languages for the locale as list of Language-objects
 LanguageDAO getLanguageDAO()
           
 Language getLanguageItemByKey(String key, Locale locale)
          This method will return the translation for a particular key in a locale.
 List<Language> getLanguageItemsByKey(String key)
          This method will return all the translations for a particular key.
 long getLongProperty(String name, long defaultValue)
           
 int getNumberAvailableLanguages()
           
 int getNumberDefinedKeys(String locale)
           
 ProjectScript getProjectScript(Integer scriptId)
          This method will return the requested project script.
 List<ProjectScript> getProjectScripts()
          This method will return all defined project scripts.
 Properties getProperties()
          returns a proxy to the properties, supplying jndi awareness
 String getProperty(String name)
           
 String getProperty(String name, String defaultValue)
           
 String[] getSortedKeys()
          Returns all of the keys currently defined in the base locale sorted and grouped in a logical manner.
 String getSystemBaseURL()
           
 SystemConfiguration getSystemConfiguration(Locale locale)
          This method will return the current configuration of the system.
 WorkflowScript getWorkflowScript(Integer id)
          This method will return the requested workflow script.
 WorkflowScriptDAO getWorkflowScriptDAO()
           
 List<WorkflowScript> getWorkflowScripts()
          This method will return all defined workflow scripts.
 void initializeConfiguration()
          This method will load the some default system configuration data into the database.
 boolean initializeLocale(String locale, boolean forceReload)
          This method will load the specified locale.
 void removeConfigurationItem(Integer id)
          Finds the Configuration by primary key id and deletes it.
 void removeConfigurationItems(Configuration configuration)
          This method will remove all configuration items that match the supplied models type and value.
 void removeConfigurationItems(int type)
          Removes all Configurations of the give type
 boolean removeCustomField(Integer customFieldId)
          searches for a custom field by primary key and removes it
 boolean removeCustomFieldValue(Integer customFieldValueId)
          removes a custom field value by primary key
 boolean removeCustomFieldValues(Integer customFieldId)
          Removes all field values of a given custom field
 void removeLanguageItem(Language language)
          Removes the Language passed as parameter
 boolean removeLanguageKey(String key)
          Removes all Languages with the give key
 void removeProjectScript(Integer projectScript_id)
          remove a project script by its id
 void removeWorkflowScript(Integer workflowScript_id)
          remove a workflow script by its id
 void resetConfigurationCache()
          This method will reset any caches in the system of configuration items for all configuration item types.
 void resetConfigurationCache(int type)
          This method will reset any caches in the system of configuration items for the specified configuration item type.
 Configuration updateConfigurationItem(Configuration configuration)
          Updates a ConfigurationItem
 List<Configuration> updateConfigurationItems(List<Configuration> configurations, int type)
          Updates the configuration items
 CustomField updateCustomField(CustomField customField)
          This method updates a custom field in the database.
 CustomFieldValue updateCustomFieldValue(CustomFieldValue customFieldValue)
          Updates a CustomFieldValue.
 List<CustomFieldValue> updateCustomFieldValues(Integer customFieldId, List<CustomFieldValue> customFieldValues)
          This method updates a set of custom field values in the database.
 void updateLanguage(Locale locale, List<Language> items)
           
 void updateLanguage(Locale locale, List<Language> items, Configuration configItem)
           
 Language updateLanguageItem(Language language)
          Updates a translations for a particular key and locale.
 ProjectScript updateProjectScript(ProjectScript projectScript)
          This method updates a project script in the database.
 WorkflowScript updateWorkflowScript(WorkflowScript workflowScript)
          This method updates a workflow script in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationServiceImpl

public ConfigurationServiceImpl(Properties configurationProperties,
                                ConfigurationDAO configurationDAO,
                                CustomFieldDAO customFieldDAO,
                                CustomFieldValueDAO customFieldValueDAO,
                                LanguageDAO languageDAO,
                                ProjectScriptDAO projectScriptDAO,
                                WorkflowScriptDAO workflowScriptDAO)
Creates a new instance using the given configuration.

Parameters:
configurationProperties - itracker configuration properties (see /WEB-INF/configuration.properties)
Method Detail

getProperty

public String getProperty(String name)
Specified by:
getProperty in interface ConfigurationService

getProperty

public String getProperty(String name,
                          String defaultValue)
Specified by:
getProperty in interface ConfigurationService

getBooleanProperty

public boolean getBooleanProperty(String name,
                                  boolean defaultValue)
Specified by:
getBooleanProperty in interface ConfigurationService

getIntegerProperty

public int getIntegerProperty(String name,
                              int defaultValue)
Specified by:
getIntegerProperty in interface ConfigurationService

getLongProperty

public long getLongProperty(String name,
                            long defaultValue)
Specified by:
getLongProperty in interface ConfigurationService

getProperties

public Properties getProperties()
returns a proxy to the properties, supplying jndi awareness

Specified by:
getProperties in interface ConfigurationService

getConfigurationItem

public Configuration getConfigurationItem(Integer id)
Specified by:
getConfigurationItem in interface ConfigurationService

getConfigurationItemsByType

public List<Configuration> getConfigurationItemsByType(int type)
Description copied from interface: ConfigurationService
Returns all the configuration items of a particular type. The name values for all the items will not be initialized.

Specified by:
getConfigurationItemsByType in interface ConfigurationService
Parameters:
type - the type of configuration items to retrieve
Returns:
an array of ConfigurationModels

getConfigurationItemsByType

public List<Configuration> getConfigurationItemsByType(int type,
                                                       Locale locale)
Description copied from interface: ConfigurationService
Returns all the configuration items of a particular type. In addition, all of the configuration items name values will be initialized to the values for the supplied locale.

Specified by:
getConfigurationItemsByType in interface ConfigurationService
Parameters:
type - the type of configuration items to retrieve
locale - the locale to use when setting the configuration items name values
Returns:
an array of ConfigurationModels

createConfigurationItem

public Configuration createConfigurationItem(Configuration configuration)
Creates a Configuration.

Specified by:
createConfigurationItem in interface ConfigurationService
Parameters:
model - The Configuration to store
Returns:
the Configuration after saving

updateConfigurationItem

public Configuration updateConfigurationItem(Configuration configuration)
Updates a ConfigurationItem

Specified by:
updateConfigurationItem in interface ConfigurationService
Parameters:
model - The model containing the data
Returns:
the Configuration after save

updateConfigurationItems

public List<Configuration> updateConfigurationItems(List<Configuration> configurations,
                                                    int type)
Updates the configuration items

Specified by:
updateConfigurationItems in interface ConfigurationService
Parameters:
models - the ConfigurationModels to update
type - The type of the ConfigurationItems to update
Returns:
an array with the saved models

removeConfigurationItem

public void removeConfigurationItem(Integer id)
Finds the Configuration by primary key id and deletes it.

Specified by:
removeConfigurationItem in interface ConfigurationService
Parameters:
id - The id of the COnfigurationBean to remove

removeConfigurationItems

public void removeConfigurationItems(int type)
Removes all Configurations of the give type

Specified by:
removeConfigurationItems in interface ConfigurationService
Parameters:
type - the type of Configuration to remove

removeConfigurationItems

public void removeConfigurationItems(Configuration configuration)
Description copied from interface: ConfigurationService
This method will remove all configuration items that match the supplied models type and value. This effectively eliminates all previous versions of the item. It is normally called prior to a create to remove any older copies of this item.

Specified by:
removeConfigurationItems in interface ConfigurationService

configurationItemExists

public boolean configurationItemExists(Configuration configuration)
Specified by:
configurationItemExists in interface ConfigurationService

configurationItemUpToDate

public boolean configurationItemUpToDate(Configuration configuration)
Specified by:
configurationItemUpToDate in interface ConfigurationService

resetConfigurationCache

public void resetConfigurationCache()
Description copied from interface: ConfigurationService
This method will reset any caches in the system of configuration items for all configuration item types.

Specified by:
resetConfigurationCache in interface ConfigurationService

resetConfigurationCache

public void resetConfigurationCache(int type)
Description copied from interface: ConfigurationService
This method will reset any caches in the system of configuration items for the specified configuration item type.

Specified by:
resetConfigurationCache in interface ConfigurationService
Parameters:
type - the type of configuration item to reset in any caches

getProjectScript

public ProjectScript getProjectScript(Integer scriptId)
Description copied from interface: ConfigurationService
This method will return the requested project script.

Specified by:
getProjectScript in interface ConfigurationService
Parameters:
scriptId - the id of the requested script
Returns:
a ProjectScript with the requested script, or null if not found

getProjectScripts

public List<ProjectScript> getProjectScripts()
Description copied from interface: ConfigurationService
This method will return all defined project scripts.

Specified by:
getProjectScripts in interface ConfigurationService
Returns:
a ProjectScript array with all defined scripts

createProjectScript

public ProjectScript createProjectScript(ProjectScript projectScript)
Description copied from interface: ConfigurationService
This method will create a new project script for persistance in the database.

Specified by:
createProjectScript in interface ConfigurationService

updateProjectScript

public ProjectScript updateProjectScript(ProjectScript projectScript)
Description copied from interface: ConfigurationService
This method updates a project script in the database.

Specified by:
updateProjectScript in interface ConfigurationService
Returns:
a ProjectScript with the updated item

removeProjectScript

public void removeProjectScript(Integer projectScript_id)
remove a project script by its id

Specified by:
removeProjectScript in interface ConfigurationService
Parameters:
id - the id of the project script to remove

getWorkflowScript

public WorkflowScript getWorkflowScript(Integer id)
Description copied from interface: ConfigurationService
This method will return the requested workflow script.

Specified by:
getWorkflowScript in interface ConfigurationService
Parameters:
id - the id of the requested script
Returns:
a WorkflowScript with the requested script, or null if not found

getWorkflowScripts

public List<WorkflowScript> getWorkflowScripts()
Description copied from interface: ConfigurationService
This method will return all defined workflow scripts.

Specified by:
getWorkflowScripts in interface ConfigurationService
Returns:
a WorkflowScript array with all defined scripts

createWorkflowScript

public WorkflowScript createWorkflowScript(WorkflowScript workflowScript)
Creates a workflow script.

Specified by:
createWorkflowScript in interface ConfigurationService
Parameters:
model - The WorkflowScript carring the data
Returns:
The WorkflowScript after inserting

updateWorkflowScript

public WorkflowScript updateWorkflowScript(WorkflowScript workflowScript)
Description copied from interface: ConfigurationService
This method updates a workflow script in the database.

Specified by:
updateWorkflowScript in interface ConfigurationService
Returns:
a WorkflowScript with the updated item

removeWorkflowScript

public void removeWorkflowScript(Integer workflowScript_id)
remove a workflow script by its id

Specified by:
removeWorkflowScript in interface ConfigurationService
Parameters:
id - the id of the workflow script to remove

getCustomField

public CustomField getCustomField(Integer id)
Description copied from interface: ConfigurationService
This method will return the requested custom field.

Specified by:
getCustomField in interface ConfigurationService
Parameters:
id - the id of the requested field
Returns:
a CustomField with the requested field, or null if not found

getCustomFields

public List<CustomField> getCustomFields()
Description copied from interface: ConfigurationService
This method will return all the custom fields defined in the system.

Specified by:
getCustomFields in interface ConfigurationService
Returns:
an array of CustomFieldModels

getCustomFields

public List<CustomField> getCustomFields(Locale locale)
Description copied from interface: ConfigurationService
This method will return all the custom fields defined in the system. It will also initialize all of the field labels using the supplied locale.

Specified by:
getCustomFields in interface ConfigurationService
Parameters:
locale - the locale to use to initialize the labels
Returns:
an array of CustomFieldModels

createCustomField

public CustomField createCustomField(CustomField customField)
Creates a custom field

Specified by:
createCustomField in interface ConfigurationService
Parameters:
customField - The CustomField carrying the data
Returns:
the CustomField after saving

updateCustomField

public CustomField updateCustomField(CustomField customField)
Description copied from interface: ConfigurationService
This method updates a custom field in the database. It does not include any updates to language items that would be used to display the localized label for the field. If any options are included, the list will be used to replace any existing options.

Specified by:
updateCustomField in interface ConfigurationService
Returns:
a CustomField with the updated item

removeCustomField

public boolean removeCustomField(Integer customFieldId)
searches for a custom field by primary key and removes it

Specified by:
removeCustomField in interface ConfigurationService
Parameters:
customFieldId - the primary key

getCustomFieldValue

public CustomFieldValue getCustomFieldValue(Integer id)
Gets a CustomFieldValue by primary key

Specified by:
getCustomFieldValue in interface ConfigurationService
Parameters:
id - the primary key
Returns:
The CustomFieldValue found or null

createCustomFieldValue

public CustomFieldValue createCustomFieldValue(CustomFieldValue customFieldValue)
Description copied from interface: ConfigurationService
This method will create a new CustomFieldValue for persistance in the database.

Specified by:
createCustomFieldValue in interface ConfigurationService

updateCustomFieldValue

public CustomFieldValue updateCustomFieldValue(CustomFieldValue customFieldValue)
Updates a CustomFieldValue.

Specified by:
updateCustomFieldValue in interface ConfigurationService
Parameters:
model - The model to update
Returns:
The CustomFieldValue after saving

updateCustomFieldValues

public List<CustomFieldValue> updateCustomFieldValues(Integer customFieldId,
                                                      List<CustomFieldValue> customFieldValues)
Description copied from interface: ConfigurationService
This method updates a set of custom field values in the database. If the array of values is null or zero length, it will remove all existing values from the custom field. Otherwise it will update the value and sort order of all the values. If the array of models contains more or less values than the current custom field, it will not remove theose values, or create new values.

Specified by:
updateCustomFieldValues in interface ConfigurationService
Parameters:
customFieldId - the id of the custom field to update
Returns:
a array of CustomFieldValueModels with the updated items

removeCustomFieldValue

public boolean removeCustomFieldValue(Integer customFieldValueId)
removes a custom field value by primary key

Specified by:
removeCustomFieldValue in interface ConfigurationService
Parameters:
customFieldValueId - the id of the custoem field

removeCustomFieldValues

public boolean removeCustomFieldValues(Integer customFieldId)
Removes all field values of a given custom field

Specified by:
removeCustomFieldValues in interface ConfigurationService
Parameters:
customFieldId - The id of the customField

getLanguageItemByKey

public Language getLanguageItemByKey(String key,
                                     Locale locale)
Description copied from interface: ConfigurationService
This method will return the translation for a particular key in a locale.

Specified by:
getLanguageItemByKey in interface ConfigurationService
Parameters:
key - the key to look up
locale - the localue to translate the key for
Returns:
a Language with the translation

getLanguageItemsByKey

public List<Language> getLanguageItemsByKey(String key)
Description copied from interface: ConfigurationService
This method will return all the translations for a particular key.

Specified by:
getLanguageItemsByKey in interface ConfigurationService
Parameters:
key - the key to look up
Returns:
an array of LanguageModels with the translations for the key

updateLanguageItem

public Language updateLanguageItem(Language language)
Description copied from interface: ConfigurationService
Updates a translations for a particular key and locale.

Specified by:
updateLanguageItem in interface ConfigurationService
Returns:
a Language with the updated translation

removeLanguageKey

public boolean removeLanguageKey(String key)
Removes all Languages with the give key

Specified by:
removeLanguageKey in interface ConfigurationService
Parameters:
key - The key to be removed

removeLanguageItem

public void removeLanguageItem(Language language)
Removes the Language passed as parameter

Specified by:
removeLanguageItem in interface ConfigurationService
Parameters:
model - The Language to remove

getSortedKeys

public String[] getSortedKeys()
Description copied from interface: ConfigurationService
Returns all of the keys currently defined in the base locale sorted and grouped in a logical manner.

Specified by:
getSortedKeys in interface ConfigurationService

getDefinedKeys

public HashMap<String,String> getDefinedKeys(String locale)
Specified by:
getDefinedKeys in interface ConfigurationService

getDefinedKeysAsArray

public List<NameValuePair> getDefinedKeysAsArray(String locale)
Specified by:
getDefinedKeysAsArray in interface ConfigurationService

getNumberDefinedKeys

public int getNumberDefinedKeys(String locale)
Specified by:
getNumberDefinedKeys in interface ConfigurationService

getLanguage

public List<Language> getLanguage(Locale locale)
Description copied from interface: ConfigurationService
returns languages for the locale as list of Language-objects

Specified by:
getLanguage in interface ConfigurationService
Returns:

getAvailableLanguages

public HashMap<String,List<String>> getAvailableLanguages()
Specified by:
getAvailableLanguages in interface ConfigurationService

getNumberAvailableLanguages

public int getNumberAvailableLanguages()
Specified by:
getNumberAvailableLanguages in interface ConfigurationService

updateLanguage

public void updateLanguage(Locale locale,
                           List<Language> items)
Specified by:
updateLanguage in interface ConfigurationService

updateLanguage

public void updateLanguage(Locale locale,
                           List<Language> items,
                           Configuration configItem)
Specified by:
updateLanguage in interface ConfigurationService

getSystemConfiguration

public SystemConfiguration getSystemConfiguration(Locale locale)
Description copied from interface: ConfigurationService
This method will return the current configuration of the system.

Specified by:
getSystemConfiguration in interface ConfigurationService
Returns:
a SystemConfiguration with the current configuration of the system

initializeLocale

public boolean initializeLocale(String locale,
                                boolean forceReload)
Description copied from interface: ConfigurationService
This method will load the specified locale. It will look for the appropriate properties file, and then load all of the resources into the database.

Specified by:
initializeLocale in interface ConfigurationService
Parameters:
locale - the locale to load
forceReload - if true, it will reload the languages from the property file even if it is listed as being up to date

initializeConfiguration

public void initializeConfiguration()
Description copied from interface: ConfigurationService
This method will load the some default system configuration data into the database. The values it loads are determined from the base ITracker.properties file so the language intiialization must be performed before this method is called.

Specified by:
initializeConfiguration in interface ConfigurationService

getLanguageDAO

public LanguageDAO getLanguageDAO()

getConfigurationDAO

public ConfigurationDAO getConfigurationDAO()

getCustomFieldDAO

public CustomFieldDAO getCustomFieldDAO()

getCustomFieldValueDAO

public CustomFieldValueDAO getCustomFieldValueDAO()

getWorkflowScriptDAO

public WorkflowScriptDAO getWorkflowScriptDAO()

getSystemBaseURL

public String getSystemBaseURL()
Specified by:
getSystemBaseURL in interface ConfigurationService


Copyright © 2002-2012 itracker. All Rights Reserved.