Esempio n. 1
0
 public virtual void ClearProcessInstanceLockTime(string processInstanceId)
 {
     DbSqlSession.Update <ExecutionEntityImpl>("clearProcessInstanceLockTime", new
     {
         id = processInstanceId
     });
 }
Esempio n. 2
0
            public virtual string Execute(ICommandContext commandContext)
            {
                DbSqlSessionFactory dbSqlSessionFactory = (DbSqlSessionFactory)commandContext.SessionFactories[typeof(DbSqlSession)];
                DbSqlSession        dbSqlSession        = new DbSqlSession(dbSqlSessionFactory, commandContext.EntityCache, connection, catalog, schema);

                commandContext.Sessions[typeof(DbSqlSession)] = dbSqlSession;
                return(dbSqlSession.DbSchemaUpdate());
            }
Esempio n. 3
0
 public virtual IResourceEntity FindResourceByDeploymentIdAndResourceName(string deploymentId, string resourceName)
 {
     return((IResourceEntity)DbSqlSession.SelectOne <ResourceEntityImpl, IResourceEntity>("selectResourceByDeploymentIdAndResourceName", new
     {
         deploymentId,
         resourceName
     }));
 }
        public virtual IList <IEventLogEntry> FindEventLogEntriesByProcessInstanceId(string processInstanceId)
        {
            IDictionary <string, object> @params = new Dictionary <string, object>(2)
            {
                ["processInstanceId"] = processInstanceId
            };

            return(DbSqlSession.SelectList <EventLogEntryEntityImpl, IEventLogEntry>("selectEventLogEntriesByProcessInstanceId", @params));
        }
        public virtual void ResetExpiredJob(string jobId)
        {
            IDictionary <string, object> @params = new Dictionary <string, object>(2)
            {
                ["id"] = jobId
            };

            DbSqlSession.Update <JobEntityImpl>("resetExpiredJob", @params);
        }
        public virtual IList <IJobEntity> FindJobsByProcessDefinitionId(string processDefinitionId)
        {
            IDictionary <string, string> @params = new Dictionary <string, string>(1)
            {
                ["processDefinitionId"] = processDefinitionId
            };

            return(DbSqlSession.SelectList <JobEntityImpl, IJobEntity>("selectJobByProcessDefinitionId", @params));
        }
Esempio n. 7
0
 public virtual IProcessDefinitionEntity FindProcessDefinitionByDeploymentAndKeyAndTenantId(string deploymentId, string processDefinitionKey, string tenantId)
 {
     return(DbSqlSession.SelectOne <ProcessDefinitionEntityImpl, IProcessDefinitionEntity>("selectProcessDefinitionByDeploymentAndKeyAndTenantId", new
     {
         deploymentId,
         processDefinitionKey,
         tenantId
     }));
 }
Esempio n. 8
0
        public virtual IProcessDefinitionEntity FindLatestProcessDefinitionByKeyAndTenantId(string processDefinitionKey, string tenantId)
        {
            IDictionary <string, object> @params = new Dictionary <string, object>(2)
            {
                ["processDefinitionKey"] = processDefinitionKey,
                ["tenantId"]             = tenantId
            };

            return(DbSqlSession.SelectOne <ProcessDefinitionEntityImpl, IProcessDefinitionEntity>("selectLatestProcessDefinitionByKeyAndTenantId", @params));
        }
        public virtual IDeploymentEntity FindLatestDeploymentByName(string deploymentName)
        {
            IList <IDeploymentEntity> list = DbSqlSession.SelectList <DeploymentEntityImpl, IDeploymentEntity>("selectDeploymentsByName", new { deploymentName }, 0, 1);

            if (list != null && list.Count > 0)
            {
                return(list[0]);
            }
            return(null);
        }
        /// <summary>
        ///
        /// </summary>
        public virtual void Commit()
        {
            log.LogDebug("firing event committing...");
            FireTransactionEvent(TransactionState.COMMITTING, false);

            log.LogDebug("committing the ibatis sql session...");
            DbSqlSession.Commit();
            log.LogDebug("firing event committed...");
            FireTransactionEvent(TransactionState.COMMITTED, true);
        }
        public virtual IList <IJobEntity> FindJobsByTypeAndProcessDefinitionId(string jobHandlerType, string processDefinitionId)
        {
            IDictionary <string, string> @params = new Dictionary <string, string>(2)
            {
                ["handlerType"]         = jobHandlerType,
                ["processDefinitionId"] = processDefinitionId
            };

            return(DbSqlSession.SelectList <JobEntityImpl, IJobEntity>("selectJobByTypeAndProcessDefinitionId", @params));
        }
