Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
461   1,381   180   6.98
178   780   0.39   66
66     2.73  
1    
 
 
  ConfigurationServiceImpl       Line # 70 461 180 0% 0.0
 
No Tests
 
1    /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10    * the Free Software Foundation; either version 2 of the License, or
11    * (at your option) any later version.
12    *
13    * This program is distributed in the hope that it will be useful,
14    * but WITHOUT ANY WARRANTY; without even the implied warranty of
15    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16    * GNU General Public License for more details.
17    */
18   
19    package org.itracker.services.implementations;
20   
21    import java.util.ArrayList;
22    import java.util.Arrays;
23    import java.util.Collection;
24    import java.util.Collections;
25    import java.util.Date;
26    import java.util.Enumeration;
27    import java.util.HashMap;
28    import java.util.Iterator;
29    import java.util.List;
30    import java.util.Locale;
31    import java.util.Map;
32    import java.util.Properties;
33    import java.util.ResourceBundle;
34   
35    import javax.naming.InitialContext;
36    import javax.naming.NamingException;
37   
38    import org.apache.log4j.Logger;
39    import org.itracker.core.resources.ITrackerResources;
40    import org.itracker.model.Configuration;
41    import org.itracker.model.CustomField;
42    import org.itracker.model.CustomFieldValue;
43    import org.itracker.model.Language;
44    import org.itracker.model.NameValuePair;
45    import org.itracker.model.ProjectScript;
46    import org.itracker.model.SystemConfiguration;
47    import org.itracker.model.WorkflowScript;
48    import org.itracker.persistence.dao.ConfigurationDAO;
49    import org.itracker.persistence.dao.CustomFieldDAO;
50    import org.itracker.persistence.dao.CustomFieldValueDAO;
51    import org.itracker.persistence.dao.LanguageDAO;
52    import org.itracker.persistence.dao.NoSuchEntityException;
53    import org.itracker.persistence.dao.ProjectScriptDAO;
54    import org.itracker.persistence.dao.WorkflowScriptDAO;
55    import org.itracker.services.ConfigurationService;
56    import org.itracker.services.util.CustomFieldUtilities;
57    import org.itracker.services.util.IssueUtilities;
58    import org.itracker.services.util.NamingUtilites;
59    import org.itracker.services.util.SystemConfigurationUtilities;
60    import org.jfree.util.Log;
61   
62    /**
63    * Implementation of the ConfigurationService Interface.
64    *
65    * @see ConfigurationService
66    */
67   
68    // TODO: Cleanup this file, go through all issues, todos, etc.
69   
 
