Search in sources :

Example 1 with PackageInfo

use of org.jboss.galleon.cli.model.PackageInfo in project galleon by wildfly.

the class StateInfoUtil method displayPackage.

private static void displayPackage(PmCommandInvocation session, Group grp) throws IOException {
    PackageInfo pkg = grp.getPackage();
    session.println("");
    session.println("Package name : " + pkg.getIdentity().getName());
    session.println("Package origin : " + pkg.getIdentity().getOrigin());
    session.println(Config.getLineSeparator() + "Package providers (features that depend on this package)");
    if (pkg.getProviders().isEmpty()) {
        session.println("default provider");
    } else {
        for (Identity id : pkg.getProviders()) {
            session.println(id.toString());
        }
    }
    session.println(Config.getLineSeparator() + "Package dependencies");
    if (grp.getGroups().isEmpty()) {
        session.println("NONE");
    } else {
        for (Group dep : grp.getGroups()) {
            session.println(dep.getIdentity().toString());
        }
    }
    session.println(Config.getLineSeparator() + "Package content");
    String customContent = pkg.getCustomContent();
    if (customContent != null) {
        session.println(customContent);
    } else if (pkg.getContent().isEmpty()) {
        session.println("NONE");
    } else {
        StringBuilder contentBuilder = new StringBuilder();
        for (String name : pkg.getContent()) {
            contentBuilder.append("  " + name + Config.getLineSeparator());
        }
        session.println(contentBuilder.toString());
    }
}
Also used : Group(org.jboss.galleon.cli.model.Group) PackageInfo(org.jboss.galleon.cli.model.PackageInfo) Identity(org.jboss.galleon.cli.model.Identity)

Example 2 with PackageInfo

use of org.jboss.galleon.cli.model.PackageInfo in project galleon by wildfly.

the class AbstractPackageCommand method getProducer.

@Override
public ProducerSpec getProducer(PmSession session) throws CommandExecutionException {
    if (pkg == null) {
        throw new CommandExecutionException("No package set.");
    }
    String fullpath = FeatureContainerPathConsumer.PACKAGES_PATH + pkg;
    FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(new AllPackagesContainer(session.getState().getContainer()), false);
    try {
        PathParser.parse(fullpath, consumer);
        Group grp = consumer.getCurrentNode(fullpath);
        if (grp == null) {
            throw new CommandExecutionException("Invalid package " + pkg);
        }
        PackageInfo info = grp.getPackage();
        if (info == null) {
            throw new CommandExecutionException("Invalid package " + pkg);
        }
        return info.getFPID().getProducer();
    } catch (PathParserException | PathConsumerException ex) {
        throw new CommandExecutionException(session, CliErrors.retrieveProducerFailed(), ex);
    }
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) Group(org.jboss.galleon.cli.model.Group) PackageInfo(org.jboss.galleon.cli.model.PackageInfo) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) PathParserException(org.jboss.galleon.cli.path.PathParserException) PathConsumerException(org.jboss.galleon.cli.path.PathConsumerException)

Example 3 with PackageInfo

use of org.jboss.galleon.cli.model.PackageInfo in project galleon by wildfly.

the class StateSearchCommand method findFeatures.

private Set<ResolvedSpecId> findFeatures(PackageInfo spec, FeatureContainer container) {
    Set<ResolvedSpecId> fspecs = new HashSet<>();
    for (Entry<ResolvedSpecId, FeatureSpecInfo> features : container.getAllSpecs().entrySet()) {
        for (PackageInfo info : features.getValue().getPackages()) {
            Group grp = container.getAllPackages().get(info.getIdentity());
            Set<Identity> identities = new HashSet<>();
            visitPkg(grp, identities);
            if (identities.contains(spec.getIdentity())) {
                fspecs.add(features.getKey());
                break;
            }
        }
    }
    return fspecs;
}
Also used : Group(org.jboss.galleon.cli.model.Group) ResolvedSpecId(org.jboss.galleon.runtime.ResolvedSpecId) PackageInfo(org.jboss.galleon.cli.model.PackageInfo) FeatureSpecInfo(org.jboss.galleon.cli.model.FeatureSpecInfo) Identity(org.jboss.galleon.cli.model.Identity) HashSet(java.util.HashSet)

