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


Java BpmnModel类代码示例

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


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

示例1: readResource

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
/**
     * 读取带跟踪的图片
     */
    @RequestMapping(value = "/process/trace/auto/{executionId}")
    public void readResource(@PathVariable("executionId") String executionId, HttpServletResponse response)
            throws Exception {
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
        BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
        List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
        // 不使用spring请使用下面的两行代码
//    ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
//    Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration());

        // 使用spring注入引擎请使用下面的这行代码
        processEngineConfiguration = processEngine.getProcessEngineConfiguration();
        Context.setProcessEngineConfiguration((ProcessEngineConfigurationImpl) processEngineConfiguration);

        ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
        InputStream imageStream = diagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds);

        // 输出资源内容到相应对象
        byte[] b = new byte[1024];
        int len;
        while ((len = imageStream.read(b, 0, 1024)) != -1) {
            response.getOutputStream().write(b, 0, len);
        }
    }
 
开发者ID:batizhao,项目名称:microservice,代码行数:28,代码来源:ActivitiController.java

示例2: getWorkflowImage

import org.activiti.bpmn.model.BpmnModel; //导入依赖的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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:ActivitiWorkflowEngine.java

示例3: tracePhoto

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
/**
 * 读取带跟踪的图片
 * @param executionId	环节ID
 * @return	封装了各种节点信息
 */
public InputStream tracePhoto(String processDefinitionId, String executionId) {
	// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
	BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
	
	List<String> activeActivityIds = Lists.newArrayList();
	if (runtimeService.createExecutionQuery().executionId(executionId).count() > 0){
		activeActivityIds = runtimeService.getActiveActivityIds(executionId);
	}
	
	// 不使用spring请使用下面的两行代码
	// ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl)ProcessEngines.getDefaultProcessEngine();
	// Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration());

	// 使用spring注入引擎请使用下面的这行代码
	Context.setProcessEngineConfiguration(processEngine.getProcessEngineConfiguration());

	return ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds);
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:24,代码来源:ActTaskService.java

示例4: testDelegateSpringBeansNotPopulatedAgain

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
/**
 * This method tests the scenario where a java delegate is not populated again with spring beans.
 */
@Test
public void testDelegateSpringBeansNotPopulatedAgain() throws Exception
{
    BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_WORKFLOW);

    ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1");
    serviceTask.setImplementation(MockJavaDelegate.class.getCanonicalName());
    serviceTask.getFieldExtensions().clear();

    // Define the job definition
    jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel));

    // Executing the job twice so that the same JavaDelegate object is used and spring beans are not wired again.
    jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
    jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:20,代码来源:ActivitiDelegateTest.java

