|
@@ -1,10 +1,12 @@
|
|
|
package com.activiti6.controller.editor;
|
|
|
|
|
|
-import java.io.ByteArrayInputStream;
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.InputStream;
|
|
|
+import java.io.*;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import org.activiti.bpmn.converter.BpmnXMLConverter;
|
|
|
+import org.activiti.bpmn.model.BpmnModel;
|
|
|
import org.activiti.editor.constants.ModelDataJsonConstants;
|
|
|
+import org.activiti.editor.language.json.converter.BpmnJsonConverter;
|
|
|
import org.activiti.engine.ActivitiException;
|
|
|
import org.activiti.engine.RepositoryService;
|
|
|
import org.activiti.engine.repository.Model;
|
|
@@ -23,6 +25,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
+
|
|
|
+import javax.xml.stream.XMLInputFactory;
|
|
|
+import javax.xml.stream.XMLStreamException;
|
|
|
+import javax.xml.stream.XMLStreamReader;
|
|
|
+
|
|
|
/**
|
|
|
* 流程信息入库
|
|
|
* liuzhize 2019年3月7日下午3:32:32
|
|
@@ -62,27 +69,37 @@ public class ModelSaveRestResource implements ModelDataJsonConstants {
|
|
|
modelJson.put(MODEL_DESCRIPTION, description);
|
|
|
model.setMetaInfo(modelJson.toString());
|
|
|
model.setName(name);
|
|
|
+
|
|
|
repositoryService.saveModel(model);
|
|
|
|
|
|
repositoryService.addModelEditorSource(model.getId(), json_xml.getBytes("utf-8"));
|
|
|
-
|
|
|
- InputStream svgStream = new ByteArrayInputStream(svg_xml.getBytes("utf-8"));
|
|
|
- TranscoderInput input = new TranscoderInput(svgStream);
|
|
|
-
|
|
|
- PNGTranscoder transcoder = new PNGTranscoder();
|
|
|
- // Setup output
|
|
|
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
|
|
- TranscoderOutput output = new TranscoderOutput(outStream);
|
|
|
-
|
|
|
- // Do the transformation
|
|
|
- transcoder.transcode(input, output);
|
|
|
- final byte[] result = outStream.toByteArray();
|
|
|
- repositoryService.addModelEditorSourceExtra(model.getId(), result);
|
|
|
- outStream.close();
|
|
|
+// test(modelId);
|
|
|
+//
|
|
|
+// InputStream svgStream = new ByteArrayInputStream(svg_xml.getBytes("utf-8"));
|
|
|
+// TranscoderInput input = new TranscoderInput(svgStream);
|
|
|
+//
|
|
|
+// PNGTranscoder transcoder = new PNGTranscoder();
|
|
|
+// // Setup output
|
|
|
+// ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
|
|
+// TranscoderOutput output = new TranscoderOutput(outStream);
|
|
|
+//
|
|
|
+// // Do the transformation
|
|
|
+// transcoder.transcode(input, output);
|
|
|
+// final byte[] result = outStream.toByteArray();
|
|
|
+// repositoryService.addModelEditorSourceExtra(model.getId(), result);
|
|
|
+// outStream.close();
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.error("Error saving model", e);
|
|
|
throw new ActivitiException("Error saving model", e);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void test(String modelId) throws XMLStreamException, IOException {
|
|
|
+ Model modelData = repositoryService.getModel(modelId);
|
|
|
+ ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));// readTree(这里面是json)
|
|
|
+ BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);// 转model
|
|
|
+ System.err.println(JSON.toJSONString(model));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|