Example 4 with PackageInfo

use of org.jboss.galleon.cli.model.PackageInfo in project galleon by wildfly.

the class StateInfoUtil method displayFeatureSpec.

private static void displayFeatureSpec(PmCommandInvocation session, Group grp) throws IOException {
    FeatureSpecInfo f = grp.getSpec();
    session.println("");
    session.println("Feature type       : " + f.getSpecId().getName());
    session.println("Feature origin     : " + f.getSpecId().getProducer());
    session.println("Feature description: " + f.getDescription());
    if (!f.isEnabled()) {
        session.println("WARNING! The feature is not enabled.");
        session.println("Missing packages");
        for (Identity m : f.getMissingPackages()) {
            session.println(m.toString());
        }
    }
    List<FeatureParameterSpec> idparams = f.getSpec().getIdParams();
    String tab = "  ";
    session.println(Config.getLineSeparator() + "Feature Id parameters");
    if (idparams.isEmpty()) {
        session.println("NONE");
    } else {
        for (FeatureParameterSpec param : idparams) {
            StringBuilder builder = new StringBuilder();
            builder.append(tab + param.getName()).append(Config.getLineSeparator());
            builder.append(tab + tab + "description  : " + "no description available").append(Config.getLineSeparator());
            builder.append(tab + tab + "type         : " + param.getType()).append(Config.getLineSeparator());
            builder.append(tab + tab + "default-value: " + param.getDefaultValue()).append(Config.getLineSeparator());
            builder.append(tab + tab + "nillable     : " + param.isNillable()).append(Config.getLineSeparator());
            session.print(builder.toString());
        }
    }
    // Add spec parameters
    session.println(Config.getLineSeparator() + "Feature parameters");
    Map<String, FeatureParameterSpec> params = f.getSpec().getParams();
    if (params.isEmpty()) {
        session.println("NONE");
    } else {
        for (Entry<String, FeatureParameterSpec> entry : params.entrySet()) {
            FeatureParameterSpec param = entry.getValue();
            if (!param.isFeatureId()) {
                StringBuilder builder = new StringBuilder();
                builder.append(tab + param.getName()).append(Config.getLineSeparator());
                builder.append(tab + tab + "description  : " + "no description available").append(Config.getLineSeparator());
                builder.append(tab + tab + "type         : " + param.getType()).append(Config.getLineSeparator());
                builder.append(tab + tab + "default-value: " + param.getDefaultValue()).append(Config.getLineSeparator());
                builder.append(tab + tab + "nillable     : " + param.isNillable()).append(Config.getLineSeparator());
                session.println(builder.toString());
            }
        }
    }
    session.println(Config.getLineSeparator() + "Packages");
    if (f.getPackages().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (PackageInfo p : f.getPackages()) {
            session.println(p.getIdentity().toString());
        }
    }
    session.println(Config.getLineSeparator() + "Provided capabilities");
    if (f.getSpec().getProvidedCapabilities().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (CapabilitySpec c : f.getSpec().getProvidedCapabilities()) {
            session.println(tab + c.toString());
        }
    }
    session.println(Config.getLineSeparator() + "Consumed capabilities");
    if (f.getSpec().getRequiredCapabilities().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (CapabilitySpec c : f.getSpec().getRequiredCapabilities()) {
            session.println(tab + c.toString());
        }
    }
    session.println(Config.getLineSeparator() + "Features dependencies");
    if (f.getSpec().getFeatureDeps().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (FeatureDependencySpec c : f.getSpec().getFeatureDeps()) {
            session.println(tab + c.getFeatureId().toString());
        }
    }
    session.println(Config.getLineSeparator() + "Features references");
    if (f.getSpec().getFeatureRefs().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (FeatureReferenceSpec c : f.getSpec().getFeatureRefs()) {
            session.println(tab + c.getFeature());
        }
    }
    session.println(Config.getLineSeparator() + "Features Annotations");
    if (f.getSpec().getAnnotations().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (FeatureAnnotation c : f.getSpec().getAnnotations()) {
            session.println(tab + c.toString());
        }
    }
}
Also used : CapabilitySpec(org.jboss.galleon.spec.CapabilitySpec) PackageInfo(org.jboss.galleon.cli.model.PackageInfo) FeatureDependencySpec(org.jboss.galleon.spec.FeatureDependencySpec) FeatureReferenceSpec(org.jboss.galleon.spec.FeatureReferenceSpec) FeatureParameterSpec(org.jboss.galleon.spec.FeatureParameterSpec) FeatureSpecInfo(org.jboss.galleon.cli.model.FeatureSpecInfo) Identity(org.jboss.galleon.cli.model.Identity) FeatureAnnotation(org.jboss.galleon.spec.FeatureAnnotation)

