View Javadoc

1   /*
2    * Copyright 2006 - 2012 Christina Bohk and Roland Ewald
3    *  
4    * Licensed under the Apache License, Version 2.0 (the "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at 
7    *  
8    *  http://www.apache.org/licenses/LICENSE-2.0
9    *  
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License. 
15   */
16  package p3j.gui.misc;
17  
18  import org.jamesii.core.data.DBConnectionData;
19  import org.jamesii.gui.application.preferences.config.ConfFile;
20  
21  import p3j.misc.Misc;
22  
23  /**
24   * Main P3J configuration file.
25   * 
26   * @author Christina Bohk
27   * @author Roland Ewald
28   * 
29   */
30  public class P3JConfigFile extends ConfFile {
31  
32    @Override
33    public void setDefaults() {
34  
35      // DAtabase settings
36      put(Misc.PREF_DB_TYPE, Misc.DEFAULT_DB_TYPE);
37      Misc.DEFAULT_DB_TYPE.writePreferences(this,
38          Misc.DEFAULT_DB_TYPE.getDefaults());
39  
40      // Execution settings
41      put(Misc.PREF_NUM_TRIALS, Misc.DEFAULT_NUM_TRIALS);
42      put(Misc.PREF_NUM_PARALLEL_THREADS, Misc.DEFAULT_NUM_PARALLEL_THREADS);
43      put(Misc.PREF_EXECUTION_MODE, Misc.DEFAULT_EXEC_MODE);
44    }
45  
46    /**
47     * Gets the dB connection data as defined in the configuration.
48     * 
49     * @return the database connection data
50     */
51    public DBConnectionData getDBConnectionData() {
52      return new DBConnectionData((String) get(Misc.PREF_DB_URL),
53          (String) get(Misc.PREF_DB_USER), (String) get(Misc.PREF_DB_PWD),
54          (String) get(Misc.PREF_HIBERNATE_DRIVER_PROPERTY));
55    }
56  
57  }