jBPM distribution 6.2.0.CR1

org.jbpm.process.audit
Class JPAAuditLogService

java.lang.Object
  extended by org.jbpm.process.audit.JPAAuditLogService
All Implemented Interfaces:
AuditLogService, AuditService

public class JPAAuditLogService
extends Object
implements AuditLogService

The idea here is that we have a entity manager factory (similar to a session factory) that we repeatedly use to generate an entity manager (which is a persistence context) for the specific service command.

While ProcessInstanceLog (and other *Log) entities do not contain LOB's (which sometimes necessitate the use of tx's even in read situations), we use transactions here none-the-less, just to be safe. Obviously, if there is already a running transaction present, we don't do anything to it.

At the end of every command, we make sure to close the entity manager we've been using -- which also means that we detach any entities that might be associated with the entity manager/persistence context. After all, this is a service which means our philosophy here is to provide a real interface, and not a leaky one.


Field Summary
static Map<String,Class<?>> criteriaFieldClasses
           
static Map<String,String> criteriaFields
           
static String NODE_INSTANCE_LOG_QUERY
           
protected  PersistenceStrategy persistenceStrategy
           
static String PROCESS_INSTANCE_LOG_QUERY
           
static String VARIABLE_INSTANCE_LOG_QUERY
           
 
Constructor Summary
JPAAuditLogService()
           
JPAAuditLogService(javax.persistence.EntityManagerFactory emf)
           
JPAAuditLogService(javax.persistence.EntityManagerFactory emf, PersistenceStrategyType type)
           
JPAAuditLogService(Environment env)
           
JPAAuditLogService(Environment env, PersistenceStrategyType type)
           
 
Method Summary
 void clear()
          Removes all entries from audit data store
protected
<C,I> List<I>
convertListToInterfaceList(List<C> internalResult, Class<I> interfaceType)
           
 void dispose()
          Indicates that work with this instance of AuditService is completed and can be disposed (release resources)
<T> List<T>
doQuery(org.kie.internal.query.data.QueryData queryData, Class<T> resultType)
           
 List<ProcessInstanceLog> findActiveProcessInstances(String processId)
          Returns all active process instances for given process id
 List<NodeInstanceLog> findNodeInstances(long processInstanceId)
          Returns all node instances that were already triggered for given process instance id
 List<NodeInstanceLog> findNodeInstances(long processInstanceId, String nodeId)
          Returns all node instances that were already triggered for given process instance id and node identifier
 ProcessInstanceLog findProcessInstance(long processInstanceId)
          Returns process instance log for given process instance id
 List<ProcessInstanceLog> findProcessInstances()
          Service methods
 List<ProcessInstanceLog> findProcessInstances(String processId)
          Returns all known process instances for given process id
 List<ProcessInstanceLog> findSubProcessInstances(long processInstanceId)
          Returns all known subprocess instance logs for given process instance id - considered parent process instance id
 List<VariableInstanceLog> findVariableInstances(long processInstanceId)
          Returns all variable logs for given process instance id
 List<VariableInstanceLog> findVariableInstances(long processInstanceId, String variableId)
          Returns all variable logs for given process instance id and variable identifier
 List<VariableInstanceLog> findVariableInstancesByName(String variableId, boolean onlyActiveProcesses)
          Returns all variable logs that are identified by variable id regardless of what process instance they belong to
 List<VariableInstanceLog> findVariableInstancesByNameAndValue(String variableId, String value, boolean onlyActiveProcesses)
          Returns all variable logs that are identified by variable id and has given value regardless of what process instance they belong to
 String getPersistenceUnitName()
           
 org.kie.internal.runtime.manager.audit.query.NodeInstanceLogQueryBuilder nodeInstanceLogQuery()
          Creates a "query builder" instance that allows the user to specify the specific query criteria to retrieve NodeInstanceLog instances.
 org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder processInstanceLogQuery()
          Creates a "query builder" instance that allows the user to specify the specific query criteria to retrieve ProcessInstanceLog instances.
 List<NodeInstanceLog> queryNodeInstanceLogs(org.kie.internal.query.data.QueryData queryData)
           
 List<ProcessInstanceLog> queryProcessInstanceLogs(org.kie.internal.query.data.QueryData queryData)
           
 List<VariableInstanceLog> queryVariableInstanceLogs(org.kie.internal.query.data.QueryData queryData)
           
 void setPersistenceUnitName(String persistenceUnitName)
           
 org.kie.internal.runtime.manager.audit.query.VariableInstanceLogQueryBuilder variableInstanceLogQuery()
          Creates a "query builder" instance that allows the user to specify the specific query criteria to retrieve VariableInstanceLog instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

