当前位置: 首页>>代码示例>>Java>>正文


Java Task类代码示例

本文整理汇总了Java中org.activiti.engine.task.Task的典型用法代码示例。如果您正苦于以下问题:Java Task类的具体用法?Java Task怎么用?Java Task使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Task类属于org.activiti.engine.task包,在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.activiti.engine.task.Task; //导入依赖的package包/类
@Override
public Boolean execute(CommandContext commandContext) {
    if (taskId == null) {
        throw new ActivitiIllegalArgumentException("taskId is null");
    }
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }

    TaskEntity task = commandContext
            .getTaskEntityManager()
            .findTaskById(taskId);

    if (task == null) {
        throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
    }
    boolean hasVariable = false;

    if (isLocal) {
        hasVariable = task.hasVariableLocal(variableName);
    } else {
        hasVariable = task.hasVariable(variableName);
    }

    return hasVariable;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:27,代码来源:HasTaskVariableCmd.java

示例2: setTaskProperties

import org.activiti.engine.task.Task; //导入依赖的package包/类
/**
 * Sets the properties on the task, using Activiti API.
 */
public void setTaskProperties(Task task, Map<QName, Serializable> properties)
{
    if(properties==null || properties.isEmpty())
        return;
    
    TypeDefinition type = typeManager.getFullTaskDefinition(task);
    Map<String, Object> variablesToSet = handlerRegistry.handleVariablesToSet(properties, type, task, Task.class);

    TaskService taskService = activitiUtil.getTaskService();
    
    // Will be set when an assignee is present in passed properties. 
    taskService.saveTask(task);            

    // Set the collected variables on the task
    taskService.setVariablesLocal(task.getId(), variablesToSet);

    setTaskOwner(task, properties);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:ActivitiPropertyConverter.java

示例3: TaskVo

import org.activiti.engine.task.Task; //导入依赖的package包/类
public TaskVo(Task task) {
	this.id = task.getId();
	this.name = task.getName();
	this.title = task.getDescription();
	this.priority = task.getPriority();
	this.owner = task.getOwner();
	this.assignee = task.getAssignee();
	this.processInstanceId = task.getProcessInstanceId();
	this.executionId = task.getExecutionId();
	this.processDefinitionId = task.getProcessDefinitionId();
	this.createTime = task.getCreateTime();
	this.taskDefinitionKey = task.getTaskDefinitionKey();
	this.dueDate = task.getDueDate();
	this.category = task.getCategory();
	this.parentTaskId = task.getParentTaskId();
	this.tenantId = task.getTenantId();
	this.formKey = task.getFormKey();
	this.suspended = task.isSuspended();
}
 
开发者ID:KayuraTeam,项目名称:kayura-activiti,代码行数:20,代码来源:TaskVo.java

示例4: execute

import org.activiti.engine.task.Task; //导入依赖的package包/类
@Override
public T execute(CommandContext commandContext) {

    if (taskId == null) {
        throw new ActivitiIllegalArgumentException("taskId is null");
    }

    TaskEntity task = commandContext
            .getTaskEntityManager()
            .findTaskById(taskId);

    if (task == null) {
        throw new ActivitiObjectNotFoundException("Cannot find task with id " + taskId, Task.class);
    }

    if (task.isSuspended()) {
        throw new ActivitiException(getSuspendedTaskException());
    }

    return execute(commandContext, task);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:22,代码来源:NeedsActiveTaskCmd.java

示例5: getTaskForTimer

import org.activiti.engine.task.Task; //导入依赖的package包/类
private WorkflowTask getTaskForTimer(Job job, ProcessInstance processInstance, Execution jobExecution) 
{
    if (job instanceof TimerEntity) 
    {
        ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
        List<String> activeActivityIds = runtimeService.getActiveActivityIds(jobExecution.getId());
        
        if(activeActivityIds.size() == 1)
        {
            PvmActivity targetActivity = def.findActivity(activeActivityIds.get(0));
            if(targetActivity != null)
            {
                // Only get tasks of active activity is a user-task 
                String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE);
                if(ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType))
                {
                    Task task = taskService.createTaskQuery().executionId(job.getExecutionId()).singleResult();
                    return typeConverter.convert(task);
                }
            }
        }
    }
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ActivitiWorkflowEngine.java

示例6: addTasksForCandidateGroups

import org.activiti.engine.task.Task; //导入依赖的package包/类
private void addTasksForCandidateGroups(List<String> groupNames, Map<String, Task> resultingTasks)
{
    if(groupNames != null && groupNames.size() > 0) {
        
        TaskQuery query = taskService.createTaskQuery().taskCandidateGroupIn(groupNames);
        
        // Additional filtering on the tenant-property in case workflow-definitions are shared across tenants
        if(!activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && tenantService.isEnabled()) {
            query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
        }
        
        List<Task> tasks =query.list();
        for(Task task : tasks)
        {
            resultingTasks.put(task.getId(), task);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:ActivitiWorkflowEngine.java

示例7: queryRuntimeTasks

import org.activiti.engine.task.Task; //导入依赖的package包/类
private List<WorkflowTask> queryRuntimeTasks(WorkflowTaskQuery query)
{
   // Runtime-tasks only exist on process-instances that are active
   // so no use in querying runtime tasks if not active
   if (!Boolean.FALSE.equals(query.isActive()))
   {
       TaskQuery taskQuery = createRuntimeTaskQuery(query);

       List<Task> results;
       int limit = query.getLimit();
       if (limit > 0)
       {
           results = taskQuery.listPage(0, limit);
       }
       else
       {
           results = taskQuery.list();
       }
       return getValidWorkflowTasks(results);
   }
   return new ArrayList<WorkflowTask>();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:ActivitiWorkflowEngine.java

示例8: setTaskOwner

import org.activiti.engine.task.Task; //导入依赖的package包/类
/**
 * @param task Task
 * @param properties Map<QName, Serializable>
 */
private void setTaskOwner(Task task, Map<QName, Serializable> properties)
{
    QName ownerKey = ContentModel.PROP_OWNER;
    if (properties.containsKey(ownerKey))
    {
        Serializable owner = properties.get(ownerKey);
        if (owner != null && !(owner instanceof String))
        {
            throw getInvalidPropertyValueException(ownerKey, owner);
        }
        String assignee = (String) owner;
        String currentAssignee = task.getAssignee();
        // Only set the assignee if the value has changes to prevent
        // triggering assignementhandlers when not needed
        if (ObjectUtils.equals(currentAssignee, assignee)==false)
        {
            activitiUtil.getTaskService().setAssignee(task.getId(), assignee);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ActivitiPropertyConverter.java

示例9: getTaskDefinition

import org.activiti.engine.task.Task; //导入依赖的package包/类
public WorkflowTaskDefinition getTaskDefinition(Task task)
{
	// Get the task-form used (retrieved from cached process-definition)
	TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    String taskDefId = null;
    if(taskFormData != null) 
    {
        taskDefId = taskFormData.getFormKey();
    }
    
    // Fetch node based on cached process-definition
    ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(task.getProcessDefinitionId());
    WorkflowNode node = convert(procDef.findActivity(task.getTaskDefinitionKey()), true);
    
    return factory.createTaskDefinition(taskDefId, node, taskDefId, false);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:ActivitiTypeConverter.java

示例10: LazyActivitiWorkflowTask

import org.activiti.engine.task.Task; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public LazyActivitiWorkflowTask(Task task, ActivitiTypeConverter typeConverter, TenantService tenantService, String workflowDefinitionName) 
{
	super(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, task.getId()), null, null, null, null, null, null, null);
	this.task = task;
	this.activitiTypeConverter = typeConverter;
	this.lazyPropertiesMap = new LazyPropertiesMap();
	
	// Fetch task-definition and a partially-initialized WorkflowTask (not including properties and path)
	WorkflowTaskDefinition taskDefinition = activitiTypeConverter.getTaskDefinition(task);
	
	WorkflowTask partiallyInitialized = typeConverter.getWorkflowObjectFactory().createTask(task.getId(), taskDefinition, taskDefinition.getId(), task.getName(),
			task.getDescription(), WorkflowTaskState.IN_PROGRESS, null, workflowDefinitionName , lazyPropertiesMap);
	
	this.definition = taskDefinition;
	this.name = taskDefinition.getId();
	this.title = partiallyInitialized.getTitle();
	this.description = partiallyInitialized.getDescription();
	this.state = partiallyInitialized.getState();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:LazyActivitiWorkflowTask.java

示例11: testGetTaskById

import org.activiti.engine.task.Task; //导入依赖的package包/类
@Test
public void testGetTaskById() throws Exception
{
    try 
    {
        workflowEngine.getTaskById("Foo");
        fail("Should blow up if Id is wrong format!");
    }
    catch(WorkflowException e)
    {
        // Do Nothing
    }
    
    WorkflowTask result = workflowEngine.getTaskById(ActivitiConstants.ENGINE_ID + "$Foo");
    assertNull("Should not find any result for fake (but valid) Id.", result);
    
    WorkflowPath path = workflowEngine.startWorkflow(workflowDef.getId(), new HashMap<QName, Serializable>());
    Task task = taskService.createTaskQuery()
        .executionId(BPMEngineRegistry.getLocalId(path.getId()))
        .singleResult();
    assertNotNull("Task shoudl exist!", task);
    
    String taskId = BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, task.getId());
    WorkflowTask wfTask = workflowEngine.getTaskById(taskId);
    assertNotNull(wfTask);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:ActivitiTaskComponentTest.java

示例12: testGetStartTaskById

import org.activiti.engine.task.Task; //导入依赖的package包/类
@Test
public void testGetStartTaskById() throws Exception
{
  
    WorkflowTask result = workflowEngine.getTaskById(ActivitiConstants.ENGINE_ID + "$Foo");
    assertNull("Should not find any result for fake (but valid) Id.", result);
    
    WorkflowPath path = workflowEngine.startWorkflow(workflowDef.getId(), new HashMap<QName, Serializable>());
   
    Task task = taskService.createTaskQuery()
        .executionId(BPMEngineRegistry.getLocalId(path.getId()))
        .singleResult();
    
    // A start task should be available for the process instance
    String startTaskId = ActivitiConstants.START_TASK_PREFIX + task.getProcessInstanceId();
    
    String taskId = createGlobalId(startTaskId);
    WorkflowTask wfTask = workflowEngine.getTaskById(taskId);
    assertNotNull(wfTask);
    assertEquals(createGlobalId(task.getProcessInstanceId()), wfTask.getPath().getId());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:ActivitiTaskComponentTest.java

示例13: checkTask

import org.activiti.engine.task.Task; //导入依赖的package包/类
@Test
public void checkTask() {
	Map<String, Object> variables = mapper.mapToVariables(taskResource);
	Assert.assertEquals(1, variables.size());
	Assert.assertEquals(47, variables.get("someIntValue"));

	TestTask taskCopy = new TestTask();
	mapper.mapFromVariables(taskCopy, variables);
	checkTaskResource(taskCopy);

	TaskInfo task = Mockito.mock(TaskInfo.class);
	Mockito.when(task.getName()).thenReturn("someTask");
	Mockito.when(task.getTaskLocalVariables()).thenReturn(variables);
	TestTask taskResourceCopy = mapper.mapToResource(TestTask.class, task);
	checkTaskResource(taskResourceCopy);
	Assert.assertEquals("someTask", taskResourceCopy.getName());

	Map<String, Object> updatedVariables = Mockito.spy(new HashMap<String, Object>());
	Task updatedTask = Mockito.mock(Task.class);
	Mockito.when(updatedTask.getTaskLocalVariables()).thenReturn(updatedVariables);
	taskResourceCopy.setPriority(12);
	taskResourceCopy.setSomeIntValue(5);
	mapper.mapFromResource(taskResourceCopy, updatedTask);
	Mockito.verify(updatedTask, Mockito.times(1)).setPriority(Mockito.eq(12));
	Mockito.verify(updatedVariables, Mockito.times(1)).put(Mockito.eq("someIntValue"), Mockito.eq(Integer.valueOf(5)));
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:27,代码来源:ActivitiResourceMapperTest.java

示例14: checkForm

import org.activiti.engine.task.Task; //导入依赖的package包/类
@Test
public void checkForm() {
	Map<String, Object> variables = mapper.mapToVariables(formResource);
	Assert.assertEquals(1, variables.size());
	Assert.assertEquals(Boolean.TRUE, variables.get("approved"));

	TestForm resourceCopy = new TestForm();
	mapper.mapFromVariables(resourceCopy, variables);
	checkFormResource(resourceCopy);

	List<FormProperty> formProperties = new ArrayList<>();
	FormProperty formProperty = Mockito.mock(FormProperty.class);
	Mockito.when(formProperty.getId()).thenReturn("approved");
	Mockito.when(formProperty.getValue()).thenReturn("true");
	formProperties.add(formProperty);

	TaskFormData formData = Mockito.mock(TaskFormData.class);
	Mockito.when(formData.getFormProperties()).thenReturn(formProperties);
	Task task = Mockito.mock(Task.class);
	Mockito.when(task.getId()).thenReturn("someTask");
	Mockito.when(formData.getTask()).thenReturn(task);
	TestForm formCopy = mapper.mapToResource(TestForm.class, formData);
	checkFormResource(formCopy);
	Assert.assertEquals("someTask", formCopy.getId());
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:26,代码来源:ActivitiResourceMapperTest.java

示例15: execute

import org.activiti.engine.task.Task; //导入依赖的package包/类
@Scheduled(cron = "0/10 * * * * ?")
public void execute() throws Exception {
    logger.info("start");

    List<Task> tasks = processEngine.getTaskService().createTaskQuery()
            .list();

    for (Task task : tasks) {
        if (task.getDueDate() != null) {
            SendNoticeCmd sendNoticeCmd = new SendNoticeCmd(task.getId());
            processEngine.getManagementService().executeCommand(
                    sendNoticeCmd);
        }
    }

    logger.info("end");
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:18,代码来源:TaskTimeoutJob.java


注:本文中的org.activiti.engine.task.Task类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。