示例5: processArtifacts

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
protected void processArtifacts(FlowElementsContainer container,
        BpmnModel model, ArrayNode shapesArrayNode, double containerX,
        double containerY) {
    for (Artifact artifact : container.getArtifacts()) {
        Class<? extends BaseBpmnJsonConverter> converter = convertersToJsonMap
                .get(artifact.getClass());

        if (converter != null) {
            try {
                converter.newInstance().convertToJson(artifact, this,
                        model, container, shapesArrayNode, containerX,
                        containerY);
            } catch (Exception e) {
                LOGGER.error("Error converting {}", artifact, e);
            }
        }
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:19,代码来源:BpmnJsonConverter.java

示例6: processJsonElements

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
public void processJsonElements(JsonNode shapesArrayNode,
        JsonNode modelNode, BaseElement parentElement,
        Map<String, JsonNode> shapeMap, BpmnModel bpmnModel) {
    for (JsonNode shapeNode : shapesArrayNode) {
        String stencilId = BpmnJsonConverterUtil.getStencilId(shapeNode);
        Class<? extends BaseBpmnJsonConverter> converter = convertersToBpmnMap
                .get(stencilId);

        try {
            BaseBpmnJsonConverter converterInstance = converter
                    .newInstance();
            converterInstance.convertToBpmnModel(shapeNode, modelNode,
                    this, parentElement, shapeMap, bpmnModel);
        } catch (Exception e) {
            LOGGER.error("Error converting {}",
                    BpmnJsonConverterUtil.getStencilId(shapeNode), e);
        }
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:20,代码来源:BpmnJsonConverter.java

示例7: traceProcessInstance

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
public List<NodeDTO> traceProcessInstance(String processInstanceId) {
    HistoricProcessInstance historicProcessInstance = processEngine
            .getHistoryService().createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();
    GetBpmnModelCmd getBpmnModelCmd = new GetBpmnModelCmd(
            historicProcessInstance.getProcessDefinitionId());
    BpmnModel bpmnModel = processEngine.getManagementService()
            .executeCommand(getBpmnModelCmd);

    Map<String, GraphicInfo> graphicInfoMap = bpmnModel.getLocationMap();

    List<NodeDTO> nodeDtos = new ArrayList<NodeDTO>();

    for (Map.Entry<String, GraphicInfo> entry : graphicInfoMap.entrySet()) {
        String key = entry.getKey();
        GraphicInfo graphicInfo = entry.getValue();
        nodeDtos.add(this.convertNodeDto(graphicInfo,
                bpmnModel.getFlowElement(key), key, bpmnModel));
    }

    return nodeDtos;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:23,代码来源:TraceService.java

示例8: deploy

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
/**
 * 根据Model部署流程
 */
@RequestMapping(value = "deploy/{modelId}")
public String deploy(@PathVariable("modelId") String modelId, RedirectAttributes redirectAttributes) {
    try {
        Model modelData = repositoryService.getModel(modelId);
        ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
        byte[] bpmnBytes = null;

        BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
        bpmnBytes = new BpmnXMLConverter().convertToXML(model);

        String processName = modelData.getName() + ".bpmn20.xml";
        Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
        redirectAttributes.addFlashAttribute("message", "部署成功,部署ID=" + deployment.getId());
    } catch (Exception e) {
        logger.error("根据模型部署流程失败:modelId={}", modelId, e);
    }
    return "redirect:/workflow/model/list";
}
 
开发者ID:batizhao,项目名称:microservice,代码行数:22,代码来源:ModelController.java

示例9: deployModel

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
@PutMapping("{modelId}/deploy")
public ResponseMessage deployModel(@PathVariable String modelId) throws Exception {
    Model modelData = repositoryService.getModel(modelId);
    if (modelData == null) {
        throw new NotFoundException("模型不存在!");
    }
    ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
    BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
    byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
    String processName = modelData.getName() + ".bpmn20.xml";
    Deployment deployment = repositoryService.createDeployment()
            .name(modelData.getName())
            .addString(processName, new String(bpmnBytes, "utf8"))
            .deploy();
    return ResponseMessage.ok(deployment).include(Deployment.class, "id", "name", "new");
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:17,代码来源:FlowableModelManagerController.java

示例10: convertToModel

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
/***
 * 流程定义转换Model
 * @param processDefinitionId
 * @return
 * @throws UnsupportedEncodingException
 * @throws XMLStreamException
 */
@PutMapping(value = "/convert-to-model/{processDefinitionId}")
public ResponseMessage<Map<String, Object>> convertToModel(@PathVariable("processDefinitionId") String processDefinitionId)
        throws UnsupportedEncodingException, XMLStreamException {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(processDefinitionId).singleResult();
    if (null == processDefinition) {
        throw new NotFoundException();
    }
    InputStream bpmnStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(),
            processDefinition.getResourceName());
    XMLInputFactory xif = XMLInputFactory.newInstance();
    InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8");
    XMLStreamReader xtr = xif.createXMLStreamReader(in);
    BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

    BpmnJsonConverter converter = new BpmnJsonConverter();
    com.fasterxml.jackson.databind.node.ObjectNode modelNode = converter.convertToJson(bpmnModel);
    org.activiti.engine.repository.Model modelData = repositoryService.newModel();
    modelData.setKey(processDefinition.getKey());
    modelData.setName(processDefinition.getResourceName().substring(0, processDefinition.getResourceName().indexOf(".")));
    modelData.setCategory(processDefinition.getDeploymentId());

    ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
    modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, processDefinition.getName());
    modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
    modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, processDefinition.getDescription());
    modelData.setMetaInfo(modelObjectNode.toString());

    repositoryService.saveModel(modelData);

    repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes("utf-8"));
    return ResponseMessage.ok(Collections.singletonMap(MODEL_ID, modelData.getId()));
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:41,代码来源:FlowableDeploymentController.java

示例11: deploy

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
/**
	 * 根据Model部署流程
	 */
	public String deploy(String id) {
		String message = "";
		try {
			org.activiti.engine.repository.Model modelData = repositoryService.getModel(id);
			BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
			JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
			BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode);
			BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
			byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);
			
			String processName = modelData.getName();
			if (!StringUtils.endsWith(processName, ".bpmn20.xml")){
				processName += ".bpmn20.xml";
			}
//			System.out.println("========="+processName+"============"+modelData.getName());
			ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
			Deployment deployment = repositoryService.createDeployment().name(modelData.getName())
					.addInputStream(processName, in).deploy();
//					.addString(processName, new String(bpmnBytes)).deploy();
			
			// 设置流程分类
			List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();
			for (ProcessDefinition processDefinition : list) {
				repositoryService.setProcessDefinitionCategory(processDefinition.getId(), modelData.getCategory());
				message = "部署成功,流程ID=" + processDefinition.getId();
			}
			if (list.size() == 0){
				message = "部署失败,没有流程。";
			}
		} catch (Exception e) {
			throw new ActivitiException("设计模型图不正确,检查模型正确性,模型ID="+id, e);
		}
		return message;
	}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:38,代码来源:ActModelService.java

示例12: export

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
/**
 * 导出model的xml文件
 * @throws IOException 
 * @throws JsonProcessingException 
 */
public void export(String id, HttpServletResponse response) {
	try {
		org.activiti.engine.repository.Model modelData = repositoryService.getModel(id);
		BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
		JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
		BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode);
		BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
		byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);

		ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
		IOUtils.copy(in, response.getOutputStream());
		String filename = bpmnModel.getMainProcess().getId() + ".bpmn20.xml";
		response.setHeader("Content-Disposition", "attachment; filename=" + filename);
		response.flushBuffer();
	} catch (Exception e) {
		throw new ActivitiException("导出model的xml文件失败,模型ID="+id, e);
	}
	
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:25,代码来源:ActModelService.java