persistenceStrategy

protected PersistenceStrategy persistenceStrategy

NODE_INSTANCE_LOG_QUERY

public static String NODE_INSTANCE_LOG_QUERY

VARIABLE_INSTANCE_LOG_QUERY

public static String VARIABLE_INSTANCE_LOG_QUERY

PROCESS_INSTANCE_LOG_QUERY

public static String PROCESS_INSTANCE_LOG_QUERY

criteriaFields

public static Map<String,String> criteriaFields

criteriaFieldClasses

public static Map<String,Class<?>> criteriaFieldClasses
Constructor Detail

JPAAuditLogService

public JPAAuditLogService()

JPAAuditLogService

public JPAAuditLogService(Environment env,
                          PersistenceStrategyType type)

JPAAuditLogService

public JPAAuditLogService(Environment env)

JPAAuditLogService

public JPAAuditLogService(javax.persistence.EntityManagerFactory emf)

JPAAuditLogService

public JPAAuditLogService(javax.persistence.EntityManagerFactory emf,
                          PersistenceStrategyType type)
Method Detail

setPersistenceUnitName

public void setPersistenceUnitName(String persistenceUnitName)

getPersistenceUnitName

public String getPersistenceUnitName()

findProcessInstances

public List<ProcessInstanceLog> findProcessInstances()
Description copied from interface: AuditLogService
Service methods

Specified by:
findProcessInstances in interface AuditLogService
Specified by:
findProcessInstances in interface AuditService
Returns:
all process instance logs or empty list if none were found

findProcessInstances

public List<ProcessInstanceLog> findProcessInstances(String processId)
Description copied from interface: AuditService
Returns all known process instances for given process id

Specified by:
findProcessInstances in interface AuditLogService
Specified by:
findProcessInstances in interface AuditService
Parameters:
processId - identifier of the process definition
Returns:
all process instance logs for given process id or empty list if none were found

findActiveProcessInstances

public List<ProcessInstanceLog> findActiveProcessInstances(String processId)
Description copied from interface: AuditService
Returns all active process instances for given process id

Specified by:
findActiveProcessInstances in interface AuditLogService
Specified by:
findActiveProcessInstances in interface AuditService
Parameters:
processId - identifier of the process definition
Returns:
all active process instance logs for given process id or empty list if none were found

findProcessInstance

public ProcessInstanceLog findProcessInstance(long processInstanceId)
Description copied from interface: AuditService
Returns process instance log for given process instance id

Specified by:
findProcessInstance in interface AuditLogService
Specified by:
findProcessInstance in interface AuditService
Parameters:
processInstanceId - unique identifier of process instance
Returns:
process instance log for given process instance id or null if not found

findSubProcessInstances

public List<ProcessInstanceLog> findSubProcessInstances(long processInstanceId)
Description copied from interface: AuditService
Returns all known subprocess instance logs for given process instance id - considered parent process instance id

Specified by:
findSubProcessInstances in interface AuditLogService
Specified by:
findSubProcessInstances in interface AuditService
Parameters:
processInstanceId - identifier of the parent process instance id
Returns:
all process instance logs that are subprocess to a given process instance id

findNodeInstances

public List<NodeInstanceLog> findNodeInstances(long processInstanceId)
Description copied from interface: AuditService
Returns all node instances that were already triggered for given process instance id

Specified by:
findNodeInstances in interface AuditLogService
Specified by:
findNodeInstances in interface AuditService
Parameters:
processInstanceId - unique identifier of process instance
Returns:
all node instance logs for given process instance id

findNodeInstances

public List<NodeInstanceLog> findNodeInstances(long processInstanceId,
                                               String nodeId)
Description copied from interface: AuditService
Returns all node instances that were already triggered for given process instance id and node identifier

Specified by:
findNodeInstances in interface AuditLogService
Specified by:
findNodeInstances in interface AuditService
Parameters:
processInstanceId - unique identifier of process instance
nodeId - node identifier - by default it should be unique id (from process definition) but if not available regular node id shall be used
Returns:

findVariableInstances

public List<VariableInstanceLog> findVariableInstances(long processInstanceId)
Description copied from interface: AuditService
Returns all variable logs for given process instance id

