/*-
* ============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.
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 to and from databases using JDBC.
+ * The Interface PfDao describes the DAO interface for reading and writing Policy Framework {@link PfConcept} concepts
+ * to and from databases using JDBC.
*/
public interface PfDao {
*/
<T extends PfConcept> void delete(Class<T> someClass, PfReferenceKey key);
+ /**
+ * 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 timeStampKey the PfTimestampKey of the object to delete
+ */
+ <T extends PfConcept> void delete(Class<T> someClass, PfTimestampKey timeStampKey);
+
/**
* Create a collection of objects in the database.
*
*/
<T extends PfConcept> void deleteAll(Class<T> someClass);
+ /**
+ * Get an object from the database, referred to by concept 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}, 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
+ * @return the objects that was retrieved from the database
+ */
+ <T extends PfConcept> List<T> getFiltered(Class<T> someClass, String name, String version);
+
+ /**
+ * Get an object from the database, referred to by concept 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}, 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
+ */
+ <T extends PfConcept> List<T> getFiltered(Class<T> someClass, String name, String version, Instant startTime,
+ Instant endTime, Map<String, Object> filterMap, String sortOrder, int getRecordNum);
+
/**
* Get an object from the database, referred to by concept 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 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 extends PfConcept> T get(Class<T> someClass, PfConceptKey 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 key the key of the object to get
- * @return the object that was retrieved from the database or null if the object was not
- * retrieved
+ * @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 extends PfConcept> T get(Class<T> someClass, PfReferenceKey key);
+ /**
+ * 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 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 extends PfConcept> T get(Class<T> someClass, PfTimestampKey timestampKey);
+
+ /**
+ * 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}
+ * @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 extends PfConcept> T get(Class<T> someClass, PfReferenceTimestampKey key);
+
/**
* Get all the objects in the database of a given type.
*
*/
<T extends PfConcept> List<T> getAll(Class<T> someClass, PfConceptKey parentKey);
+ /**
+ * 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 name the name of the concepts for which to get all versions
+ * @return the objects or null if no objects were retrieved
+ */
+ <T extends PfConcept> List<T> getAllVersions(Class<T> someClass, final String name);
+
+ /**
+ * 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 parentKeyName the name of the concepts for which to get all versions
+ * @return the objects or null if no objects were retrieved
+ */
+ <T extends PfConcept> List<T> getAllVersionsByParent(Class<T> someClass, final String parentKeyName);
+
/**
* Get a concept from the database with the given concept key.
*
/**
* Update a concept in the database.
*
- * @param <T> the type of the object to get, a subclass of {@link PfConcept}
+ * @param <T> the type of the object to update, a subclass of {@link PfConcept}
* @param obj the object to update
* @return the updated object
*/