1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.persistence.dao.common;
|
11
|
|
12
|
import java.util.List;
|
13
|
|
14
|
import org.hibernate.envers.query.criteria.AuditCriterion;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
17
|
import eu.etaxonomy.cdm.model.view.AuditEvent;
|
18
|
import eu.etaxonomy.cdm.model.view.AuditEventRecord;
|
19
|
|
20
|
public interface IVersionableDao<T extends VersionableEntity> extends ICdmEntityDao<T> {
|
21
|
|
22
|
/**
|
23
|
* Returns a list of audit events (in order) which affected the state of an entity t.
|
24
|
* The events returned either start at the AuditEvent in context and go forward in time
|
25
|
* (AuditEventSort.FORWARDS) or backwards in time (AuditEventSort.BACKWARDS). If the
|
26
|
* AuditEventContext is set to null, or to AuditEvent.CURRENT_VIEW, then all relevant
|
27
|
* AuditEvents are returned.
|
28
|
*
|
29
|
* @param t The versionable entity which was affected by the audit events
|
30
|
* @param pageSize The maximum number of audit event records returned (can be null for all audit event records)
|
31
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
32
|
* @param sort should the list be sorted going forward in time (AuditEventSort.FORWARDS) or backwards (AuditEventSort.BACKWARDS)
|
33
|
* @param propertyPaths paths initialized on the returned audited objects
|
34
|
* @return a list of AuditEventRecords, containing the AuditEvent, the state of the entity at that event, and the type of modification
|
35
|
*/
|
36
|
public List<AuditEventRecord<T>> getAuditEvents(T t, Integer pageSize, Integer pageNumber, AuditEventSort sort, List<String> propertyPaths);
|
37
|
|
38
|
/**
|
39
|
* Returns a count of audit events which affected the state of an entity t.
|
40
|
* The events either start at the AuditEvent in context and go forward in time
|
41
|
* (AuditEventSort.FORWARDS) or backwards in time (AuditEventSort.BACKWARDS). If the
|
42
|
* AuditEventContext is set to null, or to AuditEvent.CURRENT_VIEW, then all relevant
|
43
|
* AuditEvents are considered.
|
44
|
*
|
45
|
* @param t The versionable entity which was affected by the audit events
|
46
|
* @param sort should the events considered start now and go forward in time (AuditEventSort.FORWARDS) or backwards (AuditEventSort.BACKWARDS)
|
47
|
* @return a count of audit events
|
48
|
*/
|
49
|
public long countAuditEvents(T t, AuditEventSort sort);
|
50
|
|
51
|
/**
|
52
|
* A convenience method which returns a record of the next (relative to the audit event in context)
|
53
|
* audit event to affect the entity t.
|
54
|
*
|
55
|
* @param t The versionable entity affected by these audit events
|
56
|
* @return a record of the next audit event to affect t, or null if the current event is the last to affect t
|
57
|
*/
|
58
|
public AuditEventRecord<T> getNextAuditEvent(T t);
|
59
|
|
60
|
/**
|
61
|
* A convenience method which returns a record of the previous (relative to the audit event in context)
|
62
|
* audit event to affect the entity t.
|
63
|
*
|
64
|
* @param t The versionable entity affected by these audit events
|
65
|
* @return a record of the previous audit event to affect t, or null if the current event is the first to affect t
|
66
|
*/
|
67
|
public AuditEventRecord<T> getPreviousAuditEvent(T t);
|
68
|
|
69
|
/**
|
70
|
* Returns a count of the total number of audit events affecting objects of class T, optionally restricted to objects of
|
71
|
* class clazz, the AuditEvents from and to, inclusive, optionally filtered by other criteria
|
72
|
*
|
73
|
* @param clazz Restrict the results returned to objects of this class
|
74
|
* @param from The audit event to start from (or pass null to start from the beginning of the recordset)
|
75
|
* @param to The audit event to continue until (or pass null to return audit events up to the time of the query)
|
76
|
* @param criteria Extra criteria to filter by
|
77
|
* @return the count of audit events
|
78
|
*/
|
79
|
public long countAuditEvents(Class<? extends T> clazz,AuditEvent from,AuditEvent to,List<AuditCriterion> criteria);
|
80
|
|
81
|
/**
|
82
|
* Returns a list of all audit events occurring to objects of type T, optionally restricted to objects of type clazz
|
83
|
* between the AuditEvents from and to, inclusive, optionally filtered by other criteria
|
84
|
*
|
85
|
* @param clazz Restrict the results returned to objects of this class
|
86
|
* @param from The audit event to start from (inclusive, or pass null to start from the beginning of the recordset)
|
87
|
* @param to The audit event to continue until (exclusive, or pass null to return audit events up to the time of the query)
|
88
|
* @param criteria Extra criteria to filter by
|
89
|
* @param pageSize The maximum number of objects returned (can be null for all matching objects)
|
90
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based,
|
91
|
* can be null, equivalent of starting at the beginning of the recordset)
|
92
|
* @param sort Sort the events either forwards or backwards in time
|
93
|
* @param propertyPaths properties to be initialized
|
94
|
* @return
|
95
|
*/
|
96
|
public List<AuditEventRecord<T>> getAuditEvents(Class<? extends T> clazz, AuditEvent from,AuditEvent to,List<AuditCriterion> criteria, Integer pageSize, Integer pageNumber,AuditEventSort sort,List<String> propertyPaths);
|
97
|
}
|