Search in sources :

Example 6 with Table

use of org.jboss.galleon.cli.cmd.Table in project galleon by wildfly.

the class CheckUpdatesCommand method getUpdatesTable.

static Updates getUpdatesTable(ProvisioningManager mgr, PmCommandInvocation session, boolean includeAll, String fp) throws ProvisioningException, CommandExecutionException {
    if (includeAll && fp != null) {
        throw new CommandExecutionException(CliErrors.onlyOneOptionOf(FP_OPTION_NAME, ALL_DEPENDENCIES_OPTION_NAME));
    }
    ProvisioningPlan plan;
    if (fp == null) {
        plan = mgr.getUpdates(includeAll);
    } else {
        String[] split = fp.split(",+");
        List<ProducerSpec> resolved = new ArrayList<>();
        List<FeaturePackLocation> locs = new ArrayList<>();
        for (String producer : split) {
            FeaturePackLocation loc = session.getPmSession().getResolvedLocation(mgr.getInstallationHome(), producer);
            if (loc.hasBuild()) {
                locs.add(loc);
            } else {
                resolved.add(loc.getProducer());
            }
        }
        if (!resolved.isEmpty()) {
            ProducerSpec[] arr = new ProducerSpec[resolved.size()];
            plan = mgr.getUpdates(resolved.toArray(arr));
        } else {
            plan = ProvisioningPlan.builder();
        }
        if (!locs.isEmpty()) {
            addCustomUpdates(plan, locs, mgr);
        }
    }
    Updates updates = new Updates();
    updates.plan = plan;
    if (plan.isEmpty()) {
        return updates;
    }
    boolean hasPatches = false;
    for (FeaturePackUpdatePlan p : plan.getUpdates()) {
        if (p.hasNewPatches()) {
            hasPatches = true;
            break;
        }
    }
    List<String> headers = new ArrayList<>();
    headers.add(Headers.PRODUCT);
    headers.add(Headers.CURRENT_BUILD);
    headers.add(Headers.UPDATE);
    if (hasPatches) {
        headers.add(Headers.PATCHES);
    }
    if (includeAll) {
        headers.add(Headers.DEPENDENCY);
    }
    headers.add(Headers.UPDATE_CHANNEL);
    updates.t = new Table(headers);
    for (FeaturePackUpdatePlan p : plan.getUpdates()) {
        FeaturePackLocation loc = p.getInstalledLocation();
        String update = p.hasNewLocation() ? p.getNewLocation().getBuild() : NONE;
        Cell patches = null;
        if (hasPatches) {
            patches = new Cell();
            if (p.hasNewPatches()) {
                for (FPID id : p.getNewPatches()) {
                    patches.addLine(id.getBuild());
                }
            } else {
                patches.addLine(NONE);
            }
        }
        List<Cell> line = new ArrayList<>();
        line.add(new Cell(loc.getProducerName()));
        line.add(new Cell(loc.getBuild()));
        line.add(new Cell(update));
        if (hasPatches) {
            line.add(patches);
        }
        if (includeAll) {
            line.add(new Cell(p.isTransitive() ? "Y" : "N"));
        }
        FeaturePackLocation newLocation = session.getPmSession().getExposedLocation(mgr.getInstallationHome(), p.getNewLocation());
        line.add(new Cell(StateInfoUtil.formatChannel(newLocation)));
        updates.t.addCellsLine(line);
    }
    updates.t.sort(Table.SortType.ASCENDANT);
    return updates;
}
Also used : ProvisioningPlan(org.jboss.galleon.layout.ProvisioningPlan) Table(org.jboss.galleon.cli.cmd.Table) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) ArrayList(java.util.ArrayList) FeaturePackUpdatePlan(org.jboss.galleon.layout.FeaturePackUpdatePlan) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) Cell(org.jboss.galleon.cli.cmd.Table.Cell)

Example 7 with Table

use of org.jboss.galleon.cli.cmd.Table in project galleon by wildfly.

the class StateInfoUtil method buildPatches.

