Package com.logicaldoc.core.ticket

# Class HibernateTicketDAO

java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<Ticket>
com.logicaldoc.core.ticket.HibernateTicketDAO

All Implemented Interfaces:
  `PersistentObjectDAO<Ticket>`, `TicketDAO`

@Repository("ticketDAO") public class HibernateTicketDAO extends HibernatePersistentObjectDAO<Ticket> implements TicketDAO
Hibernate implementation of `TicketDAO`

Since:
  3.0
Author:
  Marco Meschieri - LogicalDOC

## Field Summary

### Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO

`ENTITY`

## Constructor Summary

Constructors
Constructor
Description
`HibernateTicketDAO(DocumentDAO documentDAO, ContextProperties config)`

## Method Summary

Modifier and Type
Method
Description
`long`
`countViewOrDownloadTickets(Long tenantId)`
Counts the DOWNLOAD or VIEW tickets
`boolean`
`deleteByDocId(long docId)`
This method deletes all tickets of the specified document.
`boolean`
`deleteByTicketId(String ticketid)`
This method deletes a download ticket.
`void`
`deleteExpired()`
Deletes all expired tickets
`Ticket`
`findByTicketId(String ticketId)`
This finds a ticket by its identifier and runs the validation
`DocumentDAO`
`getDocumentDAO()`
`void`
`init()`
`void`
`setConfig(ContextProperties config)`
`void`
`setDocumentDAO(DocumentDAO documentDAO)`
`void`
`store(Ticket entity)`
This method persists the entity object
`void`
`store(Ticket ticket, DocumentHistory transaction)`
This method persists the download ticket object and insert a new document history entry

### Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO

`bulkUpdate, count, delete, deleteAll, evict, evict, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findIdsByWhere, getDatabaseMetadata, initialize, jdbcUpdate, jdbcUpdate, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString, setSessionFactory`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface com.logicaldoc.core.PersistentObjectDAO

`bulkUpdate, count, count, count, delete, delete, deleteAll, deleteAll, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, initialize, isMariaDB, isMySQL, isOracle, isPostgreSQL, isSQLServer, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString`

## Constructor Details

### HibernateTicketDAO

public HibernateTicketDAO(DocumentDAO documentDAO, ContextProperties config)

## Method Details

### store

public void store(Ticket entity) throws PersistenceException
Description copied from interface: `PersistentObjectDAO`
This method persists the entity object

Specified by:
  `store` in interface `PersistentObjectDAO<Ticket>`
Overrides:
  `store` in class `HibernatePersistentObjectDAO<Ticket>`
Parameters:
  `entity` - entity to be stored
Throws:
  `PersistenceException` - raised in case of errors in the database

### store

public void store(Ticket ticket, DocumentHistory transaction) throws PersistenceException
Description copied from interface: `TicketDAO`
This method persists the download ticket object and insert a new document history entry

Specified by:
  `store` in interface `TicketDAO`
Parameters:
  `ticket` - the ticket to store
  `transaction` - entry to log the event
Throws:
  `PersistenceException` - error at database level

### deleteByTicketId

public boolean deleteByTicketId(String ticketid)
Description copied from interface: `TicketDAO`
This method deletes a download ticket.

Specified by:
  `deleteByTicketId` in interface `TicketDAO`
Parameters:
  `ticketid` - ID of the ticket which should be delete.
Returns:
  if the tickets have been deleted

### findByTicketId

public Ticket findByTicketId(String ticketId) throws PersistenceException
Description copied from interface: `TicketDAO`
This finds a ticket by its identifier and runs the validation

Specified by:
  `findByTicketId` in interface `TicketDAO`
Parameters:
  `ticketId` - The ticket id
Returns:
  Ticket with given ticket id
Throws:
  `PersistenceException` - error at database level

### deleteByDocId

public boolean deleteByDocId(long docId)
Description copied from interface: `TicketDAO`
This method deletes all tickets of the specified document.

Specified by:
  `deleteByDocId` in interface `TicketDAO`
Parameters:
  `docId` - ID of the document
Returns:
  if the ticket has been deleted

### setConfig

public void setConfig(ContextProperties config)

### deleteExpired

public void deleteExpired()
Description copied from interface: `TicketDAO`
Deletes all expired tickets

Specified by:
  `deleteExpired` in interface `TicketDAO`

### getDocumentDAO

public DocumentDAO getDocumentDAO()

### setDocumentDAO

public void setDocumentDAO(DocumentDAO documentDAO)

### init

@PostConstruct public void init()

### countViewOrDownloadTickets

public long countViewOrDownloadTickets(Long tenantId) throws PersistenceException
Description copied from interface: `TicketDAO`
Counts the DOWNLOAD or VIEW tickets

Specified by:
  `countViewOrDownloadTickets` in interface `TicketDAO`
Parameters:
  `tenantId` - optional tenant specification
Returns:
  Total count
Throws:
  `PersistenceException` - error in the database