本文整理汇总了Java中org.activiti.image.impl.DefaultProcessDiagramGenerator类的典型用法代码示例。如果您正苦于以下问题:Java DefaultProcessDiagramGenerator类的具体用法?Java DefaultProcessDiagramGenerator怎么用?Java DefaultProcessDiagramGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultProcessDiagramGenerator类属于org.activiti.image.impl包,在下文中一共展示了DefaultProcessDiagramGenerator类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWorkflowImage
import org.activiti.image.impl.DefaultProcessDiagramGenerator; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public InputStream getWorkflowImage(String workflowInstanceId)
{
String processInstanceId = createLocalId(workflowInstanceId);
ExecutionEntity pi = (ExecutionEntity) runtimeService.createProcessInstanceQuery()
.processInstanceId(processInstanceId).singleResult();
// If the process is finished, there is no diagram available
if (pi != null)
{
// Fetch the bpmn model
BpmnModel model = repoService.getBpmnModel(pi.getProcessDefinitionId());
if (model != null && model.getLocationMap().size() > 0)
{
ProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
return generator.generateDiagram(model,
ActivitiConstants.PROCESS_INSTANCE_IMAGE_FORMAT,
runtimeService.getActiveActivityIds(processInstanceId));
}
}
return null;
}
示例2: getProcessInstanceDiagram
import org.activiti.image.impl.DefaultProcessDiagramGenerator; //导入依赖的package包/类
@GET
@Path("/{processInstanceId}/diagram")
@Produces(MediaType.APPLICATION_JSON)
public Response getProcessInstanceDiagram(@PathParam("processInstanceId") String processInstanceId) {
ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
ProcessDefinition pde = repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());
if (pde != null && pde.hasGraphicalNotation()) {
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
InputStream diagramStream = new DefaultProcessDiagramGenerator().generateDiagram(repositoryService
.getBpmnModel(pde.getId()), "png",
runtimeService.getActiveActivityIds(processInstanceId));
try {
return Response.ok().type("image/png").entity(IOUtils.toByteArray(diagramStream)).build();
} catch (Exception e) {
throw new ActivitiIllegalArgumentException("Error exporting diagram", e);
}
} else {
throw new ActivitiIllegalArgumentException("Process instance with id '" + processInstance.getId()
+ "' has no graphical notation defined.");
}
}
示例3: execute
import org.activiti.image.impl.DefaultProcessDiagramGenerator; //导入依赖的package包/类
public InputStream execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = new GetDeploymentProcessDefinitionCmd(
processDefinitionId).execute(commandContext);
String diagramResourceName = processDefinition.getDiagramResourceName();
String deploymentId = processDefinition.getDeploymentId();
if (deploymentId != null) {
byte[] bytes = commandContext
.getResourceEntityManager()
.findResourceByDeploymentIdAndResourceName(deploymentId,
diagramResourceName).getBytes();
InputStream inputStream = new ByteArrayInputStream(bytes);
return inputStream;
}
GetBpmnModelCmd getBpmnModelCmd = new GetBpmnModelCmd(
processDefinitionId);
BpmnModel bpmnModel = getBpmnModelCmd.execute(commandContext);
ProcessEngineConfiguration processEngineConfiguration = Context
.getProcessEngineConfiguration();
InputStream is = new DefaultProcessDiagramGenerator().generateDiagram(
bpmnModel, "png",
processEngineConfiguration.getActivityFontName(),
processEngineConfiguration.getLabelFontName(), null);
return is;
}
示例4: getDiagramByte
import org.activiti.image.impl.DefaultProcessDiagramGenerator; //导入依赖的package包/类
private static byte[] getDiagramByte(ProcessInstance pi) throws Exception {
byte[] data = null;
ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
BpmnModel model = repositoryService.getBpmnModel(pi.getProcessDefinitionId());
InputStream is = processDiagramGenerator.generateDiagram(
model,
"png",
runtimeService.getActiveActivityIds(pi.getId()));
data = IOUtils.toByteArray(is);
is.close();
is = null;
return data;
}
示例5: getProcessImage
import org.activiti.image.impl.DefaultProcessDiagramGenerator; //导入依赖的package包/类
@Override
public BinaryResource getProcessImage(String processId)
{
validateIfUserAllowedToWorkWithProcess(processId);
ProcessInstance processInstance = activitiProcessEngine.getRuntimeService()
.createProcessInstanceQuery()
.processInstanceId(processId)
.singleResult();
if (processInstance == null)
{
throw new EntityNotFoundException(processId);
}
try
{
BpmnModel model = activitiProcessEngine.getRepositoryService().getBpmnModel(processInstance.getProcessDefinitionId());
if(model != null && model.getLocationMap().size() > 0)
{
List<String> activeActivities = activitiProcessEngine.getRuntimeService().getActiveActivityIds(processId);
ProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
InputStream generateDiagram = generator.generateDiagram(model, "png", activeActivities);
File file = TempFileProvider.createTempFile(processId + UUID.randomUUID(), ".png");
FileOutputStream fos = new FileOutputStream(file);
IOUtils.copy(generateDiagram, fos);
fos.close();
return new FileBinaryResource(file);
}
else
{
throw new EntityNotFoundException(processId + "/image");
}
}
catch (IOException error)
{
throw new ApiException("Error while getting process image.");
}
}