首页>代码>集成了微信公众号、工作流(activiti)可视化界面的OA开发框架,SSM>/javaaciviti/src/com/fh/controller/activiti/editor/model/ModelEditorJsonRestResources.java
package com.fh.controller.activiti.editor.model;

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;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

/** 
 * 类名称:ModelEditorJsonRestResources
 * 创建人:acticiti官方源码 fh313596790qq(青苔)
 * 更新时间:2017年12月25日
 * @version
 */
@RestController
public class ModelEditorJsonRestResources implements ModelDataJsonConstants {
  
  protected static final Logger LOGGER = LoggerFactory.getLogger(ModelEditorJsonRestResources.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.put("model", editorJsonNode);
      } catch (Exception e) {
        LOGGER.error("Error creating model JSON", e);
        throw new ActivitiException("Error creating model JSON", e);
      }
    }
    return modelNode;
  }
}
最近下载更多
sunlea  LV20 3月6日
微信网友_7269098639953920  LV2 2024年11月25日
educationAAA  LV11 2024年9月26日
最代码官方  LV168 2024年9月22日
最近浏览更多
ymsyms  LV2 10月21日
奋斗的小蚂蚁  LV16 10月17日
sdfb21 10月13日
暂无贡献等级
perfect  LV17 10月11日
newhaijun  LV16 9月15日
xiaoyumao  LV2 8月29日
dyb1220 8月23日
暂无贡献等级
lipanlong  LV10 8月21日
zhos0212  LV19 8月13日
ewan007  LV30 7月2日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友