Search in sources :

Example 46 with PluginDependencyResult

use of com.qcadoo.plugin.api.PluginDependencyResult in project qcadoo by qcadoo.

the class DefaultPluginDependencyManager method getDependentPlugins.

private Set<PluginDependencyInformation> getDependentPlugins(final List<Plugin> plugins, final boolean includeDisabled, final PluginStatusResolver pluginStatusResolver) {
    List<Plugin> enabledDependencyPlugins = new LinkedList<Plugin>();
    Set<String> argumentPluginIdentifiersSet = getArgumentIdentifiersSet(plugins);
    for (Plugin plugin : pluginAccessor.getPlugins()) {
        if (includeDisabled) {
            if (pluginStatusResolver.isPluginNotInstalled(plugin)) {
                continue;
            }
        } else {
            if (!pluginStatusResolver.isPluginEnabled(plugin)) {
                continue;
            }
        }
        for (Plugin pluginToDisable : plugins) {
            for (PluginDependencyInformation dependencyInfo : plugin.getRequiredPlugins()) {
                if (dependencyInfo.getIdentifier().equals(pluginToDisable.getIdentifier())) {
                    enabledDependencyPlugins.add(plugin);
                    break;
                }
            }
        }
    }
    Set<PluginDependencyInformation> enabledDependencies = new HashSet<PluginDependencyInformation>();
    for (Plugin plugin : enabledDependencyPlugins) {
        enabledDependencies.add(new PluginDependencyInformation(plugin.getIdentifier()));
    }
    if (!enabledDependencyPlugins.isEmpty()) {
        PluginDependencyResult nextLevelDependencioesResult = getDependenciesToDisable(enabledDependencyPlugins, pluginStatusResolver);
        enabledDependencies.addAll(nextLevelDependencioesResult.getDependenciesToDisable());
    }
    Iterator<PluginDependencyInformation> dependencyInfoIterator = enabledDependencies.iterator();
    while (dependencyInfoIterator.hasNext()) {
        if (argumentPluginIdentifiersSet.contains(dependencyInfoIterator.next().getIdentifier())) {
            dependencyInfoIterator.remove();
        }
    }
    return enabledDependencies;
}
Also used : PluginDependencyResult(com.qcadoo.plugin.api.PluginDependencyResult) PluginDependencyInformation(com.qcadoo.plugin.api.PluginDependencyInformation) LinkedList(java.util.LinkedList) Plugin(com.qcadoo.plugin.api.Plugin) HashSet(java.util.HashSet)

Aggregations

PluginDependencyResult (com.qcadoo.plugin.api.PluginDependencyResult)46 Test (org.junit.Test)39 Plugin (com.qcadoo.plugin.api.Plugin)38 InternalPlugin (com.qcadoo.plugin.internal.api.InternalPlugin)36 PluginDependencyInformation (com.qcadoo.plugin.api.PluginDependencyInformation)28 HashSet (java.util.HashSet)23 PluginOperationResult (com.qcadoo.plugin.api.PluginOperationResult)15 SimplePluginStatusResolver (com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver)15 ArrayList (java.util.ArrayList)11 VersionOfDependency (com.qcadoo.plugin.api.VersionOfDependency)7 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)4 QcadooPluginPlugin (com.qcadoo.model.beans.qcadooPlugin.QcadooPluginPlugin)4 InOrder (org.mockito.InOrder)3 Version (com.qcadoo.plugin.api.Version)2 PluginException (com.qcadoo.plugin.internal.PluginException)2 File (java.io.File)1 LinkedList (java.util.LinkedList)1 CycleDetector (org.jgrapht.alg.CycleDetector)1 DefaultDirectedGraph (org.jgrapht.graph.DefaultDirectedGraph)1 DefaultEdge (org.jgrapht.graph.DefaultEdge)1