Exemplo n.º 1
0
 public virtual void checkDeleteHistoricVariableInstance(HistoricVariableInstanceEntity variable)
 {
     if (variable != null && !TenantManager.isAuthenticatedTenant(variable.TenantId))
     {
         throw LOG.exceptionCommandWithUnauthorizedTenant("delete the historic variable instance '" + variable.Id + "'");
     }
 }
Exemplo n.º 2
0
        public virtual UserOperationLogContextEntryBuilder inContextOf <T1>(HistoricVariableInstanceEntity variable, ResourceDefinitionEntity <T1> definition, IList <PropertyChange> propertyChanges)
        {
            if (propertyChanges == null || propertyChanges.Count == 0)
            {
                if (OPERATION_TYPE_CREATE.Equals(entry_Renamed.OperationType))
                {
                    propertyChanges = Arrays.asList(PropertyChange.EMPTY_CHANGE);
                }
            }
            entry_Renamed.PropertyChanges       = propertyChanges;
            entry_Renamed.RootProcessInstanceId = variable.RootProcessInstanceId;
            entry_Renamed.ProcessDefinitionId   = variable.ProcessDefinitionId;
            entry_Renamed.ProcessInstanceId     = variable.ProcessInstanceId;
            entry_Renamed.ExecutionId           = variable.ExecutionId;
            entry_Renamed.CaseDefinitionId      = variable.CaseDefinitionId;
            entry_Renamed.CaseInstanceId        = variable.CaseInstanceId;
            entry_Renamed.CaseExecutionId       = variable.CaseExecutionId;
            entry_Renamed.TaskId = variable.TaskId;

            if (definition != null)
            {
                if (definition is ProcessDefinitionEntity)
                {
                    entry_Renamed.ProcessDefinitionKey = definition.Key;
                }
                entry_Renamed.DeploymentId = definition.DeploymentId;
            }

            return(this);
        }
Exemplo n.º 3
0
        public override IList <HistoricVariableInstance> executeList(CommandContext commandContext, Page page)
        {
            checkQueryOk();
            ensureVariablesInitialized();
            IList <HistoricVariableInstance> historicVariableInstances = commandContext.HistoricVariableInstanceManager.findHistoricVariableInstancesByQueryCriteria(this, page);

            if (historicVariableInstances != null)
            {
                foreach (HistoricVariableInstance historicVariableInstance in historicVariableInstances)
                {
                    HistoricVariableInstanceEntity variableInstanceEntity = (HistoricVariableInstanceEntity)historicVariableInstance;
                    if (shouldFetchValue(variableInstanceEntity))
                    {
                        try
                        {
                            variableInstanceEntity.getTypedValue(isCustomObjectDeserializationEnabled);
                        }
                        catch (Exception t)
                        {
                            // do not fail if one of the variables fails to load
                            LOG.exceptionWhileGettingValueForVariable(t);
                        }
                    }
                }
            }
            return(historicVariableInstances);
        }
Exemplo n.º 4
0
 public virtual void checkDeleteHistoricVariableInstance(HistoricVariableInstanceEntity variable)
 {
     if (variable != null && !string.ReferenceEquals(variable.ProcessDefinitionKey, null))
     {
         AuthorizationManager.checkAuthorization(DELETE_HISTORY, PROCESS_DEFINITION, variable.ProcessDefinitionKey);
     }
     // XXX if CAM-6570 is implemented, there should be a check for variables of standalone tasks here as well
 }
Exemplo n.º 5
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;
                }
            }
        }
Exemplo n.º 6
0
        public virtual Void execute(CommandContext commandContext)
        {
            ensureNotEmpty(typeof(BadUserRequestException), "variableInstanceId", variableInstanceId);

            HistoricVariableInstanceEntity variable = commandContext.HistoricVariableInstanceManager.findHistoricVariableInstanceByVariableInstanceId(variableInstanceId);

            ensureNotNull(typeof(NotFoundException), "No historic variable instance found with id: " + variableInstanceId, "variable", variable);

            foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.checkDeleteHistoricVariableInstance(variable);
            }

            commandContext.HistoricDetailManager.deleteHistoricDetailsByVariableInstanceId(variableInstanceId);

            commandContext.HistoricVariableInstanceManager.deleteHistoricVariableInstanceByVariableInstanceId(variableInstanceId);

            // create user operation log
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.camunda.bpm.engine.impl.repository.ResourceDefinitionEntity<?> definition = null;
            ResourceDefinitionEntity <object> definition = null;

            try
            {
                if (!string.ReferenceEquals(variable.ProcessDefinitionId, null))
                {
                    definition = commandContext.ProcessEngineConfiguration.DeploymentCache.findDeployedProcessDefinitionById(variable.ProcessDefinitionId);
                }
                else if (!string.ReferenceEquals(variable.CaseDefinitionId, null))
                {
                    definition = commandContext.ProcessEngineConfiguration.DeploymentCache.findDeployedCaseDefinitionById(variable.CaseDefinitionId);
                }
            }
            catch (NullValueException)
            {
                // definition has been deleted already
            }
            commandContext.OperationLogManager.logHistoricVariableOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE_HISTORY, variable, definition, new PropertyChange("name", null, variable.Name));

            return(null);
        }
