use of io.jpom.model.node.ScriptCacheModel in project Jpom by dromara.
the class NodeEditController method del.
/**
* 删除节点
*
* @param id 节点id
* @return json
*/
@PostMapping(value = "del.json", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String del(@ValidatorItem String id) {
HttpServletRequest request = getRequest();
this.checkDataBind(id, request);
//
{
ProjectInfoCacheModel projectInfoCacheModel = new ProjectInfoCacheModel();
projectInfoCacheModel.setNodeId(id);
projectInfoCacheModel.setWorkspaceId(projectInfoCacheService.getCheckUserWorkspace(request));
boolean exists = projectInfoCacheService.exists(projectInfoCacheModel);
Assert.state(!exists, "该节点下还存在项目,不能删除");
}
//
{
ScriptCacheModel scriptCacheModel = new ScriptCacheModel();
scriptCacheModel.setNodeId(id);
scriptCacheModel.setWorkspaceId(nodeScriptServer.getCheckUserWorkspace(request));
boolean exists = nodeScriptServer.exists(scriptCacheModel);
Assert.state(!exists, "该节点下还存在脚本模版,不能删除");
}
//
this.delNodeData(id, request);
return JsonMessage.getString(200, "操作成功");
}
use of io.jpom.model.node.ScriptCacheModel in project Jpom by dromara.
the class NodeScriptHandler method createLog.
/**
* 创建执行日志
*
* @param attributes 参数属性
* @return 执行ID
*/
private String createLog(Map<String, Object> attributes) {
NodeModel nodeInfo = (NodeModel) attributes.get("nodeInfo");
UserModel userModel = (UserModel) attributes.get("userInfo");
ScriptCacheModel dataItem = (ScriptCacheModel) attributes.get("dataItem");
NodeScriptExecuteLogServer logServer = SpringUtil.getBean(NodeScriptExecuteLogServer.class);
NodeScriptServer nodeScriptServer = SpringUtil.getBean(NodeScriptServer.class);
//
try {
BaseServerController.resetInfo(userModel);
//
ScriptCacheModel scriptCacheModel = new ScriptCacheModel();
scriptCacheModel.setId(dataItem.getId());
scriptCacheModel.setLastRunUser(userModel.getId());
nodeScriptServer.update(scriptCacheModel);
//
ScriptExecuteLogCacheModel scriptExecuteLogCacheModel = new ScriptExecuteLogCacheModel();
scriptExecuteLogCacheModel.setScriptId(dataItem.getScriptId());
scriptExecuteLogCacheModel.setNodeId(nodeInfo.getId());
scriptExecuteLogCacheModel.setScriptName(dataItem.getName());
scriptExecuteLogCacheModel.setTriggerExecType(0);
scriptExecuteLogCacheModel.setWorkspaceId(nodeInfo.getWorkspaceId());
logServer.insert(scriptExecuteLogCacheModel);
return scriptExecuteLogCacheModel.getId();
} finally {
BaseServerController.removeAll();
}
}
Aggregations