Esempio n. 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="variableName"></param>
        /// <returns></returns>
        public virtual IVariableInstanceEntity FindVariableInstanceByTaskAndName(string taskId, string variableName)
        {
            IDictionary <string, string> @params = new Dictionary <string, string>(2)
            {
                ["taskId"] = taskId,
                ["name"]   = variableName
            };

            return(DbSqlSession.SelectOne <VariableInstanceEntityImpl, IVariableInstanceEntity>("selectVariableInstanceByTaskAndName", @params));
        }
Esempio n. 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="names"></param>
        /// <returns></returns>
        public virtual IList <IVariableInstanceEntity> FindVariableInstancesByTaskAndNames(string taskId, IEnumerable <string> names)
        {
            IDictionary <string, object> @params = new Dictionary <string, object>(2)
            {
                ["taskId"] = taskId,
                ["names"]  = names
            };

            return(DbSqlSession.SelectList <VariableInstanceEntityImpl, IVariableInstanceEntity>("selectVariableInstancesByTaskAndNames", @params));
        }
Esempio n. 14
0
        public virtual void UpdateExecutionTenantIdForDeployment(string deploymentId, string newTenantId)
        {
            Dictionary <string, object> @params = new Dictionary <string, object>
            {
                ["deploymentId"] = deploymentId,
                ["tenantId"]     = newTenantId
            };

            DbSqlSession.Update <ExecutionEntityImpl>("updateExecutionTenantIdForDeployment", @params);
        }
Esempio n. 15
0
            public string execute(CommandContext commandContext)
            {
                commandContext.AuthorizationManager.checkCamundaAdmin();
                DbSqlSessionFactory dbSqlSessionFactory = (DbSqlSessionFactory)commandContext.SessionFactories[typeof(DbSqlSession)];
                DbSqlSession        dbSqlSession        = new DbSqlSession(dbSqlSessionFactory, connection, catalog, schema);

                commandContext.Sessions[typeof(DbSqlSession)] = dbSqlSession;
                dbSqlSession.dbSchemaUpdate();

                return("");
            }
Esempio n. 16
0
        public virtual IList <IIdentityLinkEntity> FindIdentityLinkByProcessDefinitionUserAndGroup(string processDefinitionId, string userId, string groupId)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>
            {
                ["processDefinitionId"] = processDefinitionId,
                ["userId"]  = userId,
                ["groupId"] = groupId
            };

            return(DbSqlSession.SelectList <IdentityLinkEntityImpl, IIdentityLinkEntity>("selectIdentityLinkByProcessDefinitionUserAndGroup", parameters));
        }
        public object Execute(ICommandContext commandContext)
        {
            DbSqlSession dbSqlSession = commandContext.DbSqlSession;

            if (dbSqlSession != null)
            {
                dbSqlSession.PerformSchemaOperationsProcessEngineBuild();
            }

            return(commandContext.GetResult());
        }
