Add DAO Enabled Tosca Model
[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  * @author Liam Fallon (liam.fallon@est.tech)
29  */
30 public class DaoParameters {
31     /** The default PF DAO plugin class. */
32     public static final String DEFAULT_PLUGIN_CLASS = "org.onap.policy.models.dao.impl.DefaultPfDao";
33
34     private String pluginClass = DEFAULT_PLUGIN_CLASS;
35     private String persistenceUnit;
36
37     private Properties jdbcProperties = new Properties();
38
39     /**
40      * Gets the DAO plugin class, this is the DAO class to use and it must implement the
41      * {@link PfDao} interface.
42      *
43      * @return the DAO plugin class
44      */
45     public String getPluginClass() {
46         return pluginClass;
47     }
48
49     /**
50      * Sets the DAO plugin class, a class that implements the {@link PfDao} interface.
51      *
52      * @param daoPluginClass the DAO plugin class
53      */
54     public void setPluginClass(final String daoPluginClass) {
55         pluginClass = daoPluginClass;
56     }
57
58     /**
59      * Gets the persistence unit for the DAO. The persistence unit defines the JDBC properties the
60      * DAO will use. The persistence unit must defined in the {@code META-INF/persistence.xml}
61      * resource file
62      *
63      * @return the persistence unit to use for JDBC access
64      */
65     public String getPersistenceUnit() {
66         return persistenceUnit;
67     }
68
69     /**
70      * Sets the persistence unit for the DAO. The persistence unit defines the JDBC properties the
71      * DAO will use. The persistence unit must defined in the {@code META-INF/persistence.xml}
72      * resource file
73      *
74      * @param daoPersistenceUnit the persistence unit to use for JDBC access
75      */
76     public void setPersistenceUnit(final String daoPersistenceUnit) {
77         persistenceUnit = daoPersistenceUnit;
78     }
79
80     /**
81      * Gets the JDBC properties.
82      *
83      * @return the JDBC properties
84      */
85     public Properties getJdbcProperties() {
86         return jdbcProperties;
87     }
88
89     /**
90      * Sets the JDBC properties.
91      *
92      * @param jdbcProperties the JDBC properties
93      */
94     public void setJdbcProperties(final Properties jdbcProperties) {
95         this.jdbcProperties = jdbcProperties;
96     }
97
98     /**
99      * Gets a single JDBC property.
100      *
101      * @param key the key of the property
102      * @return the JDBC property
103      */
104     public String getJdbcProperty(final String key) {
105         return jdbcProperties.getProperty(key);
106     }
107
108     /**
109      * Sets a single JDBC property.
110      *
111      * @param key the key of the property
112      * @param value the value of the JDBC property
113      */
114     public void setJdbcProperty(final String key, final String value) {
115         jdbcProperties.setProperty(key, value);
116     }
117
118     /*
119      * (non-Javadoc)
120      *
121      * @see java.lang.Object#toString()
122      */
123     @Override
124     public String toString() {
125         return "DAOParameters [pluginClass=" + pluginClass + ", persistenceUnit=" + persistenceUnit
126                 + ", jdbcProperties=" + jdbcProperties + "]";
127     }
128 }