Exemplo n.º 7
0
        public override IList <HistoricVariableInstance> executeList(CommandContext commandContext, IDictionary <string, object> parameterMap, int firstResult, int maxResults)
        {
            IList <HistoricVariableInstance> historicVariableInstances = commandContext.HistoricVariableInstanceManager.findHistoricVariableInstancesByNativeQuery(parameterMap, firstResult, maxResults);

            if (historicVariableInstances != null)
            {
                foreach (HistoricVariableInstance historicVariableInstance in historicVariableInstances)
                {
                    HistoricVariableInstanceEntity variableInstanceEntity = (HistoricVariableInstanceEntity)historicVariableInstance;
                    try
                    {
                        variableInstanceEntity.getTypedValue(isCustomObjectDeserializationEnabled);
                    }
                    catch (Exception t)
                    {
                        // do not fail if one of the variables fails to load
                        LOG.exceptionWhileGettingValueForVariable(t);
                    }
                }
            }
            return(historicVariableInstances);
        }
Exemplo n.º 8
0
        /// <summary>
        ///     customized insert behavior for HistoricVariableUpdateEventEntity
        /// </summary>
        protected internal virtual void InsertHistoricVariableUpdateEntity(
            HistoricVariableUpdateEventEntity historyEvent)
        {
            log.LogDebug("InsertHistoricVariableUpdateEntityEF缓存:", historyEvent.GetType().Name + " id:" + historyEvent.Id, historyEvent);
            //throw new NotImplementedException();
            //var dbEntityManager = DbEntityManager;

            // insert update only if history level = FULL
            if (ShouldWriteHistoricDetail(historyEvent))
            {
                // insert byte array entity (if applicable)
                var byteValue = historyEvent.ByteValue;
                if (byteValue != null)
                {
                    var byteArrayEntity = new ResourceEntity(historyEvent.VariableName, byteValue);
                    //Context.CommandContext.GetDbEntityManager<ResourceEntity>().Add(byteArrayEntity);//.DbEntityManager.insert(byteArrayEntity);
                    Context.CommandContext.ResourceManager.InsertResource(byteArrayEntity);
                    historyEvent.ByteArrayId = byteArrayEntity.Id;
                }
                //dbEntityManager.Insert(historyEvent);
                historyEventRepository.Add(historyEvent as HistoricDetailEventEntity);
            }

            // always insert/update HistoricProcessVariableInstance
            if (historyEvent.IsEventOfType(HistoryEventTypes.VariableInstanceCreate))
            {
                var persistentObject = new HistoricVariableInstanceEntity(historyEvent);
                //dbEntityManager.insert(persistentObject);
                //Context.CommandContext.GetDbEntityManager<HistoricVariableInstanceEntity>().Add(persistentObject);
                Context.CommandContext.HistoricVariableInstanceManager.Add(persistentObject);
            }
            else if (historyEvent.IsEventOfType(HistoryEventTypes.VariableInstanceUpdate) ||
                     historyEvent.IsEventOfType(HistoryEventTypes.VariableInstanceMigrate))
            {
                HistoricVariableInstanceEntity historicVariableInstanceEntity =
                    //dbEntityManager.selectById<HistoricVariableInstanceEntity>(typeof(HistoricVariableInstanceEntity),historyEvent.VariableInstanceId);
                    //Context.CommandContext.GetDbEntityManager<HistoricVariableInstanceEntity>().Get(historyEvent.VariableInstanceId);
                    Context.CommandContext.HistoricVariableInstanceManager.Get(historyEvent.VariableInstanceId);
                if (historicVariableInstanceEntity != null)
                {
                    historicVariableInstanceEntity.UpdateFromEvent(historyEvent);
                    historicVariableInstanceEntity.State = HistoricVariableInstanceEntity.StateCreated;
                }
                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.
                    var persistentObject = new HistoricVariableInstanceEntity(historyEvent);
                    //Context.CommandContext.GetDbEntityManager<HistoricVariableInstanceEntity>().Add(persistentObject);
                    Context.CommandContext.HistoricVariableInstanceManager.Add(persistentObject);
                }
            }
            else if (historyEvent.IsEventOfType(HistoryEventTypes.VariableInstanceDelete))
            {
                HistoricVariableInstanceEntity historicVariableInstanceEntity =
                    //Context.CommandContext.GetDbEntityManager<HistoricVariableInstanceEntity>().Single(m => m.Id ==
                    //    historyEvent.VariableInstanceId);
                    Context.CommandContext.HistoricVariableInstanceManager.Single(
                        m => m.Id == historyEvent.VariableInstanceId);
                if (historicVariableInstanceEntity != null)
                {
                    //版本更新
                    //historicVariableInstanceEntity.Delete();
                    historicVariableInstanceEntity.State = HistoricVariableInstanceEntity.StateDeleted;
                }
            }
        }
Exemplo n.º 9
0
 protected internal virtual bool shouldFetchValue(HistoricVariableInstanceEntity entity)
 {
     // do not fetch values for byte arrays eagerly (unless requested by the user)
     return(isByteArrayFetchingEnabled || !AbstractTypedValueSerializer.BINARY_VALUE_TYPES.Contains(entity.Serializer.Type.Name));
 }