Example usage for org.springframework.roo.addon.roobot.eclipse.client RooAddOnVersion RooAddOnVersion

List of usage examples for org.springframework.roo.addon.roobot.eclipse.client RooAddOnVersion RooAddOnVersion

Introduction

In this page you can find the example usage for org.springframework.roo.addon.roobot.eclipse.client RooAddOnVersion RooAddOnVersion.

Prototype

public RooAddOnVersion(Bundle bundle, BundleVersion bundleVersion) 

Source Link

Usage

From source file:org.springframework.roo.addon.roobot.eclipse.client.AddOnRooBotEclipseOperationsImpl.java

private List<Plugin> convertToAddOns(LinkedList<Bundle> filteredSearchResults) {
    BundleContext bc = context.getBundleContext();
    org.osgi.framework.Bundle[] bundles = bc.getBundles();
    Map<String, org.osgi.framework.Bundle> installedBundleBySymbolicName = new HashMap<String, org.osgi.framework.Bundle>();
    for (org.osgi.framework.Bundle bundle : bundles) {
        installedBundleBySymbolicName.put(bundle.getSymbolicName(), bundle);
    }//from   ww w. jav  a 2s .  c  o m

    ArrayList<Plugin> result = new ArrayList<Plugin>();
    for (Bundle bundle : filteredSearchResults) {
        org.osgi.framework.Bundle installedBundle = installedBundleBySymbolicName.get(bundle.getSymbolicName());

        // create add-on for each bundle
        Plugin plugin = new Plugin(bundle.getSymbolicName());

        // add all available versions
        List<BundleVersion> versions = BundleVersion.orderByVersion(bundle.getVersions());
        for (BundleVersion version : versions) {
            RooAddOnVersion addOnVersion = new RooAddOnVersion(bundle, version);
            addOnVersion.setTitle(version.getPresentationName());
            addOnVersion.setVersion(version.getVersion());
            addOnVersion.setDescription(version.getDescription());
            addOnVersion.setRuntimeVersion(version.getRooVersion());
            // name needs to match between bundle and version
            addOnVersion.setName(plugin.getName());

            if (installedBundle != null
                    && installedBundle.getVersion().toString().equals(version.getVersion())) {
                addOnVersion.setInstalled(true);
            }

            plugin.addVersion(addOnVersion);
            plugin.setLatestReleasedVersion(addOnVersion);
        }

        result.add(plugin);
    }
    return result;
}