70    public class ConfigurationServiceImpl implements ConfigurationService {
71   
72    private static final Logger logger = Logger.getLogger(ConfigurationServiceImpl.class.getName());
73    // TODO make final static?
74    private final Properties props;
75    private ConfigurationDAO configurationDAO;
76    private CustomFieldDAO customFieldDAO;
77    private CustomFieldValueDAO customFieldValueDAO;
78    private LanguageDAO languageDAO;
79    private ProjectScriptDAO projectScriptDAO;
80    private WorkflowScriptDAO workflowScriptDAO;
81   
82   
83    private static final Long _START_TIME_MILLIS = System.currentTimeMillis();
84    private String jndiPropertiesOverridePrefix;
85   
86    /**
87    * Creates a new instance using the given configuration.
88    *
89    * @param configurationProperties itracker configuration properties
90    * (see /WEB-INF/configuration.properties)
91    */
 
92  0 toggle public ConfigurationServiceImpl(Properties configurationProperties,
93    ConfigurationDAO configurationDAO, CustomFieldDAO customFieldDAO,
94    CustomFieldValueDAO customFieldValueDAO, LanguageDAO languageDAO,
95    ProjectScriptDAO projectScriptDAO, WorkflowScriptDAO workflowScriptDAO) {
96  0 if (configurationProperties == null) {
97  0 throw new IllegalArgumentException("null configurationProperties");
98    }
99  0 this.props = configurationProperties;
100  0 props.setProperty("start_time_millis", String.valueOf(_START_TIME_MILLIS));
101   
102    // initialize naming context prefix for properties overrides
103  0 this.jndiPropertiesOverridePrefix = props.getProperty(
104    "jndi_override_prefix", null);
105   
106  0 this.configurationDAO = configurationDAO;
107  0 this.customFieldDAO = customFieldDAO;
108  0 this.customFieldValueDAO = customFieldValueDAO;
109  0 this.languageDAO = languageDAO;
110   
111  0 this.projectScriptDAO = projectScriptDAO;
112  0 this.workflowScriptDAO = workflowScriptDAO;
113    }
114   
 
115  0 toggle public String getProperty(String name) {
116  0 String value = null;
117  0 if (null != jndiPropertiesOverridePrefix) {
118   
119  0 if (logger.isDebugEnabled()) {
120   
121  0 logger.debug("getProperty: looking up '" + name
122    + "' from jndi context "
123    + jndiPropertiesOverridePrefix);
124   
125   
126    }
127  0 try {
128  0 value = NamingUtilites.getStringValue(new InitialContext(),
129    jndiPropertiesOverridePrefix + "/" + name, null);
130  0 if (null == value) {
131  0 if (logger.isDebugEnabled()) {
132  0 logger.debug("getProperty: value not found in jndi: " + name);
133    }
134    }
135    } catch (Exception e) {
136  0 logger.debug("getProperty: caught exception looking up value for " + name, e);
137    }
138   
139    }
140   
141  0 if (null == value) {
142  0 value = props.getProperty(name, null);
143    }
144  0 if (logger.isDebugEnabled()) {
145  0 logger.debug("getProperty: returning " + value + " for name: " + name);
146    }
147  0 return value;
148    }
149   
 
150  0 toggle public String getProperty(String name, String defaultValue) {
151  0 String val = getProperty(name);
152  0 return (val == null) ? defaultValue : val;
153    }
154   
 
155  0 toggle public boolean getBooleanProperty(String name, boolean defaultValue) {
156  0 String value = getProperty(name);
157   
158  0 return (value == null ? defaultValue : Boolean.valueOf(value));
159    }
160   
 
161  0 toggle public int getIntegerProperty(String name, int defaultValue) {
162  0 String value = getProperty(name);
163   
164  0 try {
165  0 return (value == null) ? defaultValue : Integer.parseInt(value);
166    } catch (NumberFormatException ex) {
167  0 return defaultValue;
168    }
169   
170    }
171   
 
172  0 toggle public long getLongProperty(String name, long defaultValue) {
173  0 String value = getProperty(name);
174  0 try {
175  0 return (value == null) ? defaultValue : Long.parseLong(value);
176    } catch (NumberFormatException ex) {
177  0 return defaultValue;
178    }
179   
180    }
181    /**
182    * returns a proxy to the properties, supplying jndi awareness
183    */
 
184  0 toggle public Properties getProperties() {
185  0 Properties p = new Properties(props) {
186   
187    /**
188    *
189    */
190    private static final long serialVersionUID = -9126991683132905153L;
191   
 
192  0 toggle @Override
193    public synchronized Object get(Object key) {
194  0 if (null != super.getProperty(
195    "jndi_override_prefix", null)) {
196  0 if (logger.isInfoEnabled()) {
197  0 logger.info("get: looking for override for " + key
198    + " in jndi properties override: "
199    + super.getProperty(
200    "jndi_override_prefix", null));
201    }
202  0 Object val = null;
203  0 try {
204  0 val = NamingUtilites.lookup(new InitialContext(),
205    super.getProperty(
206    "jndi_override_prefix", null) + "/" + String.valueOf(key));
207    } catch (NamingException e) {
208  0 if (logger.isDebugEnabled()) {
209  0 logger.debug("get: failed to create initial context", e);
210    }
211    }
212  0 if (null != val) {
213  0 if (logger.isDebugEnabled()) {
214  0 logger.debug("get: returning " + val);
215    }
216  0 return val;
217    }
218   
219    }
220  0 if (logger.isDebugEnabled()) {
221  0 logger.debug("get: get value of " + key + " from super");
222    }
223  0 return super.get(key);
224    }
225    };
226  0 return p;
227    }
228   
 
229  0 toggle public Configuration getConfigurationItem(Integer id) {
230  0 Configuration configItem = configurationDAO.findByPrimaryKey(id);
231  0 return configItem;
232    }
233   
 
234  0 toggle public List<Configuration> getConfigurationItemsByType(int type) {
235  0 List<Configuration> configItems = configurationDAO.findByType(type);
236  0 Collections.sort(configItems, new Configuration.ConfigurationOrderComparator());
237  0 return configItems;
238    }
239   
 
240  0 toggle public List<Configuration> getConfigurationItemsByType(int type, Locale locale) {
241  0 List<Configuration> items = getConfigurationItemsByType(type);
242   
243  0 for (int i = 0; i < items.size(); i++) {
244  0 if (items.get(i).getType() == SystemConfigurationUtilities.TYPE_STATUS) {
245  0 items.get(i).setName(IssueUtilities.getStatusName(items.get(i).getValue(), locale));
246  0 } else if (items.get(i).getType() == SystemConfigurationUtilities.TYPE_SEVERITY) {
247  0 items.get(i).setName(IssueUtilities.getSeverityName(items.get(i).getValue(), locale));
248  0 } else if (items.get(i).getType() == SystemConfigurationUtilities.TYPE_RESOLUTION) {
249  0 items.get(i).setName(IssueUtilities.getResolutionName(items.get(i).getValue(), locale));
250    }
251    }
252  0 return items;
253    }
254   
255    /**
256    * Creates a <code>Configuration</code>.
257    *
258    * @param model The <code>Configuration</code> to store
259    * @return the <code>Configuration</code> after saving
260    * @todo replace hardcoded version by a resource
261    */
 
262  0 toggle public Configuration createConfigurationItem(Configuration configuration) {
263   
264  0 Configuration configurationItem = new Configuration();
265   
266  0 configurationItem.setType( configuration.getType() );
267  0 configurationItem.setOrder( configuration.getOrder() );
268  0 configurationItem.setValue( configuration.getValue() );
269  0 configurationItem.setCreateDate(new Date());
270  0 configurationItem.setVersion( this.getProperty("version") );
271  0 configurationDAO.saveOrUpdate(configurationItem);
272   
273  0 return configurationItem;
274   
275    }
276   
277    /**
278    * Updates a <code>ConfigurationItem</code>
279    *
280    * @param model The model containing the data
281    * @return the <code>Configuration</code> after save
282    */
 
283  0 toggle public Configuration updateConfigurationItem(Configuration configuration) {
284    // find item by primary key
285  0 Configuration configurationItem = configurationDAO.findByPrimaryKey(configuration.getId());
286   
287    // update now
288  0 configurationDAO.saveOrUpdate( configurationItem );
289    // get model from saved item
290  0 return configurationItem;
291    }
292   
293    /**
294    * Updates the configuration items
295    *
296    * @param models the <code>ConfigurationModels</code> to update
297    * @param type The type of the <code>ConfigurationItem</code>s to update
298    * @return an array with the saved models
299    */
 
300  0 toggle public List<Configuration> updateConfigurationItems(List<Configuration> configurations, int type) {
301   
302    // remove all items
303    // removeConfigurationItems(type);
304  0 List<Configuration> configurationItems = new ArrayList<Configuration>();
305  0 for (Iterator<Configuration> iterator = configurations.iterator(); iterator.hasNext();) {
306   
307    // create a new item
308  0 Configuration configurationItem = (Configuration) iterator.next();
309  0 Configuration curConfiguration = configurationDAO.findByPrimaryKey(configurationItem.getId());
310   
311    // curConfiguration.setCreateDate(configurationItem.getCreateDate());
312    // curConfiguration.setLastModifiedDate(configurationItem.getLastModifiedDate());
313  0 curConfiguration.setName(configurationItem.getName());
314  0 curConfiguration.setOrder(configurationItem.getOrder());
315  0 curConfiguration.setType(configurationItem.getType());
316  0 curConfiguration.setValue(configurationItem.getValue());
317  0 curConfiguration.setVersion(configurationItem.getVersion());
318   
319    // set Modified date
320    // curConfiguration.setLastModifiedDate(new Date());
321    // save or update
322  0 this.configurationDAO.saveOrUpdate( curConfiguration );
323  0 configurationItems.add(curConfiguration);
324    }
325    // sort array
326  0 Collections.sort(configurationItems);
327   
328  0 return configurationItems;
329    }
330   
331    /**
332    * Finds the <code>Configuration</code> by primary key <code>id<code>
333    * and deletes it.
334    *
335    * @param id The id of the <code>COnfigurationBean</code> to remove
336    */
 
337  0 toggle public void removeConfigurationItem(Integer id) {
338   
339  0 Configuration configBean = this.configurationDAO.findByPrimaryKey(id);
340  0 if ( configBean != null ) {
341  0 this.configurationDAO.delete( configBean );
342    }
343    }
344   
345    /**
346    * Removes all <code>Configuration</code>s of the give <code>type</code>
347    *
348    * @param type the type of <code>Configuration</code> to remove
349    */
 
350  0 toggle public void removeConfigurationItems(int type) {
351   
352    // find the configuration beans by its type
353  0 Collection<Configuration> currentItems = configurationDAO.findByType(type);
354   
355  0 for (Iterator<Configuration> iter = currentItems.iterator(); iter.hasNext();) {
356    // get current config bean
357  0 Configuration config = (Configuration) iter.next();
358    // delete it
359  0 this.configurationDAO.delete( config );
360    }
361    }
362   
 
363  0 toggle public void removeConfigurationItems(Configuration configuration) {
364    // TODO: never used, therefore commented, task added:
365    // Vector currentIds = new Vector();
366  0 Collection<Configuration> currentItems = configurationDAO.findByTypeAndValue(configuration.getType(), configuration.getValue());
367  0 for (Iterator<Configuration> iter = currentItems.iterator(); iter.hasNext();) {
368  0 Configuration configItem = (Configuration) iter.next();
369  0 configurationDAO.delete(configItem);
370    }
371    }
372   
 
373  0 toggle public boolean configurationItemExists(Configuration configuration) {
374   
375  0 if (configuration != null && configuration.getVersion() != null) {
376   
377  0 Collection<Configuration> configItems = configurationDAO.findByTypeAndValue(configuration.getType(), configuration.getValue());
378   
379  0 if (configItems != null && configItems.size() > 0) {
380   
381  0 return true;
382   
383    }
384   
385    }
386   
387  0 return false;
388   
389    }
390   
 
391  0 toggle public boolean configurationItemUpToDate(Configuration configuration) {
392   
393  0 long currentVersion = 0;
394   
395  0 if (configuration != null && configuration.getVersion() != null) {
396   
397  0 Collection<Configuration> configItems = configurationDAO.findByTypeAndValue(configuration.getType(), configuration.getValue());
398   
399  0 for (Iterator<Configuration> iter = configItems.iterator(); iter.hasNext();) {
400   
401  0 Configuration configItem = (Configuration) iter.next();
402   
403  0 if (configItem != null) {
404   
405  0 currentVersion = Math.max(SystemConfigurationUtilities.getVersionAsLong(configItem.getVersion()),
406    currentVersion);
407   
408    }
409   
410    }
411   
412  0 if (currentVersion >= SystemConfigurationUtilities.getVersionAsLong(configuration.getVersion())) {
413   
414  0 return true;
415   
416    }
417   
418    }
419   
420  0 return false;
421   
422    }
423   
 
424  0 toggle public void resetConfigurationCache() {
425   
426  0 IssueUtilities.setResolutions(getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_RESOLUTION));
427   
428  0 IssueUtilities.setSeverities(getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_SEVERITY));
429   
430  0 IssueUtilities.setStatuses(getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_STATUS));
431   
432  0 IssueUtilities.setCustomFields(getCustomFields());
433   
434    }
435   
 
