summaryrefslogtreecommitdiffstats
path: root/models-dao/src/main/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-03-14 10:01:58 +0000
committerliamfallon <liam.fallon@est.tech>2019-03-14 10:01:58 +0000
commit4c28d2cdbf03be9dfe51caa05d45ba341b4c94cd (patch)
tree9689b2e6a2d6017c8ab9ece7e94c8dd097f3c66d /models-dao/src/main/java
parent748e3cd4a9e89b3b87a74b9134d45687f197409b (diff)
Add DAO Enabled Tosca Model
Add DAO annotations to TOSCA model Add keying between concepts and define foreign keys in objects for translation to DB schema Added provider interface, factory, and stubbed implementation. Completed unit test for models-base Completed unit test for models-dao Completed unit test for models-tosca Issue-ID: POLICY-1195 Change-Id: I53a0ba8b7a679b6887b38bdab184b60315e0cf5b Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-dao/src/main/java')
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java2
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/PfDaoFactory.java8
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/converters/CDataConditioner.java2
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/converters/Uuid2String.java4
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/converters/package-info.java2
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java12
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/package-info.java2
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/package-info.java6
8 files changed, 27 insertions, 11 deletions
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java b/models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java
index 18ae74ae1..a6b6f2f2e 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java
@@ -24,6 +24,8 @@ import java.util.Properties;
/**
* This class is a POJO that holds properties for PF DAOs.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
*/
public class DaoParameters {
/** The default PF DAO plugin class. */
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/PfDaoFactory.java b/models-dao/src/main/java/org/onap/policy/models/dao/PfDaoFactory.java
index 3b7e31eb8..6b7c7b3ad 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/PfDaoFactory.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/PfDaoFactory.java
@@ -20,6 +20,8 @@
package org.onap.policy.models.dao;
+import javax.ws.rs.core.Response;
+
import org.onap.policy.common.utils.validation.Assertions;
import org.onap.policy.models.base.PfModelException;
import org.slf4j.Logger;
@@ -28,6 +30,8 @@ import org.slf4j.LoggerFactory;
/**
* This factory class returns a Policy Framework DAO for the configured persistence mechanism. The
* factory uses the plugin class specified in {@link DaoParameters} to instantiate a DAO instance.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
*/
public class PfDaoFactory {
// Get a reference to the logger
@@ -52,7 +56,7 @@ public class PfDaoFactory {
String errorMessage =
"Policy Framework DAO class not found for DAO plugin \"" + daoParameters.getPluginClass() + "\"";
LOGGER.error(errorMessage, e);
- throw new PfModelException(errorMessage, e);
+ throw new PfModelException(Response.Status.INTERNAL_SERVER_ERROR, errorMessage, e);
}
// Check the class is a Policy Framework DAO
@@ -60,7 +64,7 @@ public class PfDaoFactory {
String errorMessage = "Specified DAO plugin class \"" + daoParameters.getPluginClass()
+ "\" does not implement the PfDao interface";
LOGGER.error(errorMessage);
- throw new PfModelException(errorMessage);
+ throw new PfModelException(Response.Status.INTERNAL_SERVER_ERROR, errorMessage);
}
return (PfDao) pfDaoObject;
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/converters/CDataConditioner.java b/models-dao/src/main/java/org/onap/policy/models/dao/converters/CDataConditioner.java
index 327f65ece..e4cfd74d3 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/converters/CDataConditioner.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/converters/CDataConditioner.java
@@ -25,7 +25,7 @@ import javax.persistence.Converter;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
- * The Class CDATAConditioner converts a CDATA String to and from database format by removing spaces
+ * The Class CDataConditioner converts a CDATA String to and from database format by removing spaces
* at the ends of lines and platform-specific new line endings.
*/
@Converter
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/converters/Uuid2String.java b/models-dao/src/main/java/org/onap/policy/models/dao/converters/Uuid2String.java
index a2b1c085a..369b5a19d 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/converters/Uuid2String.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/converters/Uuid2String.java
@@ -27,7 +27,9 @@ import javax.persistence.Converter;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
- * The Class UUIDConverter converts a UUID to and from database format.
+ * The Class UuidConverter converts a UUID to and from database format.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
*/
@Converter
public class Uuid2String extends XmlAdapter<String, UUID> implements AttributeConverter<UUID, String> {
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/converters/package-info.java b/models-dao/src/main/java/org/onap/policy/models/dao/converters/package-info.java
index 416eff20c..184f59b0e 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/converters/package-info.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/converters/package-info.java
@@ -21,6 +21,8 @@
/**
* Contains converters used by PF EclipseLink marshaling and unmarshaling of
* {@link org.onap.policy.models.base.PfConcept} instances to and from files and databases.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
*/
package org.onap.policy.models.dao.converters;
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
index 429632db0..947b866a1 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
@@ -27,6 +27,7 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
+import javax.ws.rs.core.Response;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfConceptKey;
@@ -61,7 +62,8 @@ public class DefaultPfDao implements PfDao {
public void init(final DaoParameters daoParameters) throws PfModelException {
if (daoParameters == null || daoParameters.getPersistenceUnit() == null) {
LOGGER.error("Policy Framework persistence unit parameter not set");
- throw new PfModelException("Policy Framework persistence unit parameter not set");
+ throw new PfModelException(Response.Status.INTERNAL_SERVER_ERROR,
+ "Policy Framework persistence unit parameter not set");
}
LOGGER.debug("Creating Policy Framework persistence unit \"{}\" . . .", daoParameters.getPersistenceUnit());
@@ -72,7 +74,7 @@ public class DefaultPfDao implements PfDao {
String errorMessage = "Creation of Policy Framework persistence unit \""
+ daoParameters.getPersistenceUnit() + "\" failed";
LOGGER.warn(errorMessage, ex);
- throw new PfModelException(errorMessage, ex);
+ throw new PfModelException(Response.Status.INTERNAL_SERVER_ERROR, errorMessage, ex);
}
LOGGER.debug("Created Policy Framework persistence unit \"{}\"", daoParameters.getPersistenceUnit());
}
@@ -85,7 +87,8 @@ public class DefaultPfDao implements PfDao {
protected final synchronized EntityManager getEntityManager() {
if (emf == null) {
LOGGER.warn("Policy Framework DAO has not been initialized");
- throw new PfModelRuntimeException("Policy Framework DAO has not been initialized");
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
+ "Policy Framework DAO has not been initialized");
}
return emf.createEntityManager();
@@ -196,8 +199,7 @@ public class DefaultPfDao implements PfDao {
}
@Override
- public <T extends PfConcept> int deleteByConceptKey(final Class<T> someClass,
- final Collection<PfConceptKey> keys) {
+ public <T extends PfConcept> int deleteByConceptKey(final Class<T> someClass, final Collection<PfConceptKey> keys) {
if (keys == null || keys.isEmpty()) {
return 0;
}
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/package-info.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/package-info.java
index 0d27628a0..f62116639 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/package-info.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/package-info.java
@@ -21,5 +21,7 @@
/**
* Contains a default DAO implementation for the PF {@link org.onap.policy.models.base.PfConcept}
* classes that uses javax persistence.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
*/
package org.onap.policy.models.dao.impl;
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/package-info.java b/models-dao/src/main/java/org/onap/policy/models/dao/package-info.java
index e8cfbe4e7..c4cb6a265 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/package-info.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/package-info.java
@@ -19,9 +19,11 @@
*/
/**
- * Defines and implements the Data Access Object (DAO) that allows Apex
- * {@link org.onap.policy.apex.model.basicmodel.concepts.AxConcept} concepts to be read from and written to databases
+ * Defines and implements the Data Access Object (DAO) that allows Policy Framework
+ * {@link org.onap.policy.models.base.pfConcept} concepts to be read from and written to databases
* over JDBC.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
*/
package org.onap.policy.models.dao;