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


Java BpmnJsonConverter.convertToJson方法代码示例

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


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

示例1: convertToModel

import org.activiti.editor.language.json.converter.BpmnJsonConverter; //导入方法依赖的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

示例2: convertToModel

import org.activiti.editor.language.json.converter.BpmnJsonConverter; //导入方法依赖的package包/类
/**
 * 将部署的流程转换为模型
 * @param procDefId
 * @throws UnsupportedEncodingException
 * @throws XMLStreamException
 */
@Transactional(readOnly = false)
public org.activiti.engine.repository.Model convertToModel(String procDefId) throws UnsupportedEncodingException, XMLStreamException {
	
	ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
	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();
	ObjectNode modelNode = converter.convertToJson(bpmnModel);
	org.activiti.engine.repository.Model modelData = repositoryService.newModel();
	modelData.setKey(processDefinition.getKey());
	modelData.setName(processDefinition.getResourceName());
	modelData.setCategory(processDefinition.getCategory());//.getDeploymentId());
	modelData.setDeploymentId(processDefinition.getDeploymentId());
	modelData.setVersion(Integer.parseInt(String.valueOf(repositoryService.createModelQuery().modelKey(modelData.getKey()).count()+1)));

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

	repositoryService.saveModel(modelData);

	repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes("utf-8"));

	return modelData;
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:39,代码来源:ActProcessService.java

示例3: jsonToModelTest

import org.activiti.editor.language.json.converter.BpmnJsonConverter; //导入方法依赖的package包/类
@Test
public void jsonToModelTest() throws Exception {

	BpmnModel bpmnModel = buildModel();
	BpmnJsonConverter jsonConverter = new BpmnJsonExConverter();
	ObjectNode objectNode = jsonConverter.convertToJson(bpmnModel);
	System.out.println(objectNode.toString());

	bpmnModel = jsonConverter.convertToBpmnModel(objectNode);
	BpmnXMLConverter converter = new BpmnXMLConverter();
	String xml = new String(converter.convertToXML(bpmnModel), "UTF-8");

	System.out.println(xml);
}
 
开发者ID:KayuraTeam,项目名称:kayura-activiti,代码行数:15,代码来源:BpmnModelTest.java

示例4: convertToModel

import org.activiti.editor.language.json.converter.BpmnJsonConverter; //导入方法依赖的package包/类
/**
 * 转换流程定义为模型
 * @param processDefinitionId
 * @return
 * @throws UnsupportedEncodingException
 * @throws XMLStreamException
 */
@RequestMapping(value = "/process/convert-to-model/{processDefinitionId}")
public String convertToModel(@PathVariable("processDefinitionId") String processDefinitionId)
        throws UnsupportedEncodingException, XMLStreamException {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(processDefinitionId).singleResult();
    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();
    ObjectNode modelNode = converter.convertToJson(bpmnModel);
    Model modelData = repositoryService.newModel();
    modelData.setKey(processDefinition.getKey());
    modelData.setName(processDefinition.getResourceName());
    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 "redirect:/chapter20/model/list";
}
 
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:39,代码来源:DeploymentController.java

示例5: convertToJsonTest

import org.activiti.editor.language.json.converter.BpmnJsonConverter; //导入方法依赖的package包/类
public void convertToJsonTest() {

		BpmnModel bpmnModel = buildModel();

		BpmnJsonConverter jsonConverter = new BpmnJsonExConverter();
		ObjectNode objectNode = jsonConverter.convertToJson(bpmnModel);

		System.out.println(objectNode.toString());
	}
 
开发者ID:KayuraTeam,项目名称:kayura-activiti,代码行数:10,代码来源:BpmnModelTest.java


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