Package org.activiti.engine.impl.db

Examples of org.activiti.engine.impl.db.DbSqlSession$DeletePersistentObjectOperation


        }

        // 操作修改运行表中的PROC_DEF_ID_字段的值
        String processInstanceId = processInstance.getId();
        String processDefinitionId = processDefinition.getId();
        DbSqlSession dbSqlSession = commandContext.getDbSqlSession();

        // 操作Task表
        TaskEntityManager taskEntityManager = commandContext
                .getTaskEntityManager();
        List<TaskEntity> tasks = taskEntityManager
                .findTasksByProcessInstanceId(processInstanceId);

        for (TaskEntity taskEntity : tasks) {
            taskEntity.setProcessDefinitionId(processDefinitionId);
            taskEntity.update();
        }

        // 操作Execution表
        List<Execution> executions = new ExecutionQueryImpl(commandContext)
                .processInstanceId(processInstanceId).list();

        for (Execution execution : executions) {
            if (execution instanceof ExecutionEntity) {
                ((ExecutionEntity) execution)
                        .setProcessDefinitionId(processDefinitionId);
                dbSqlSession.update((ExecutionEntity) execution);
            }
        }

        // 操作Job表
        List<Job> jobs = new JobQueryImpl(commandContext).processInstanceId(
                processInstanceId).list();

        for (Job job : jobs) {
            ((JobEntity) job).setProcessDefinitionId(processDefinitionId);
            dbSqlSession.update((JobEntity) job);
        }

        JdbcTemplate jdbcTemplate = ApplicationContextHelper
                .getBean(JdbcTemplate.class);

        // 操作Identitylink表
        IdentityLinkEntityManager identityLinkEntityManager = commandContext
                .getIdentityLinkEntityManager();
        List<IdentityLinkEntity> identityLinks = identityLinkEntityManager
                .findIdentityLinksByProcessInstanceId(processInstanceId);

        for (IdentityLinkEntity identityLinkEntity : identityLinks) {
            // identityLinkEntity.setProcessDefId(processDefinitionId);
            // dbSqlSession.update(identityLinkEntity);
            jdbcTemplate
                    .update("update ACT_RU_IDENTITYLINK set PROC_DEF_ID_=? where ID_=?",
                            processDefinitionId, identityLinkEntity.getId());
        }

        // 操作historicProcessInstance表
        HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager = commandContext
                .getHistoricProcessInstanceEntityManager();
        HistoricProcessInstanceEntity historicProcessInstance = historicProcessInstanceEntityManager
                .findHistoricProcessInstance(processInstanceId);
        historicProcessInstance.setProcessDefinitionId(processDefinitionId);
        dbSqlSession.update(historicProcessInstance);

        return null;
    }
View Full Code Here


    attachment.setType(attachmentType);
    attachment.setTaskId(taskId);
    attachment.setProcessInstanceId(processInstanceId);
    attachment.setUrl(url);
   
    DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
    dbSqlSession.insert(attachment);
   
    if (content!=null) {
      byte[] bytes = IoUtil.readInputStream(content, attachmentName);
      ByteArrayEntity byteArray = new ByteArrayEntity(bytes);
      dbSqlSession.insert(byteArray);
      attachment.setContentId(byteArray.getId());
    }

    commandContext.getHistoryManager()
     .createAttachmentComment(taskId, processInstanceId, attachmentName, true);
View Full Code Here

  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void setReplacedBy(InterpretableExecution replacedBy) {
    this.replacedBy = (ExecutionEntity) replacedBy;
   
    CommandContext commandContext = Context.getCommandContext();
    DbSqlSession dbSqlSession = commandContext.getDbSqlSession();

    // update the related tasks
    for (TaskEntity task: getTasks()) {
      task.setExecutionId(replacedBy.getId());
      task.setExecution(this.replacedBy);
      this.replacedBy.addTask(task);
    }
   
    // All tasks have been moved to 'replacedBy', safe to clear the list
    this.tasks.clear();
   
    tasks = dbSqlSession.findInCache(TaskEntity.class);
    for (TaskEntity task: tasks) {
      if (id.equals(task.getExecutionId())) {
        task.setExecutionId(replacedBy.getId());
      }
    }
   
    // update the related jobs
    List<JobEntity> jobs = getJobs();
    for (JobEntity job: jobs) {
      job.setExecution((ExecutionEntity) replacedBy);
    }
   
    // update the related event subscriptions
    List<EventSubscriptionEntity> eventSubscriptions = getEventSubscriptions();
    for (EventSubscriptionEntity subscriptionEntity: eventSubscriptions) {
      subscriptionEntity.setExecution((ExecutionEntity) replacedBy);
    }
   
    // update the related process variables
    List<VariableInstanceEntity> variables = (List) commandContext
      .getVariableInstanceManager()
      .findVariableInstancesByExecutionId(id);
   
    for (VariableInstanceEntity variable: variables) {
      variable.setExecutionId(replacedBy.getId());
    }
    variables = dbSqlSession.findInCache(VariableInstanceEntity.class);
    for (VariableInstanceEntity variable: variables) {
      if (id.equals(variable.getExecutionId())) {
        variable.setExecutionId(replacedBy.getId());
      }
    }
View Full Code Here

    getDbSqlSession().insert((PersistentObject) model);
  }

  public void updateModel(ModelEntity updatedModel) {
    CommandContext commandContext = Context.getCommandContext();
    DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
    dbSqlSession.update(updatedModel);
  }
