Example #1
0
        /// <summary>
        /// customized insert behavior for HistoricVariableUpdateEventEntity </summary>
        protected internal virtual void insertHistoricVariableUpdateEntity(HistoricVariableUpdateEventEntity historyEvent)
        {
            DbEntityManager dbEntityManager = DbEntityManager;

            // insert update only if history level = FULL
            if (shouldWriteHistoricDetail(historyEvent))
            {
                // insert byte array entity (if applicable)
                sbyte[] byteValue = historyEvent.ByteValue;
                if (byteValue != null)
                {
                    ByteArrayEntity byteArrayEntity = new ByteArrayEntity(historyEvent.VariableName, byteValue, ResourceTypes.HISTORY);
                    byteArrayEntity.RootProcessInstanceId = historyEvent.RootProcessInstanceId;
                    byteArrayEntity.RemovalTime           = historyEvent.RemovalTime;

                    Context.CommandContext.ByteArrayManager.insertByteArray(byteArrayEntity);
                    historyEvent.ByteArrayId = byteArrayEntity.Id;
                }
                dbEntityManager.insert(historyEvent);
            }

            // always insert/update HistoricProcessVariableInstance
            if (historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_CREATE))
            {
                HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent);
                dbEntityManager.insert(persistentObject);
            }
            else if (historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_UPDATE) || historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_MIGRATE))
            {
                HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(typeof(HistoricVariableInstanceEntity), historyEvent.VariableInstanceId);
                if (historicVariableInstanceEntity != null)
                {
                    historicVariableInstanceEntity.updateFromEvent(historyEvent);
                    historicVariableInstanceEntity.State = org.camunda.bpm.engine.history.HistoricVariableInstance_Fields.STATE_CREATED;
                }
                else
                {
                    // #CAM-1344 / #SUPPORT-688
                    // this is a FIX for process instances which were started in camunda fox 6.1 and migrated to camunda BPM 7.0.
                    // in fox 6.1 the HistoricVariable instances were flushed to the DB when the process instance completed.
                    // Since fox 6.2 we populate the HistoricVariable table as we go.
                    HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent);
                    dbEntityManager.insert(persistentObject);
                }
            }
            else if (historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_DELETE))
            {
                HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(typeof(HistoricVariableInstanceEntity), historyEvent.VariableInstanceId);
                if (historicVariableInstanceEntity != null)
                {
                    historicVariableInstanceEntity.State = org.camunda.bpm.engine.history.HistoricVariableInstance_Fields.STATE_DELETED;
                }
            }
        }
Example #2
0
 public virtual HistoricProcessInstanceEventEntity findHistoricProcessInstanceEvent(string eventId)
 {
     if (HistoryEnabled)
     {
         return(DbEntityManager.selectById(typeof(HistoricProcessInstanceEventEntity), eventId));
     }
     return(null);
 }
Example #3
0
 public virtual HistoricCaseInstanceEntity findHistoricCaseInstance(string caseInstanceId)
 {
     if (HistoryEnabled)
     {
         return(DbEntityManager.selectById(typeof(HistoricCaseInstanceEntity), caseInstanceId));
     }
     return(null);
 }
Example #4
0
        public virtual Stream execute(CommandContext commandContext)
        {
            DbEntityManager  dbEntityManger = commandContext.DbEntityManager;
            AttachmentEntity attachment     = dbEntityManger.selectById(typeof(AttachmentEntity), attachmentId);

            string contentId = attachment.ContentId;

            if (string.ReferenceEquals(contentId, null))
            {
                return(null);
            }

            ByteArrayEntity byteArray = dbEntityManger.selectById(typeof(ByteArrayEntity), contentId);

            sbyte[] bytes = byteArray.Bytes;

            return(new MemoryStream(bytes));
        }
Example #5
0
            public object execute(CommandContext commandContext)
            {
                DbEntityManager dbEntityManager      = commandContext.DbEntityManager;
                PropertyEntity  historyLevelProperty = dbEntityManager.selectById(typeof(PropertyEntity), "historyLevel");

                if (historyLevelProperty != null)
                {
                    dbEntityManager.delete(historyLevelProperty);
                }
                return(null);
            }
Example #6
0
            public object execute(CommandContext commandContext)
            {
                DbEntityManager dbEntityManager      = commandContext.DbEntityManager;
                PropertyEntity  historyLevelProperty = dbEntityManager.selectById(typeof(PropertyEntity), "historyLevel");

                if (historyLevelProperty != null)
                {
                    if (processEngineConfiguration.HistoryLevel.Id != new int?(historyLevelProperty.Value))
                    {
                        historyLevelProperty.Value = Convert.ToString(processEngineConfiguration.HistoryLevel.Id);
                        dbEntityManager.merge(historyLevelProperty);
                    }
                }
                else
                {
                    HistoryLevelSetupCommand.dbCreateHistoryLevel(commandContext);
                }
                return(null);
            }
Example #7
0
            public override Void execute(CommandContext commandContext)
            {
                DbEntityManagerFactory dbEntityManagerFactory = new DbEntityManagerFactory(Context.ProcessEngineConfiguration.IdGenerator);
                DbEntityManager        entityManager          = dbEntityManagerFactory.openSession();

                JobEntity job = entityManager.selectById(typeof(JobEntity), JOB_ENTITY_ID);

                job.LockOwner = lockOwner;
                entityManager.forceUpdate(job);

                monitor.sync();

                // flush the changed entity and create a lock for the table
                entityManager.flush();

                monitor.sync();

                // commit transaction and remove the lock
                commandContext.TransactionContext.commit();

                return(null);
            }
