summaryrefslogtreecommitdiffstats
path: root/models-dao/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-02-11 16:18:32 +0000
committerliamfallon <liam.fallon@est.tech>2020-02-12 13:13:50 +0000
commit88bcb550c2efd5e43ad3d256fe075a6bf7e90538 (patch)
treee670f0f0c4cd77e3648aa7387525d6b2bdd94fec /models-dao/src
parentfd79f7920d454c35d6a8c02d430d9beba434dcc2 (diff)
Implement validation and hierarchical get
NOTE: This review will require changes to the persistence.xml file in other policy framework components. This change brings in two changes: 1) Validation of the references betwen policies, policy types, and data types This change mans that additions to and changes to policies, policy types, and data types must be structurally correct in the change coming in and with whatever is already in the database 2) Hierarchical return of referenced entitites on policy types, policies and data types. When a policy, policy type, or data type is read from the database, the entities referenced byt the returned policy, policy type, or data type are returned as well. Tests are amended for the stricter validation and structure. Examples are corrected where they are incorrect. Issue-ID: POLICY-1402 Change-Id: Ie6a4cb7ed336562338924079114df405f0ab889f Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-dao/src')
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java11
1 files changed, 11 insertions, 0 deletions
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 b3d72a3fd..6707e70a2 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
@@ -26,11 +26,13 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
+
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import javax.ws.rs.core.Response;
+
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
@@ -411,6 +413,9 @@ public class DefaultPfDao implements PfDao {
final EntityManager mg = getEntityManager();
try {
final T t = mg.find(someClass, key);
+ if (t != null) {
+ mg.refresh(t);
+ }
return checkAndReturn(someClass, t);
} finally {
mg.close();
@@ -425,6 +430,9 @@ public class DefaultPfDao implements PfDao {
final EntityManager mg = getEntityManager();
try {
final T t = mg.find(someClass, key);
+ if (t != null) {
+ mg.refresh(t);
+ }
return checkAndReturn(someClass, t);
} finally {
mg.close();
@@ -439,6 +447,9 @@ public class DefaultPfDao implements PfDao {
final EntityManager mg = getEntityManager();
try {
final T t = mg.find(someClass, key);
+ if (t != null) {
+ mg.refresh(t);
+ }
return checkAndReturn(someClass, t);
} finally {
mg.close();