436  0 toggle public void resetConfigurationCache(int type) {
437   
438  0 if (type == SystemConfigurationUtilities.TYPE_RESOLUTION) {
439   
440  0 IssueUtilities.setResolutions(getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_RESOLUTION));
441   
442  0 } else if (type == SystemConfigurationUtilities.TYPE_SEVERITY) {
443   
444  0 IssueUtilities.setSeverities(getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_SEVERITY));
445   
446  0 } else if (type == SystemConfigurationUtilities.TYPE_STATUS) {
447   
448  0 IssueUtilities.setStatuses(getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_STATUS));
449   
450  0 } else if (type == SystemConfigurationUtilities.TYPE_CUSTOMFIELD) {
451   
452  0 IssueUtilities.setCustomFields(getCustomFields());
453   
454    }
455   
456    }
457   
 
458  0 toggle public ProjectScript getProjectScript(Integer scriptId) {
459   
460  0 ProjectScript projectScript = this.projectScriptDAO.findByPrimaryKey(scriptId);
461  0 return projectScript;
462   
463    }
464   
 
465  0 toggle public List<ProjectScript> getProjectScripts() {
466  0 List<ProjectScript> projectScripts = this.projectScriptDAO.findAll();
467  0 return projectScripts;
468    }
469   
470   
 
471  0 toggle public ProjectScript createProjectScript(ProjectScript projectScript) {
472   
473    // create project script and populate data
474  0 ProjectScript editprojectScript = new ProjectScript();
475  0 editprojectScript.setFieldId(projectScript.getFieldId());
476  0 editprojectScript.setPriority(projectScript.getPriority());
477  0 editprojectScript.setProject(projectScript.getProject());
478  0 editprojectScript.setScript(projectScript.getScript());
479    // moved date stuff to BaseHibernateDAO
480    // editprojectScript.setCreateDate(new Date());
481    // editprojectScript.setLastModifiedDate(editprojectScript.getCreateDate());
482   
483    // save entity
484  0 this.projectScriptDAO.save(editprojectScript);
485   
486  0 return editprojectScript;
487    }
488   
 
489  0 toggle public ProjectScript updateProjectScript(ProjectScript projectScript) {
490  0 ProjectScript editprojectScript;
491   
492  0 editprojectScript = projectScriptDAO.findByPrimaryKey(projectScript.getId());
493  0 editprojectScript.setFieldId(projectScript.getFieldId());
494  0 editprojectScript.setPriority(projectScript.getPriority());
495  0 editprojectScript.setProject(projectScript.getProject());
496  0 editprojectScript.setScript(projectScript.getScript());
497    // moved date stuff to BaseHibernateDAO
498    // editprojectScript.setLastModifiedDate(new Date());
499  0 this.projectScriptDAO.saveOrUpdate(editprojectScript);
500  0 return editprojectScript;
501    }
502   
503    /**
504    * remove a project script by its id
505    *
506    * @todo get all ProjectScriptBeans with that script attached and delete the ProjectScriptBean
507    * @param id the id of the project script to remove
508    */
 
509  0 toggle public void removeProjectScript( Integer projectScript_id ) {
510  0 if ( projectScript_id != null ) {
511  0 ProjectScript projectScript = this.projectScriptDAO.findByPrimaryKey(projectScript_id);
512  0 if ( projectScript != null ) {
513  0 this.projectScriptDAO.delete(projectScript);
514    }
515    }
516    }
517   
 
518  0 toggle public WorkflowScript getWorkflowScript(Integer id) {
519   
520  0 WorkflowScript workflowScript = workflowScriptDAO.findByPrimaryKey(id);
521   
522  0 return workflowScript;
523   
524    }
525   
 