Example #8
0
 public virtual ProcessDefinitionEntity findLatestProcessDefinitionById(string processDefinitionId)
 {
     return(DbEntityManager.selectById(typeof(ProcessDefinitionEntity), processDefinitionId));
 }
Example #9
0
 public virtual DecisionRequirementsDefinitionEntity findLatestDefinitionById(string id)
 {
     return(DbEntityManager.selectById(typeof(DecisionRequirementsDefinitionEntity), id));
 }
Example #10
0
 protected internal virtual FilterEntity findFilterByIdInternal(string filterId)
 {
     return(DbEntityManager.selectById(typeof(FilterEntity), filterId));
 }
Example #11
0
        /// <summary>
        /// general history event insert behavior </summary>
        protected internal virtual void insertOrUpdate(HistoryEvent historyEvent)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager dbEntityManager = getDbEntityManager();
            DbEntityManager dbEntityManager = DbEntityManager;

            if (isInitialEvent(historyEvent))
            {
                dbEntityManager.insert(historyEvent);
            }
            else
            {
                if (dbEntityManager.getCachedEntity(historyEvent.GetType(), historyEvent.Id) == null)
                {
                    if (historyEvent is HistoricScopeInstanceEvent)
                    {
                        // if this is a scope, get start time from existing event in DB
                        HistoricScopeInstanceEvent existingEvent = (HistoricScopeInstanceEvent)dbEntityManager.selectById(historyEvent.GetType(), historyEvent.Id);
                        if (existingEvent != null)
                        {
                            HistoricScopeInstanceEvent historicScopeInstanceEvent = (HistoricScopeInstanceEvent)historyEvent;
                            historicScopeInstanceEvent.StartTime = existingEvent.StartTime;
                        }
                    }
                    if (string.ReferenceEquals(historyEvent.Id, null))
                    {
                        //          dbSqlSession.insert(historyEvent);
                    }
                    else
                    {
                        dbEntityManager.merge(historyEvent);
                    }
                }
            }
        }
Example #12
0
        // users /////////////////////////////////////////

        public virtual UserEntity findUserById(string userId)
        {
            checkAuthorization(Permissions.READ, Resources.USER, userId);
            return(DbEntityManager.selectById(typeof(UserEntity), userId));
        }
Example #13
0
 public virtual PropertyEntity findPropertyById(string propertyId)
 {
     return(DbEntityManager.selectById(typeof(PropertyEntity), propertyId));
 }
Example #14
0
 public virtual HistoricBatchEntity findHistoricBatchById(string batchId)
 {
     return(DbEntityManager.selectById(typeof(HistoricBatchEntity), batchId));
 }
Example #15
0
 public virtual CaseExecutionEntity findCaseExecutionById(string caseExecutionId)
 {
     return(DbEntityManager.selectById(typeof(CaseExecutionEntity), caseExecutionId));
 }
Example #16
0
	  public virtual JobDefinitionEntity findById(string jobDefinitionId)
	  {
		return DbEntityManager.selectById(typeof(JobDefinitionEntity), jobDefinitionId);
	  }
Example #17
0
 public virtual ExecutionEntity findExecutionById(string executionId)
 {
     return(DbEntityManager.selectById(typeof(ExecutionEntity), executionId));
 }
Example #18
0
        // groups //////////////////////////////////////////

        public virtual GroupEntity findGroupById(string groupId)
        {
            checkAuthorization(Permissions.READ, Resources.GROUP, groupId);
            return(DbEntityManager.selectById(typeof(GroupEntity), groupId));
        }
Example #19
0
        //tenants //////////////////////////////////////////

        public virtual TenantEntity findTenantById(string tenantId)
        {
            checkAuthorization(Permissions.READ, Resources.TENANT, tenantId);
            return(DbEntityManager.selectById(typeof(TenantEntity), tenantId));
        }
Example #20
0
 public virtual ExternalTaskEntity findExternalTaskById(string id)
 {
     return(DbEntityManager.selectById(typeof(ExternalTaskEntity), id));
 }
Example #21
0
 public virtual DeploymentEntity findDeploymentById(string deploymentId)
 {
     return(DbEntityManager.selectById(typeof(DeploymentEntity), deploymentId));
 }
Example #22
0
 public virtual Incident findIncidentById(string id)
 {
     return((Incident)DbEntityManager.selectById(typeof(IncidentEntity), id));
 }
Example #23
0
 public virtual TaskEntity findTaskById(string id)
 {
     ensureNotNull("Invalid task id", "id", id);
     return(DbEntityManager.selectById(typeof(TaskEntity), id));
 }
Example #24
0
 public virtual BatchEntity findBatchById(string id)
 {
     return(DbEntityManager.selectById(typeof(BatchEntity), id));
 }
Example #25
0
 public virtual DecisionDefinitionEntity findDecisionDefinitionById(string decisionDefinitionId)
 {
     return(DbEntityManager.selectById(typeof(DecisionDefinitionEntity), decisionDefinitionId));
 }
Example #26
0
 public virtual UserOperationLogEntry findOperationLogById(string entryId)
 {
     return(DbEntityManager.selectById(typeof(UserOperationLogEntryEventEntity), entryId));
 }