本文整理汇总了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;
}
示例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);
}
}
示例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.");
}
}
示例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());
}