| @@ -22,6 +22,9 @@ public class Constant { | |||||
| public final static int Git_Category_Id = 39; | public final static int Git_Category_Id = 39; | ||||
| public final static String Topic_Dataset = "ci4s-dataset"; | |||||
| public final static String Topic_model = "ci4s-model"; | |||||
| public final static String Item_Public = "public"; | public final static String Item_Public = "public"; | ||||
| public final static String Source_Auto_Export = "auto_export"; | public final static String Source_Auto_Export = "auto_export"; | ||||
| @@ -39,14 +39,8 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| private ExperimentInsDao experimentInsDao; | private ExperimentInsDao experimentInsDao; | ||||
| @Resource | @Resource | ||||
| private ExperimentDao experimentDao; | private ExperimentDao experimentDao; | ||||
| @Resource | |||||
| private WorkflowService workflowService; | |||||
| @Value("${argo.url}") | @Value("${argo.url}") | ||||
| private String argoUrl; | private String argoUrl; | ||||
| @Value("${argo.convert}") | |||||
| private String argoConvert; | |||||
| @Value("${argo.workflowRun}") | |||||
| private String argoWorkflowRun; | |||||
| @Value("${argo.workflowStatus}") | @Value("${argo.workflowStatus}") | ||||
| private String argoWorkflowStatus; | private String argoWorkflowStatus; | ||||
| @Value("${argo.workflowTermination}") | @Value("${argo.workflowTermination}") | ||||
| @@ -59,10 +53,6 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| private String argoWorkflowPodLog; | private String argoWorkflowPodLog; | ||||
| @Value("${argo.ins.logsLines}") | @Value("${argo.ins.logsLines}") | ||||
| private int logsLines; | private int logsLines; | ||||
| @Value("${minio.endpoint}") | |||||
| private String minioEndpoint; | |||||
| @Resource | |||||
| private NewHttpUtils httpUtils; | |||||
| @Resource | @Resource | ||||
| private K8sClientUtil k8sClientUtil; | private K8sClientUtil k8sClientUtil; | ||||
| @Resource | @Resource | ||||
| @@ -50,7 +50,7 @@ public class GitServiceImpl implements GitService { | |||||
| String req = httpUtils.sendPost(gitendpoint + "/oauth/token", null, JsonUtils.mapToJson(params)); | String req = httpUtils.sendPost(gitendpoint + "/oauth/token", null, JsonUtils.mapToJson(params)); | ||||
| // 解析响应JSON | // 解析响应JSON | ||||
| if (StringUtils.isEmpty(req)) { | if (StringUtils.isEmpty(req)) { | ||||
| throw new RuntimeException("终止响应内容为空。"); | |||||
| throw new RuntimeException("gitlink用户信息出错"); | |||||
| } | } | ||||
| // 将响应的JSON字符串转换为Map对象 | // 将响应的JSON字符串转换为Map对象 | ||||
| Map<String, Object> runResMap = JsonUtils.jsonToMap(req); | Map<String, Object> runResMap = JsonUtils.jsonToMap(req); | ||||
| @@ -61,7 +61,7 @@ public class GitServiceImpl implements GitService { | |||||
| //通过access_token获取用户信息 | //通过access_token获取用户信息 | ||||
| String userReq = httpUtils.sendGetWithToken(gitendpoint + "/api/users/get_user_info.json", null, accessToken); | String userReq = httpUtils.sendGetWithToken(gitendpoint + "/api/users/get_user_info.json", null, accessToken); | ||||
| if (StringUtils.isEmpty(userReq)) { | if (StringUtils.isEmpty(userReq)) { | ||||
| throw new RuntimeException("终止响应内容为空。"); | |||||
| throw new RuntimeException("gitlink用户信息出错"); | |||||
| } | } | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String ci4sUsername = loginUser.getUsername(); | String ci4sUsername = loginUser.getUsername(); | ||||
| @@ -71,8 +71,7 @@ public class GitServiceImpl implements GitService { | |||||
| jedis.set(ci4sUsername + "_gitUserInfo", userReq); | jedis.set(ci4sUsername + "_gitUserInfo", userReq); | ||||
| return accessToken; | return accessToken; | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| log.error("登录GitLink失败。", e); | |||||
| return null; | |||||
| throw new RuntimeException("gitlink用户信息出错"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -578,7 +578,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| // 拼接project | // 拼接project | ||||
| GitProjectVo gitProjectVo = new GitProjectVo(); | GitProjectVo gitProjectVo = new GitProjectVo(); | ||||
| gitProjectVo.setRepositoryName(repositoryName); | gitProjectVo.setRepositoryName(repositoryName); | ||||
| gitProjectVo.setName(modelsVo.getName()); | |||||
| gitProjectVo.setName(Constant.Topic_model + "-" + modelsVo.getName()); | |||||
| gitProjectVo.setDescription(modelsVo.getDescription()); | gitProjectVo.setDescription(modelsVo.getDescription()); | ||||
| gitProjectVo.setPrivate(!modelsVo.getIsPublic()); | gitProjectVo.setPrivate(!modelsVo.getIsPublic()); | ||||
| gitProjectVo.setUserId(userId); | gitProjectVo.setUserId(userId); | ||||
| @@ -604,7 +604,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| // 创建分支 | // 创建分支 | ||||
| gitService.createBranch(token, (String) userInfo.get("login"), repositoryName, branchName, "master"); | gitService.createBranch(token, (String) userInfo.get("login"), repositoryName, branchName, "master"); | ||||
| // 定义标签 标签1:ci4s-model 标签2:ModelTag 标签3:ModelType | // 定义标签 标签1:ci4s-model 标签2:ModelTag 标签3:ModelType | ||||
| gitService.createTopic(token, gitlinIid, "ci4s-model"); | |||||
| gitService.createTopic(token, gitlinIid, Constant.Topic_model); | |||||
| if (StringUtils.isNotEmpty(modelsVo.getModelTag())) { | if (StringUtils.isNotEmpty(modelsVo.getModelTag())) { | ||||
| gitService.createTopic(token, gitlinIid, "modeltag-" + modelsVo.getModelTag()); | gitService.createTopic(token, gitlinIid, "modeltag-" + modelsVo.getModelTag()); | ||||
| } | } | ||||
| @@ -943,7 +943,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| String req = httpUtils.sendGetWithToken(url, null, token); | String req = httpUtils.sendGetWithToken(url, null, token); | ||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | ||||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | ||||
| List<ModelsVo> collect = convert(projects, "ci4s-model", modelTagName, modelTypeName); | |||||
| List<ModelsVo> collect = convert(projects, Constant.Topic_model, modelTagName, modelTypeName); | |||||
| List<ModelsVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | List<ModelsVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | ||||
| collect(Collectors.toList()); | collect(Collectors.toList()); | ||||
| return new PageImpl<>(result, pageRequest, collect.size()); | return new PageImpl<>(result, pageRequest, collect.size()); | ||||
| @@ -957,7 +957,6 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword(); | String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword(); | ||||
| Map<String, Object> userInfo = getUserInfo(ci4sUsername, gitLinkUsername, gitLinkPassword); | Map<String, Object> userInfo = getUserInfo(ci4sUsername, gitLinkUsername, gitLinkPassword); | ||||
| Integer userId = (Integer) userInfo.get("user_id"); | |||||
| String token = (String) userInfo.get("token"); | String token = (String) userInfo.get("token"); | ||||
| //拼接查询url | //拼接查询url | ||||
| @@ -974,7 +973,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| String req = httpUtils.sendGetWithToken(url, null, token); | String req = httpUtils.sendGetWithToken(url, null, token); | ||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | ||||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | ||||
| List<ModelsVo> collect = convert(projects, "ci4s-model", modelTagName, modelTypeName); | |||||
| List<ModelsVo> collect = convert(projects, Constant.Topic_model, modelTagName, modelTypeName); | |||||
| List<ModelsVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | List<ModelsVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | ||||
| collect(Collectors.toList()); | collect(Collectors.toList()); | ||||
| return new PageImpl<>(result, pageRequest, collect.size()); | return new PageImpl<>(result, pageRequest, collect.size()); | ||||
| @@ -1207,7 +1206,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| } | } | ||||
| } | } | ||||
| if (modelTopicName != null) { | |||||
| if (modelTopicName != null && modelTopic.equals(modelTopicName)) { | |||||
| if (StringUtils.isNotEmpty(modelTagName) && !modelTagName.toLowerCase().equals(modelTag)) { | if (StringUtils.isNotEmpty(modelTagName) && !modelTagName.toLowerCase().equals(modelTag)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| @@ -1219,6 +1218,8 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| Map<String, Object> author = (Map<String, Object>) map.get("author"); | Map<String, Object> author = (Map<String, Object>) map.get("author"); | ||||
| newModelVo.setCreateBy((String) author.get("name")); | newModelVo.setCreateBy((String) author.get("name")); | ||||
| newModelVo.setOwner((String) author.get("login")); | newModelVo.setOwner((String) author.get("login")); | ||||
| String name = (String) map.get("name"); | |||||
| newModelVo.setName(name.substring((modelTopic + "-").length())); | |||||
| result.add(newModelVo); | result.add(newModelVo); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1273,7 +1274,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| modelDependency1TreeVo.setChildModelList(childModelList); | modelDependency1TreeVo.setChildModelList(childModelList); | ||||
| } | } | ||||
| Map<String, Object> getUserInfo(String ci4sUsername, String gitLinkUsername, String gitLinkPassword) throws IOException { | |||||
| Map<String, Object> getUserInfo(String ci4sUsername, String gitLinkUsername, String gitLinkPassword) throws Exception { | |||||
| Jedis jedis = new Jedis(redisHost, redisPort); | Jedis jedis = new Jedis(redisHost, redisPort); | ||||
| String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); | String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); | ||||
| if (userReq == null) { | if (userReq == null) { | ||||
| @@ -94,7 +94,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| String repositoryName = ci4sUsername + "_dataset_" + DateUtils.dateTimeNow(); | String repositoryName = ci4sUsername + "_dataset_" + DateUtils.dateTimeNow(); | ||||
| GitProjectVo gitProjectVo = new GitProjectVo(); | GitProjectVo gitProjectVo = new GitProjectVo(); | ||||
| gitProjectVo.setRepositoryName(repositoryName); | gitProjectVo.setRepositoryName(repositoryName); | ||||
| gitProjectVo.setName(datasetVo.getName()); | |||||
| gitProjectVo.setName(Constant.Topic_Dataset + "-" + datasetVo.getName()); | |||||
| gitProjectVo.setDescription(datasetVo.getDescription()); | gitProjectVo.setDescription(datasetVo.getDescription()); | ||||
| gitProjectVo.setPrivate(!datasetVo.getIsPublic()); | gitProjectVo.setPrivate(!datasetVo.getIsPublic()); | ||||
| gitProjectVo.setUserId(userId); | gitProjectVo.setUserId(userId); | ||||
| @@ -111,7 +111,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| gitService.createBranch(token, (String) userInfo.get("login"), repositoryName, branchName, "master"); | gitService.createBranch(token, (String) userInfo.get("login"), repositoryName, branchName, "master"); | ||||
| // 定义标签 标签1:ci4s-dataset 标签2:DataTag 标签3:DataType | // 定义标签 标签1:ci4s-dataset 标签2:DataTag 标签3:DataType | ||||
| gitService.createTopic(token, gitlinIid, "ci4s-dataset"); | |||||
| gitService.createTopic(token, gitlinIid, Constant.Topic_Dataset); | |||||
| if (StringUtils.isNotEmpty(datasetVo.getDataTag())) { | if (StringUtils.isNotEmpty(datasetVo.getDataTag())) { | ||||
| gitService.createTopic(token, gitlinIid, "datatag-" + datasetVo.getDataTag()); | gitService.createTopic(token, gitlinIid, "datatag-" + datasetVo.getDataTag()); | ||||
| } | } | ||||
| @@ -320,7 +320,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | ||||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | ||||
| List<NewDatasetVo> collect = convert(projects, "ci4s-dataset", dataset.getDataTag(), dataset.getDataType()); | |||||
| List<NewDatasetVo> collect = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); | |||||
| List<NewDatasetVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | List<NewDatasetVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | ||||
| collect(Collectors.toList()); | collect(Collectors.toList()); | ||||
| return new PageImpl<>(result, pageRequest, collect.size()); | return new PageImpl<>(result, pageRequest, collect.size()); | ||||
| @@ -348,7 +348,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| if (projects == null) { | if (projects == null) { | ||||
| return new PageImpl<>(new ArrayList<>(), pageRequest, 0); | return new PageImpl<>(new ArrayList<>(), pageRequest, 0); | ||||
| } | } | ||||
| List<NewDatasetVo> collect = convert(projects, "ci4s-dataset", dataset.getDataTag(), dataset.getDataType()); | |||||
| List<NewDatasetVo> collect = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); | |||||
| List<NewDatasetVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | List<NewDatasetVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | ||||
| collect(Collectors.toList()); | collect(Collectors.toList()); | ||||
| return new PageImpl<>(result, pageRequest, collect.size()); | return new PageImpl<>(result, pageRequest, collect.size()); | ||||
| @@ -532,7 +532,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| } | } | ||||
| } | } | ||||
| if (datasetTopicName != null) { | |||||
| if (datasetTopicName != null && datasetTopic.equals(datasetTopicName)) { | |||||
| if (StringUtils.isNotEmpty(datasetTagName) && !datasetTagName.toLowerCase().equals(datasetTag)) { | if (StringUtils.isNotEmpty(datasetTagName) && !datasetTagName.toLowerCase().equals(datasetTag)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| @@ -545,6 +545,8 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| Map<String, Object> author = (Map<String, Object>) map.get("author"); | Map<String, Object> author = (Map<String, Object>) map.get("author"); | ||||
| newDatasetVo.setCreateBy((String) author.get("name")); | newDatasetVo.setCreateBy((String) author.get("name")); | ||||
| newDatasetVo.setOwner((String) author.get("login")); | newDatasetVo.setOwner((String) author.get("login")); | ||||
| String name = (String)map.get("name"); | |||||
| newDatasetVo.setName(name.substring((datasetTopic +"-").length())); | |||||
| result.add(newDatasetVo); | result.add(newDatasetVo); | ||||
| } | } | ||||
| } | } | ||||