首页>代码>集成了微信公众号、工作流(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;
  }
}
最近下载更多
educationAAA  LV10 9月26日
最代码官方  LV168 9月22日
最近浏览更多
interface  LV22 昨天
abdkfksdkf  LV16 9月29日
CrystalQ  LV8 9月29日
yfb790910  LV2 9月29日
Gin19960217  LV4 9月29日
带羽abcd 9月28日
暂无贡献等级
whfuai  LV14 9月28日
xiaozhi丶  LV15 9月26日
educationAAA  LV10 9月26日
y1214435276  LV9 9月26日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友