|
@@ -21,8 +21,7 @@ import java.io.File;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static java.util.stream.Collectors.groupingBy;
|
|
|
-import static java.util.stream.Collectors.toMap;
|
|
|
+import static java.util.stream.Collectors.*;
|
|
|
|
|
|
@Service
|
|
|
public class SupplementService {
|
|
@@ -41,7 +40,7 @@ public class SupplementService {
|
|
|
DirectedWeightedPseudograph graph = buildDirectedGraph(cluster);
|
|
|
VertexScoringAlgorithm<String, Double> pr = new PageRank<>(graph, 0.85, 100, 0.0001);
|
|
|
cluster.forEach(diffText -> {
|
|
|
- SupplementItem supplementItem = new SupplementItem(null,
|
|
|
+ SupplementItem supplementItem = new SupplementItem(0,
|
|
|
masterId,
|
|
|
diffText.getBugId(),
|
|
|
diffText.getIndex(),
|
|
@@ -89,7 +88,7 @@ public class SupplementService {
|
|
|
DirectedWeightedPseudograph graph = buildDirectedGraphForDiffImg(cluster);
|
|
|
VertexScoringAlgorithm<String, Double> pr = new PageRank<>(graph, 0.85, 100, 0.0001);
|
|
|
cluster.forEach(diffImg -> {
|
|
|
- SupplementItem supplementItem = new SupplementItem(null,
|
|
|
+ SupplementItem supplementItem = new SupplementItem(0,
|
|
|
masterId,
|
|
|
diffImg.getBugId(),
|
|
|
diffImg.getIndex(),
|
|
@@ -142,13 +141,12 @@ public class SupplementService {
|
|
|
|
|
|
public List<SupplementDTO> getSupplementByMasterId(String masterId, Map<String, BugDTO> bugMap) {
|
|
|
List<SupplementItem> supplementItems = supplementDao.findByMasterId(masterId);
|
|
|
-
|
|
|
+ List<String> sups = supplementItems.stream().map(SupplementItem::getSupplementId).distinct().collect(toList());
|
|
|
Map<String, List<SupplementItem>> supplementMap = supplementItems.stream().collect(groupingBy(SupplementItem::getSupplementId));
|
|
|
- Map<String, Long> supplementBugNumsMap = countBugsForSupplementReverseOrder(masterId);
|
|
|
List<SupplementDTO> sortedSupplements = new ArrayList<>(supplementMap.size());
|
|
|
|
|
|
|
|
|
- supplementBugNumsMap.forEach((supId, num) -> {
|
|
|
+ sups.forEach(supId -> {
|
|
|
SupplementDTO su = buildSupplement(supId, supplementMap, bugMap);
|
|
|
sortedSupplements.add(su);
|
|
|
});
|
|
@@ -193,14 +191,7 @@ public class SupplementService {
|
|
|
return su;
|
|
|
}
|
|
|
|
|
|
- private Map<String, Long> countBugsForSupplementReverseOrder(String masterId) {
|
|
|
- List<Object[]> supplementBugNums = supplementDao.countBugs(masterId);
|
|
|
- Map<String, Long> supplementBugNumsMap = new HashMap<>();
|
|
|
- supplementBugNums.forEach(record -> {
|
|
|
- supplementBugNumsMap.put((String) record[0], (Long) record[1]);
|
|
|
- });
|
|
|
- return sortByValue(supplementBugNumsMap);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
private Map<String, Long> sortByValue(final Map<String, Long> wordCounts) {
|
|
|
return wordCounts.entrySet()
|
|
@@ -285,11 +276,16 @@ public class SupplementService {
|
|
|
}
|
|
|
|
|
|
public Map<String, List<String>> getMaster2BugIdsMap(List<String> masterIds) {
|
|
|
- List<Object[]> masterBugs = supplementDao.findAllBugsByMasterIds(masterIds);
|
|
|
+ List<SupplementItem> supItems = supplementDao.findByMasterIdIn(masterIds);
|
|
|
+ List<String[]> masterBugs = supItems.stream()
|
|
|
+ .map(item -> item.getMasterId() + "-" + item.getBugId())
|
|
|
+ .distinct()
|
|
|
+ .map(s -> s.split("-"))
|
|
|
+ .collect(toList());
|
|
|
Map<String, List<String>> masterBugIdsMap = new HashMap<>();
|
|
|
- for (Object[] masterBug : masterBugs) {
|
|
|
- String masterId = (String) masterBug[0];
|
|
|
- String bugId = (String) masterBug[1];
|
|
|
+ for (String[] masterBug : masterBugs) {
|
|
|
+ String masterId = masterBug[0];
|
|
|
+ String bugId = masterBug[1];
|
|
|
|
|
|
if (masterBugIdsMap.get(masterId) == null) {
|
|
|
List<String> bugs = new ArrayList<>();
|