13 changed files with 201 additions and 485 deletions
@ -0,0 +1,43 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
|||
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" |
|||
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" |
|||
xmlns:activiti="http://activiti.org/bpmn" |
|||
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" |
|||
xmlns:tns="http://www.activiti.org/test" |
|||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
|||
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
expressionLanguage="http://www.w3.org/1999/XPath" |
|||
id="m1566628843418" |
|||
name="" |
|||
targetNamespace="http://www.activiti.org/test" |
|||
typeLanguage="http://www.w3.org/2001/XMLSchema"> |
|||
<process xmlns="" id="myProcess_1" isClosed="false" isExecutable="true" |
|||
processType="None"> |
|||
<startEvent id="_2" name="开始"/> |
|||
<userTask activiti:exclusive="true" id="_3" name="UserTask"> |
|||
<extensionElements> |
|||
<activiti:taskListener event="create"/> |
|||
</extensionElements> |
|||
</userTask> |
|||
</process> |
|||
<bpmndi:BPMNDiagram xmlns="" |
|||
documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" |
|||
id="Diagram-_1" |
|||
name="New Diagram"> |
|||
<bpmndi:BPMNPlane bpmnElement="myProcess_1"> |
|||
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2"> |
|||
<omgdc:Bounds height="32.0" width="32.0" x="245.0" y="100.0"/> |
|||
<bpmndi:BPMNLabel> |
|||
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/> |
|||
</bpmndi:BPMNLabel> |
|||
</bpmndi:BPMNShape> |
|||
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3"> |
|||
<omgdc:Bounds height="55.0" width="85.0" x="255.0" y="200.0"/> |
|||
<bpmndi:BPMNLabel> |
|||
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/> |
|||
</bpmndi:BPMNLabel> |
|||
</bpmndi:BPMNShape> |
|||
</bpmndi:BPMNPlane> |
|||
</bpmndi:BPMNDiagram> |
|||
</definitions> |
|||
@ -1,92 +0,0 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.annotation.LogOperation; |
|||
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.dto.ModelDTO; |
|||
import com.elink.esua.epdc.service.ActModelService; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.activiti.engine.repository.Model; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 模型管理 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("model") |
|||
@Api(tags="模型管理") |
|||
public class ActModelController { |
|||
@Autowired |
|||
private ActModelService actModelService; |
|||
|
|||
@GetMapping("page") |
|||
@ApiOperation("分页") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , |
|||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , |
|||
@ApiImplicitParam(name = "key", value = "key", paramType = "query", dataType="String"), |
|||
@ApiImplicitParam(name = "name", value = "name", paramType = "query", dataType="String") |
|||
}) |
|||
public Result<PageData<Model>> page(@ApiIgnore @RequestParam Map<String, Object> params){ |
|||
PageData<Model> page = actModelService.page(params); |
|||
|
|||
return new Result<PageData<Model>>().ok(page); |
|||
} |
|||
|
|||
@PostMapping |
|||
@ApiOperation("新增模型") |
|||
@LogOperation("新增模型") |
|||
public Result save(@RequestBody ModelDTO dto) throws Exception{ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto); |
|||
|
|||
actModelService.save(dto.getName(), dto.getKey(), dto.getDescription()); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("deploy/{id}") |
|||
@ApiOperation("部署") |
|||
@LogOperation("部署") |
|||
public Result deploy(@PathVariable("id") String id) { |
|||
actModelService.deploy(id); |
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export/{id}") |
|||
@ApiOperation("导出") |
|||
@LogOperation("导出") |
|||
public void export(@PathVariable("id") String id, @ApiIgnore HttpServletResponse response) { |
|||
actModelService.export(id, response); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@ApiOperation("删除") |
|||
@LogOperation("删除") |
|||
public Result delete(@RequestBody String[] ids) { |
|||
for(String id : ids) { |
|||
actModelService.delete(id); |
|||
} |
|||
return new Result(); |
|||
} |
|||
} |
|||
@ -1,38 +0,0 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.editor.main; |
|||
|
|||
import org.activiti.engine.ActivitiException; |
|||
import org.apache.commons.io.IOUtils; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.io.InputStream; |
|||
|
|||
/** |
|||
* Stencilset |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("service") |
|||
public class StencilsetRestResource { |
|||
|
|||
@RequestMapping(value="/editor/stencilset", method = RequestMethod.GET, produces = "application/json;charset=utf-8") |
|||
public @ResponseBody String getStencilset() { |
|||
InputStream stencilsetStream = this.getClass().getClassLoader().getResourceAsStream("stencilset.json"); |
|||
try { |
|||
return IOUtils.toString(stencilsetStream, "utf-8"); |
|||
} catch (Exception e) { |
|||
throw new ActivitiException("Error while loading stencil set", e); |
|||
} |
|||
} |
|||
} |
|||
@ -1,69 +0,0 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.editor.model; |
|||
|
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.fasterxml.jackson.databind.node.ObjectNode; |
|||
import org.activiti.editor.constants.ModelDataJsonConstants; |
|||
import org.activiti.engine.ActivitiException; |
|||
import org.activiti.engine.RepositoryService; |
|||
import org.activiti.engine.repository.Model; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* Model Editor |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("service") |
|||
public class ModelEditorJsonRestResource implements ModelDataJsonConstants { |
|||
|
|||
protected static final Logger LOGGER = LoggerFactory.getLogger(ModelEditorJsonRestResource.class); |
|||
|
|||
@Autowired |
|||
private RepositoryService repositoryService; |
|||
|
|||
@Autowired |
|||
private ObjectMapper objectMapper; |
|||
|
|||
@RequestMapping(value="/model/{modelId}/json", method = RequestMethod.GET, produces = "application/json") |
|||
public ObjectNode getEditorJson(@PathVariable String modelId) { |
|||
ObjectNode modelNode = null; |
|||
|
|||
Model model = repositoryService.getModel(modelId); |
|||
|
|||
if (model != null) { |
|||
try { |
|||
if (StringUtils.isNotEmpty(model.getMetaInfo())) { |
|||
modelNode = (ObjectNode) objectMapper.readTree(model.getMetaInfo()); |
|||
} else { |
|||
modelNode = objectMapper.createObjectNode(); |
|||
modelNode.put(MODEL_NAME, model.getName()); |
|||
} |
|||
modelNode.put(MODEL_ID, model.getId()); |
|||
ObjectNode editorJsonNode = (ObjectNode) objectMapper.readTree( |
|||
new String(repositoryService.getModelEditorSource(model.getId()), "utf-8")); |
|||
modelNode.set("model", editorJsonNode); |
|||
|
|||
} catch (Exception e) { |
|||
LOGGER.error("Error creating model JSON", e); |
|||
throw new ActivitiException("Error creating model JSON", e); |
|||
} |
|||
} |
|||
return modelNode; |
|||
} |
|||
} |
|||
@ -1,90 +0,0 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.editor.model; |
|||
|
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.fasterxml.jackson.databind.node.ObjectNode; |
|||
import com.elink.esua.epdc.commons.tools.xss.XssHttpServletRequestWrapper; |
|||
import org.activiti.editor.constants.ModelDataJsonConstants; |
|||
import org.activiti.engine.ActivitiException; |
|||
import org.activiti.engine.RepositoryService; |
|||
import org.activiti.engine.repository.Model; |
|||
import org.apache.batik.transcoder.TranscoderInput; |
|||
import org.apache.batik.transcoder.TranscoderOutput; |
|||
import org.apache.batik.transcoder.image.PNGTranscoder; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.InputStream; |
|||
|
|||
/** |
|||
* Model Rest |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("service") |
|||
public class ModelSaveRestResource implements ModelDataJsonConstants { |
|||
protected static final Logger LOGGER = LoggerFactory.getLogger(ModelSaveRestResource.class); |
|||
|
|||
@Autowired |
|||
private RepositoryService repositoryService; |
|||
@Autowired |
|||
private ObjectMapper objectMapper; |
|||
|
|||
@RequestMapping(value="/model/{modelId}/save", method = RequestMethod.PUT) |
|||
@ResponseStatus(value = HttpStatus.OK) |
|||
public void saveModel(@PathVariable String modelId, HttpServletRequest request) { |
|||
try { |
|||
HttpServletRequest orgRequest = XssHttpServletRequestWrapper.getOrgRequest(request); |
|||
String name = orgRequest.getParameter("name"); |
|||
String description = orgRequest.getParameter("description"); |
|||
String jsonXml = orgRequest.getParameter("json_xml"); |
|||
String svgXml = orgRequest.getParameter("svg_xml"); |
|||
|
|||
Model model = repositoryService.getModel(modelId); |
|||
|
|||
ObjectNode modelJson = (ObjectNode) objectMapper.readTree(model.getMetaInfo()); |
|||
|
|||
modelJson.put(MODEL_NAME, name); |
|||
modelJson.put(MODEL_DESCRIPTION, description); |
|||
model.setMetaInfo(modelJson.toString()); |
|||
model.setName(name); |
|||
|
|||
repositoryService.saveModel(model); |
|||
|
|||
repositoryService.addModelEditorSource(model.getId(), jsonXml.getBytes("utf-8")); |
|||
|
|||
InputStream svgStream = new ByteArrayInputStream(svgXml.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); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
After Width: | Height: | Size: 4.2 KiB |
@ -0,0 +1,21 @@ |
|||
registry { |
|||
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa |
|||
type = "nacos" |
|||
|
|||
nacos { |
|||
serverAddr = "47.104.224.45" |
|||
namespace = "public" |
|||
cluster = "default" |
|||
} |
|||
} |
|||
|
|||
config { |
|||
# file、nacos 、apollo、zk、consul、etcd3 |
|||
type = "nacos" |
|||
|
|||
nacos { |
|||
serverAddr = "47.104.224.45" |
|||
namespace = "public" |
|||
cluster = "default" |
|||
} |
|||
} |
|||
Loading…
Reference in new issue