Package net.sf.basedb.core
Class ChangeHistory
- java.lang.Object
-
- net.sf.basedb.core.BasicItem
-
- net.sf.basedb.core.ChangeHistory
-
- All Implemented Interfaces:
AccessControlled
,Identifiable
public class ChangeHistory extends BasicItem
- Version:
- 2.13
- Author:
- Nicklas
- Last modified
- $Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
-
-
Field Summary
Fields Modifier and Type Field Description static Item
TYPE
The type of item represented by this class.private boolean
valuesPermissions
-
Constructor Summary
Constructors Constructor Description ChangeHistory(ChangeHistoryDetailData data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
deleteStrayEntries(ProgressReporter progress)
Delete all history entries that are linking to non-existing items.static ChangeHistory
getById(DbControl dc, int id)
Get aChangeHistory
item when you know the ID.String
getChangeInfo()
Get some additional free-text information about the change.static ItemQuery<ChangeHistory>
getChangesBy(Job job)
Get all changes made by the specified job.static ItemQuery<ChangeHistory>
getChangesBy(User user)
Get all changes made by the specified user.static ItemQuery<ChangeHistory>
getChangesIn(Session session)
Get all changes made in the specified session.ChangeType
getChangeType()
Get the type of change that was made.Client
getClient(DbControl dc)
Load the client application that was used when the change was made.Integer
getClientId()
Get the ID of the client application that was used to make the change.(package private) ChangeHistoryDetailData
getData()
Get theBasicData
object that holds all data for this item.static ItemQuery<ChangeHistory>
getHistoryOf(BasicItem item)
Get the history for a given item.BasicItem
getItem(DbControl dc)
Load the item that was changed.int
getItemId()
Get the ID of the item that was changed.Item
getItemType()
Get the type of the item that was changed.Job
getJob(DbControl dc)
Load the job that was executing when the change was made.Integer
getJobId()
Get the ID of the job that was executing when the change was madeString
getNewValue()
Get the new value of the property had immediately after this change.String
getOldValue()
Get the old value of the property had before this change.PluginDefinition
getPlugin(DbControl dc)
Load the plug-in that made the change.Integer
getPluginId()
Get the ID of the plug-in that was making the change.Project
getProject(DbControl dc)
Load the project that was active when the change was made.Integer
getProjectId()
Get the ID of the project that was active when the change was made.Session
getSession(DbControl dc)
Load the session in which the change was made.int
getSessionId()
Get the ID of the session in which the change was made.Date
getTime()
Get the date and time the change was made.Item
getType()
Get the type of item represented by the object.User
getUser(DbControl dc)
Load the user that made the change.int
getUserId()
Get the ID of the user that made the change.(package private) void
initPermissions(int granted, int denied)
WRITE permission and higher is always denied.-
Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
-
-
-
-
Field Detail
-
TYPE
public static final Item TYPE
The type of item represented by this class.- See Also:
Item.CHANGEHISTORY
,getType()
-
valuesPermissions
private boolean valuesPermissions
-
-
Constructor Detail
-
ChangeHistory
ChangeHistory(ChangeHistoryDetailData data)
-
-
Method Detail
-
getById
public static ChangeHistory getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
Get aChangeHistory
item when you know the ID.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.id
- The ID of the item to load- Returns:
- The
ChangeHistory
item - Throws:
ItemNotFoundException
- If an item with the specified ID is not foundPermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission to the itemBaseException
- If there is another error
-
getHistoryOf
public static ItemQuery<ChangeHistory> getHistoryOf(BasicItem item)
Get the history for a given item.- Parameters:
item
- The item to get the history for- Throws:
InvalidUseOfNullException
- If the item is null
-
getChangesBy
public static ItemQuery<ChangeHistory> getChangesBy(User user)
Get all changes made by the specified user.- Parameters:
user
- A user object- Throws:
InvalidUseOfNullException
- If the user is null
-
getChangesBy
public static ItemQuery<ChangeHistory> getChangesBy(Job job)
Get all changes made by the specified job.- Parameters:
job
- A job object- Throws:
InvalidUseOfNullException
- If the job is null
-
getChangesIn
public static ItemQuery<ChangeHistory> getChangesIn(Session session)
Get all changes made in the specified session.- Parameters:
session
- A session object- Throws:
InvalidUseOfNullException
- If the session is null
-
deleteStrayEntries
public static int deleteStrayEntries(ProgressReporter progress)
Delete all history entries that are linking to non-existing items. This method is intended to be executed at regular intervals by a cleanup application.- Parameters:
progress
- An optional progress reporter- Since:
- 2.13
-
getData
ChangeHistoryDetailData getData()
Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.
-
getType
public Item getType()
Description copied from interface:Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in theItem
enumeration.- Returns:
- A value indicating the type of item
-
initPermissions
void initPermissions(int granted, int denied) throws BaseException
WRITE permission and higher is always denied. READ permission is granted based on role permissions.- Overrides:
initPermissions
in classBasicItem
- Parameters:
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass- Throws:
BaseException
- If the permissions couldn't be initialised
-
getTime
public Date getTime()
Get the date and time the change was made.
-
getChangeType
public ChangeType getChangeType()
Get the type of change that was made.
-
getItemId
public int getItemId()
Get the ID of the item that was changed.
-
getItemType
public Item getItemType()
Get the type of the item that was changed.
-
getItem
public BasicItem getItem(DbControl dc)
Load the item that was changed.- Parameters:
dc
- A DbControl to use for database access, or null to use the same DbControl this history entry belongs to- Returns:
- A BasicItem
- Throws:
ItemNotFoundException
- If the item no longer exists in the databasePermissionDeniedException
- If the logged in user doesn't have permission to access the item
-
getChangeInfo
public String getChangeInfo()
Get some additional free-text information about the change.- Returns:
- A string, or null if no information is available
-
getOldValue
public String getOldValue()
Get the old value of the property had before this change.- Returns:
- The old value or null if not known or if the logged in user doesn't have permission to see it
- Since:
- 3.3
-
getNewValue
public String getNewValue()
Get the new value of the property had immediately after this change.- Returns:
- The new value or null if not known or if the logged in user doesn't have permission to see it
- Since:
- 3.3
-
getUserId
public int getUserId()
Get the ID of the user that made the change.
-
getUser
public User getUser(DbControl dc)
Load the user that made the change.- Parameters:
dc
- A DbControl to use for database access, or null to use the same DbControl this history entry belongs to- Throws:
ItemNotFoundException
- If the user no longer exists in the databasePermissionDeniedException
- If the logged in user doesn't have permission to access the other user
-
getSessionId
public int getSessionId()
Get the ID of the session in which the change was made.
-
getSession
public Session getSession(DbControl dc)
Load the session in which the change was made.- Parameters:
dc
- A DbControl to use for database access, or null to use the same DbControl this history entry belongs to- Throws:
ItemNotFoundException
- If the session no longer exists in the databasePermissionDeniedException
- If the logged in user doesn't have permission to access the session
-
getClientId
public Integer getClientId()
Get the ID of the client application that was used to make the change.- Returns:
- The ID or null if the client application is not known
-
getClient
public Client getClient(DbControl dc)
Load the client application that was used when the change was made.- Parameters:
dc
- A DbControl to use for database access, or null to use the same DbControl this history entry belongs to- Returns:
- A Client object or null if it is not known which client that was used
- Throws:
ItemNotFoundException
- If the client application no longer exists in the databasePermissionDeniedException
- If the logged in user doesn't have permission to access the client
-
getProjectId
public Integer getProjectId()
Get the ID of the project that was active when the change was made.- Returns:
- The ID or null if no project was active
-
getProject
public Project getProject(DbControl dc)
Load the project that was active when the change was made.- Parameters:
dc
- A DbControl to use for database access, or null to use the same DbControl this history entry belongs to- Returns:
- A Project object or null if no project was active
- Throws:
ItemNotFoundException
- If the client application no longer exists in the databasePermissionDeniedException
- If the logged in user doesn't have permission to access the project
-
getPluginId
public Integer getPluginId()
Get the ID of the plug-in that was making the change.- Returns:
- The ID or null if the change was not made by a plug-in
-
getPlugin
public PluginDefinition getPlugin(DbControl dc)
Load the plug-in that made the change.- Parameters:
dc
- A DbControl to use for database access, or null to use the same DbControl this history entry belongs to- Returns:
- A PluginDefinition object or null if the change was not made by a plug-in
- Throws:
ItemNotFoundException
- If the plug-in no longer exists in the databasePermissionDeniedException
- If the logged in user doesn't have permission to access the plug-in
-
getJobId
public Integer getJobId()
Get the ID of the job that was executing when the change was made- Returns:
- The ID or null if the no job was executing
-
getJob
public Job getJob(DbControl dc)
Load the job that was executing when the change was made.- Parameters:
dc
- A DbControl to use for database access, or null to use the same DbControl this history entry belongs to- Returns:
- A Job object or null if no job was executing when the change was made
- Throws:
ItemNotFoundException
- If the job no longer exists in the databasePermissionDeniedException
- If the logged in user doesn't have permission to access the job
-
-