Esempio n. 18
0
        public virtual IList <IIdentityLinkEntity> FindIdentityLinkByProcessInstanceUserGroupAndType(string processInstanceId, string userId, string groupId, string type)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>
            {
                ["processInstanceId"] = processInstanceId,
                ["userId"]            = userId,
                ["groupId"]           = groupId,
                ["type"] = type
            };

            return(DbSqlSession.SelectList <IdentityLinkEntityImpl, IIdentityLinkEntity>("selectIdentityLinkByProcessInstanceUserGroupAndType", parameters));
        }
        public virtual IMessageEventSubscriptionEntity FindMessageStartEventSubscriptionByName(string messageName, string tenantId)
        {
            IDictionary <string, string> @params = new Dictionary <string, string>
            {
                ["eventName"] = messageName,
                ["tenantId"]  = tenantId
            };

            IMessageEventSubscriptionEntity entity = DbSqlSession.SelectOne <MessageEventSubscriptionEntityImpl, IMessageEventSubscriptionEntity>("selectMessageStartEventSubscriptionByName", @params);

            return(entity);
        }
        public virtual IList <IEventSubscriptionEntity> FindEventSubscriptionsByTypeAndProcessDefinitionId(string type, string processDefinitionId, string tenantId)
        {
            const string query = "selectEventSubscriptionsByTypeAndProcessDefinitionId";
            IDictionary <string, string> @params = new Dictionary <string, string>
            {
                ["eventType"]           = type,
                ["processDefinitionId"] = processDefinitionId,
                ["tenantId"]            = tenantId
            };

            return(DbSqlSession.SelectList <EventSubscriptionEntityImpl, IEventSubscriptionEntity>(query, @params));
        }
Esempio n. 21
0
        public virtual TableMetaData getTableMetaData(string tableName)
        {
            TableMetaData result    = new TableMetaData();
            ResultSet     resultSet = null;

            try
            {
                try
                {
                    result.TableName = tableName;
                    DatabaseMetaData metaData = DbSqlSession.SqlSession.Connection.MetaData;

                    if (DbSqlSessionFactory.POSTGRES.Equals(DbSqlSession.DbSqlSessionFactory.DatabaseType))
                    {
                        tableName = tableName.ToLower();
                    }

                    string databaseSchema = DbSqlSession.DbSqlSessionFactory.DatabaseSchema;
                    tableName = DbSqlSession.prependDatabaseTablePrefix(tableName);

                    resultSet = metaData.getColumns(null, databaseSchema, tableName, null);
                    while (resultSet.next())
                    {
                        string name = resultSet.getString("COLUMN_NAME").ToUpper();
                        string type = resultSet.getString("TYPE_NAME").ToUpper();
                        result.addColumnMetaData(name, type);
                    }
                }
                catch (SQLException se)
                {
                    throw se;
                }
                finally
                {
                    if (resultSet != null)
                    {
                        resultSet.close();
                    }
                }
            }
            catch (Exception e)
            {
                throw LOG.retrieveMetadataException(e);
            }

            if (result.ColumnNames.Count == 0)
            {
                // According to API, when a table doesn't exist, null should be returned
                result = null;
            }
            return(result);
        }
        public virtual IList <IEventLogEntry> FindEventLogEntries(long startLogNr, long pageSize)
        {
            IDictionary <string, object> @params = new Dictionary <string, object>(2)
            {
                ["startLogNr"] = startLogNr
            };

            if (pageSize > 0)
            {
                @params["endLogNr"] = startLogNr + pageSize + 1;
            }
            return(DbSqlSession.SelectList <EventLogEntryEntityImpl, IEventLogEntry>("selectEventLogEntries", @params));
        }
Esempio n. 23
0
        public virtual IList <IHistoricTaskInstance> FindHistoricTaskInstancesAndVariablesByQueryCriteria(IHistoricTaskInstanceQuery historicTaskInstanceQuery)
        {
            var query = historicTaskInstanceQuery as HistoricTaskInstanceQueryImpl;

            // paging doesn't work for combining task instances and variables
            // due to an outer join, so doing it in-memory
            if (query.FirstResult < 0 || query.MaxResults <= 0)
            {
                return(new List <IHistoricTaskInstance>());
            }

            int firstResult = query.FirstResult;
            int maxResults  = query.MaxResults;

            // setting max results, limit to 20000 results for performance reasons
            if (query.TaskVariablesLimit != null)
            {
                query.MaxResults = query.TaskVariablesLimit.GetValueOrDefault();
            }
            else
            {
                query.MaxResults = ProcessEngineConfiguration.HistoricTaskQueryLimit;
            }
            query.FirstResult = 0;

            IList <IHistoricTaskInstance> instanceList = DbSqlSession.SelectListWithRawParameterWithoutFilter <HistoricTaskInstanceEntityImpl, IHistoricTaskInstance>("selectHistoricTaskInstancesWithVariablesByQueryCriteria", historicTaskInstanceQuery, query.FirstResult, query.MaxResults);

            if (instanceList != null && instanceList.Count > 0)
            {
                if (firstResult > 0)
                {
                    if (firstResult <= instanceList.Count)
                    {
                        int toIndex = firstResult + Math.Min(maxResults, instanceList.Count - firstResult);
                        return(instanceList.Skip(firstResult).Take(toIndex).ToList());
                    }
                    else
                    {
                        return(new List <IHistoricTaskInstance>());
                    }
                }
                else
                {
                    int toIndex = Math.Min(maxResults, instanceList.Count);
                    return(instanceList.Skip(0).Take(toIndex).ToList());
                }
            }

            return(instanceList);
        }
