feat:实验编辑重名判断
This commit is contained in:
parent
6009fb46e9
commit
8d30a7fa0d
|
@ -91,7 +91,7 @@ public class ExperimentController extends BaseController {
|
|||
*/
|
||||
@PutMapping
|
||||
@ApiOperation("编辑实验")
|
||||
public GenericsAjaxResult<Experiment> edit(@RequestBody Experiment experiment) throws IOException {
|
||||
public GenericsAjaxResult<Experiment> edit(@RequestBody Experiment experiment) throws Exception {
|
||||
return genericsSuccess(this.experimentService.update(experiment));
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public interface ExperimentInsService {
|
|||
|
||||
/**
|
||||
* 查询非终止态的实例
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
List<ExperimentIns> queryByExperimentIsNotTerminated();
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public interface ExperimentService {
|
|||
* @param experiment 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
Experiment update(Experiment experiment) throws IOException;
|
||||
Experiment update(Experiment experiment) throws Exception;
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
|
|
|
@ -580,8 +580,9 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
|
|||
flag = StringUtils.equals("Terminated", (String) workflowMap.get("phase"));
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -151,8 +151,9 @@ public class ExperimentServiceImpl implements ExperimentService {
|
|||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public Experiment update(Experiment experiment) throws IOException {
|
||||
public Experiment update(Experiment experiment) throws Exception {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
checkDeclaredName(experiment);
|
||||
experiment.setUpdateBy(loginUser.getUsername());
|
||||
experiment.setUpdateTime(new Date());
|
||||
this.experimentDao.update(experiment);
|
||||
|
@ -207,12 +208,9 @@ public class ExperimentServiceImpl implements ExperimentService {
|
|||
public Experiment runExperiment(Integer id) throws Exception {
|
||||
//先查出实验记录
|
||||
Experiment experiment = this.queryById(id);
|
||||
|
||||
if (experiment == null) {
|
||||
System.out.println("No experiment");
|
||||
}
|
||||
|
||||
|
||||
Workflow workflow = workflowService.queryById(experiment.getWorkflowId());
|
||||
if(workflow == null) {
|
||||
throw new RuntimeException("流水线不存在,请先创建流水线");
|
||||
|
@ -232,7 +230,7 @@ public class ExperimentServiceImpl implements ExperimentService {
|
|||
//这里全局参数是一个json数组,需要转换成一个list<Map>
|
||||
List<Map<String, Object>> params = JacksonUtil.parseJSONStr2MapList(StringUtils.isEmpty(experiment.getGlobalParam()) ? "[]" : experiment.getGlobalParam());
|
||||
runReqMap.put("params", params);
|
||||
//// 实验字段的Map,不要写成一行!否则会返回null
|
||||
// 实验字段的Map,不要写成一行!否则会返回null
|
||||
Map<String, Object> experimentMap = new HashMap<>();
|
||||
experimentMap.put("name", "experiment-"+experiment.getId());
|
||||
runReqMap.put("experiment", experimentMap);
|
||||
|
@ -332,7 +330,7 @@ public class ExperimentServiceImpl implements ExperimentService {
|
|||
// 现在我们知道还有另一个具有相同名称的流水线
|
||||
Field[] fields = Experiment.class.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true); // 使私有字段可访问
|
||||
field.setAccessible(true);
|
||||
if ("name".equals(field.getName()) && field.isAnnotationPresent(CheckDuplicate.class)) {
|
||||
// 如果字段是“name”并且标记了CheckDuplicate注解
|
||||
CheckDuplicate annotation = field.getAnnotation(CheckDuplicate.class);
|
||||
|
|
Loading…
Reference in New Issue