Package org.opencastproject.workflow.api
Class WorkflowServiceDatabaseImpl
java.lang.Object
org.opencastproject.workflow.api.WorkflowServiceDatabaseImpl
- All Implemented Interfaces:
WorkflowServiceDatabase
Implements
WorkflowServiceDatabase. Defines permanent storage for workflow.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DBSessionprotected DBSessionFactoryprotected javax.persistence.EntityManagerFactoryFactory used to createEntityManagers for transactionsstatic final StringJPA persistence unit nameprotected SecurityServiceThe security service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) CreatesEntityManagerFactoryusing persistence provider and properties passed via OSGi.intReturns the number of events workflows have been run on.longGets the amount of workflow instances.getRunningWorkflowInstancesByMediaPackage(String mediaPackageId) Gets all workflow instances that are currently running on the mediapackage.getWorkflow(long workflowId) Gets a single workflow by its identifier.getWorkflow(long workflowId, String orgId) Gets a single workflow by its identifiergetWorkflowIndexData(int limit, int offset) Gets workflow index data for all events.getWorkflowInstances(int limit, int offset) Gets workflow instances for current organization.getWorkflowInstancesByMediaPackage(String mediaPackageId) Gets all workflow instances for a mediapackage.getWorkflowInstancesForCleanup(WorkflowInstance.WorkflowState state, Date dateCreated) Gets all workflow instances previous to the specified datebooleanmediaPackageHasActiveWorkflows(String mediaPackageId) Returns true if the media package with the given identifier currently has a workflow running on it.voidremoveFromDatabase(WorkflowInstance instance) Removes a single workflow.voidsetDBSessionFactory(DBSessionFactory dbSessionFactory) voidsetEntityManagerFactory(javax.persistence.EntityManagerFactory emf) OSGi DIvoidsetSecurityService(SecurityService securityService) OSGi callback to set the security service.voidupdateInDatabase(WorkflowInstance instance) Updates a single workflow.booleanuserHasActiveWorkflows(String userId) Returns true there are still workflows running that were created by the user with the given identifier.
-
Field Details
-
PERSISTENCE_UNIT
JPA persistence unit name- See Also:
-
emf
protected javax.persistence.EntityManagerFactory emfFactory used to createEntityManagers for transactions -
dbSessionFactory
-
db
-
securityService
The security service
-
-
Constructor Details
-
WorkflowServiceDatabaseImpl
public WorkflowServiceDatabaseImpl()
-
-
Method Details
-
setEntityManagerFactory
public void setEntityManagerFactory(javax.persistence.EntityManagerFactory emf) OSGi DI -
setDBSessionFactory
-
setSecurityService
OSGi callback to set the security service.- Parameters:
securityService- the securityService to set
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) CreatesEntityManagerFactoryusing persistence provider and properties passed via OSGi.- Parameters:
cc-
-
getWorkflow
public WorkflowInstance getWorkflow(long workflowId) throws NotFoundException, WorkflowDatabaseException Gets a single workflow by its identifier.- Specified by:
getWorkflowin interfaceWorkflowServiceDatabase- Parameters:
workflowId- the series identifier- Returns:
- the
WorkflowInstancefor this workflow - Throws:
NotFoundException- if there is no workflow with this identifierWorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
getWorkflow
public WorkflowInstance getWorkflow(long workflowId, String orgId) throws NotFoundException, WorkflowDatabaseException Description copied from interface:WorkflowServiceDatabaseGets a single workflow by its identifier- Specified by:
getWorkflowin interfaceWorkflowServiceDatabase- Parameters:
workflowId- the series identifier- Returns:
- the
WorkflowInstancefor this workflow - Throws:
NotFoundException- if there is no workflow with this identifierWorkflowDatabaseException- if there is a problem communicating with the underlying data store
-
getWorkflowInstances
public List<WorkflowInstance> getWorkflowInstances(int limit, int offset) throws WorkflowDatabaseException Gets workflow instances for current organization.- Specified by:
getWorkflowInstancesin interfaceWorkflowServiceDatabase- Parameters:
limit- max number of workflows to be returnedoffset- only return workflows from this point onwards- Returns:
- list of all
WorkflowInstances - Throws:
WorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
getWorkflowInstancesForCleanup
public List<WorkflowInstance> getWorkflowInstancesForCleanup(WorkflowInstance.WorkflowState state, Date dateCreated) throws WorkflowDatabaseException Gets all workflow instances previous to the specified date- Specified by:
getWorkflowInstancesForCleanupin interfaceWorkflowServiceDatabase- Parameters:
state- Only returns workflows currently in the given statedateCreated- Only returns workflows created prior to the given date- Returns:
- list of the
WorkflowInstances - Throws:
WorkflowDatabaseException- See Also:
-
countWorkflows
Gets the amount of workflow instances.- Specified by:
countWorkflowsin interfaceWorkflowServiceDatabase- Parameters:
state- Only counts workflows currently in the given state- Returns:
- Amount of workflow instances
- Throws:
WorkflowDatabaseException- See Also:
-
getWorkflowIndexData
public List<WorkflowIndexData> getWorkflowIndexData(int limit, int offset) throws WorkflowDatabaseException Gets workflow index data for all events. Selects only workflow id, state, mediapackage id and organization id- Specified by:
getWorkflowIndexDatain interfaceWorkflowServiceDatabase- Parameters:
limit- max number of data objects to be returnedoffset- only return data from this point onwards- Returns:
- list of
WorkflowIndexDatas - Throws:
WorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
countMediaPackages
Returns the number of events workflows have been run on.- Specified by:
countMediaPackagesin interfaceWorkflowServiceDatabase- Returns:
- the number of latest workflows
- Throws:
WorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
getWorkflowInstancesByMediaPackage
public List<WorkflowInstance> getWorkflowInstancesByMediaPackage(String mediaPackageId) throws WorkflowDatabaseException Gets all workflow instances for a mediapackage.- Specified by:
getWorkflowInstancesByMediaPackagein interfaceWorkflowServiceDatabase- Parameters:
mediaPackageId- the media package id- Returns:
- list of all
WorkflowInstances for the given mediapackage id - Throws:
WorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
getRunningWorkflowInstancesByMediaPackage
public List<WorkflowInstance> getRunningWorkflowInstancesByMediaPackage(String mediaPackageId) throws WorkflowDatabaseException Gets all workflow instances that are currently running on the mediapackage.- Specified by:
getRunningWorkflowInstancesByMediaPackagein interfaceWorkflowServiceDatabase- Parameters:
mediaPackageId- the mediapackage id- Returns:
- list of all
WorkflowInstances for the given mediapackage id - Throws:
WorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
mediaPackageHasActiveWorkflows
public boolean mediaPackageHasActiveWorkflows(String mediaPackageId) throws WorkflowDatabaseException Returns true if the media package with the given identifier currently has a workflow running on it.- Specified by:
mediaPackageHasActiveWorkflowsin interfaceWorkflowServiceDatabase- Parameters:
mediaPackageId- the media package identifier- Returns:
- true, if a workflow is running; false otherwise
- Throws:
WorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
userHasActiveWorkflows
Returns true there are still workflows running that were created by the user with the given identifier.- Specified by:
userHasActiveWorkflowsin interfaceWorkflowServiceDatabase- Parameters:
userId- the user identifier- Returns:
- true, if a workflow is running; false otherwise
- Throws:
WorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
updateInDatabase
Updates a single workflow.- Specified by:
updateInDatabasein interfaceWorkflowServiceDatabase- Parameters:
instance- the workflow instance- Throws:
WorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
removeFromDatabase
Removes a single workflow.- Specified by:
removeFromDatabasein interfaceWorkflowServiceDatabase- Parameters:
instance- the workflow instance- Throws:
WorkflowDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-