Search in sources :

Example 36 with PluginDependencyInformation

use of com.qcadoo.plugin.api.PluginDependencyInformation 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

PluginDependencyInformation (com.qcadoo.plugin.api.PluginDependencyInformation)36 Plugin (com.qcadoo.plugin.api.Plugin)28 PluginDependencyResult (com.qcadoo.plugin.api.PluginDependencyResult)28 Test (org.junit.Test)28 InternalPlugin (com.qcadoo.plugin.internal.api.InternalPlugin)24 HashSet (java.util.HashSet)24 VersionOfDependency (com.qcadoo.plugin.api.VersionOfDependency)10 ArrayList (java.util.ArrayList)8 PluginOperationResult (com.qcadoo.plugin.api.PluginOperationResult)4 SimplePluginStatusResolver (com.qcadoo.plugin.internal.dependencymanager.SimplePluginStatusResolver)4 Version (com.qcadoo.plugin.api.Version)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 QcadooPluginPlugin (com.qcadoo.model.beans.qcadooPlugin.QcadooPluginPlugin)1 DefaultPlugin (com.qcadoo.plugin.internal.DefaultPlugin)1 PluginException (com.qcadoo.plugin.internal.PluginException)1 File (java.io.File)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1