|
|
|
@@ -10,6 +10,7 @@ import com.ruoyi.platform.service.GitService; |
|
|
|
import com.ruoyi.platform.service.NewDatasetService; |
|
|
|
import com.ruoyi.platform.utils.*; |
|
|
|
import com.ruoyi.platform.vo.GitProjectVo; |
|
|
|
import com.ruoyi.platform.vo.ModelsVo; |
|
|
|
import com.ruoyi.platform.vo.NewDatasetVo; |
|
|
|
import com.ruoyi.platform.vo.VersionVo; |
|
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
|
@@ -229,20 +230,21 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
|
// 拼接查询url |
|
|
|
String datasetTagName = dataset.getDatasetTagName(); |
|
|
|
String datasetTypeName = dataset.getDatasetTypeName(); |
|
|
|
String topic_name = "ci4s-dataset"; |
|
|
|
topic_name = StringUtils.isEmpty(datasetTagName) ? topic_name : topic_name + ",datatag-" + datasetTagName; |
|
|
|
topic_name = StringUtils.isEmpty(datasetTagName) ? topic_name : topic_name + ",datatype-" + datasetTypeName; |
|
|
|
String url = gitendpoint + "/api/users/" + (String) userInfo.get("login") + "/projects.json?page=" + pageRequest.getPageNumber() + "&limit=" + pageRequest.getPageSize() + "&category=manage&topic_name=" + topic_name; |
|
|
|
String name = dataset.getName(); |
|
|
|
|
|
|
|
String url = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage"; |
|
|
|
|
|
|
|
String name = dataset.getName(); |
|
|
|
if (StringUtils.isNotEmpty(name)){ |
|
|
|
url =url + "&search=" + name; |
|
|
|
} |
|
|
|
String req = httpUtils.sendGetWithToken(url, null, token); |
|
|
|
Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); |
|
|
|
Integer total = (Integer) stringObjectMap.get("count"); |
|
|
|
List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); |
|
|
|
return new PageImpl<>(convert(projects), pageRequest, total); |
|
|
|
|
|
|
|
List<NewDatasetVo> collect = convert(projects, "ci4s-dataset", datasetTagName, datasetTypeName); |
|
|
|
List<NewDatasetVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). |
|
|
|
collect(Collectors.toList()); |
|
|
|
return new PageImpl<>(result, pageRequest, collect.size()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -257,10 +259,9 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
|
// 拼接查询url |
|
|
|
String datasetTagName = dataset.getDatasetTagName(); |
|
|
|
String datasetTypeName = dataset.getDatasetTypeName(); |
|
|
|
String topic_name = "ci4s-dataset"; |
|
|
|
topic_name = StringUtils.isEmpty(datasetTagName) ? topic_name : topic_name + ",datatag-" + datasetTagName; |
|
|
|
topic_name = StringUtils.isEmpty(datasetTagName) ? topic_name : topic_name + ",datatype-" + datasetTypeName; |
|
|
|
String url = gitendpoint + "/api/projects.json?user_id=" + userId + "&page=" + pageRequest.getPageNumber() + "&limit=" + pageRequest.getPageSize() + "&sort_by=praises_count&topic_name=" + topic_name; |
|
|
|
|
|
|
|
String url = gitendpoint + "/api/projects.json?user_id=" + userId + "&sort_by=praises_count"; |
|
|
|
|
|
|
|
String name = dataset.getName(); |
|
|
|
if (StringUtils.isNotEmpty(name)){ |
|
|
|
url =url + "&search=" + name; |
|
|
|
@@ -268,12 +269,14 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
|
|
|
|
|
String req = httpUtils.sendGetWithToken(url, null, token); |
|
|
|
Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); |
|
|
|
Integer total = (Integer) stringObjectMap.get("total_count"); |
|
|
|
List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); |
|
|
|
if (projects == null) { |
|
|
|
return new PageImpl<>(new ArrayList<>(), pageRequest, 0); |
|
|
|
} |
|
|
|
return new PageImpl<>(convert(projects), pageRequest, total); |
|
|
|
List<NewDatasetVo> collect = convert(projects, "ci4s-dataset", datasetTagName, datasetTypeName); |
|
|
|
List<NewDatasetVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). |
|
|
|
collect(Collectors.toList()); |
|
|
|
return new PageImpl<>(result, pageRequest, collect.size()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -422,8 +425,9 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<NewDatasetVo> convert(List<Map<String, Object>> lst) { |
|
|
|
public List<NewDatasetVo> convert(List<Map<String, Object>> lst, String datasetTopic, String datasetTagName, String datasetTypeName) { |
|
|
|
if (lst != null && lst.size() > 0) { |
|
|
|
List<NewDatasetVo> result = new ArrayList<>(); |
|
|
|
List<NewDatasetVo> newDatasetVos = ConvertUtil.convertListMapToObjectList(lst, NewDatasetVo.class); |
|
|
|
|
|
|
|
for (NewDatasetVo newDatasetVo : newDatasetVos) { |
|
|
|
@@ -434,26 +438,28 @@ public class NewDatasetServiceImpl implements NewDatasetService { |
|
|
|
|
|
|
|
if (map != null) { |
|
|
|
List<Map<String, Object>> topics = (List<Map<String, Object>>) map.get("topics"); |
|
|
|
if (topics != null) { |
|
|
|
topics.forEach(topic -> { |
|
|
|
String name = (String) topic.get("name"); |
|
|
|
if (name != null) { |
|
|
|
if (name.startsWith("datatag-")) { |
|
|
|
newDatasetVo.setDataTag(name.substring("datatag-".length())); |
|
|
|
} else if (name.startsWith("datatype-")) { |
|
|
|
newDatasetVo.setDataType(name.substring("datatype-".length())); |
|
|
|
if (topics != null && topics.size() > 0 && datasetTopic.equals(topics.get(0).get("name"))) { |
|
|
|
String datasettag = (String) topics.get(1).get("name"); |
|
|
|
String datasetype = (String) topics.get(2).get("name"); |
|
|
|
datasettag = datasettag.substring("modeltag_".length()); |
|
|
|
datasetype = datasetype.substring("modeltype_".length()); |
|
|
|
if (StringUtils.isNotEmpty(datasetTagName) && !datasetTagName.toLowerCase().equals(datasettag)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(datasetTypeName) && !datasetTypeName.toLowerCase().equals(datasetype)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
newDatasetVo.setDataTag(datasetTagName); |
|
|
|
newDatasetVo.setDataType(datasetTypeName); |
|
|
|
|
|
|
|
Map<String, Object> author = (Map<String, Object>) map.get("author"); |
|
|
|
newDatasetVo.setCreateBy((String) author.get("name")); |
|
|
|
newDatasetVo.setOwner((String) author.get("login")); |
|
|
|
result.add(newDatasetVo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return newDatasetVos; |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|