Add DAO module for Models
[policy/models.git] / models-dao / src / main / java / org / onap / policy / models / dao / DaoParameters.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.models.dao;
22
23 import java.util.Properties;
24
25 /**
26  * This class is a POJO that holds properties for PF DAOs.
27  */
28 public class DaoParameters {
29     /** The default PF DAO plugin class. */
30     public static final String DEFAULT_PLUGIN_CLASS = "org.onap.policy.models.dao.impl.DefaultPfDao";
31
32     private String pluginClass = DEFAULT_PLUGIN_CLASS;
33     private String persistenceUnit;
34
35     private Properties jdbcProperties = new Properties();
36
37     /**
38      * Gets the DAO plugin class, this is the DAO class to use and it must implement the
39      * {@link PfDao} interface.
40      *
41      * @return the DAO plugin class
42      */
43     public String getPluginClass() {
44         return pluginClass;
45     }
46
47     /**
48      * Sets the DAO plugin class, a class that implements the {@link PfDao} interface.
49      *
50      * @param daoPluginClass the DAO plugin class
51      */
52     public void setPluginClass(final String daoPluginClass) {
53         pluginClass = daoPluginClass;
54     }
55
56     /**
57      * Gets the persistence unit for the DAO. The persistence unit defines the JDBC properties the
58      * DAO will use. The persistence unit must defined in the {@code META-INF/persistence.xml}
59      * resource file
60      *
61      * @return the persistence unit to use for JDBC access
62      */
63     public String getPersistenceUnit() {
64         return persistenceUnit;
65     }
66
67     /**
68      * Sets the persistence unit for the DAO. The persistence unit defines the JDBC properties the
69      * DAO will use. The persistence unit must defined in the {@code META-INF/persistence.xml}
70      * resource file
71      *
72      * @param daoPersistenceUnit the persistence unit to use for JDBC access
73      */
74     public void setPersistenceUnit(final String daoPersistenceUnit) {
75         persistenceUnit = daoPersistenceUnit;
76     }
77
78     /**
79      * Gets the JDBC properties.
80      *
81      * @return the JDBC properties
82      */
83     public Properties getJdbcProperties() {
84         return jdbcProperties;
85     }
86
87     /**
88      * Sets the JDBC properties.
89      *
90      * @param jdbcProperties the JDBC properties
91      */
92     public void setJdbcProperties(final Properties jdbcProperties) {
93         this.jdbcProperties = jdbcProperties;
94     }
95
96     /**
97      * Gets a single JDBC property.
98      *
99      * @param key the key of the property
100      * @return the JDBC property
101      */
102     public String getJdbcProperty(final String key) {
103         return jdbcProperties.getProperty(key);
104     }
105
106     /**
107      * Sets a single JDBC property.
108      *
109      * @param key the key of the property
110      * @param value the value of the JDBC property
111      */
112     public void setJdbcProperty(final String key, final String value) {
113         jdbcProperties.setProperty(key, value);
114     }
115
116     /*
117      * (non-Javadoc)
118      *
119      * @see java.lang.Object#toString()
120      */
121     @Override
122     public String toString() {
123         return "DAOParameters [pluginClass=" + pluginClass + ", persistenceUnit=" + persistenceUnit
124                 + ", jdbcProperties=" + jdbcProperties + "]";
125     }
126 }