Search in sources :

Example 11 with WebApp

use of org.cytoscape.app.internal.net.WebApp 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);
}
Also used : App(org.cytoscape.app.internal.manager.App) WebApp(org.cytoscape.app.internal.net.WebApp) Set(java.util.Set) CyVersion(org.cytoscape.application.CyVersion) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) File(java.io.File) Release(org.cytoscape.app.internal.net.WebApp.Release) WebApp(org.cytoscape.app.internal.net.WebApp)

Example 12 with WebApp

use of org.cytoscape.app.internal.net.WebApp 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);
    }
}
Also used : App(org.cytoscape.app.internal.manager.App) WebApp(org.cytoscape.app.internal.net.WebApp) TaskIterator(org.cytoscape.work.TaskIterator) OpenBrowser(org.cytoscape.util.swing.OpenBrowser) CommandExecutorTaskFactory(org.cytoscape.command.CommandExecutorTaskFactory) HashMap(java.util.HashMap) WebApp(org.cytoscape.app.internal.net.WebApp)

Aggregations

WebApp (org.cytoscape.app.internal.net.WebApp)12 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 App (org.cytoscape.app.internal.manager.App)3 WebQuerier (org.cytoscape.app.internal.net.WebQuerier)3 TaskIterator (org.cytoscape.work.TaskIterator)3 File (java.io.File)2 List (java.util.List)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 InstallAppsFromWebAppTask (org.cytoscape.app.internal.task.InstallAppsFromWebAppTask)2 Task (org.cytoscape.work.Task)2 TaskMonitor (org.cytoscape.work.TaskMonitor)2 Map (java.util.Map)1 Set (java.util.Set)1 TreePath (javax.swing.tree.TreePath)1 DownloadStatus (org.cytoscape.app.internal.net.DownloadStatus)1 Update (org.cytoscape.app.internal.net.Update)1 Release (org.cytoscape.app.internal.net.WebApp.Release)1