Esempio n. 24
0
        public virtual IProcessDefinitionEntity FindProcessDefinitionByKeyAndVersion(string processDefinitionKey, int?processDefinitionVersion)
        {
            IList <IProcessDefinitionEntity> results = DbSqlSession.SelectList <ProcessDefinitionEntityImpl, IProcessDefinitionEntity>("selectProcessDefinitionsByKeyAndVersion", new { processDefinitionKey, processDefinitionVersion });

            if (results.Count == 1)
            {
                return(results[0]);
            }
            else if (results.Count > 1)
            {
                throw new ActivitiException("There are " + results.Count + " process definitions with key = '" + processDefinitionKey + "' and version = '" + processDefinitionVersion + "'.");
            }
            return(null);
        }
        public virtual IList <ITask> FindTasksAndVariablesByQueryCriteria(ITaskQuery taskQuery)
        {
            const string  query        = "selectTaskWithVariablesByQueryCriteria";
            TaskQueryImpl taskQueyImpl = taskQuery as TaskQueryImpl;

            // paging doesn't work for combining task instances and variables due to
            // an outer join, so doing it in-memory
            if (taskQueyImpl.FirstResult < 0 || taskQueyImpl.MaxResults <= 0)
            {
                return(new List <ITask>());
            }

            int firstResult = taskQueyImpl.FirstResult;
            int maxResults  = taskQueyImpl.MaxResults;

            // setting max results, limit to 20000 results for performance reasons
            if (taskQueyImpl.TaskVariablesLimit != null)
            {
                taskQueyImpl.MaxResults = taskQueyImpl.TaskVariablesLimit.GetValueOrDefault();
            }
            else
            {
                taskQueyImpl.MaxResults = ProcessEngineConfiguration.TaskQueryLimit;
            }
            taskQueyImpl.FirstResult = 0;

            IList <ITask> instanceList = DbSqlSession.SelectListWithRawParameterWithoutFilter <TaskEntityImpl, ITask>(query, taskQueyImpl, taskQueyImpl.FirstResult, taskQueyImpl.MaxResults);

            if (instanceList != null && instanceList.Count > 0)
            {
                if (firstResult > 0)
                {
                    if (firstResult <= instanceList.Count)
                    {
                        int toIndex = firstResult + Math.Min(maxResults, instanceList.Count - firstResult);
                        return(instanceList.Skip(firstResult).Take(toIndex).ToList());
                    }
                    else
                    {
                        return(new List <ITask>());
                    }
                }
                else
                {
                    int toIndex = Math.Min(maxResults, instanceList.Count);
                    return(instanceList.Skip(0).Take(toIndex).ToList());
                }
            }
            return(new List <ITask>());
        }
Esempio n. 26
0
        public virtual TablePage GetTablePage(ITablePageQuery tablePageQuery, int firstResult, int maxResults)
        {
            TablePage          tablePage          = new TablePage();
            TablePageQueryImpl tablePageQueryImpl = tablePageQuery as TablePageQueryImpl;

            IList <Dictionary <string, object> > tableData = DbSqlSession.SelectList <PropertyEntityImpl, Dictionary <string, object> >("selectTableData", null, firstResult, maxResults);

            tablePage.TableName   = tablePageQueryImpl.TableName;
            tablePage.Total       = GetTableCount(tablePageQueryImpl.TableName);
            tablePage.Rows        = (IList <IDictionary <string, object> >)tableData;
            tablePage.FirstResult = firstResult;

            return(tablePage);
        }
