mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-03 03:36:49 +00:00
Some changes to pull back on the generics
This commit is contained in:
parent
364347b7bb
commit
ebc903c78c
@ -42,7 +42,7 @@ import static org.hibernate.criterion.Restrictions.sqlRestriction;
|
|||||||
*
|
*
|
||||||
* @param <T> type of objects to manage by this manager
|
* @param <T> type of objects to manage by this manager
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractDbManager<T> implements CrudManager<ArchivableEntity> {
|
public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(AbstractDbManager.class);
|
private static final Logger LOGGER = LogManager.getLogger(AbstractDbManager.class);
|
||||||
private static final int MAX_CLASS_CACHE_ENTRIES = 500;
|
private static final int MAX_CLASS_CACHE_ENTRIES = 500;
|
||||||
|
@ -10,14 +10,13 @@ import java.util.List;
|
|||||||
* Interface defining database CRUD operations (Create, Read, Update, Delete).
|
* Interface defining database CRUD operations (Create, Read, Update, Delete).
|
||||||
* @param <T> the object type, T.
|
* @param <T> the object type, T.
|
||||||
*/
|
*/
|
||||||
public interface CrudManager<T> extends OrderedListQuerier<T> {
|
public interface CrudManager<T extends Serializable> extends OrderedListQuerier<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all instances of the associated class.
|
|
||||||
*
|
*
|
||||||
* @return the number of entities deleted
|
* @param classToSet
|
||||||
*/
|
*/
|
||||||
int deleteAll();
|
void setClazz(Class<T> classToSet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the <code>Object</code> in the database. If the <code>Object</code> had
|
* Saves the <code>Object</code> in the database. If the <code>Object</code> had
|
||||||
@ -51,23 +50,6 @@ public interface CrudManager<T> extends OrderedListQuerier<T> {
|
|||||||
*/
|
*/
|
||||||
AbstractEntity get(String name) throws DBManagerException;
|
AbstractEntity get(String name) throws DBManagerException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the <code>Object</code> from the database. This searches the
|
|
||||||
* database for an entry whose name matches <code>name</code>. It then
|
|
||||||
* reconstructs the <code>Object</code> from the database entry. It will also
|
|
||||||
* load all the lazy fields in the given class. If the parameter <code>recurse</code>
|
|
||||||
* is set to true, this method will recursively descend into each of the object's fields
|
|
||||||
* to load all the lazily-loaded entities. If false, only the fields belonging to the object
|
|
||||||
* itself will be loaded.
|
|
||||||
*
|
|
||||||
* @param name name of the object
|
|
||||||
* @param recurse whether to recursively load lazy data throughout the object's structures
|
|
||||||
* @return object if found, otherwise null.
|
|
||||||
* @throws DBManagerException if unable to search the database or recreate
|
|
||||||
* the <code>Object</code>
|
|
||||||
*/
|
|
||||||
AbstractEntity getAndLoadLazyFields(String name, boolean recurse)
|
|
||||||
throws DBManagerException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the <code>Object</code> from the database. This searches the
|
* Retrieves the <code>Object</code> from the database. This searches the
|
||||||
@ -81,39 +63,20 @@ public interface CrudManager<T> extends OrderedListQuerier<T> {
|
|||||||
*/
|
*/
|
||||||
T get(Serializable id) throws DBManagerException;
|
T get(Serializable id) throws DBManagerException;
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Retrieves the <code>Object</code> from the database. This searches the
|
/**
|
||||||
// * database for an entry whose id matches <code>id</code>. It then
|
* Returns a list of all <code>T</code>s of type <code>clazz</code> in the database, with no
|
||||||
// * reconstructs the <code>Object</code> from the database entry. It will also
|
* additional restrictions.
|
||||||
// * load all the lazy fields in the given class. If the parameter <code>recurse</code>
|
* <p>
|
||||||
// * is set to true, this method will recursively descend into each of the object's fields
|
* This would be useful if <code>T</code> has several subclasses being
|
||||||
// * to load all the lazily-loaded entities. If false, only the fields belonging to the object
|
* managed. This class argument allows the caller to limit which types of
|
||||||
// * itself will be loaded.
|
* <code>T</code> should be returned.
|
||||||
// *
|
*
|
||||||
// * @param id id of the object
|
* @return list of <code>T</code> names
|
||||||
// * @param recurse whether to recursively load lazy data throughout the object's structures
|
* @throws DBManagerException if unable to search the database
|
||||||
// * @return object if found, otherwise null.
|
*/
|
||||||
// * @throws DBManagerException if unable to search the database or recreate
|
List<T> getList()
|
||||||
// * the <code>Object</code>
|
throws DBManagerException;
|
||||||
// */
|
|
||||||
// AbstractEntity getAndLoadLazyFields(Serializable id, boolean recurse)
|
|
||||||
// throws DBManagerException;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Returns a list of all <code>T</code>s of type <code>clazz</code> in the database, with no
|
|
||||||
// * additional restrictions.
|
|
||||||
// * <p>
|
|
||||||
// * This would be useful if <code>T</code> has several subclasses being
|
|
||||||
// * managed. This class argument allows the caller to limit which types of
|
|
||||||
// * <code>T</code> should be returned.
|
|
||||||
// *
|
|
||||||
// * @param AbstractEntity class type of <code>T</code>s to search for (may be null to
|
|
||||||
// * use Class<T>)
|
|
||||||
// * @return list of <code>T</code> names
|
|
||||||
// * @throws DBManagerException if unable to search the database
|
|
||||||
// */
|
|
||||||
// List<AbstractEntity> getList(AbstractEntity entity)
|
|
||||||
// throws DBManagerException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all <code>T</code>s of type <code>clazz</code> in the database, with an
|
* Returns a list of all <code>T</code>s of type <code>clazz</code> in the database, with an
|
||||||
@ -123,29 +86,13 @@ public interface CrudManager<T> extends OrderedListQuerier<T> {
|
|||||||
* managed. This class argument allows the caller to limit which types of
|
* managed. This class argument allows the caller to limit which types of
|
||||||
* <code>T</code> should be returned.
|
* <code>T</code> should be returned.
|
||||||
*
|
*
|
||||||
* @param AbstractEntity class type of <code>T</code>s to search for (may be null to
|
|
||||||
* use Class<T>)
|
|
||||||
* @param additionalRestriction - an added Criterion to use in the query, null for none
|
* @param additionalRestriction - an added Criterion to use in the query, null for none
|
||||||
* @return list of <code>T</code> names
|
* @return list of <code>T</code> names
|
||||||
* @throws DBManagerException if unable to search the database
|
* @throws DBManagerException if unable to search the database
|
||||||
*/
|
*/
|
||||||
List<AbstractEntity> getList(AbstractEntity entity, Criterion additionalRestriction)
|
List<AbstractEntity> getList(Criterion additionalRestriction)
|
||||||
throws DBManagerException;
|
throws DBManagerException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the object from the database. This removes all of the database
|
|
||||||
* entries that stored information with regards to the this object.
|
|
||||||
* <p>
|
|
||||||
* If the object is referenced by any other tables then this will throw a
|
|
||||||
* <code>DBManagerException</code>.
|
|
||||||
*
|
|
||||||
* @param name name of the object to delete
|
|
||||||
* @return true if successfully found and deleted the object
|
|
||||||
* @throws DBManagerException if unable to find the baseline or delete it
|
|
||||||
* from the database
|
|
||||||
*/
|
|
||||||
boolean delete(String name) throws DBManagerException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the object from the database. This removes all of the database
|
* Deletes the object from the database. This removes all of the database
|
||||||
* entries that stored information with regards to the this object.
|
* entries that stored information with regards to the this object.
|
||||||
@ -158,7 +105,7 @@ public interface CrudManager<T> extends OrderedListQuerier<T> {
|
|||||||
* @throws DBManagerException if unable to find the baseline or delete it
|
* @throws DBManagerException if unable to find the baseline or delete it
|
||||||
* from the database
|
* from the database
|
||||||
*/
|
*/
|
||||||
boolean delete(Serializable id)
|
boolean deleteById(Serializable id)
|
||||||
throws DBManagerException;
|
throws DBManagerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,11 +115,18 @@ public interface CrudManager<T> extends OrderedListQuerier<T> {
|
|||||||
* If the object is referenced by any other tables then this will throw a
|
* If the object is referenced by any other tables then this will throw a
|
||||||
* <code>DBManagerException</code>.
|
* <code>DBManagerException</code>.
|
||||||
*
|
*
|
||||||
* @param object object to delete
|
* @param entity object to delete
|
||||||
* @return true if successfully found and deleted the object
|
* @return true if successfully found and deleted the object
|
||||||
* @throws DBManagerException if unable to delete the object from the database
|
* @throws DBManagerException if unable to delete the object from the database
|
||||||
*/
|
*/
|
||||||
boolean delete(AbstractEntity object) throws DBManagerException;
|
boolean delete(T entity) throws DBManagerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes all instances of the associated class.
|
||||||
|
*
|
||||||
|
* @return the number of entities deleted
|
||||||
|
*/
|
||||||
|
int deleteAll();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Archives the named object and updates it in the database.
|
* Archives the named object and updates it in the database.
|
||||||
|
@ -28,7 +28,7 @@ import java.util.Map;
|
|||||||
* archive, and delete operations for managing objects in a database.
|
* archive, and delete operations for managing objects in a database.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DBManager<T> extends AbstractDbManager<AbstractEntity> {
|
public class DBManager<T> extends AbstractDbManager<T> {
|
||||||
private static final Logger LOGGER = LogManager.getLogger(DBManager.class);
|
private static final Logger LOGGER = LogManager.getLogger(DBManager.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -442,7 +442,7 @@ public class DBManager<T> extends AbstractDbManager<AbstractEntity> {
|
|||||||
* @throws DBManagerException if unable to find the baseline or delete it
|
* @throws DBManagerException if unable to find the baseline or delete it
|
||||||
* from the database
|
* from the database
|
||||||
*/
|
*/
|
||||||
public final boolean delete(final Serializable id)
|
public final boolean deleteById(final Serializable id)
|
||||||
throws DBManagerException {
|
throws DBManagerException {
|
||||||
return retryTemplate.execute(new RetryCallback<Boolean, DBManagerException>() {
|
return retryTemplate.execute(new RetryCallback<Boolean, DBManagerException>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,16 +7,16 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* Interface defining methods for getting ordered lists from a data source. Includes
|
* Interface defining methods for getting ordered lists from a data source. Includes
|
||||||
* properties for sorting, paging, and searching.
|
* properties for sorting, paging, and searching.
|
||||||
* @param <AbstractEntity> the record type, AbstractEntity.
|
* @param <T> the record type, T.
|
||||||
*/
|
*/
|
||||||
public interface OrderedListQuerier<AbstractEntity> {
|
public interface OrderedListQuerier<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all <code>T</code>s that are ordered by a column and
|
* Returns a list of all <code>T</code>s that are ordered by a column and
|
||||||
* direction (ASC, DESC) that is provided by the user. This method helps
|
* direction (ASC, DESC) that is provided by the user. This method helps
|
||||||
* support the server-side processing in the JQuery DataTables.
|
* support the server-side processing in the JQuery DataTables.
|
||||||
*
|
*
|
||||||
* @param entity class type of <code>T</code>s to search for (may be null to
|
* @param clazz class type of <code>T</code>s to search for (may be null to
|
||||||
* use Class<T>)
|
* use Class<T>)
|
||||||
* @param columnToOrder Column to be ordered
|
* @param columnToOrder Column to be ordered
|
||||||
* @param ascending direction of sort
|
* @param ascending direction of sort
|
||||||
@ -30,7 +30,7 @@ public interface OrderedListQuerier<AbstractEntity> {
|
|||||||
* @throws DBManagerException if unable to create the list
|
* @throws DBManagerException if unable to create the list
|
||||||
*/
|
*/
|
||||||
FilteredRecordsList getOrderedList(
|
FilteredRecordsList getOrderedList(
|
||||||
AbstractEntity entity, String columnToOrder,
|
Class<? extends T> clazz, String columnToOrder,
|
||||||
boolean ascending, int firstResult,
|
boolean ascending, int firstResult,
|
||||||
int maxResults, String search,
|
int maxResults, String search,
|
||||||
Map<String, Boolean> searchableColumns)
|
Map<String, Boolean> searchableColumns)
|
||||||
@ -43,7 +43,7 @@ public interface OrderedListQuerier<AbstractEntity> {
|
|||||||
* support the server-side processing in the JQuery DataTables. For entities that support
|
* support the server-side processing in the JQuery DataTables. For entities that support
|
||||||
* soft-deletes, the returned list does not contain <code>T</code>s that have been soft-deleted.
|
* soft-deletes, the returned list does not contain <code>T</code>s that have been soft-deleted.
|
||||||
*
|
*
|
||||||
* @param entity class type of <code>T</code>s to search for (may be null to
|
* @param clazz class type of <code>T</code>s to search for (may be null to
|
||||||
* use Class<T>)
|
* use Class<T>)
|
||||||
* @param columnToOrder Column to be ordered
|
* @param columnToOrder Column to be ordered
|
||||||
* @param ascending direction of sort
|
* @param ascending direction of sort
|
||||||
@ -58,10 +58,10 @@ public interface OrderedListQuerier<AbstractEntity> {
|
|||||||
* @throws DBManagerException if unable to create the list
|
* @throws DBManagerException if unable to create the list
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("checkstyle:parameternumber")
|
@SuppressWarnings("checkstyle:parameternumber")
|
||||||
FilteredRecordsList<AbstractEntity> getOrderedList(
|
FilteredRecordsList<T> getOrderedList(
|
||||||
AbstractEntity entity, String columnToOrder,
|
Class<? extends T> clazz, String columnToOrder,
|
||||||
boolean ascending, int firstResult,
|
boolean ascending, int firstResult,
|
||||||
int maxResults, String search,
|
int maxResults, String search,
|
||||||
Map<String, Boolean> searchableColumns, CriteriaModifier criteriaModifier)
|
Map<String, Boolean> searchableColumns, CriteriaModifier criteriaModifier)
|
||||||
throws DBManagerException;
|
throws DBManagerException;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user