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


Java ProcessDefinitionQuery.singleResult方法代码示例

本文整理汇总了Java中org.activiti.engine.repository.ProcessDefinitionQuery.singleResult方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessDefinitionQuery.singleResult方法的具体用法?Java ProcessDefinitionQuery.singleResult怎么用?Java ProcessDefinitionQuery.singleResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.activiti.engine.repository.ProcessDefinitionQuery的用法示例。


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

示例1: getProcessDefinition

import org.activiti.engine.repository.ProcessDefinitionQuery; //导入方法依赖的package包/类
@Override
public ProcessDefinition getProcessDefinition(String definitionId)
{
    ProcessDefinitionQuery query = activitiProcessEngine
            .getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionId(definitionId);
    
    if (tenantService.isEnabled() && deployWorkflowsInTenant) 
    {
        query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%");
    }
    
    org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult();
    
    if (processDefinition == null) 
    {
        throw new EntityNotFoundException(definitionId); 
    }

    ProcessDefinition deploymentRest = createProcessDefinitionRest((ProcessDefinitionEntity) processDefinition);
    return deploymentRest;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:ProcessDefinitionsImpl.java

示例2: definitionCache

import org.activiti.engine.repository.ProcessDefinitionQuery; //导入方法依赖的package包/类
/**
 * 流程定义对象缓存
 *
 * @param definitionMap
 * @param processDefinitionId
 */
private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) {
    if (definitionMap.get(processDefinitionId) == null) {
        ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
        processDefinitionQuery.processDefinitionId(processDefinitionId);
        ProcessDefinition processDefinition = processDefinitionQuery.singleResult();

        // 放入缓存
        definitionMap.put(processDefinitionId, processDefinition);
    }
}
 
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:17,代码来源:HistoryProcessInstanceController.java

示例3: getProcessDefinitionImage

import org.activiti.engine.repository.ProcessDefinitionQuery; //导入方法依赖的package包/类
@Override
public BinaryResource getProcessDefinitionImage(String definitionId)
{
	ProcessDefinitionQuery query = activitiProcessEngine
            .getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionId(definitionId);
    
    if (tenantService.isEnabled() && deployWorkflowsInTenant) 
    {
        query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%");
    }
    
    org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult();
    
    if (processDefinition == null) 
    {
        throw new EntityNotFoundException(definitionId); 
    }
    
    try
    {
    	InputStream processDiagram = activitiProcessEngine.getRepositoryService().getProcessDiagram(definitionId);
    	if (processDiagram != null) 
    	{
         File file = TempFileProvider.createTempFile(definitionId + UUID.randomUUID(), ".png");
         FileOutputStream fos = new FileOutputStream(file);
         IOUtils.copy(processDiagram, fos);
         fos.close();
             
         return new FileBinaryResource(file);
    	}
    	else
    	{
    		throw new ApiException("No image available for definitionId " + definitionId); 
    	}
    }
    catch (IOException error)
    {
        throw new ApiException("Error while getting process definition image.");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:43,代码来源:ProcessDefinitionsImpl.java

示例4: testClasspathDeployment

import org.activiti.engine.repository.ProcessDefinitionQuery; //导入方法依赖的package包/类
@Test
    public void testClasspathDeployment() throws Exception {

        // 定义classpath
        String bpmnClasspath = "chapter5/candidateUserInUserTask.bpmn";
        String pngClasspath = "chapter5/candidateUserInUserTask.png";

        // 创建部署构建器
        DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();

        // 添加资源
        deploymentBuilder.addClasspathResource(bpmnClasspath);
        deploymentBuilder.addClasspathResource(pngClasspath);

        // 执行部署
        deploymentBuilder.deploy();

        // 验证流程定义是否部署成功
        ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
        long count = processDefinitionQuery.processDefinitionKey("candidateUserInUserTask").count();
        assertEquals(1, count);

        // 读取图片文件
        ProcessDefinition processDefinition = processDefinitionQuery.singleResult();
        String diagramResourceName = processDefinition.getDiagramResourceName();
        assertEquals(pngClasspath, diagramResourceName);

        Map<String, Object> vars = new HashMap<String, Object>();
        ArrayList<Date> objs = new ArrayList<Date>();
        objs.add(new Date());
        vars.put("list", objs);
//        vars.put("aaa", "333");
        runtimeService.startProcessInstanceByKey("candidateUserInUserTask", vars);
        List<Task> list = taskService.createTaskQuery().includeProcessVariables().list();
        System.out.println(list);
        Task task = taskService.createTaskQuery().taskId(list.get(0).getId())
                .includeProcessVariables().includeTaskLocalVariables().singleResult();
        CommandContext commandContext = Context.getCommandContext();
        System.out.println(task);
        System.out.println(commandContext);

//        ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
//        Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration());
//        Context.setCommandContext(defaultProcessEngine.getProcessEngineConfiguration().getCommandContextFactory().createCommandContext(null));
        System.out.println(Context.getCommandContext());
        System.out.println(task.getProcessVariables());
    }
 
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:48,代码来源:ClasspathDeploymentTest.java


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