Specified by:
findVariableInstances in interface AuditLogService
Specified by:
findVariableInstances in interface AuditService
Parameters:
processInstanceId - unique identifier of process instance
Returns:
all variables logs for given process instance or empty list of none were found

findVariableInstances

public List<VariableInstanceLog> findVariableInstances(long processInstanceId,
                                                       String variableId)
Description copied from interface: AuditService
Returns all variable logs for given process instance id and variable identifier

Specified by:
findVariableInstances in interface AuditLogService
Specified by:
findVariableInstances in interface AuditService
Parameters:
processInstanceId - unique identifier of process instance
variableId - variable name
Returns:
all variable logs for given process instance and variable identifier or empty list if none were found

findVariableInstancesByName

public List<VariableInstanceLog> findVariableInstancesByName(String variableId,
                                                             boolean onlyActiveProcesses)
Description copied from interface: AuditService
Returns all variable logs that are identified by variable id regardless of what process instance they belong to

Specified by:
findVariableInstancesByName in interface AuditLogService
Specified by:
findVariableInstancesByName in interface AuditService
Parameters:
variableId - variable name
onlyActiveProcesses - indicates if only active process instances should be considered or both active and completed
Returns:
all variable logs for given variable id or empty list if none were found

findVariableInstancesByNameAndValue

public List<VariableInstanceLog> findVariableInstancesByNameAndValue(String variableId,
                                                                     String value,
                                                                     boolean onlyActiveProcesses)
Description copied from interface: AuditService
Returns all variable logs that are identified by variable id and has given value regardless of what process instance they belong to

Specified by:
findVariableInstancesByNameAndValue in interface AuditLogService
Specified by:
findVariableInstancesByNameAndValue in interface AuditService
Parameters:
variableId - variable name
value - value of the variable
onlyActiveProcesses - indicates if only active process instances should be considered or both active and completed
Returns:
all variable logs for given variable id and its value matches given value or empty list if none were found

clear

public void clear()
Description copied from interface: AuditService
Removes all entries from audit data store

Specified by:
clear in interface AuditService

dispose

public void dispose()
Description copied from interface: AuditService
Indicates that work with this instance of AuditService is completed and can be disposed (release resources)

Specified by:
dispose in interface AuditService

nodeInstanceLogQuery

public org.kie.internal.runtime.manager.audit.query.NodeInstanceLogQueryBuilder nodeInstanceLogQuery()
Description copied from interface: AuditLogService
Creates a "query builder" instance that allows the user to specify the specific query criteria to retrieve NodeInstanceLog instances.

Specified by:
nodeInstanceLogQuery in interface AuditLogService
Returns:
a NodeInstanceLogQueryBuilder instance

variableInstanceLogQuery

public org.kie.internal.runtime.manager.audit.query.VariableInstanceLogQueryBuilder variableInstanceLogQuery()
Description copied from interface: AuditLogService
Creates a "query builder" instance that allows the user to specify the specific query criteria to retrieve VariableInstanceLog instances.

Specified by:
variableInstanceLogQuery in interface AuditLogService
Returns:
a VariableInstanceLogQueryBuilder instance

processInstanceLogQuery

public org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder processInstanceLogQuery()
Description copied from interface: AuditLogService
Creates a "query builder" instance that allows the user to specify the specific query criteria to retrieve ProcessInstanceLog instances.

Specified by:
processInstanceLogQuery in interface AuditLogService
Returns:
a ProcessInstanceLogQueryBuilder instance

queryNodeInstanceLogs

public List<NodeInstanceLog> queryNodeInstanceLogs(org.kie.internal.query.data.QueryData queryData)
Specified by:
queryNodeInstanceLogs in interface AuditLogService

queryVariableInstanceLogs

public List<VariableInstanceLog> queryVariableInstanceLogs(org.kie.internal.query.data.QueryData queryData)
Specified by:
queryVariableInstanceLogs in interface AuditLogService

queryProcessInstanceLogs

public List<ProcessInstanceLog> queryProcessInstanceLogs(org.kie.internal.query.data.QueryData queryData)
Specified by:
queryProcessInstanceLogs in interface AuditLogService

convertListToInterfaceList

protected <C,I> List<I> convertListToInterfaceList(List<C> internalResult,
                                                   Class<I> interfaceType)

doQuery

public <T> List<T> doQuery(org.kie.internal.query.data.QueryData queryData,
                           Class<T> resultType)

jBPM distribution 6.2.0.CR1

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