526  0 toggle public List<WorkflowScript> getWorkflowScripts() {
527  0 List<WorkflowScript> workflowScripts = workflowScriptDAO.findAll();
528  0 return workflowScripts;
529    }
530   
531    /**
532    * Creates a workflow script.
533    *
534    * @param model The <code>WorkflowScript</code> carring the data
535    * @return The <code>WorkflowScript</code> after inserting
536    */
 
537  0 toggle public WorkflowScript createWorkflowScript(WorkflowScript workflowScript) {
538   
539    // create workflow script and populate data
540  0 WorkflowScript editworkflowScript = new WorkflowScript();
541  0 editworkflowScript.setName(workflowScript.getName());
542  0 editworkflowScript.setScript(workflowScript.getScript());
543  0 editworkflowScript.setEvent(workflowScript.getEvent());
544    // moved date stuff to BaseHibernateDAO
545    // editworkflowScript.setLastModifiedDate(new Date());
546    // editworkflowScript.setCreateDate(new Date());
547    // editworkflowScript.setLastModifiedDate(editworkflowScript.getCreateDate());
548   
549    // save entity
550  0 workflowScriptDAO.save(editworkflowScript);
551   
552  0 return editworkflowScript;
553    }
554   
 
555  0 toggle public WorkflowScript updateWorkflowScript(WorkflowScript workflowScript) {
556  0 WorkflowScript editworkflowScript;
557   
558  0 editworkflowScript = workflowScriptDAO.findByPrimaryKey(workflowScript.getId());
559  0 editworkflowScript.setName(workflowScript.getName());
560  0 editworkflowScript.setScript(workflowScript.getScript());
561  0 editworkflowScript.setEvent(workflowScript.getEvent());
562    // moved date stuff to BaseHibernateDAO
563    // editworkflowScript.setLastModifiedDate(new Date());
564  0 workflowScriptDAO.saveOrUpdate(editworkflowScript);
565  0 return editworkflowScript;
566    }
567   
568    /**
569    * remove a workflow script by its id
570    *
571    * @todo get all ProjectScriptBeans with that script attached and delete the ProjectScriptBean
572    * @param id the id of the workflow script to remove
573    */
 
574  0 toggle public void removeWorkflowScript( Integer workflowScript_id ) {
575  0 if ( workflowScript_id != null ) {
576  0 WorkflowScript workflowScript = this.workflowScriptDAO.findByPrimaryKey(workflowScript_id);
577  0 if ( workflowScript != null ) {
578  0 this.workflowScriptDAO.delete(workflowScript);
579    }
580    }
581    }
582   
 
583  0 toggle public CustomField getCustomField(Integer id) {
584   
585  0 CustomField customField = customFieldDAO.findByPrimaryKey(id);
586   
587  0 return customField;
588   
589    }
590   
 
591  0 toggle public List<CustomField> getCustomFields() {
592  0 List<CustomField> customFields = customFieldDAO.findAll();
593  0 Collections.sort(customFields, new CustomField.NameComparator());
594  0 return customFields;
595   
596    }
597   
 
598  0 toggle public List<CustomField> getCustomFields(Locale locale) {
599   
600  0 if (true)
601  0 return null;
602    // skip this code.
603  0 List<CustomField> fields = getCustomFields();
604   
605  0 for (int i = 0; i < fields.size(); i++) {
606   
607    // fields.get(i).setLabels(locale);
608   
609    }
610  0 Collections.sort(fields, new CustomField.NameComparator());
611   
612  0 return fields;
613   
614    }
615   
616    /**
617    * Creates a custom field
618    *
619    * @param customField The <code>CustomField</code> carrying the data
620    * @return the <code>CustomField</code> after saving
621    */
 
622  0 toggle public CustomField createCustomField(CustomField customField) {
623  0 CustomField addcustomField = new CustomField();
624  0 addcustomField.setDateFormat(customField.getDateFormat());
625  0 addcustomField.setFieldType(customField.getFieldType());
626  0 addcustomField.setOptions(customField.getOptions());
627    // addcustomField.setName(customField.getName());
628  0 addcustomField.setRequired(customField.isRequired());
629  0 this.customFieldDAO.save( addcustomField );
630   
631    /* if (addcustomField.getOptions() != null && addcustomField.getOptions().size() > 0) {
632    removeCustomFieldValues(addcustomField.getId());
633    List<CustomFieldValue> newOptions = addcustomField.getOptions();
634   
635    for (int i = 0; i < newOptions.size(); i++) {
636    newOptions.get(i).getCustomField().setId(addcustomField.getId());
637    createCustomFieldValue(newOptions.get(i));
638    }
639    }
640    */
641  0 return addcustomField;
642    }
643   
 
644  0 toggle public CustomField updateCustomField(CustomField customField) {
645  0 CustomField editcustomField = customFieldDAO.findByPrimaryKey(customField.getId());
646   
647  0 editcustomField.setDateFormat(customField.getDateFormat());
648  0 editcustomField.setFieldType(customField.getFieldType());
649  0 editcustomField.setOptions(customField.getOptions());
650    // editcustomField.setName(customField.getName());
651  0 editcustomField.setRequired(customField.isRequired());
652    // moved date stuff to BaseHibernateDAO
653    // editcustomField.setLastModifiedDate(new Date());
654   
655  0 this.customFieldDAO.saveOrUpdate( editcustomField );
656   
657    /* if (editcustomField.getOptions() != null && editcustomField.getOptions().size() > 0) {
658    removeCustomFieldValues(editcustomField.getId());
659    List<CustomFieldValue> newOptions = editcustomField.getOptions();
660   
661    for (int i = 0; i < newOptions.size(); i++) {
662    createCustomFieldValue(newOptions.get(i));
663    }
664    }
665    */
666  0 return editcustomField;
667    }
668   
669    /**
670    * searches for a custom field by primary key and removes it
671    *
672    * @param customFieldId the primary key
673    */
 
674  0 toggle public boolean removeCustomField(Integer customFieldId) {
675  0 boolean status = true;
676  0 boolean del_Status = true;
677  0 CustomField customField = customFieldDAO.findByPrimaryKey(customFieldId);
678   
679  0 if ( customField != null ) {
680  0 try {
681  0 if(customField.getFieldType() == CustomField.Type.LIST)
682  0 status = this.removeCustomFieldValues(customFieldId);
683  0 String key = CustomFieldUtilities.getCustomFieldLabelKey(customField.getId());
684  0 this.customFieldDAO.delete(customField);
685  0 if(key != null)
686  0 status = this.removeLanguageKey(key);
687    } catch (Exception ex) {
688  0 del_Status = false;
689    }
690    }
691  0 if ( ! del_Status )
692  0 status = del_Status;
693   
694  0 return status;
695    }
696   
697   
698    /**
699    * Gets a <code>CustomFieldValue</code> by primary key
700    *
701    * @param id the primary key
702    * @return The <code>CustomFieldValue</code> found or <code>null</code>
703    */
 