示例13: convertToModelTest

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
@Test
public void convertToModelTest() throws Exception {

	BpmnModel bpmnModel = buildModel();
	BpmnXMLConverter converter = new BpmnXMLConverter();
	String xml = new String(converter.convertToXML(bpmnModel), "UTF-8");

	byte[] bytes = xml.getBytes();
	ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);

	XMLInputFactory xif = XMLInputFactory.newInstance();
	InputStreamReader in = new InputStreamReader(inputStream, "UTF-8");
	XMLStreamReader xtr = xif.createXMLStreamReader(in);

	bpmnModel = converter.convertToBpmnModel(xtr);

	xml = new String(converter.convertToXML(bpmnModel), "UTF-8");
	System.out.println(xml);
}
 
开发者ID:KayuraTeam,项目名称:kayura-activiti,代码行数:20,代码来源:BpmnModelTest.java

示例14: readResource

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
/**
 * 读取流程资源
 */
@RequestMapping(value = "trace/data/auto/{executionId}")
public void readResource(@PathVariable("executionId") String executionId, HttpServletResponse response)
        throws Exception {
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
    BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
    List<String> highLightedFlows = getHighLightedFlows(processDefinition, processInstance.getId());
    ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
    InputStream imageStream =diagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds, highLightedFlows);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len;
    while ((len = imageStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:22,代码来源:TraceProcessController.java

示例15: deploy

import org.activiti.bpmn.model.BpmnModel; //导入依赖的package包/类
/**
 * 根据Model部署流程
 */
@RequestMapping(value = "deploy/{modelId}")
public String deploy(@PathVariable("modelId") String modelId, RedirectAttributes redirectAttributes) {
    try {
        Model modelData = repositoryService.getModel(modelId);
        ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
        byte[] bpmnBytes = null;

        BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
        bpmnBytes = new BpmnXMLConverter().convertToXML(model);

        String processName = modelData.getName() + ".bpmn20.xml";
        Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
        redirectAttributes.addFlashAttribute("message", "部署成功,部署ID=" + deployment.getId());
    } catch (Exception e) {
        logger.error("根据模型部署流程失败:modelId={}", modelId, e);
    }
    return "redirect:/chapter20/model/list";
}
 
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:22,代码来源:ModelController.java


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