public static String buildPatches(PmCommandInvocation invoc, ProvisioningLayout<FeaturePackLayout> layout) throws ProvisioningException {
    if (!layout.hasPatches()) {
        return null;
    }
    Table table = new Table(Headers.PATCH, Headers.PATCH_FOR, Headers.UPDATE_CHANNEL);
    for (FeaturePackLayout fpLayout : layout.getOrderedFeaturePacks()) {
        List<FeaturePackLayout> patches = layout.getPatches(fpLayout.getFPID());
        for (FeaturePackLayout patch : patches) {
            FeaturePackLocation loc = invoc.getPmSession().getExposedLocation(null, patch.getFPID().getLocation());
            FPID patchFor = patch.getSpec().getPatchFor();
            table.addLine(patch.getFPID().getBuild(), patchFor.getProducer().getName() + FeaturePackLocation.BUILD_START + patchFor.getBuild(), formatChannel(loc));
        }
    }
    if (!table.isEmpty()) {
        table.sort(Table.SortType.ASCENDANT);
        return table.build();
    }
    return null;
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 8 with Table

use of org.jboss.galleon.cli.cmd.Table in project galleon by wildfly.

the class StateInfoUtil method buildOptionsTable.

private static String buildOptionsTable(Set<ProvisioningOption> options) {
    Table t = new Table(Headers.OPTION, Headers.REQUIRED, Headers.DEFAULT_VALUE);
    for (ProvisioningOption opt : options) {
        t.addLine("--" + opt.getName() + "=", opt.isRequired() ? "Y" : "N", opt.getDefaultValue() == null ? "" : opt.getDefaultValue());
    }
    t.sort(Table.SortType.ASCENDANT);
    return t.build();
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) ProvisioningOption(org.jboss.galleon.ProvisioningOption)

Example 9 with Table

use of org.jboss.galleon.cli.cmd.Table in project galleon by wildfly.

the class StateInfoUtil method printFeaturePack.

public static void printFeaturePack(PmCommandInvocation commandInvocation, FeaturePackLocation loc) {
    loc = commandInvocation.getPmSession().getExposedLocation(null, loc);
    Table t = new Table(Headers.PRODUCT, Headers.BUILD, Headers.UPDATE_CHANNEL);
    t.addLine(loc.getProducer().getName(), loc.getBuild(), formatChannel(loc));
    commandInvocation.print(t.build());
}
Also used : Table(org.jboss.galleon.cli.cmd.Table)

Example 10 with Table

use of org.jboss.galleon.cli.cmd.Table in project galleon by wildfly.

the class MavenGetInfo method runCommand.

@Override
protected void runCommand(PmCommandInvocation session) throws CommandExecutionException {
    Table t = new Table(Headers.CONFIGURATION_ITEM, Headers.VALUE);
    MavenConfig config = session.getPmSession().getPmConfiguration().getMavenConfig();
    t.addLine("Maven xml settings", (config.getSettings() == null ? "No settings file set" : config.getSettings().normalize().toString()));
    t.addLine("Local repository", config.getLocalRepository().normalize().toString());
    t.addLine("Default release policy", config.getDefaultReleasePolicy());
    t.addLine("Default snapshot policy", config.getDefaultSnapshotPolicy());
    t.addLine("Enable release", "" + config.isReleaseEnabled());
    t.addLine("Enable snapshot", "" + config.isSnapshotEnabled());
    t.addLine("Offline", "" + config.isOffline());
    Cell repositories = new Cell();
    Cell title = new Cell("Remote repositories");
    if (config.getRemoteRepositories().isEmpty()) {
        repositories.addLine("None");
    } else {
        for (MavenRemoteRepository rep : session.getPmSession().getPmConfiguration().getMavenConfig().getRemoteRepositories()) {
            repositories.addLine(rep.getName());
            repositories.addLine(" url=" + rep.getUrl());
            repositories.addLine(" type=" + rep.getType());
            repositories.addLine(" release=" + (rep.getEnableRelease() == null ? config.isReleaseEnabled() : rep.getEnableRelease()));
            repositories.addLine(" releaseUpdatePolicy=" + (rep.getReleaseUpdatePolicy() == null ? config.getDefaultReleasePolicy() : rep.getReleaseUpdatePolicy()));
            repositories.addLine(" snapshot=" + (rep.getEnableSnapshot() == null ? config.isSnapshotEnabled() : rep.getEnableSnapshot()));
            repositories.addLine(" snapshotUpdatePolicy=" + (rep.getSnapshotUpdatePolicy() == null ? config.getDefaultSnapshotPolicy() : rep.getSnapshotUpdatePolicy()));
        }
    }
    t.addCellsLine(title, repositories);
    t.sort(Table.SortType.ASCENDANT);
    session.println(t.build());
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) MavenRemoteRepository(org.jboss.galleon.cli.config.mvn.MavenRemoteRepository) MavenConfig(org.jboss.galleon.cli.config.mvn.MavenConfig) Cell(org.jboss.galleon.cli.cmd.Table.Cell)

Aggregations

Table (org.jboss.galleon.cli.cmd.Table)10 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)5 ArrayList (java.util.ArrayList)4 Cell (org.jboss.galleon.cli.cmd.Table.Cell)4 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)4 HashMap (java.util.HashMap)2 Set (java.util.Set)2 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)2 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)2 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)2 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ProvisioningOption (org.jboss.galleon.ProvisioningOption)1 UniverseVisitor (org.jboss.galleon.cli.UniverseManager.UniverseVisitor)1 MavenConfig (org.jboss.galleon.cli.config.mvn.MavenConfig)1 MavenRemoteRepository (org.jboss.galleon.cli.config.mvn.MavenRemoteRepository)1 ConfigInfo (org.jboss.galleon.cli.model.ConfigInfo)1