704  0 toggle public CustomFieldValue getCustomFieldValue(Integer id) {
705   
706  0 CustomFieldValue cfvBean = (CustomFieldValue)
707    this.customFieldValueDAO.findByPrimaryKey(id);
708   
709  0 return cfvBean;
710    }
711   
 
712  0 toggle public CustomFieldValue createCustomFieldValue(CustomFieldValue customFieldValue) {
713  0 CustomFieldValue addcustomFieldValue = new CustomFieldValue();
714  0 addcustomFieldValue.setCustomField(customFieldValue.getCustomField());
715  0 addcustomFieldValue.setValue(customFieldValue.getValue());
716    // addcustomFieldValue.setName(customFieldValue.getName());
717  0 this.customFieldValueDAO.save(addcustomFieldValue);
718   
719  0 return addcustomFieldValue;
720    }
721   
722   
723    /**
724    * Updates a <code>CustomFieldValue</code>.
725    *
726    * @param model The model to update
727    * @return The <code>CustomFieldValue</code> after saving
728    */
 
729  0 toggle public CustomFieldValue updateCustomFieldValue(CustomFieldValue customFieldValue) {
730  0 CustomFieldValue editcustomFieldValue = this.customFieldValueDAO.findByPrimaryKey( customFieldValue.getId() );
731    // moved date stuff to BaseHibernateDAO
732    // editcustomFieldValue.setCreateDate(customFieldValue.getCreateDate());
733  0 editcustomFieldValue.setCustomField(customFieldValue.getCustomField());
734  0 editcustomFieldValue.setValue(customFieldValue.getValue());
735    // moved date stuff to BaseHibernateDAO
736    // editcustomFieldValue.setLastModifiedDate(new Date());
737    // editcustomFieldValue.setName(customFieldValue.getName());
738  0 this.customFieldValueDAO.saveOrUpdate( editcustomFieldValue );
739  0 return editcustomFieldValue;
740    }
741   
 
742  0 toggle public List<CustomFieldValue> updateCustomFieldValues(Integer customFieldId, List<CustomFieldValue> customFieldValues) {
743  0 List<CustomFieldValue> customFieldValueItems = new ArrayList<CustomFieldValue>();
744   
745  0 if(customFieldId != null) {
746  0 try {
747  0 CustomField customField = customFieldDAO.findByPrimaryKey(customFieldId);
748  0 if(customFieldValues == null || customFieldValues.size() == 0) {
749    // Collection<CustomFieldValue> currValues = customField.getOptions();
750    // boolean status = currValues.removeAll(currValues);
751    } else {
752  0 for (Iterator<CustomFieldValue> iterator = customFieldValues.iterator(); iterator.hasNext();) {
753   
754    // create a new item
755  0 CustomFieldValue customFieldValueItem = (CustomFieldValue) iterator.next();
756  0 CustomFieldValue curCustomFieldValue = customFieldValueDAO.findByPrimaryKey(customFieldValueItem.getId());
757   
758  0 curCustomFieldValue.setCreateDate(customFieldValueItem.getCreateDate());
759    // moved date stuff to BaseHibernateDAO
760    // curCustomFieldValue.setLastModifiedDate(customFieldValueItem.getLastModifiedDate());
761    // curCustomFieldValue.setName(customFieldValueItem.getName());
762  0 curCustomFieldValue.setValue(customFieldValueItem.getValue());
763  0 curCustomFieldValue.setCustomField(customFieldValueItem.getCustomField());
764  0 curCustomFieldValue.setSortOrder(customFieldValueItem.getSortOrder());
765   
766    // set Modified date
767    // curCustomFieldValue.setLastModifiedDate(new Date());
768    // save or update
769  0 this.customFieldValueDAO.saveOrUpdate( curCustomFieldValue );
770  0 customFieldValueItems.add(curCustomFieldValue);
771   
772    }
773    // sort array
774    // Collections.sort(customFieldValueItems);
775  0 customField.setOptions(customFieldValueItems);
776  0 return customFieldValueItems;
777   
778    }
779    } catch(Exception fe) {
780    }
781    }
782   
783    // Arrays.sort(customFieldValues, new CustomFieldValue());
784  0 return customFieldValues;
785    }
786   
787    /**
788    * removes a custom field value by primary key
789    *
790    * @param customFieldValueId the id of the custoem field
791    */
 
792  0 toggle public boolean removeCustomFieldValue(Integer customFieldValueId) {
793  0 boolean status = true;
794  0 boolean del_Status = true;
795   
796    // find custom field value by id
797  0 CustomFieldValue customFieldValue = this.customFieldValueDAO.findByPrimaryKey(customFieldValueId);
798   
799    // remove from parent field
800    // customFieldValue.getCustomField().getOptions().remove(customFieldValue);
801    // delete it
802  0 try {
803  0 this.customFieldValueDAO.delete(customFieldValue);
804    } catch (Exception ex) {
805  0 del_Status = false;
806    }
807  0 if ( ! del_Status )
808  0 status = del_Status;
809   
810  0 return status;
811    }
812   
813    /**
814    * Removes all field values of a given custom field
815    *
816    * @param customFieldId The id of the customField
817    */
 
818  0 toggle public boolean removeCustomFieldValues(Integer customFieldId) {
819  0 boolean status = true;
820  0 boolean lp_Status = true;
821  0 CustomField customField = this.customFieldDAO.findByPrimaryKey( customFieldId );
822    // get values of the field
823  0 List<CustomFieldValue> customFieldValues = customField.getOptions();
824  0 for ( Iterator<CustomFieldValue> iter = customFieldValues.iterator(); iter.hasNext();) {
825    // get current
826  0 CustomFieldValue customFieldValue = (CustomFieldValue)iter.next();
827  0 String key = CustomFieldUtilities.getCustomFieldOptionLabelKey(customFieldId, customFieldValue.getId());
828    // remove from collection
829  0 iter.remove();
830    // delete from datasource
831  0 try {
832  0 this.customFieldValueDAO.delete( customFieldValue );
833   
834  0 if(key != null)
835  0 status = this.removeLanguageKey(key);
836    } catch (Exception ex) {
837  0 lp_Status = false;
838    }
839    }
840  0 if (! lp_Status )
841  0 status = lp_Status;
842   
843  0 return status;
844    }
845   
 