View Full Code Here

      log.info("dropping and recreating db");
     
      CommandExecutor commandExecutor = ((ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getCommandExecutor();
      commandExecutor.execute(new Command<Object>() {
        public Object execute(CommandContext commandContext) {
          DbSqlSession session = commandContext.getSession(DbSqlSession.class);
          session.dbSchemaDrop();
          session.dbSchemaCreate();
          return null;
        }
      });

      if (exception!=null) {
View Full Code Here

     
      CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor();
      CommandConfig config = new CommandConfig().transactionNotSupported();
      commandExecutor.execute(config, new Command<Object>() {
        public Object execute(CommandContext commandContext) {
          DbSqlSession session = commandContext.getSession(DbSqlSession.class);
          session.dbSchemaDrop();
          session.dbSchemaCreate();
          return null;
        }
      });

      Assert.fail(outputMessage.toString());
View Full Code Here

      log.info("dropping and recreating db");
     
      CommandExecutor commandExecutor = ((ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getCommandExecutor();
      commandExecutor.execute(new Command<Object>() {
        public Object execute(CommandContext commandContext) {
          DbSqlSession session = commandContext.getSession(DbSqlSession.class);
          session.dbSchemaDrop();
          session.dbSchemaCreate();
          return null;
        }
      });

      if (exception!=null) {
View Full Code Here

      keyList.add(processDefinition.getKey());
    }
   
    CommandContext commandContext = Context.getCommandContext();
    ProcessDefinitionEntityManager processDefinitionManager = commandContext.getProcessDefinitionEntityManager();
    DbSqlSession dbSqlSession = commandContext.getSession(DbSqlSession.class);
    for (ProcessDefinitionEntity processDefinition : processDefinitions) {
      List<TimerEntity> timers = new ArrayList<TimerEntity>();
      if (deployment.isNew()) {
        int processDefinitionVersion;

        ProcessDefinitionEntity latestProcessDefinition = null;
        if (processDefinition.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) {
          latestProcessDefinition = processDefinitionManager
              .findLatestProcessDefinitionByKeyAndTenantId(processDefinition.getKey(), processDefinition.getTenantId());
        } else {
          latestProcessDefinition = processDefinitionManager
              .findLatestProcessDefinitionByKey(processDefinition.getKey());
        }
           
        if (latestProcessDefinition != null) {
          processDefinitionVersion = latestProcessDefinition.getVersion() + 1;
        } else {
          processDefinitionVersion = 1;
        }

        processDefinition.setVersion(processDefinitionVersion);
        processDefinition.setDeploymentId(deployment.getId());

        String nextId = idGenerator.getNextId();
        String processDefinitionId = processDefinition.getKey()
          + ":" + processDefinition.getVersion()
          + ":" + nextId; // ACT-505
                  
        // ACT-115: maximum id length is 64 charcaters
        if (processDefinitionId.length() > 64) {         
          processDefinitionId = nextId;
        }
        processDefinition.setId(processDefinitionId);
       
        if(commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
          commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
              ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, processDefinition));
        }

        removeObsoleteTimers(processDefinition);
        addTimerDeclarations(processDefinition, timers);
       
        removeObsoleteMessageEventSubscriptions(processDefinition, latestProcessDefinition);
        addMessageEventSubscriptions(processDefinition);
       
        removeObsoleteSignalEventSubScription(processDefinition, latestProcessDefinition);
        addSignalEventSubscriptions(processDefinition);

        dbSqlSession.insert(processDefinition);
        addAuthorizations(processDefinition);

        if(commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
          commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
              ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, processDefinition));
View Full Code Here

    // details are not updatable so we always provide the same object as the state
    return HistoricDetailEntity.class;
  }
 
  public void delete() {
    DbSqlSession dbSqlSession = Context
      .getCommandContext()
      .getDbSqlSession();

    dbSqlSession.delete(this);
  }
View Full Code Here

    }
  }
 
  public void updateUser(User updatedUser) {
    CommandContext commandContext = Context.getCommandContext();
    DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
    dbSqlSession.update((PersistentObject) updatedUser);
   
    if(getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
      getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
          ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, updatedUser));
    }
View Full Code Here

TOP

Related Classes of org.activiti.engine.impl.db.DbSqlSession$DeletePersistentObjectOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.