use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.
the class ResolveAppDependenciesTask method resolveAppDependencies.
private void resolveAppDependencies(App appToInstall) throws Exception {
CyVersion version = appManager.getCyVersion();
if (!appToInstall.isCompatible(version))
throw new Exception("Unable to install " + appToInstall.getAppName() + ".\nIt is incompatible with this version of Cytoscape (" + version.getVersion() + ").");
taskMonitor.setStatusMessage("Resolving dependencies for " + appToInstall.getAppName() + "...");
for (App installedApp : appManager.getInstalledApps()) {
if (installedApp.getAppName().equals(appToInstall.getAppName())) {
appsToReplace.put(appToInstall, installedApp);
break;
}
}
dependencyStack.push(appToInstall.getAppName());
if (appToInstall.getDependencies() != null)
for (App.Dependency dep : appToInstall.getDependencies()) {
if (dependencyStack.contains(dep.getName()))
throw new Exception("Invalid circular dependency: " + dep.getName());
else if (findAppForDep(dep, appsToInstall) != null)
continue;
else if (findAppForDep(dep, appManager.getInstalledApps()) != null)
continue;
else {
App dependencyApp = findAppForDep(dep, appQueue);
if (dependencyApp != null) {
appQueue.remove(dependencyApp);
} else {
Set<WebApp> webApps = appManager.getWebQuerier().getAllApps();
if (webApps == null)
throw new Exception("Cannot access the App Store to resolve dependencies. Please check your internet connection.");
WebApp webApp = findWebAppForDep(dep, webApps);
if (webApp == null)
throw new Exception("Cannot find dependency: " + dependencyStack.firstElement() + " requires " + dep.getName() + ", which is not available in the App Store");
List<Release> releases = webApp.getReleases();
Release latestRelease = releases.get(releases.size() - 1);
if (WebQuerier.compareVersions(dep.getVersion(), latestRelease.getReleaseVersion()) >= 0) {
taskMonitor.setStatusMessage("Downloading dependency for " + dependencyStack.firstElement() + ": " + webApp.getFullName());
File appFile = appManager.getWebQuerier().downloadApp(webApp, null, new File(appManager.getDownloadedAppsPath()), status);
dependencyApp = appManager.getAppParser().parseApp(appFile);
} else
throw new Exception("Cannot find dependency: " + dependencyStack.firstElement() + " requires " + dep.getName() + " " + dep.getVersion() + " or later, latest release in App Store is " + latestRelease.getReleaseVersion());
}
resolveAppDependencies(dependencyApp);
}
}
dependencyStack.pop();
appsToInstall.add(appToInstall);
}
use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.
the class InstallAppsFromFileTask method run.
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
taskMonitor.setTitle("Install from File");
taskMonitor.setTitle("");
List<App> apps = new ArrayList<App>();
for (File appFile : appFiles) {
App app = appManager.getAppParser().parseApp(appFile);
apps.add(app);
}
taskMonitor.setStatusMessage("Starting install...");
insertTasksAfterCurrentTask(new ResolveAppDependenciesTask(apps, appManager, promptToReplace));
}
use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.
the class WebQuerier method checkForUpdates.
public Set<Update> checkForUpdates(Set<App> apps, AppManager appManager) {
Set<Update> updates = new HashSet<Update>();
Update update;
for (App app : apps) {
for (String url : appsByUrl.keySet()) {
update = checkForUpdate(app, url, appManager);
if (update != null) {
updates.add(update);
break;
}
}
}
return updates;
}
use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.
the class AppStoreTask method run.
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
WebApp webApp = null;
if (app != null) {
webApp = getWebApp(app);
url = APP_STORE + "apps/" + app;
} else {
url = APP_STORE;
}
// Do we have access to the CyBrowser?
App cyBrowser = getApp("cybrowser");
// System.out.println("cybrowser: "+cyBrowser);
if (useCybrowser == true && cyBrowser != null && cyBrowser.getStatus() == App.AppStatus.INSTALLED) {
CommandExecutorTaskFactory commandTF = serviceRegistrar.getService(CommandExecutorTaskFactory.class);
TaskManager<?, ?> taskManager = serviceRegistrar.getService(TaskManager.class);
// Yes, use it!
Map<String, Object> args = new HashMap<>();
args.put("url", url);
args.put("id", "AppStore");
TaskIterator ti = commandTF.createTaskIterator("cybrowser", "dialog", args, null);
taskManager.execute(ti);
} else {
// No, use the standard open browser
OpenBrowser openBrowser = serviceRegistrar.getService(OpenBrowser.class);
openBrowser.openURL(url);
}
}
use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.
the class AbstractAppTask method getApp.
protected App getApp(String appName) {
List<App> matchingApps = new ArrayList<App>();
for (App app : appList) {
if (appName.equalsIgnoreCase(app.getAppName()))
if (app.getStatus() == AppStatus.INSTALLED)
return app;
matchingApps.add(app);
}
if (matchingApps.size() == 0)
return null;
// OK, we have multiple matching apps. Find the latest version
// and return that one
Collections.sort(matchingApps, new VersionCompare());
return matchingApps.get(matchingApps.size() - 1);
}
Aggregations