846  0 toggle public Language getLanguageItemByKey(String key, Locale locale) {
847  0 Language languageItem;
848  0 try {
849  0 languageItem = languageDAO.findByKeyAndLocale(key, ITrackerResources.BASE_LOCALE);
850    } catch (RuntimeException e) {
851  0 languageItem = null;
852    }
853   
854  0 if (null == locale){
855   
856  0 locale = ITrackerResources.getLocale(ITrackerResources.BASE_LOCALE);
857   
858    }
859  0 try {
860  0 return languageDAO.findByKeyAndLocale(key, locale.getLanguage());
861    } catch (RuntimeException re) {
862  0 if (null == languageItem) {
863  0 languageItem = new Language(locale.getDisplayName(), key, ITrackerResources.getBundle(locale.getLanguage()).getString(key));
864    }
865    }
866  0 if (!"".equals(locale.getCountry())) {
867  0 try {
868  0 return languageDAO.findByKeyAndLocale(key, locale.toString());
869    } catch (RuntimeException ex){
870  0 if (null == languageItem){
871  0 return new Language(locale.getDisplayName(), key, ITrackerResources.getBundle(locale).getString(key));
872    }
873    }
874    }
875   
876  0 return languageItem;
877   
878    }
879   
 
880  0 toggle public List<Language> getLanguageItemsByKey(String key) {
881  0 List<Language> languageItems = languageDAO.findByKey(key);
882   
883  0 return languageItems;
884    }
885   
 
886  0 toggle public Language updateLanguageItem(Language language) {
887  0 Language languageItem;
888   
889  0 try {
890  0 languageItem = languageDAO.findByKeyAndLocale(language.getResourceKey(), language.getLocale());
891  0 languageItem.setLocale(language.getLocale());
892  0 languageItem.setResourceKey(language.getResourceKey());
893  0 languageItem.setResourceValue(language.getResourceValue());
894    // moved date stuff to BaseHibernateDAO
895    // languageItem.setLastModifiedDate(new Timestamp(new Date().getTime()));
896    } catch (NoSuchEntityException fe) {
897  0 logger.debug("NoSuchEntityException: Language, now populating Language");
898  0 languageItem = new Language();
899  0 languageItem.setLocale(language.getLocale());
900  0 languageItem.setResourceKey(language.getResourceKey());
901  0 languageItem.setResourceValue(language.getResourceValue());
902    // moved date stuff to BaseHibernateDAO
903    // languageItem.setCreateDate(new Timestamp(new Date().getTime()));
904    // languageItem.setLastModifiedDate(languageItem.getCreateDate());
905    }
906  0 logger.debug("Start saveOrUpdate Language");
907  0 languageDAO.saveOrUpdate(languageItem);
908  0 logger.debug("Saved Language");
909  0 return languageItem;
910    }
911   
912    /**
913    * Removes all <code>Language</code>s with the give key
914    *
915    * @param key The key to be removed
916    */
 
917  0 toggle public boolean removeLanguageKey(String key) {
918  0 boolean status = true;
919  0 boolean lp_Status = true;
920   
921    // find all <code>Language</code>s for the given key
922  0 List<Language> languageItems = languageDAO.findByKey(key);
923   
924  0 for (Iterator<Language> iter = languageItems.iterator(); iter.hasNext();) {
925    // delete current item
926  0 Language language = (Language) iter.next();
927  0 try {
928  0 this.languageDAO.delete(language);
929    } catch (Exception ex) {
930  0 lp_Status = false;
931    }
932    }
933  0 if ( ! lp_Status )
934  0 status = lp_Status;
935   
936  0 return status;
937    }
938    /**
939    * Removes the <code>Language</code> passed as parameter
940    *
941    * @param model The <code>Language</code> to remove
942    */
 
943  0 toggle public void removeLanguageItem(Language language) {
944   
945  0 Language languageItem = languageDAO.findByKeyAndLocale(language.getResourceKey(), language.getLocale());
946   
947  0 if ( languageItem != null ) {
948    // delete item
949  0 this.languageDAO.delete( languageItem );
950    }
951    }
952   
 
953  0 toggle public String[] getSortedKeys() {
954   
955  0 int i = 0;
956  0 Collection<Language> items = languageDAO.findByLocale(ITrackerResources.BASE_LOCALE);
957  0 String[] sortedKeys = new String[items.size()];
958   
959  0 for (Iterator<Language> iter = items.iterator(); iter.hasNext(); i++) {
960  0 Language item = (Language) iter.next();
961  0 sortedKeys[i] = item.getResourceKey();
962    }
963   
964    // Now sort the list of keys in a logical manner
965   
966  0 Arrays.sort(sortedKeys);
967  0 return sortedKeys;
968   
969    }
970   
 
971  0 toggle public HashMap<String,String> getDefinedKeys(String locale) {
972   
973  0 HashMap<String,String> keys = new HashMap<String,String>();
974   
975  0 if (locale == null || locale.equals("")) {
976  0 locale = ITrackerResources.BASE_LOCALE;
977    }
978   
979   
980  0 Collection<Language> items = languageDAO.findByLocale(locale);
981  0 for (Iterator<Language> iter = items.iterator(); iter.hasNext();) {
982  0 Language item = (Language) iter.next();
983  0 keys.put(item.getResourceKey(), item.getResourceValue());
984    }
985   
986   
987  0 return keys;
988   
989    }
990   
 
991  0 toggle public List<NameValuePair> getDefinedKeysAsArray(String locale) {
992  0 NameValuePair[] keys = null;
993  0 if (locale == null || locale.equals("")) {
994  0 locale = ITrackerResources.BASE_LOCALE;
995    }
996   
997  0 int i = 0;
998  0 Collection<Language> items = languageDAO.findByLocale(locale);
999  0 keys = new NameValuePair[items.size()];
1000   
1001  0 for (Iterator<Language> iter = items.iterator(); iter.hasNext(); i++) {
1002  0 Language item = (Language) iter.next();
1003  0 keys[i] = new NameValuePair(item.getResourceKey(), item.getResourceValue());
1004    }
1005   
1006  0 Arrays.sort(keys);
1007  0 return Arrays.asList(keys);
1008   
1009    }
1010   
 
1011  0 toggle public int getNumberDefinedKeys(String locale) {
1012   
1013  0 return getDefinedKeys(locale).size();
1014   
1015    }
1016   
 
