testResults.add(result);
}
List<PackageVersionComposite> latestResults = new ArrayList<PackageVersionComposite>();
PackageVersionComposite latestPackage = null;
for (PackageVersionComposite newPackage : modifiedResults) {
latestPackage = newPackage;
for (PackageVersionComposite pack : testResults) {
if (pack.getPackageName().equals(latestPackage.getPackageName())
&& latestPackage.getPackageVersion().getVersion().compareTo(pack.getPackageVersion().getVersion()) < 0) {
latestPackage = pack;
}
}
latestResults.add(latestPackage);
}
List<PackageVersionComposite> finalResults = new ArrayList<PackageVersionComposite>();
long count = 0;
for (PackageVersionComposite pack : latestResults) {
if (finalResults.contains(pack)) {
continue;
} else {
finalResults.add(pack);
count++;
}
}
Collections.sort(finalResults, new Comparator() {
public int compare(Object o1, Object o2) {
PackageVersionComposite p1 = (PackageVersionComposite) o1;
PackageVersionComposite p2 = (PackageVersionComposite) o2;
return p1.getPackageName().compareToIgnoreCase(p2.getPackageName());
}
});
return new PageList<PackageVersionComposite>(finalResults, (int) count, pc);
}