Commit 40ebb7e4 by 王厚康

集成modeler

parent 7b833b70
......@@ -8,6 +8,7 @@ import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
......@@ -20,6 +21,24 @@ import javax.servlet.http.HttpServletResponse;
@RequestMapping("model")
public class ModelCreateController {
@GetMapping("createNew")
public void createNewModel(HttpServletRequest request, HttpServletResponse response) {
try {
response.sendRedirect(request.getContextPath() + "/modeler.html?modelId=newID");
} catch (Exception e) {
e.printStackTrace();
}
}
@GetMapping("editModel")
public void editModel(HttpServletRequest request, HttpServletResponse response,String modelId) {
try {
response.sendRedirect(request.getContextPath() + "/modeler.html?modelId=" + modelId);
} catch (Exception e) {
e.printStackTrace();
}
}
@RequestMapping("create")
public void createModel(HttpServletRequest request, HttpServletResponse response){
try{
......
......@@ -46,7 +46,21 @@ public class ModelEditorJsonRestResource implements ModelDataJsonConstants {
@RequestMapping(value="/model/{modelId}/json", method = RequestMethod.GET, produces = "application/json")
public ObjectNode getEditorJson(@PathVariable String modelId) {
ObjectNode modelNode = null;
if("newID".equals(modelId)){
modelNode = objectMapper.createObjectNode();
modelNode.put(MODEL_NAME, "modelName");
modelNode.put(MODEL_ID, "newID");
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode editorNode = objectMapper.createObjectNode();
editorNode.put("id", "canvas");
editorNode.put("resourceId", "canvas");
ObjectNode stencilSetNode = objectMapper.createObjectNode();
stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
editorNode.put("stencilset", stencilSetNode);
modelNode.put("model", editorNode);
return modelNode;
}
Model model = repositoryService.getModel(modelId);
if (model != null) {
......
......@@ -59,7 +59,17 @@ public class ModelSaveRestResource implements ModelDataJsonConstants {
try {
Model model = repositoryService.getModel(modelId);
if(model==null){
model = repositoryService.newModel();
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode modelObjectNode = objectMapper.createObjectNode();
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name);
modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);
model.setMetaInfo(modelObjectNode.toString());
}
ObjectNode modelJson = (ObjectNode) objectMapper.readTree(model.getMetaInfo());
modelJson.put(MODEL_NAME, name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment