summaryrefslogtreecommitdiffstats
path: root/models-dao/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'models-dao/src/main/java/org')
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java34
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java60
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/ProxyDao.java49
3 files changed, 3 insertions, 140 deletions
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java
index 7358ab11b..380a9831e 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,12 +22,10 @@
package org.onap.policy.models.dao;
-import java.time.Instant;
import java.util.Collection;
import java.util.List;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfGeneratedIdKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfReferenceKey;
import org.onap.policy.models.base.PfReferenceTimestampKey;
@@ -95,15 +94,6 @@ public interface PfDao {
<T extends PfConcept> void delete(Class<T> someClass, PfTimestampKey timeStampKey);
/**
- * Delete an Policy Framework concept on the database.
- *
- * @param <T> the type of the object to delete, a subclass of {@link PfConcept}
- * @param someClass the class of the object to delete, a subclass of {@link PfConcept}
- * @param idKey the PfConceptIdKey of the object to delete
- */
- <T extends PfConcept> void delete(Class<T> someClass, PfGeneratedIdKey idKey);
-
- /**
* Create a collection of objects in the database.
*
* @param <T> the type of the object to create, a subclass of {@link PfConcept}
@@ -203,16 +193,6 @@ public interface PfDao {
<T extends PfConcept> T get(Class<T> someClass, PfTimestampKey timestampKey);
/**
- * Get an object from the database, referred to by reference key.
- *
- * @param <T> the type of the object to get, a subclass of {@link PfConcept}
- * @param someClass the class of the object to get, a subclass of {@link PfConcept}
- * @param idKey the PfConceptIdKey of the object to get
- * @return the object that was retrieved from the database or null if the object was not retrieved
- */
- <T extends PfConcept> T get(Class<T> someClass, PfGeneratedIdKey idKey);
-
- /**
* Get an object from the database, referred to by reference timestamp key.
*
* @param <T> the type of the object to get, a subclass of {@link PfConcept}
@@ -273,18 +253,6 @@ public interface PfDao {
<T extends PfConcept> List<T> getAllVersionsByParent(Class<T> someClass, final String parentKeyName);
/**
- * Get all the objects in the database of a given type.
- *
- * @param <T> the type of the objects to get, a subclass of {@link PfConcept}
- * @param someClass the class of the objects to get, a subclass of {@link PfConcept}
- * @param key the key of the PfGeneratedIdKey to get
- * @param timeStamp the timeStamp of the concepts to get
- * @return the objects or null if no objects were retrieved
- */
- <T extends PfConcept> List<T> getByTimestamp(final Class<T> someClass,
- final PfGeneratedIdKey key, final Instant timeStamp);
-
- /**
* Get a concept from the database with the given concept key.
*
* @param <T> the type of the object to get, a subclass of {@link PfConcept}
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 1b1b77da2..22c5c5397 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +22,6 @@
package org.onap.policy.models.dao.impl;
-import java.sql.Timestamp;
-import java.time.Instant;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -34,7 +33,6 @@ import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfGeneratedIdKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.base.PfReferenceKey;
@@ -60,7 +58,6 @@ public class DefaultPfDao implements PfDao {
private static final String NAME = "name";
private static final String VERSION = "version";
private static final String TIMESTAMP = "timeStamp";
- private static final String GENERATEDID = "Id";
private static final String PARENT_NAME = "parentname";
private static final String PARENT_VERSION = "parentversion";
private static final String LOCAL_NAME = "localname";
@@ -78,8 +75,6 @@ public class DefaultPfDao implements PfDao {
private static final String NAME_FILTER = "c.key.name = :name";
private static final String VERSION_FILTER = "c.key.version = :version";
private static final String TIMESTAMP_FILTER = "c.key.timeStamp = :timeStamp";
- private static final String TIMESTAMP_FILTER_NOKEY = "c.timeStamp = :timeStamp";
- private static final String GENERATED_ID_FILTER = "c.key.generatedId = :Id";
private static final String PARENT_NAME_FILTER = "c.key.parentKeyName = :parentname";
private static final String PARENT_VERSION_FILTER = "c.key.parentKeyVersion = :parentversion";
private static final String LOCAL_NAME_FILTER = "c.key.localName = :localname";
@@ -92,9 +87,6 @@ public class DefaultPfDao implements PfDao {
private static final String DELETE_BY_TIMESTAMP_KEY =
DELETE_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + TIMESTAMP_FILTER;
- private static final String DELETE_BY_GENERATED_ID_KEY =
- DELETE_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + GENERATED_ID_FILTER;
-
private static final String DELETE_BY_REFERENCE_KEY =
DELETE_FROM_TABLE + WHERE + PARENT_NAME_FILTER + AND + PARENT_VERSION_FILTER + AND + LOCAL_NAME_FILTER;
@@ -109,9 +101,6 @@ public class DefaultPfDao implements PfDao {
private static final String SELECT_BY_CONCEPT_KEY =
SELECT_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER;
- private static final String SELECT_BY_TIMESTAMP_NOKEY =
- SELECT_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + TIMESTAMP_FILTER_NOKEY;
-
private static final String SELECT_BY_REFERENCE_KEY =
SELECT_FROM_TABLE + WHERE + PARENT_NAME_FILTER + AND + PARENT_VERSION_FILTER + AND + LOCAL_NAME_FILTER;
// @formatter:on
@@ -255,27 +244,6 @@ public class DefaultPfDao implements PfDao {
}
@Override
- public <T extends PfConcept> void delete(final Class<T> someClass, final PfGeneratedIdKey key) {
- if (key == null) {
- return;
- }
- final var mg = getEntityManager();
- try {
- // @formatter:off
- mg.getTransaction().begin();
- mg.createQuery(setQueryTable(DELETE_BY_GENERATED_ID_KEY, someClass), someClass)
- .setParameter(NAME, key.getName())
- .setParameter(VERSION, key.getVersion())
- .setParameter(GENERATEDID, key.getGeneratedId())
- .executeUpdate();
- mg.getTransaction().commit();
- // @formatter:on
- } finally {
- mg.close();
- }
- }
-
- @Override
public <T extends PfConcept> void createCollection(final Collection<T> objs) {
if (objs == null || objs.isEmpty()) {
return;
@@ -418,11 +386,6 @@ public class DefaultPfDao implements PfDao {
}
@Override
- public <T extends PfConcept> T get(final Class<T> someClass, final PfGeneratedIdKey key) {
- return genericGet(someClass, key);
- }
-
- @Override
public <T extends PfConcept> T get(final Class<T> someClass, final PfTimestampKey key) {
return genericGet(someClass, key);
}
@@ -535,27 +498,6 @@ public class DefaultPfDao implements PfDao {
}
@Override
- public <T extends PfConcept> List<T> getByTimestamp(final Class<T> someClass, final PfGeneratedIdKey key,
- final Instant timeStamp) {
- if (someClass == null || key == null || timeStamp == null) {
- return Collections.emptyList();
- }
-
- final var mg = getEntityManager();
- try {
- // @formatter:off
- return mg.createQuery(setQueryTable(SELECT_BY_TIMESTAMP_NOKEY, someClass), someClass)
- .setParameter(NAME, key.getName())
- .setParameter(VERSION, key.getVersion())
- .setParameter(TIMESTAMP, Timestamp.from(timeStamp))
- .getResultList();
- // @formatter:on
- } finally {
- mg.close();
- }
- }
-
- @Override
public <T extends PfConcept> T getConcept(final Class<T> someClass, final PfConceptKey key) {
if (someClass == null || key == null) {
return null;
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/ProxyDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/ProxyDao.java
index 72d56834d..d0681e1e4 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/ProxyDao.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/ProxyDao.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +21,6 @@
package org.onap.policy.models.dao.impl;
-import java.sql.Timestamp;
-import java.time.Instant;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -32,7 +31,6 @@ import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfGeneratedIdKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfReferenceKey;
import org.onap.policy.models.base.PfReferenceTimestampKey;
@@ -58,7 +56,6 @@ public class ProxyDao implements PfDao {
private static final String NAME = "name";
private static final String VERSION = "version";
private static final String TIMESTAMP = "timeStamp";
- private static final String GENERATEDID = "Id";
private static final String PARENT_NAME = "parentname";
private static final String PARENT_VERSION = "parentversion";
private static final String LOCAL_NAME = "localname";
@@ -76,8 +73,6 @@ public class ProxyDao implements PfDao {
private static final String NAME_FILTER = "c.key.name = :name";
private static final String VERSION_FILTER = "c.key.version = :version";
private static final String TIMESTAMP_FILTER = "c.key.timeStamp = :timeStamp";
- private static final String TIMESTAMP_FILTER_NOKEY = "c.timeStamp = :timeStamp";
- private static final String GENERATED_ID_FILTER = "c.key.generatedId = :Id";
private static final String PARENT_NAME_FILTER = "c.key.parentKeyName = :parentname";
private static final String PARENT_VERSION_FILTER = "c.key.parentKeyVersion = :parentversion";
private static final String LOCAL_NAME_FILTER = "c.key.localName = :localname";
@@ -90,9 +85,6 @@ public class ProxyDao implements PfDao {
private static final String DELETE_BY_TIMESTAMP_KEY =
DELETE_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + TIMESTAMP_FILTER;
- private static final String DELETE_BY_GENERATED_ID_KEY =
- DELETE_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + GENERATED_ID_FILTER;
-
private static final String DELETE_BY_REFERENCE_KEY =
DELETE_FROM_TABLE + WHERE + PARENT_NAME_FILTER + AND + PARENT_VERSION_FILTER + AND + LOCAL_NAME_FILTER;
@@ -107,9 +99,6 @@ public class ProxyDao implements PfDao {
private static final String SELECT_BY_CONCEPT_KEY =
SELECT_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER;
- private static final String SELECT_BY_TIMESTAMP_NOKEY =
- SELECT_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + TIMESTAMP_FILTER_NOKEY;
-
private static final String SELECT_BY_REFERENCE_KEY =
SELECT_FROM_TABLE + WHERE + PARENT_NAME_FILTER + AND + PARENT_VERSION_FILTER + AND + LOCAL_NAME_FILTER;
// @formatter:on
@@ -187,21 +176,6 @@ public class ProxyDao implements PfDao {
}
@Override
- public <T extends PfConcept> void delete(final Class<T> someClass, final PfGeneratedIdKey key) {
- if (key == null) {
- return;
- }
-
- // @formatter:off
- mg.createQuery(setQueryTable(DELETE_BY_GENERATED_ID_KEY, someClass), someClass)
- .setParameter(NAME, key.getName())
- .setParameter(VERSION, key.getVersion())
- .setParameter(GENERATEDID, key.getGeneratedId())
- .executeUpdate();
- // @formatter:on
- }
-
- @Override
public <T extends PfConcept> void createCollection(final Collection<T> objs) {
if (objs == null || objs.isEmpty()) {
return;
@@ -308,11 +282,6 @@ public class ProxyDao implements PfDao {
}
@Override
- public <T extends PfConcept> T get(final Class<T> someClass, final PfGeneratedIdKey key) {
- return genericGet(someClass, key);
- }
-
- @Override
public <T extends PfConcept> T get(final Class<T> someClass, final PfTimestampKey key) {
return genericGet(someClass, key);
}
@@ -397,22 +366,6 @@ public class ProxyDao implements PfDao {
}
@Override
- public <T extends PfConcept> List<T> getByTimestamp(final Class<T> someClass, final PfGeneratedIdKey key,
- final Instant timeStamp) {
- if (someClass == null || key == null || timeStamp == null) {
- return Collections.emptyList();
- }
-
- // @formatter:off
- return mg.createQuery(setQueryTable(SELECT_BY_TIMESTAMP_NOKEY, someClass), someClass)
- .setParameter(NAME, key.getName())
- .setParameter(VERSION, key.getVersion())
- .setParameter(TIMESTAMP, Timestamp.from(timeStamp))
- .getResultList();
- // @formatter:on
- }
-
- @Override
public <T extends PfConcept> T getConcept(final Class<T> someClass, final PfConceptKey key) {
if (someClass == null || key == null) {
return null;