X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-dao%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Fdao%2FPfDao.java;h=eb77be9c0e97be3eda59472ac0328ce19af04c43;hb=fcbf3698fa3e3fbc6ea3364d80d4a3f3a8d37650;hp=609afefd429131202e1dca40eea3ff3034f826fe;hpb=162cb586fe139460dd3d0404274e85b3f4ead15b;p=policy%2Fmodels.git 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 609afefd4..eb77be9c0 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 @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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,13 +21,16 @@ package org.onap.policy.models.dao; +import java.time.Instant; import java.util.Collection; import java.util.List; - +import java.util.Map; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfReferenceKey; +import org.onap.policy.models.base.PfReferenceTimestampKey; +import org.onap.policy.models.base.PfTimestampKey; /** * The Interface PfDao describes the DAO interface for reading and writing Policy Framework {@link PfConcept} concepts @@ -81,6 +85,15 @@ public interface PfDao { */ void delete(Class someClass, PfReferenceKey key); + /** + * Delete an Policy Framework concept on the database. + * + * @param 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 timeStampKey the PfTimestampKey of the object to delete + */ + void delete(Class someClass, PfTimestampKey timeStampKey); + /** * Create a collection of objects in the database. * @@ -108,7 +121,7 @@ public interface PfDao { int deleteByConceptKey(Class someClass, Collection keys); /** - * policypolicypolicy Delete a collection of objects in the database referred to by reference key. + * Delete a collection of objects in the database referred to by reference key. * * @param the type of the objects to delete, a subclass of {@link PfConcept} * @param someClass the class of the objects to delete, a subclass of {@link PfConcept} @@ -132,17 +145,39 @@ public interface PfDao { * @param someClass the class of the object to get, a subclass of {@link PfConcept}, if name is null, all concepts * of type T are returned, if name is not null and version is null, all versions of that concept matching the * name are returned. - * @param key the key of the object to get + * @param name the name of the object to get, null returns all objects + * @param version the version the object to get, null returns all objects for a specified name * @return the objects that was retrieved from the database */ - List getFiltered(Class someClass, PfConceptKey key); + List getFiltered(Class someClass, String name, String version); + + /** + * Get an object from the database, referred to by concept key. + * + * @param 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}, if name is null, all concepts + * of type T are returned, if name is not null and version is null, all versions of that concept matching the + * name are returned. + * @param name the name of the object to get, null returns all objects + * @param version the version the object to get, null returns all objects for a specified name + * @param startTime the start timeStamp to filter from database, filter rule: startTime <= filteredRecord timeStamp + * <= endTime. null for ignore start time. + * @param endTime the end timeStamp to filter from database, filter rule: startTime <= filteredRecord timeStamp <= + * endTime. null for ignore end time + * @param filterMap Map store extra key/value used to filter from database, can be null. + * @param sortOrder sortOrder to query database + * @param getRecordNum Total query count from database + * @return the objects that was retrieved from the database + */ + List getFiltered(Class someClass, String name, String version, Instant startTime, + Instant endTime, Map filterMap, String sortOrder, int getRecordNum); /** * Get an object from the database, referred to by concept key. * * @param 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 key the key of the object to get + * @param key the PfConceptKey of the object to get * @return the object that was retrieved from the database */ T get(Class someClass, PfConceptKey key); @@ -152,11 +187,31 @@ public interface PfDao { * * @param 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 key the key of the object to get + * @param key the PfReferenceKey of the object to get * @return the object that was retrieved from the database or null if the object was not retrieved */ T get(Class someClass, PfReferenceKey key); + /** + * Get an object from the database, referred to by reference key. + * + * @param 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 timestampKey the PfTimestampKey of the object to get + * @return the object that was retrieved from the database or null if the object was not retrieved + */ + T get(Class someClass, PfTimestampKey timestampKey); + + /** + * Get an object from the database, referred to by reference timestamp key. + * + * @param 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 key the PfReferenceTimestampKey of the object to get + * @return the object that was retrieved from the database or null if the object was not retrieved + */ + T get(Class someClass, PfReferenceTimestampKey key); + /** * Get all the objects in the database of a given type. * @@ -187,23 +242,14 @@ public interface PfDao { List getAllVersions(Class someClass, final String name); /** - * Get latest version of objects in the database of a given type. - * - * @param 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} - * @return the objects or null if no objects were retrieved - */ - List getLatestVersions(Class someClass); - - /** - * Get latest version of an object in the database of a given type. + * Get all the objects in the database of a given type. * * @param 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 conceptName the name of the concept for which to get the latest version + * @param parentKeyName the name of the concepts for which to get all versions * @return the objects or null if no objects were retrieved */ - T getLatestVersion(Class someClass, final String conceptName); + List getAllVersionsByParent(Class someClass, final String parentKeyName); /** * Get a concept from the database with the given concept key.