Class OracleDialect

  • All Implemented Interfaces:
    DatabaseDialect, org.copperengine.management.DatabaseDialectMXBean

    public class OracleDialect
    extends java.lang.Object
    implements DatabaseDialect, org.copperengine.management.DatabaseDialectMXBean
    Oracle implementation of the DatabaseDialect interface It supports multiple engines (cluster) connected to one database.
    • Constructor Detail

      • OracleDialect

        public OracleDialect()
    • Method Detail

      • setConcurrentResponseLoading

        public void setConcurrentResponseLoading​(boolean concurrentResponseLoading)
      • setDbBatchingLatencyMSec

        public void setDbBatchingLatencyMSec​(int dbBatchingLatencyMSec)
        Specified by:
        setDbBatchingLatencyMSec in interface org.copperengine.management.DatabaseDialectMXBean
      • setDefaultStaleResponseRemovalTimeout

        public void setDefaultStaleResponseRemovalTimeout​(long defaultStaleResponseRemovalTimeout)
        Sets the default removal timeout for stale responses in the underlying database. A response is stale/timed out when there is no workflow instance waiting for it within the specified amount of time.
        Specified by:
        setDefaultStaleResponseRemovalTimeout in interface org.copperengine.management.DatabaseDialectMXBean
        Parameters:
        defaultStaleResponseRemovalTimeout - timeout
      • setRemoveWhenFinished

        public void setRemoveWhenFinished​(boolean removeWhenFinished)
        Specified by:
        setRemoveWhenFinished in interface DatabaseDialect
        Specified by:
        setRemoveWhenFinished in interface org.copperengine.management.DatabaseDialectMXBean
        Parameters:
        removeWhenFinished - If true (default), finished workflow instances are removed from the database.
      • setEngineIdProvider

        public void setEngineIdProvider​(EngineIdProvider engineIdProvider)
      • setSerializer

        public void setSerializer​(Serializer serializer)
      • setLockWaitSeconds

        public void setLockWaitSeconds​(int lockWaitSeconds)
      • setMultiEngineMode

        public void setMultiEngineMode​(boolean multiEngineMode)
      • setRuntimeStatisticsCollector

        public void setRuntimeStatisticsCollector​(RuntimeStatisticsCollector runtimeStatisticsCollector)
      • isRemoveWhenFinished

        public boolean isRemoveWhenFinished()
        Specified by:
        isRemoveWhenFinished in interface org.copperengine.management.DatabaseDialectMXBean
      • getSerializer

        public Serializer getSerializer()
      • getDefaultStaleResponseRemovalTimeout

        public long getDefaultStaleResponseRemovalTimeout()
        Specified by:
        getDefaultStaleResponseRemovalTimeout in interface org.copperengine.management.DatabaseDialectMXBean
      • resumeBrokenBusinessProcesses

        public void resumeBrokenBusinessProcesses​(java.sql.Connection con)
                                           throws java.lang.Exception
        Specified by:
        resumeBrokenBusinessProcesses in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • dequeue

        public java.util.List<Workflow<?>> dequeue​(java.lang.String ppoolId,
                                                   int max,
                                                   java.sql.Connection con)
                                            throws java.lang.Exception
        Specified by:
        dequeue in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • updateQueueState

        public int updateQueueState​(int max,
                                    java.sql.Connection con)
                             throws java.sql.SQLException
        Specified by:
        updateQueueState in interface DatabaseDialect
        Throws:
        java.sql.SQLException
      • deleteStaleResponse

        public int deleteStaleResponse​(java.sql.Connection con,
                                       int maxRows)
                                throws java.lang.Exception
        Specified by:
        deleteStaleResponse in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • insert

        public void insert​(java.util.List<Workflow<?>> wfs,
                           java.sql.Connection con)
                    throws java.lang.Exception
        Specified by:
        insert in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • insert

        public void insert​(Workflow<?> wf,
                           java.sql.Connection con)
                    throws java.lang.Exception
        Specified by:
        insert in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • restart

        public void restart​(java.lang.String workflowInstanceId,
                            java.sql.Connection c)
                     throws java.lang.Exception
        Specified by:
        restart in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • restartAll

        public void restartAll​(java.sql.Connection c)
                        throws java.lang.Exception
        Specified by:
        restartAll in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • deleteBroken

        public void deleteBroken​(java.lang.String workflowInstanceId,
                                 java.sql.Connection c)
                          throws java.lang.Exception
        Specified by:
        deleteBroken in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • deleteWaiting

        public void deleteWaiting​(java.lang.String workflowInstanceId,
                                  java.sql.Connection c)
                           throws java.lang.Exception
        Specified by:
        deleteWaiting in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • restartFiltered

        public void restartFiltered​(org.copperengine.management.model.WorkflowInstanceFilter filter,
                                    java.sql.Connection c)
                             throws java.lang.Exception
        Specified by:
        restartFiltered in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • deleteFiltered

        public void deleteFiltered​(org.copperengine.management.model.WorkflowInstanceFilter filter,
                                   java.sql.Connection c)
                            throws java.lang.Exception
        Specified by:
        deleteFiltered in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • getINTfromBOOLEAN

        public int getINTfromBOOLEAN​(java.lang.Boolean input)
      • notify

        public void notify​(java.util.List<Response<?>> responses,
                           java.sql.Connection c)
                    throws java.lang.Exception
        Specified by:
        notify in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • error

        public void error​(Workflow<?> w,
                          java.lang.Throwable t,
                          java.sql.Connection con)
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • checkDbConsistency

        public java.util.List<java.lang.String> checkDbConsistency​(java.sql.Connection con)
                                                            throws java.lang.Exception
        Description copied from interface: DatabaseDialect
        Checks the DB consistency, e.g. at system startup, by deserialising all workflow instances in the underlying database.
        Specified by:
        checkDbConsistency in interface DatabaseDialect
        Parameters:
        con - database connection
        Returns:
        list of ids of bad workflows which could not be deserialized
        Throws:
        java.lang.Exception - For any SQL error like losing connection or such.
      • getDbBatchingLatencyMSec

        public int getDbBatchingLatencyMSec()
        Specified by:
        getDbBatchingLatencyMSec in interface org.copperengine.management.DatabaseDialectMXBean
      • getDialectDescription

        public java.lang.String getDialectDescription()
        Specified by:
        getDialectDescription in interface org.copperengine.management.DatabaseDialectMXBean
      • setWorkflowPersistencePlugin

        public void setWorkflowPersistencePlugin​(WorkflowPersistencePlugin workflowPersistencePlugin)
      • read

        public Workflow<?> read​(java.lang.String workflowInstanceId,
                                java.sql.Connection con)
                         throws java.lang.Exception
        Specified by:
        read in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • createReadStmt

        protected java.sql.PreparedStatement createReadStmt​(java.sql.Connection c,
                                                            java.lang.String workflowId)
                                                     throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • queryAllActive

        public java.util.List<Workflow<?>> queryAllActive​(java.lang.String className,
                                                          java.sql.Connection c,
                                                          int max)
                                                   throws java.sql.SQLException
        Description copied from interface: DatabaseDialect
        Query workflows that were active at the moment in (ENQUEUE, RUNNING or WAITING) state
        Specified by:
        queryAllActive in interface DatabaseDialect
        Parameters:
        className - - optional, specify which className it want to return. May be null. (No filtering for class name done in this case) If specified, the className must fully match the class name, so no regexp or similar is allowed. className must be given as fully qualified name (i.e. with package names prepending). Example is org.copperengine.examples.workflows.MyWorkflow
        c - - database connection
        max - maximum number to be queried (Translates to LIMIT max or FETCH ,max or similar on SQL queries SELECT)
        Returns:
        List of active workflows.
        Throws:
        java.sql.SQLException - If anything goes wrong regarding SQL.
      • schemaMatches

        public static boolean schemaMatches​(java.sql.Connection c)
                                     throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • readDatabaseClock

        public java.util.Date readDatabaseClock​(java.sql.Connection con)
                                         throws java.sql.SQLException
        Description copied from interface: DatabaseDialect
        Read the current system time from the underlying database system
        Specified by:
        readDatabaseClock in interface DatabaseDialect
        Parameters:
        con - database connection
        Returns:
        Current database clock time
        Throws:
        java.sql.SQLException - Any sql error happening in here.
      • queryQueueSize

        public int queryQueueSize​(java.lang.String processorPoolId,
                                  int max,
                                  java.sql.Connection con)
                           throws java.sql.SQLException
        Specified by:
        queryQueueSize in interface DatabaseDialect
        Throws:
        java.sql.SQLException
      • queryObjectState

        public java.lang.String queryObjectState​(java.lang.String id,
                                                 java.sql.Connection con)
                                          throws java.lang.Exception
        Specified by:
        queryObjectState in interface DatabaseDialect
        Throws:
        java.lang.Exception
      • queryWorkflowInstances

        public java.util.List<Workflow<?>> queryWorkflowInstances​(org.copperengine.management.model.WorkflowInstanceFilter filter,
                                                                  java.sql.Connection con)
                                                           throws java.sql.SQLException
        Specified by:
        queryWorkflowInstances in interface DatabaseDialect
        Throws:
        java.sql.SQLException
      • countWorkflowInstances

        public int countWorkflowInstances​(org.copperengine.management.model.WorkflowInstanceFilter filter,
                                          java.sql.Connection con)
                                   throws java.sql.SQLException
        Specified by:
        countWorkflowInstances in interface DatabaseDialect
        Throws:
        java.sql.SQLException
      • queryAuditTrailInstances

        public java.util.List<org.copperengine.management.model.AuditTrailInfo> queryAuditTrailInstances​(org.copperengine.management.model.AuditTrailInstanceFilter filter,
                                                                                                         java.sql.Connection c)
                                                                                                  throws java.sql.SQLException
        Specified by:
        queryAuditTrailInstances in interface DatabaseDialect
        Throws:
        java.sql.SQLException
      • isBlank

        protected boolean isBlank​(java.lang.String str)
      • queryAuditTrailMessage

        public java.lang.String queryAuditTrailMessage​(long id,
                                                       java.sql.Connection con)
                                                throws java.sql.SQLException
        Specified by:
        queryAuditTrailMessage in interface DatabaseDialect
        Throws:
        java.sql.SQLException
      • countAuditTrailInstances

        public int countAuditTrailInstances​(org.copperengine.management.model.AuditTrailInstanceFilter filter,
                                            java.sql.Connection con)
                                     throws java.sql.SQLException
        Specified by:
        countAuditTrailInstances in interface DatabaseDialect
        Throws:
        java.sql.SQLException
      • decode

        protected PersistentWorkflow<?> decode​(java.sql.ResultSet rs)
                                        throws java.sql.SQLException,
                                               java.lang.Exception
        Throws:
        java.sql.SQLException
        java.lang.Exception
      • addLimitation

        protected void addLimitation​(java.lang.StringBuilder sql,
                                     int max)
      • addLimitationAndOffset

        protected void addLimitationAndOffset​(java.lang.StringBuilder sql,
                                              int max,
                                              int offset)