Esempio n. 27
0
        public virtual IList <IProcessInstance> FindProcessInstanceAndVariablesByQueryCriteria(IProcessInstanceQuery query)
        {
            ProcessInstanceQueryImpl executionQuery = query as ProcessInstanceQueryImpl;

            // paging doesn't work for combining process instances and variables due
            // to an outer join, so doing it in-memory
            if (executionQuery.FirstResult < 0 || executionQuery.MaxResults <= 0)
            {
                return(new List <IProcessInstance>());
            }

            int firstResult = executionQuery.FirstResult;
            int maxResults  = executionQuery.MaxResults;

            // setting max results, limit to 20000 results for performance reasons
            if (executionQuery.ProcessInstanceVariablesLimit != null)
            {
                executionQuery.MaxResults = executionQuery.ProcessInstanceVariablesLimit.GetValueOrDefault();
            }
            else
            {
                executionQuery.MaxResults = ProcessEngineConfiguration.ExecutionQueryLimit;
            }
            executionQuery.FirstResult = 0;

            IList <IProcessInstance> instanceList = DbSqlSession.SelectListWithRawParameterWithoutFilter <ExecutionEntityImpl, IProcessInstance>("selectProcessInstanceWithVariablesByQueryCriteria", executionQuery, executionQuery.FirstResult, executionQuery.MaxResults);

            if (instanceList != null && instanceList.Count > 0)
            {
                if (firstResult > 0)
                {
                    if (firstResult <= instanceList.Count)
                    {
                        int toIndex = firstResult + Math.Min(maxResults, instanceList.Count - firstResult);
                        return(instanceList.Skip(firstResult).Take(toIndex).ToList());
                    }
                    else
                    {
                        return(new List <IProcessInstance>());
                    }
                }
                else
                {
                    int toIndex = Math.Min(maxResults, instanceList.Count);
                    return(instanceList.Skip(0).Take(toIndex).ToList());
                }
            }
            return(new List <IProcessInstance>());
        }
Esempio n. 28
0
        public virtual void UpdateProcessInstanceLockTime(string processInstanceId, DateTime lockDate, DateTime expirationTime)
        {
            Dictionary <string, object> @params = new Dictionary <string, object>
            {
                ["id"]             = processInstanceId,
                ["lockTime"]       = lockDate,
                ["expirationTime"] = expirationTime
            };

            int result = DbSqlSession.Update <ExecutionEntityImpl>("updateProcessInstanceLockTime", @params);

            if (result == 0)
            {
                throw new ActivitiOptimisticLockingException("Could not lock process instance");
            }
        }
Esempio n. 29
0
        public virtual IList <IProcessDefinition> FindProcessDefinitionsByQueryCriteria(IProcessDefinitionQuery processDefinitionQuery, Page page)
        {
            // List<ProcessDefinition> processDefinitions =
            return(DbSqlSession.SelectList <ProcessDefinitionEntityImpl, IProcessDefinition>("selectProcessDefinitionsByQueryCriteria", processDefinitionQuery, page));

            // skipped this after discussion within the team
            // // retrieve process definitions from cache
            // (https://activiti.atlassian.net/browse/ACT-1020) to have all available
            // information
            // ArrayList<ProcessDefinition> result = new
            // ArrayList<ProcessDefinition>();
            // for (ProcessDefinition processDefinitionEntity : processDefinitions)
            // {
            // ProcessDefinitionEntity fullProcessDefinition = Context
            // .getProcessEngineConfiguration()
            // .getDeploymentCache().resolveProcessDefinition((ProcessDefinitionEntity)processDefinitionEntity);
            // result.add(fullProcessDefinition);
            // }
            // return result;
        }
        public virtual IList <ITask> FindTasksByQueryCriteria(ITaskQuery taskQuery)
        {
            const string query = "selectTaskByQueryCriteria";

            return(DbSqlSession.SelectList <TaskEntityImpl, ITask>(query, taskQuery));
        }