Search in sources :

Example 1 with JoinRule

use of com.qlangtech.tis.git.GitUtils.JoinRule in project tis by qlangtech.

the class OfflineManager method editWorkflow.

public void editWorkflow(WorkflowPojo pojo, BasicModule action, Context context) throws Exception {
    String name = pojo.getName();
    WorkFlowCriteria criteria = new WorkFlowCriteria();
    criteria.createCriteria().andNameEqualTo(name);
    List<WorkFlow> workflowList = workflowDAOFacade.getWorkFlowDAO().selectByExample(criteria);
    // 1、检测是否存在
    if (CollectionUtils.isEmpty(workflowList)) {
        action.addErrorMessage(context, "没有名字为" + name + "的工作流");
        return;
    }
    WorkFlow workFlow = workflowList.get(0);
    if (workFlow.getInChange().intValue() == 0) {
        action.addErrorMessage(context, "工作流不在变更中");
        return;
    }
    // 2、检测xml是否正确
    JoinRule task = pojo.getTask();
    if (task == null || StringUtils.isBlank(task.getContent())) {
        action.addErrorMessage(context, "脚本内容不能为空");
        return;
    }
    if (!isXmlValid(task)) {
        action.addErrorMessage(context, "XML解析失败,请检测XML格式");
        return;
    }
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("name", name);
    // jsonObject.put("tables", StringUtils.join(pojo.getDependTableIds(), ","));
    jsonObject.put("task", pojo.getTask());
    try {
        GitUtils.$().updateWorkflowFile(name, name, jsonObject.toString(1), "update workflow " + name);
    } catch (Exception e) {
        action.addErrorMessage(context, "git配置文件修改失败");
        action.addErrorMessage(context, e.getMessage());
    }
}
Also used : JSONObject(org.json.JSONObject) JoinRule(com.qlangtech.tis.git.GitUtils.JoinRule) SQLException(java.sql.SQLException)

Example 2 with JoinRule

use of com.qlangtech.tis.git.GitUtils.JoinRule in project tis by qlangtech.

the class OfflineDatasourceAction method getWorkflowPojo.

private WorkflowPojo getWorkflowPojo(Context context) {
    String name = this.getString("workflowName");
    if (StringUtils.isBlank(name)) {
        this.addErrorMessage(context, "工作流名不能为空");
        return null;
    }
    if (!isWordCharacter(name)) {
        this.addErrorMessage(context, "工作流名必须由英文字符,数字和下划线组成");
        return null;
    }
    String taskScript = this.getString("taskScript");
    if (StringUtils.isBlank(taskScript)) {
        this.addErrorMessage(context, "脚本内容不能为空");
        return null;
    }
    return new WorkflowPojo(name, new JoinRule(taskScript));
}
Also used : JoinRule(com.qlangtech.tis.git.GitUtils.JoinRule) WorkflowPojo(com.qlangtech.tis.offline.pojo.WorkflowPojo)

Aggregations

JoinRule (com.qlangtech.tis.git.GitUtils.JoinRule)2 WorkflowPojo (com.qlangtech.tis.offline.pojo.WorkflowPojo)1 SQLException (java.sql.SQLException)1 JSONObject (org.json.JSONObject)1