new function to get a package and its dependencies
This commit is contained in:
parent
c9aed83465
commit
19517d5b6c
@ -8,6 +8,7 @@ import fr.packageviewer.distribution.ArchDistribution;
|
|||||||
import fr.packageviewer.distribution.Distribution;
|
import fr.packageviewer.distribution.Distribution;
|
||||||
import fr.packageviewer.distribution.FedoraDistribution;
|
import fr.packageviewer.distribution.FedoraDistribution;
|
||||||
import fr.packageviewer.pack.SearchedPackage;
|
import fr.packageviewer.pack.SearchedPackage;
|
||||||
|
import fr.packageviewer.pack.Package;
|
||||||
|
|
||||||
public class Searcher {
|
public class Searcher {
|
||||||
public static List<SearchedPackage> searchForAll(String packet) {
|
public static List<SearchedPackage> searchForAll(String packet) {
|
||||||
@ -74,4 +75,40 @@ public class Searcher {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for the specific package in the specific distribution, we need the searchedPackage to get informations about it like it name and distribution
|
||||||
|
* @param pSearchedPackage the package to search for
|
||||||
|
* @return a complete package with its dependencies
|
||||||
|
* @author Capelier-Marla
|
||||||
|
*/
|
||||||
|
public static Package getPackage(SearchedPackage pSearchedPackage) {
|
||||||
|
// we get the name of the distribution of the package
|
||||||
|
String distName = pSearchedPackage.getDistribution();
|
||||||
|
// we create a distribution object
|
||||||
|
Distribution distribution;
|
||||||
|
switch (distName) {
|
||||||
|
case "archlinux":
|
||||||
|
distribution = new ArchDistribution();
|
||||||
|
break;
|
||||||
|
case "fedora":
|
||||||
|
distribution = new FedoraDistribution();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("Error: Unknown");
|
||||||
|
System.exit(1);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// create the futue package we'll get from searching
|
||||||
|
Future<Package> packet = distribution.getPackageTree(pSearchedPackage.getName(), 4);
|
||||||
|
// object containing the package we're looking for
|
||||||
|
Package result;
|
||||||
|
try {
|
||||||
|
result = packet.get();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// return the package
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user