Java Code Examples for org.activiti.engine.task.Task#getProcessDefinitionId()

The following examples show how to use org.activiti.engine.task.Task#getProcessDefinitionId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskQueryImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void localize(Task task) {
  task.setLocalizedName(null);
  task.setLocalizedDescription(null);
  
  if (locale != null) {
    String processDefinitionId = task.getProcessDefinitionId();
    if (processDefinitionId != null) {
      ObjectNode languageNode = Context.getLocalizationElementProperties(locale, task.getTaskDefinitionKey(), processDefinitionId, withLocalizationFallback);
      if (languageNode != null) {
        JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME);
        if (languageNameNode != null && languageNameNode.isNull() == false) {
          task.setLocalizedName(languageNameNode.asText());
        }
        
        JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION);
        if (languageDescriptionNode != null && languageDescriptionNode.isNull() == false) {
          task.setLocalizedDescription(languageDescriptionNode.asText());
        }
      }
    }
  }
}
 
Example 2
Source File: TaskQueryImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void localize(Task task) {
    task.setLocalizedName(null);
    task.setLocalizedDescription(null);

    if (locale != null) {
        String processDefinitionId = task.getProcessDefinitionId();
        if (processDefinitionId != null) {
            ObjectNode languageNode = Context.getLocalizationElementProperties(locale, task.getTaskDefinitionKey(), processDefinitionId, withLocalizationFallback);
            if (languageNode != null) {
                JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME);
                if (languageNameNode != null && !languageNameNode.isNull()) {
                    task.setLocalizedName(languageNameNode.asText());
                }

                JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION);
                if (languageDescriptionNode != null && !languageDescriptionNode.isNull()) {
                    task.setLocalizedDescription(languageDescriptionNode.asText());
                }
            }
        }
    }
}
 
Example 3
Source File: AttachmentEntityManagerImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteAttachmentsByTaskId(String taskId) {
  checkHistoryEnabled();
  List<AttachmentEntity> attachments = findAttachmentsByTaskId(taskId);
  boolean dispatchEvents = getEventDispatcher().isEnabled();

  String processInstanceId = null;
  String processDefinitionId = null;
  String executionId = null;

  if (dispatchEvents && attachments != null && !attachments.isEmpty()) {
    // Forced to fetch the task to get hold of the process definition
    // for event-dispatching, if available
    Task task = getTaskEntityManager().findById(taskId);
    if (task != null) {
      processDefinitionId = task.getProcessDefinitionId();
      processInstanceId = task.getProcessInstanceId();
      executionId = task.getExecutionId();
    }
  }

  for (Attachment attachment : attachments) {
    String contentId = attachment.getContentId();
    if (contentId != null) {
      getByteArrayEntityManager().deleteByteArrayById(contentId);
    }
    
    attachmentDataManager.delete((AttachmentEntity) attachment);
    
    if (dispatchEvents) {
      getEventDispatcher().dispatchEvent(
          ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_DELETED, attachment, executionId, processInstanceId, processDefinitionId));
    }
  }
}
 
Example 4
Source File: AttachmentEntityManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void deleteAttachmentsByTaskId(String taskId) {
    checkHistoryEnabled();
    List<AttachmentEntity> attachments = getDbSqlSession().selectList("selectAttachmentsByTaskId", taskId);
    boolean dispatchEvents = getProcessEngineConfiguration().getEventDispatcher().isEnabled();

    String processInstanceId = null;
    String processDefinitionId = null;
    String executionId = null;

    if (dispatchEvents && attachments != null && !attachments.isEmpty()) {
        // Forced to fetch the task to get hold of the process definition for event-dispatching, if available
        Task task = getTaskManager().findTaskById(taskId);
        if (task != null) {
            processDefinitionId = task.getProcessDefinitionId();
            processInstanceId = task.getProcessInstanceId();
            executionId = task.getExecutionId();
        }
    }

    for (AttachmentEntity attachment : attachments) {
        String contentId = attachment.getContentId();
        if (contentId != null) {
            getByteArrayManager().deleteByteArrayById(contentId);
        }
        getDbSqlSession().delete(attachment);
        if (dispatchEvents) {
            getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                    ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_DELETED, attachment, executionId, processInstanceId, processDefinitionId));
        }
    }
}
 
Example 5
Source File: ActivitiInternalProcessConnector.java    From lemon with Apache License 2.0 4 votes vote down vote up
/**
 * 获得任务表单,不包含表单内容.
 */
public FormDTO findTaskForm(String taskId) {
    if (taskId == null) {
        logger.error("taskId cannot be null");

        return null;
    }

    Task task = processEngine.getTaskService().createTaskQuery()
            .taskId(taskId).singleResult();

    if (task == null) {
        logger.error("cannot find task for {}", taskId);

        return null;
    }

    String processDefinitionId = task.getProcessDefinitionId();
    String activityId = task.getTaskDefinitionKey();
    FormDTO formDto = new FormDTO();
    formDto.setTaskId(taskId);

    List<BpmConfOperation> bpmConfOperations = bpmConfOperationManager
            .find("from BpmConfOperation where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
                    processDefinitionId, activityId);

    for (BpmConfOperation bpmConfOperation : bpmConfOperations) {
        formDto.getButtons().add(bpmConfOperation.getValue());
    }

    formDto.setProcessDefinitionId(processDefinitionId);
    formDto.setActivityId(activityId);

    List<BpmConfForm> bpmConfForms = bpmConfFormManager
            .find("from BpmConfForm where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
                    processDefinitionId, activityId);

    if (!bpmConfForms.isEmpty()) {
        BpmConfForm bpmConfForm = bpmConfForms.get(0);

        if (!Integer.valueOf(2).equals(bpmConfForm.getStatus())) {
            // 外部表单
            if (Integer.valueOf(1).equals(bpmConfForm.getType())) {
                formDto.setRedirect(true);
                formDto.setUrl(bpmConfForm.getValue());
            } else {
                formDto.setCode(bpmConfForm.getValue());
            }
        }
    }

    return formDto;
}