Example 5 with PackageInfo

use of org.jboss.galleon.cli.model.PackageInfo in project galleon by wildfly.

the class StateSearchCommand method run.

private void run(FeatureContainer container, PmCommandInvocation invoc, boolean dependencySearch) throws PathParserException, PathConsumerException, ProvisioningException {
    if (pkg != null) {
        PackageInfo spec = getPackage(dependencySearch ? container : new AbstractPackageCommand.AllPackagesContainer(container), pkg);
        invoc.println(Config.getLineSeparator() + "As a direct dependency of a package:");
        StringBuilder pBuilder = new StringBuilder();
        for (Entry<String, Group> pkgs : container.getPackages().entrySet()) {
            Group root = pkgs.getValue();
            for (Group g : root.getGroups()) {
                for (Group dep : g.getGroups()) {
                    if (dep.getIdentity().equals(spec.getIdentity())) {
                        pBuilder.append("  " + g.getIdentity()).append(Config.getLineSeparator());
                        break;
                    }
                }
            }
        }
        if (pBuilder.length() != 0) {
            invoc.println(pBuilder.toString());
        } else {
            invoc.println("NONE");
        }
        Set<ResolvedSpecId> fspecs = findFeatures(spec, container);
        invoc.println("Reachable from features:");
        if (fspecs.isEmpty()) {
            invoc.println("NONE");
        } else {
            for (ResolvedSpecId id : fspecs) {
                List<FeatureInfo> features = container.getAllFeatures().get(id);
                // Can be null if we have all specs whatever the set of features.
                if (features != null) {
                    for (FeatureInfo fi : features) {
                        invoc.println("  " + fi.getPath());
                    }
                } else {
                    invoc.println("      [spec only] " + toPath(id));
                }
            }
        }
        return;
    }
    invoc.println(Config.getLineSeparator() + "Packages:");
    StringBuilder pBuilder = new StringBuilder();
    for (Entry<String, Group> pkgs : container.getPackages().entrySet()) {
        Group root = pkgs.getValue();
        for (Group g : root.getGroups()) {
            PackageInfo p = g.getPackage();
            if (p.getIdentity().toString().contains(query)) {
                pBuilder.append("  " + FeatureContainerPathConsumer.PACKAGES_PATH + p.getIdentity()).append(Config.getLineSeparator());
                if (!dependencySearch) {
                    pBuilder.append("    Reachable from features:").append(Config.getLineSeparator());
                    Set<ResolvedSpecId> fspecs = findFeatures(p, container);
                    if (fspecs.isEmpty()) {
                        pBuilder.append("      NONE" + Config.getLineSeparator());
                    }
                    for (ResolvedSpecId id : fspecs) {
                        List<FeatureInfo> features = container.getAllFeatures().get(id);
                        // Can be null if we have all specs whatever the set of features.
                        if (features != null) {
                            for (FeatureInfo fi : features) {
                                pBuilder.append("      " + fi.getPath()).append(Config.getLineSeparator());
                            }
                        } else {
                            pBuilder.append("  [spec only] " + toPath(id)).append(Config.getLineSeparator());
                        }
                    }
                }
            }
        }
    }
    if (pBuilder.length() != 0) {
        invoc.println(pBuilder.toString());
    } else {
        invoc.println("NONE");
    }
    pBuilder = new StringBuilder();
    invoc.println(Config.getLineSeparator() + "Package dependencies:");
    for (Entry<String, Group> pkgs : container.getPackages().entrySet()) {
        Group root = pkgs.getValue();
        for (Group g : root.getGroups()) {
            StringBuilder depBuilder = new StringBuilder();
            for (Group dep : g.getGroups()) {
                if (dep.getIdentity().toString().contains(query)) {
                    depBuilder.append("  " + dep.getIdentity()).append(Config.getLineSeparator());
                    break;
                }
            }
            if (depBuilder.length() != 0) {
                pBuilder.append("  Found as a direct dependencies of " + g.getIdentity()).append(Config.getLineSeparator());
                pBuilder.append(depBuilder);
            }
        }
    }
    if (pBuilder.length() != 0) {
        invoc.println(pBuilder.toString());
    } else {
        invoc.println("NONE");
    }
    pBuilder = new StringBuilder();
    invoc.println(Config.getLineSeparator() + "Package content:");
    for (Entry<String, Group> entry : container.getPackages().entrySet()) {
        Group root = entry.getValue();
        for (Group g : root.getGroups()) {
            PackageInfo pkginfo = g.getPackage();
            StringBuilder contentBuilder = new StringBuilder();
            for (String c : pkginfo.getContent()) {
                if (c.contains(query)) {
                    contentBuilder.append(c).append(Config.getLineSeparator());
                }
            }
            if (contentBuilder.length() != 0) {
                pBuilder.append("  Found in content of " + g.getIdentity()).append(Config.getLineSeparator());
                pBuilder.append(contentBuilder);
            }
        }
    }
    if (pBuilder.length() != 0) {
        invoc.println(pBuilder.toString());
    } else {
        invoc.println("NONE");
    }
    pBuilder = new StringBuilder();
    // Features?
    invoc.println(Config.getLineSeparator() + "Features:");
    for (Entry<ResolvedSpecId, List<FeatureInfo>> features : container.getAllFeatures().entrySet()) {
        ResolvedSpecId id = features.getKey();
        List<FeatureInfo> fs = features.getValue();
        if (fs == null) {
            if (id.getName().contains(query)) {
                pBuilder.append("  [spec only] " + toPath(id)).append(Config.getLineSeparator());
            }
        } else {
            for (FeatureInfo fi : fs) {
                if (fi.getPath().contains(query)) {
                    pBuilder.append("  " + fi.getPath()).append(Config.getLineSeparator());
                }
            }
        }
    }
    if (pBuilder.length() != 0) {
        invoc.println(pBuilder.toString());
    } else {
        invoc.println("NONE");
    }
}
Also used : Group(org.jboss.galleon.cli.model.Group) ResolvedSpecId(org.jboss.galleon.runtime.ResolvedSpecId) PackageInfo(org.jboss.galleon.cli.model.PackageInfo) FeatureInfo(org.jboss.galleon.cli.model.FeatureInfo) List(java.util.List)

Aggregations

PackageInfo (org.jboss.galleon.cli.model.PackageInfo)5 Group (org.jboss.galleon.cli.model.Group)4 Identity (org.jboss.galleon.cli.model.Identity)3 FeatureSpecInfo (org.jboss.galleon.cli.model.FeatureSpecInfo)2 ResolvedSpecId (org.jboss.galleon.runtime.ResolvedSpecId)2 HashSet (java.util.HashSet)1 List (java.util.List)1 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)1 FeatureInfo (org.jboss.galleon.cli.model.FeatureInfo)1 FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)1 PathConsumerException (org.jboss.galleon.cli.path.PathConsumerException)1 PathParserException (org.jboss.galleon.cli.path.PathParserException)1 CapabilitySpec (org.jboss.galleon.spec.CapabilitySpec)1 FeatureAnnotation (org.jboss.galleon.spec.FeatureAnnotation)1 FeatureDependencySpec (org.jboss.galleon.spec.FeatureDependencySpec)1 FeatureParameterSpec (org.jboss.galleon.spec.FeatureParameterSpec)1 FeatureReferenceSpec (org.jboss.galleon.spec.FeatureReferenceSpec)1