1017  0 toggle public List<Language> getLanguage(Locale locale) {
1018   
1019   
1020  0 Map<String,String> language = new HashMap<String,String>();
1021   
1022  0 if (locale == null) {
1023  0 locale = new Locale("");
1024    }
1025   
1026  0 String localeString = (locale.toString().equals("") ? ITrackerResources.BASE_LOCALE : locale.toString());
1027   
1028  0 Collection<Language> items = languageDAO.findByLocale(localeString);
1029   
1030  0 for (Iterator<Language> iterator = items.iterator(); iterator.hasNext();) {
1031   
1032  0 Language item = (Language) iterator.next();
1033   
1034  0 language.put(item.getResourceKey(), item.getResourceValue());
1035   
1036    }
1037    // if (locale != null && !"".equals(locale.getLanguage())) {
1038    //
1039    // Collection<Language> languageItems = languageDAO.findByLocale(locale.getLanguage());
1040    //
1041    // for (Iterator<Language> iterator = languageItems.iterator(); iterator.hasNext();) {
1042    //
1043    // Language item = (Language) iterator.next();
1044    //
1045    // language.put(item.getResourceKey(), item.getResourceValue());
1046    //
1047    // }
1048    //
1049    // if (!"".equals(locale.getCountry())) {
1050    //
1051    // Collection<Language> countryItems = languageDAO.findByLocale(locale.toString());
1052    //
1053    // for (Iterator<Language> iterator = countryItems.iterator(); iterator.hasNext();) {
1054    //
1055    // Language item = (Language) iterator.next();
1056    //
1057    // language.put(item.getResourceKey(), item.getResourceValue());
1058    //
1059    // }
1060    //
1061    // }
1062    //
1063    // }
1064   
1065  0 Language[] languageArray = new Language[language.size()];
1066   
1067  0 int i = 0;
1068   
1069   
1070  0 for (Iterator<String> iterator = language.keySet().iterator(); iterator.hasNext(); i++) {
1071   
1072  0 String key = (String) iterator.next();
1073   
1074  0 languageArray[i] = new Language(localeString, key, (String) language.get(key));
1075   
1076    }
1077   
1078  0 return Arrays.asList(languageArray);
1079   
1080    }
1081   
 
1082  0 toggle public HashMap<String,List<String>> getAvailableLanguages() {
1083   
1084  0 HashMap<String,List<String>> languages = new HashMap<String,List<String>>();
1085  0 List<Configuration> locales = getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_LOCALE);
1086   
1087  0 for (int i = 0; i < locales.size(); i++) {
1088  0 String Baselocalestring = locales.get(i).getValue();
1089  0 if (! ITrackerResources.BASE_LOCALE.equalsIgnoreCase(Baselocalestring)) {
1090   
1091  0 if (Baselocalestring.length() == 2) {
1092    // languages.put(Baselocalestring, new ArrayList());
1093  0 List<String> languageList = new ArrayList<String>();
1094  0 for (int j = 0; j < locales.size(); j++) {
1095  0 String localestring = locales.get(j).getValue();
1096  0 if (!ITrackerResources.BASE_LOCALE.equalsIgnoreCase(localestring) && localestring.length() > 2 ) {
1097  0 String baseLanguage = localestring.substring(0, 2);
1098  0 if (baseLanguage.equals(Baselocalestring) && localestring.length() == 5 && localestring.indexOf('_') == 2) {
1099  0 languageList.add(localestring);
1100    }
1101    }
1102    }
1103  0 languages.put(Baselocalestring,languageList);
1104    }
1105    }
1106    }
1107   
1108  0 return languages;
1109   
1110    }
1111   
 
1112  0 toggle @SuppressWarnings("unchecked")
1113    public int getNumberAvailableLanguages() {
1114   
1115  0 int numLanguages = 0;
1116  0 HashMap<String,List<String>> availableLanguages = getAvailableLanguages();
1117   
1118  0 for (Iterator iter = availableLanguages.keySet().iterator(); iter.hasNext();) {
1119  0 List<List> languages = new ArrayList<List>();
1120  0 List list = availableLanguages.get((String)iter.next());
1121  0 languages.add(list);
1122   
1123  0 if (languages != null && languages.size() > 0) {
1124  0 numLanguages += languages.size();
1125    } else {
1126  0 numLanguages += 1;
1127    }
1128   
1129    }
1130   
1131  0 return numLanguages;
1132   
1133    }
1134   
 
1135  0 toggle public void updateLanguage(Locale locale, List<Language> items) {
1136   
1137  0 if (locale != null && items != null) {
1138  0 Configuration configItem = new Configuration(SystemConfigurationUtilities.TYPE_LOCALE, locale
1139    .toString(), props.getProperty("version"));
1140  0 updateLanguage(locale, items, configItem);
1141   
1142    }
1143   
1144    }
1145   
 
1146  0 toggle public void updateLanguage(Locale locale, List<Language> items, Configuration configItem) {
1147  0 for (int i = 0; i < items.size(); i++) {
1148   
1149  0 if (items.get(i) != null) {
1150  0 updateLanguageItem(items.get(i));
1151    }
1152    }
1153  0 removeConfigurationItems(configItem);
1154  0 createConfigurationItem(configItem);
1155    }
1156   
 
1157  0 toggle public SystemConfiguration getSystemConfiguration(Locale locale) {
1158   
1159  0 SystemConfiguration config = new SystemConfiguration();
1160   
1161    // Load the basic system configuration
1162   
1163  0 List<Configuration> resolutions = getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_RESOLUTION);
1164   
1165  0 for (int i = 0; i < resolutions.size(); i++) {
1166   
1167  0 resolutions.get(i).setName(ITrackerResources.getString(SystemConfigurationUtilities
1168    .getLanguageKey(resolutions.get(i)), locale));
1169   
1170    }
1171   
1172  0 config.setResolutions(resolutions);
1173   
1174  0 List<Configuration> severities = getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_SEVERITY);
1175   
1176  0 for (int i = 0; i < severities.size(); i++) {
1177   
1178  0 severities.get(i).setName(ITrackerResources.getString(SystemConfigurationUtilities
1179    .getLanguageKey(severities.get(i)), locale));
1180   
1181    }
1182   
1183  0 config.setSeverities(severities);
1184   
1185  0 List<Configuration> statuses = getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_STATUS);
1186   
1187  0 for (int i = 0; i < statuses.size(); i++) {
1188   
1189  0 statuses.get(i).setName(ITrackerResources.getString(SystemConfigurationUtilities.getLanguageKey(statuses.get(i)),
1190    locale));
1191   
1192    }
1193   
1194  0 config.setStatuses(statuses);
1195   
1196    // Now load the CustomFields
1197   
1198    // config.setCustomFields(IssueUtilities.getCustomFields(locale));
1199   
1200    // Now set the system version
1201   
1202  0 config.setVersion(props.getProperty("version"));
1203   
1204  0 return config;
1205   
1206    }
1207   
1208   
1209   
 
