|
|
@@ -67,6 +67,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername(); |
|
|
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername(); |
|
|
String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword(); |
|
|
String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword(); |
|
|
String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); |
|
|
String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); |
|
|
|
|
|
// 得到用户操作的路径 |
|
|
Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq); |
|
|
Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq); |
|
|
Integer userId = (Integer) userInfo.get("user_id"); |
|
|
Integer userId = (Integer) userInfo.get("user_id"); |
|
|
// 拼接project |
|
|
// 拼接project |
|
|
@@ -101,7 +102,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
|
|
|
|
|
|
// 命令行操作 git clone 项目地址 |
|
|
// 命令行操作 git clone 项目地址 |
|
|
DVCUtils.gitClone(localPath, projectUrl, branchName, gitLinkUsername, gitLinkPassword); |
|
|
DVCUtils.gitClone(localPath, projectUrl, branchName, gitLinkUsername, gitLinkPassword); |
|
|
String s3Path = "management-platform-files" + "/" + ci4sUsername + "/" + "datasets" + "/" + gitlinIid + "/" + repositoryName + "/" + branchName; |
|
|
|
|
|
|
|
|
String s3Path = "management-platform-files" + "/" + relatePath + "/" + branchName; |
|
|
|
|
|
|
|
|
DVCUtils.moveFiles(sourcePath, datasetPath); |
|
|
DVCUtils.moveFiles(sourcePath, datasetPath); |
|
|
// 拼接生产的元数据后写入yaml文件 |
|
|
// 拼接生产的元数据后写入yaml文件 |
|
|
@@ -117,7 +118,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
datasetVo.setIdentifier(repositoryName); |
|
|
datasetVo.setIdentifier(repositoryName); |
|
|
datasetVo.setId(gitlinIid); |
|
|
datasetVo.setId(gitlinIid); |
|
|
datasetVo.setOwner((String) userInfo.get("login")); |
|
|
datasetVo.setOwner((String) userInfo.get("login")); |
|
|
datasetVo.setRelativePaths(ci4sUsername+"/" + gitlinIid + "/" + datasetVo.getName()); |
|
|
|
|
|
|
|
|
datasetVo.setRelativePaths(relatePath); |
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(datasetVo.getDatasetSource())){ |
|
|
if (StringUtils.isEmpty(datasetVo.getDatasetSource())){ |
|
|
datasetVo.setDatasetSource("用户上传"); |
|
|
datasetVo.setDatasetSource("用户上传"); |
|
|
@@ -170,7 +171,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
DVCUtils.dvcCheckout(localPath); |
|
|
DVCUtils.dvcCheckout(localPath); |
|
|
|
|
|
|
|
|
// 准备数据 |
|
|
// 准备数据 |
|
|
String s3Path = "management-platform-files" + "/" + ci4sUsername + "/" + "datasets" + "/" + datasetVo.getId() + "/" + repositoryName + "/" + branchName; |
|
|
|
|
|
|
|
|
String s3Path = "management-platform-files" + "/" + relatePath + "/" + branchName; |
|
|
|
|
|
|
|
|
DVCUtils.moveFiles(sourcePath, datasetPath); |
|
|
DVCUtils.moveFiles(sourcePath, datasetPath); |
|
|
// 拼接生产的元数据后写入yaml文件 |
|
|
// 拼接生产的元数据后写入yaml文件 |
|
|
@@ -190,7 +191,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
datasetVo.setDescription(newDatasetVo.getDescription()); |
|
|
datasetVo.setDescription(newDatasetVo.getDescription()); |
|
|
datasetVo.setDataTag(newDatasetVo.getDataTag()); |
|
|
datasetVo.setDataTag(newDatasetVo.getDataTag()); |
|
|
datasetVo.setDataType(newDatasetVo.getDataType()); |
|
|
datasetVo.setDataType(newDatasetVo.getDataType()); |
|
|
datasetVo.setRelativePaths(ci4sUsername + "/" + datasetVo.getId() + "/" + datasetVo.getName()); |
|
|
|
|
|
|
|
|
datasetVo.setRelativePaths(relatePath); |
|
|
YamlUtils.generateYamlFile(JsonUtils.objectToMap(datasetVo), localPath, "dataset"); |
|
|
YamlUtils.generateYamlFile(JsonUtils.objectToMap(datasetVo), localPath, "dataset"); |
|
|
//dvc数据跟踪 |
|
|
//dvc数据跟踪 |
|
|
// 配置远程S3地址 |
|
|
// 配置远程S3地址 |
|
|
@@ -266,7 +267,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public NewDatasetVo getNewDatasetDesc(Integer id, String repositoryName, String repo, String owner, String version) throws Exception { |
|
|
|
|
|
|
|
|
public NewDatasetVo getNewDatasetDesc(Integer id, String name, String repo, String owner, String version) throws Exception { |
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername(); |
|
|
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername(); |
|
|
String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword(); |
|
|
String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword(); |
|
|
@@ -278,9 +279,9 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
} |
|
|
} |
|
|
version = (String) versionList.get(0).get("name"); |
|
|
version = (String) versionList.get(0).get("name"); |
|
|
} |
|
|
} |
|
|
List<Map<String, Object>> fileDetailsAfterGitPull = DVCUtils.getFileDetailsAfterGitPull(localPathlocal +loginUser.getUsername()+"/datasets/" + id, repositoryName, version, "data",gitLinkUsername, gitLinkPassword); |
|
|
|
|
|
|
|
|
List<Map<String, Object>> fileDetailsAfterGitPull = DVCUtils.getFileDetailsAfterGitPull(localPathlocal +loginUser.getUsername()+"/datasets/" + id, name, version, "data",gitLinkUsername, gitLinkPassword); |
|
|
// 在localPathlocal+id+"/"+repositoryName目录下的dataset.yaml中取到元数据 |
|
|
// 在localPathlocal+id+"/"+repositoryName目录下的dataset.yaml中取到元数据 |
|
|
Map<String, Object> stringObjectMap = YamlUtils.loadYamlFile(localPathlocal +loginUser.getUsername()+"/datasets/" + id + "/" + repositoryName + "/" + "dataset.yaml"); |
|
|
|
|
|
|
|
|
Map<String, Object> stringObjectMap = YamlUtils.loadYamlFile(localPathlocal +loginUser.getUsername()+"/datasets/" + id + "/" + name + "/" + "dataset.yaml"); |
|
|
NewDatasetVo newDatasetVo = ConvertUtil.convertMapToObject(stringObjectMap, NewDatasetVo.class); |
|
|
NewDatasetVo newDatasetVo = ConvertUtil.convertMapToObject(stringObjectMap, NewDatasetVo.class); |
|
|
List<VersionVo> versionVos = new ArrayList<VersionVo>(); |
|
|
List<VersionVo> versionVos = new ArrayList<VersionVo>(); |
|
|
if (fileDetailsAfterGitPull!=null&&fileDetailsAfterGitPull.size()>0){ |
|
|
if (fileDetailsAfterGitPull!=null&&fileDetailsAfterGitPull.size()>0){ |
|
|
@@ -372,7 +373,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String repositoryName,Integer id, String version) throws Exception { |
|
|
|
|
|
|
|
|
public ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String name,Integer id, String version) throws Exception { |
|
|
// 命令行操作 git clone 项目地址 |
|
|
// 命令行操作 git clone 项目地址 |
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername(); |
|
|
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername(); |
|
|
@@ -381,7 +382,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
Jedis jedis = new Jedis(redisHost); |
|
|
Jedis jedis = new Jedis(redisHost); |
|
|
String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); |
|
|
String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); |
|
|
Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq); |
|
|
Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq); |
|
|
String localPath = localPathlocal+ loginUser.getUsername()+"/datasets/"+id+"/"+repositoryName; |
|
|
|
|
|
|
|
|
String localPath = localPathlocal+ loginUser.getUsername()+"/datasets/"+id+"/"+name; |
|
|
//不需要,没意义,我查看详情已经是最新的了 |
|
|
//不需要,没意义,我查看详情已经是最新的了 |
|
|
// if(folder.exists() && folder.isDirectory()){ |
|
|
// if(folder.exists() && folder.isDirectory()){ |
|
|
// //切换分支 |
|
|
// //切换分支 |
|
|
@@ -419,7 +420,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
InputStreamResource resource = new InputStreamResource(new FileInputStream(zipFile)); |
|
|
InputStreamResource resource = new InputStreamResource(new FileInputStream(zipFile)); |
|
|
|
|
|
|
|
|
return ResponseEntity.ok() |
|
|
return ResponseEntity.ok() |
|
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename="+repositoryName+"_"+version+"_data.zip") |
|
|
|
|
|
|
|
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename="+name+"_"+version+"_data.zip") |
|
|
.contentType(MediaType.APPLICATION_OCTET_STREAM) |
|
|
.contentType(MediaType.APPLICATION_OCTET_STREAM) |
|
|
.contentLength(zipFile.length()) |
|
|
.contentLength(zipFile.length()) |
|
|
.body(resource); |
|
|
.body(resource); |
|
|
|