org.jbpm.task.service.persistence
Class TaskPersistenceManager

java.lang.Object
  extended by org.jbpm.task.service.persistence.TaskPersistenceManager

public class TaskPersistenceManager
extends Object


Method Summary
 boolean beginTransaction()
           
 javax.persistence.Query createNewQuery(String queryString)
           
 javax.persistence.Query createQuery(String queryName)
           
 void deleteEntity(Object entity)
           
 void endPersistenceContext()
           
 void endTransaction(boolean txOwner)
          This method attempts to end a transaction -- if it's called by someone/thing claiming to be the transaction owner (otherwise known as the thing that started the transaction).
 Object findEntity(Class<?> entityClass, Object primaryKey)
           
 List<DeadlineSummary> getUnescalatedDeadlines()
          Special onetime method
 List<DeadlineSummary> getUnescalatedDeadlinesList()
           
 List<TaskSummary> queryTasksWithUserIdAndLanguage(String queryName, String userId, String language)
           
 void rollBackTransaction(boolean txOwner)
           
 void saveEntity(Object entity)
           
 void setTaskStatusInTransaction(Object taskId, Status taskStatus)
          Special onetime method
 boolean userExists(String userId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

beginTransaction

public boolean beginTransaction()

endTransaction

public void endTransaction(boolean txOwner)
This method attempts to end a transaction -- if it's called by someone/thing claiming to be the transaction owner (otherwise known as the thing that started the transaction).

If we're the tx owner, we first check if the tx has been marked for rollback. If it's marked for rollback, it doesn't make sense to commit since committing will only throw an exception. Instead, we rollback the tx.

If it's not marked for rollback, we commit the tx.

Unfortunately, rolling back or committing might have caused an exception. If we haven't yet tried to rollback, then we do it at this point: committing didn't work and we don't want to leave the transaction open.

While we could technically add more code to make sure that the transaction is closed (for example, a finally clause that checks if the tx is active, etc), that's overkill because the code below does everything possible to close the transaction.

Anything done in a finally clause would either being confusing (for example, checking if the tx is active after the tx has been commited successfully) or simply retry what had already been done (rollback when that had already been tried in the catch clause).

Parameters:
em - The EntityManager: neccessary for local/entity transactions.
txOwner - Whether or not the caller started this transaction.

rollBackTransaction

public void rollBackTransaction(boolean txOwner)

endPersistenceContext

public void endPersistenceContext()

getUnescalatedDeadlines

public List<DeadlineSummary> getUnescalatedDeadlines()
Special onetime method

Returns:

setTaskStatusInTransaction

public void setTaskStatusInTransaction(Object taskId,
                                       Status taskStatus)
Special onetime method

Parameters:
taskId -
taskStatus -

getUnescalatedDeadlinesList

public List<DeadlineSummary> getUnescalatedDeadlinesList()

findEntity

public Object findEntity(Class<?> entityClass,
                         Object primaryKey)

deleteEntity

public void deleteEntity(Object entity)

saveEntity

public void saveEntity(Object entity)

createQuery

public javax.persistence.Query createQuery(String queryName)

createNewQuery

public javax.persistence.Query createNewQuery(String queryString)

userExists

public boolean userExists(String userId)

queryTasksWithUserIdAndLanguage

public List<TaskSummary> queryTasksWithUserIdAndLanguage(String queryName,
                                                         String userId,
                                                         String language)


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.