1210  0 toggle public boolean initializeLocale(String locale, boolean forceReload) {
1211  0 boolean result = false;
1212   
1213  0 Configuration localeConfig = new Configuration(SystemConfigurationUtilities.TYPE_LOCALE, locale,
1214    props.getProperty("version"));
1215   
1216  0 if (!configurationItemUpToDate(localeConfig) || forceReload) {
1217   
1218  0 logger.debug("Loading database with locale " + locale);
1219   
1220    // PropertiesFileHandler localePropertiesHandler = new PropertiesFileHandler(
1221    // "/org/itracker/core/resources/ITracker"
1222    // + (ITrackerResources.BASE_LOCALE.equals(locale) ? "" : "_" + locale) + ".properties");
1223   
1224    // if (localePropertiesHandler.hasProperties()) {
1225   
1226    // Properties localeProperties = localePropertiesHandler.getProperties();
1227   
1228    // logger.debug("Locale " + locale + " contains " + localeProperties.size() + " properties.");
1229   
1230    // for (Enumeration<?> propertiesEnumeration = localeProperties.propertyNames();
1231    // propertiesEnumeration.hasMoreElements();) {
1232    // String key = (String) propertiesEnumeration.nextElement();
1233    // String value = localeProperties.getProperty(key);
1234    // updateLanguageItem(new Language(locale, key, value));
1235    // }
1236   
1237  0 removeConfigurationItems(localeConfig);
1238    //
1239  0 createConfigurationItem(localeConfig);
1240    //
1241  0 ITrackerResources.clearBundle(ITrackerResources.getLocale(locale));
1242   
1243  0 result = true;
1244   
1245   
1246    }
1247   
1248  0 return result;
1249   
1250    }
1251   
 
1252  0 toggle public void initializeConfiguration() {
1253   
1254    // Need to eventually add in code that detects the current version of
1255    // the config and update
1256   
1257    // if necessary
1258   
1259   
1260  0 List<Configuration> initialized = getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_INITIALIZED);
1261   
1262  0 if (initialized == null || initialized.size() != 1) {
1263   
1264  0 logger.debug("System does not appear to be initialized, initializing system configuration.");
1265   
1266  0 ResourceBundle baseLanguage = ITrackerResources.getBundle(ITrackerResources.getLocale(ITrackerResources.BASE_LOCALE));
1267  0 getLanguage(ITrackerResources.getLocale(ITrackerResources.BASE_LOCALE));
1268   
1269  0 if (baseLanguage == null) {
1270   
1271  0 throw new IllegalStateException (
1272    "Languages must be initialized before the system configuration can be loaded.");
1273   
1274    }
1275   
1276    // Remove any previous configuration information, possibly left
1277    // over from previous failed initialization
1278   
1279  0 logger.debug("Removing previous incomplete initialization information.");
1280   
1281  0 removeConfigurationItems(SystemConfigurationUtilities.TYPE_STATUS);
1282   
1283  0 removeConfigurationItems(SystemConfigurationUtilities.TYPE_SEVERITY);
1284   
1285  0 removeConfigurationItems(SystemConfigurationUtilities.TYPE_RESOLUTION);
1286  0 Enumeration<String> keys = baseLanguage.getKeys();
1287  0 while (keys.hasMoreElements()) {
1288  0 String key = keys.nextElement();
1289  0 if (key.startsWith(ITrackerResources.KEY_BASE_RESOLUTION)) {
1290   
1291  0 try {
1292   
1293  0 String resolutionString = key.substring(20);
1294  0 if (Log.isDebugEnabled()) {
1295  0 logger.debug("Adding new configuration resolution value: " + resolutionString);
1296    }
1297  0 int resolutionNumber = Integer.parseInt(resolutionString);
1298   
1299  0 createConfigurationItem(new Configuration(
1300    SystemConfigurationUtilities.TYPE_RESOLUTION, resolutionString, props
1301    .getProperty("version"), resolutionNumber));
1302   
1303    } catch (RuntimeException e) {
1304   
1305  0 logger.error("Unable to load resolution value: " + key, e);
1306  0 throw e;
1307   
1308    }
1309   
1310    }
1311   
1312  0 if (key.startsWith(ITrackerResources.KEY_BASE_SEVERITY)) {
1313   
1314  0 try {
1315   
1316  0 String severityString = key.substring(18);
1317   
1318  0 logger.debug("Adding new configuration severity value: " + severityString);
1319   
1320  0 int severityNumber = Integer.parseInt(severityString);
1321   
1322  0 createConfigurationItem(new Configuration(SystemConfigurationUtilities.TYPE_SEVERITY,
1323    severityString, props.getProperty("version"), severityNumber));
1324   
1325    } catch (RuntimeException e) {
1326   
1327  0 logger.error("Unable to load severity value: " + key, e);
1328  0 throw e;
1329    }
1330   
1331    }
1332   
1333  0 if (key.startsWith(ITrackerResources.KEY_BASE_STATUS)) {
1334   
1335  0 try {
1336   
1337  0 String statusString = key.substring(16);
1338   
1339  0 logger.debug("Adding new configuration status value: " + statusString);
1340   
1341  0 int statusNumber = Integer.parseInt(statusString);
1342   
1343  0 createConfigurationItem(new Configuration(SystemConfigurationUtilities.TYPE_STATUS,
1344    statusString, props.getProperty("version"), statusNumber));
1345    } catch (RuntimeException e) {
1346  0 logger.error("Unable to load status value: " + key, e);
1347  0 throw e;
1348    }
1349    }
1350    }
1351  0 createConfigurationItem(new Configuration(SystemConfigurationUtilities.TYPE_INITIALIZED, "1",
1352    props.getProperty("version")));
1353    }
1354   
1355   
1356    }
1357   
 
1358  0 toggle public LanguageDAO getLanguageDAO() {
1359  0 return languageDAO;
1360    }
1361   
 
1362  0 toggle public ConfigurationDAO getConfigurationDAO() {
1363  0 return configurationDAO;
1364    }
1365   
 
1366  0 toggle public CustomFieldDAO getCustomFieldDAO() {
1367  0 return customFieldDAO;
1368    }
1369   
 
1370  0 toggle public CustomFieldValueDAO getCustomFieldValueDAO() {
1371  0 return customFieldValueDAO;
1372    }
1373   
 
1374  0 toggle public WorkflowScriptDAO getWorkflowScriptDAO() {
1375  0 return workflowScriptDAO;
1376    }
1377   
 
1378  0 toggle public String getSystemBaseURL() {
1379  0 return getProperty(PNAME_SYSTEM_BASE_URL);
1380    }
1381    }