Package org.jboss.as.cli.util

Examples of org.jboss.as.cli.util.StrictSizeTable$Column


                }
                if(!step.has(Util.RESULT)) {
                    throw new CommandFormatException("Failed to read the main resource info of the deployment: " + Util.getFailureDescription(step));
                }
                ModelNode stepResponse = step.get(Util.RESULT);
                final StrictSizeTable table = new StrictSizeTable(1);
                table.addCell(Util.NAME, stepResponse.get(Util.NAME).asString());
                table.addCell(Util.RUNTIME_NAME, stepResponse.get(Util.RUNTIME_NAME).asString());
                ctx.printLine(table.toString());

                final SimpleTable groups = new SimpleTable(new String[]{"SERVER GROUP", "STATE"});
                if(addedServerGroups == null) {
                    if(steps.hasNext()) {
                        throw new CommandFormatException("Didn't expect results for server groups but received " + (result.asPropertyList().size() - 1) + " more steps.");
                    }
                } else {
                    for(String sg : addedServerGroups) {
                        final Property prop = steps.next();
                        stepResponse = prop.getValue();
                        if(stepResponse.has(prop.getName())) { // TODO remove when the structure is consistent
                            stepResponse = stepResponse.get(prop.getName());
                        }

                        if(stepResponse.hasDefined(Util.RESULT)) {
                            final ModelNode stepResult = stepResponse.get(Util.RESULT);
                            if(stepResult.hasDefined(Util.ENABLED)) {
                                groups.addLine(new String[]{sg, stepResult.get(Util.ENABLED).asBoolean() ? Util.ENABLED : "added"});
                            } else {
                                groups.addLine(new String[]{sg, "n/a"});
                            }
                        } else {
                            groups.addLine(new String[]{sg, "no response"});
                        }
                    }
                }

                if(otherServerGroups != null) {
                    for(String sg : otherServerGroups) {
                        groups.addLine(new String[]{sg, "not added"});
                    }
                }
                ctx.printLine(groups.toString(true));
        } else {
            final StrictSizeTable table = new StrictSizeTable(1);
            table.addCell(Util.NAME, result.get(Util.NAME).asString());
            table.addCell(Util.RUNTIME_NAME, result.get(Util.RUNTIME_NAME).asString());
            table.addCell(Util.PERSISTENT, result.get(Util.PERSISTENT).asString());
            table.addCell(Util.ENABLED, result.get(Util.ENABLED).asString());
            table.addCell(Util.STATUS, result.get(Util.STATUS).asString());
            ctx.printLine(table.toString());
        }
        } finally {
            addedServerGroups = null;
            otherServerGroups = null;
        }
View Full Code Here


        final List<String> names = Util.getDeployments(client);
        if(names.isEmpty()) {
            return;
        }

        final StrictSizeTable table = new StrictSizeTable(names.size());
        final List<Property> descriptions = getDeploymentDescriptions(ctx, names).asPropertyList();
        for(Property prop : descriptions) {
            final ModelNode step = prop.getValue();
            if(step.hasDefined(Util.RESULT)) {
                final ModelNode result = step.get(Util.RESULT);
                table.addCell(Util.NAME, result.get(Util.NAME).asString());
                table.addCell(Util.RUNTIME_NAME, result.get(Util.RUNTIME_NAME).asString());
                if(result.has(Util.ENABLED)) {
                    table.addCell(Util.ENABLED, result.get(Util.ENABLED).asString());
                }
                if(result.has(Util.STATUS)) {
                    table.addCell(Util.STATUS, result.get(Util.STATUS).asString());
                }
            }
            if(!table.isAtLastRow()) {
                table.nextRow();
            }
        }
        throw new CommandFormatException(table.toString());
    }
View Full Code Here

                                        // potentially, allowed and default values
//                                        SimpleTable attrTable = attrDescriptions == null ? null :
//                                            new SimpleTable(new String[]{"ATTR NAME", "VALUE", "TYPE", "NILLABLE", "REQUIRED", "ACCESS", "EXPR", "RESTART", "STORAGE"});
//                                      SimpleTable childrenTable = childDescriptions == null ? null :
//                                            new SimpleTable(new String[]{"CHILD NAME", "MIN-OCCURS", "MAX-OCCURS"});
                                        StrictSizeTable attrTable = attrDescriptions == null ? null : new StrictSizeTable(attrDescriptions.keys().size());
                                        StrictSizeTable childrenTable = childDescriptions == null ? null : new StrictSizeTable(childDescriptions.keys().size());
                                        if(typeNames == null && attrTable == null && childrenTable == null) {
                                            typeNames = new ArrayList<String>();
                                        }

                                        for (Property prop : props) {
                                            final StringBuilder buf = new StringBuilder();
                                            if(typeNames == null || !typeNames.contains(prop.getName())) {
                                                if(attrDescriptions == null) {
                                                    buf.append(prop.getName());
                                                    buf.append('=');
                                                    buf.append(prop.getValue().asString());
// TODO the value should be formatted nicer but the current fomatter uses new lines for complex value which doesn't work here
//                                                    final ModelNode value = prop.getValue();
//                                                    ModelNodeFormatter.Factory.forType(value.getType()).format(buf, 0, value);
                                                    typeNames.add(buf.toString());
                                                    buf.setLength(0);
                                                } else {
                                                    if(attrDescriptions.hasDefined(prop.getName())) {
                                                        final ModelNode attrDescr = attrDescriptions.get(prop.getName());
/*                                                        attrTable.addLine(new String[]{prop.getName(),
                                                                prop.getValue().asString(),
                                                                getAsString(attrDescr, Util.TYPE),
                                                                getAsString(attrDescr, Util.NILLABLE),
                                                                getAsString(attrDescr, Util.REQUIRED),
                                                                getAsString(attrDescr, Util.ACCESS_TYPE),
                                                                getAsString(attrDescr, Util.EXPRESSIONS_ALLOWED),
                                                                getAsString(attrDescr, Util.RESTART_REQUIRED),
                                                                getAsString(attrDescr, Util.STORAGE)
                                                                });
*/
                                                        attrTable.addCell("ATTRIBUTE", prop.getName());
                                                        attrTable.addCell(Util.VALUE, prop.getValue().asString());
                                                        for(String name : attrDescr.keys()) {
                                                            if(!Util.DESCRIPTION.equals(name) &&
                                                                    !Util.HEAD_COMMENT_ALLOWED.equals(name) &&
                                                                    !Util.TAIL_COMMENT_ALLOWED.equals(name)) {
                                                                attrTable.addCell(name, attrDescr.get(name).asString());
                                                            }
                                                        }
                                                    } else {
/*                                                        attrTable.addLine(new String[]{prop.getName(),
                                                                prop.getValue().asString(),
                                                                "n/a", "n/a", "n/a", "n/a", "n/a", "n/a"
                                                            });
*/
                                                        attrTable.addCell("ATTRIBUTE", prop.getName());
                                                        attrTable.addCell(Util.VALUE, prop.getValue().asString());
                                                    }
                                                    if(!attrTable.isAtLastRow()) {
                                                        attrTable.nextRow();
                                                    }
                                                }
                                            } else if(childDescriptions != null) {
                                                if(childDescriptions.hasDefined(prop.getName())) {
                                                    final ModelNode childDescr = childDescriptions.get(prop.getName());
/*                                                    childrenTable.addLine(new String[]{prop.getName(),
                                                            getAsString(childDescr, Util.MIN_OCCURS),
                                                            getAsString(childDescr, Util.MAX_OCCURS)
                                                            });
*/
                                                    childrenTable.addCell("CHILD", prop.getName());
                                                    for(String name : childDescr.keys()) {
                                                        if(!Util.DESCRIPTION.equals(name) &&
                                                                !Util.HEAD_COMMENT_ALLOWED.equals(name) &&
                                                                !Util.TAIL_COMMENT_ALLOWED.equals(name)) {
                                                            childrenTable.addCell(name, childDescr.get(name).asString());
                                                        }
                                                    }
                                                } else {
//                                                    attrTable.addLine(new String[]{prop.getName(), "n/a", "n/a"});
                                                    childrenTable.addCell("CHILD", prop.getName());
                                                }
                                                if(!childrenTable.isAtLastRow()) {
                                                    childrenTable.nextRow();
                                                }
                                            }
                                        }

                                        if(childrenTable != null && !childrenTable.isEmpty()) {
                                            ctx.printLine(childrenTable.toString());
                                        }
                                        if(attrTable != null && !attrTable.isEmpty()) {
                                            ctx.printLine(attrTable.toString());
                                        }
                                    }
View Full Code Here

        final List<String> names = Util.getDeployments(client);
        if(names.isEmpty()) {
            return;
        }

        final StrictSizeTable table = new StrictSizeTable(names.size());
        final List<Property> descriptions = getDeploymentDescriptions(ctx, names).asPropertyList();
        for(Property prop : descriptions) {
            final ModelNode step = prop.getValue();
            if(step.hasDefined(Util.RESULT)) {
                final ModelNode result = step.get(Util.RESULT);
                table.addCell(Util.NAME, result.get(Util.NAME).asString());
                table.addCell(Util.RUNTIME_NAME, result.get(Util.RUNTIME_NAME).asString());
                if(result.has(Util.ENABLED)) {
                    table.addCell(Util.ENABLED, result.get(Util.ENABLED).asString());
                }
                if(result.has(Util.STATUS)) {
                    table.addCell(Util.STATUS, result.get(Util.STATUS).asString());
                }
            }
            if(!table.isAtLastRow()) {
                table.nextRow();
            }
        }
        throw new CommandFormatException(table.toString());
    }
View Full Code Here

        final List<String> names = Util.getDeployments(client);
        if(names.isEmpty()) {
            return;
        }

        final StrictSizeTable table = new StrictSizeTable(names.size());
        final List<Property> descriptions = getDeploymentDescriptions(ctx, names).asPropertyList();
        for(Property prop : descriptions) {
            final ModelNode step = prop.getValue();
            if(step.hasDefined(Util.RESULT)) {
                final ModelNode result = step.get(Util.RESULT);
                table.addCell(Util.NAME, result.get(Util.NAME).asString());
                table.addCell(Util.RUNTIME_NAME, result.get(Util.RUNTIME_NAME).asString());
                if(result.has(Util.ENABLED)) {
                    table.addCell(Util.ENABLED, result.get(Util.ENABLED).asString());
                }
                if(result.has(Util.STATUS)) {
                    table.addCell(Util.STATUS, result.get(Util.STATUS).asString());
                }
            }
            if(!table.isAtLastRow()) {
                table.nextRow();
            }
        }
        throw new CommandFormatException(table.toString());
    }
View Full Code Here

                    }
                    if(!table.isEmpty()) {
                        ctx.printLine(table.toString(true));
                    }
                } else {
                    final StrictSizeTable table = new StrictSizeTable(1);
                    table.addCell(Util.NAME, stepResponse.get(Util.NAME).asString());
                    table.addCell(Util.RUNTIME_NAME, stepResponse.get(Util.RUNTIME_NAME).asString());
                    ctx.printLine(table.toString());
                    final SimpleTable groups = new SimpleTable(new String[] { SERVER_GROUP, STATE });
                    if (addedServerGroups == null) {
                        if (steps.hasNext()) {
                            throw new CommandFormatException("Didn't expect results for server groups but received "
                                    + (result.asPropertyList().size() - 1) + " more steps.");
                        }
                    } else {
                        for (String sg : addedServerGroups) {
                            final Property prop = steps.next();
                            stepResponse = prop.getValue();
                            if (stepResponse.has(prop.getName())) { // TODO remove when the structure is consistent
                                stepResponse = stepResponse.get(prop.getName());
                            }

                            if (stepResponse.hasDefined(Util.RESULT)) {
                                final ModelNode stepResult = stepResponse.get(Util.RESULT);
                                if (stepResult.hasDefined(Util.ENABLED)) {
                                    groups.addLine(new String[] { sg,
                                            stepResult.get(Util.ENABLED).asBoolean() ? Util.ENABLED : ADDED });
                                } else {
                                    groups.addLine(new String[] { sg, N_A });
                                }
                            } else {
                                groups.addLine(new String[] { sg, "no response" });
                            }
                        }
                    }

                    if (otherServerGroups != null) {
                        for (String sg : otherServerGroups) {
                            groups.addLine(new String[] { sg, NOT_ADDED });
                        }
                    }
                    ctx.printLine(groups.toString(true));
                }
            } else {
                final SimpleTable table = new SimpleTable(new String[] { NAME, RUNTIME_NAME, PERSISTENT, ENABLED, STATUS });
                final String deploymentName = name.getValue(ctx.getParsedCommandLine());
                if(deploymentName == null || deploymentName.indexOf('*') >= 0) {
                    final List<Property> list = result.asPropertyList();
                    if (!list.isEmpty()) {
                        final Pattern pattern = Pattern.compile(Util.wildcardToJavaRegex(deploymentName == null ? "*" : deploymentName));
                        for (Property p : list) {
                            final ModelNode node = p.getValue();
                            final String name = node.get(Util.NAME).asString();
                            if(pattern.matcher(name).matches()) {
                                table.addLine(new String[]{name, node.get(Util.RUNTIME_NAME).asString(),
                                        node.get(Util.PERSISTENT).asString(), node.get(Util.ENABLED).asString(),
                                        node.get(Util.STATUS).asString()});
                            }
                        }
                    }
                } else {
                    table.addLine(new String[]{result.get(Util.NAME).asString(), result.get(Util.RUNTIME_NAME).asString(),
                            result.get(Util.PERSISTENT).asString(), result.get(Util.ENABLED).asString(),
                            result.get(Util.STATUS).asString()});
                }
                if(!table.isEmpty()) {
                    ctx.printLine(table.toString());
                }
            }
        } finally {
            addedServerGroups = null;
            otherServerGroups = null;
View Full Code Here

        final List<String> names = Util.getDeployments(client);
        if(names.isEmpty()) {
            return;
        }

        final StrictSizeTable table = new StrictSizeTable(names.size());
        final List<Property> descriptions = getDeploymentDescriptions(ctx, names).asPropertyList();
        for(Property prop : descriptions) {
            final ModelNode step = prop.getValue();
            if(step.hasDefined(Util.RESULT)) {
                final ModelNode result = step.get(Util.RESULT);
                table.addCell(Util.NAME, result.get(Util.NAME).asString());
                table.addCell(Util.RUNTIME_NAME, result.get(Util.RUNTIME_NAME).asString());
                if(result.has(Util.ENABLED)) {
                    table.addCell(Util.ENABLED, result.get(Util.ENABLED).asString());
                }
                if(result.has(Util.STATUS)) {
                    table.addCell(Util.STATUS, result.get(Util.STATUS).asString());
                }
            }
            if(!table.isAtLastRow()) {
                table.nextRow();
            }
        }
        throw new CommandFormatException(table.toString());
    }
View Full Code Here

                if(!step.has(Util.RESULT)) {
                    ctx.error("Failed to read the main resource info of the deployment: " + Util.getFailureDescription(step));
                    return;
                }
                ModelNode stepResponse = step.get(Util.RESULT);
                final StrictSizeTable table = new StrictSizeTable(1);
                table.addCell(Util.NAME, stepResponse.get(Util.NAME).asString());
                table.addCell(Util.RUNTIME_NAME, stepResponse.get(Util.RUNTIME_NAME).asString());
                ctx.printLine(table.toString());

                final SimpleTable groups = new SimpleTable(new String[]{"SERVER GROUP", "STATE"});
                if(addedServerGroups == null) {
                    if(steps.hasNext()) {
                        ctx.error("Didn't expect results for server groups but received " + (result.asPropertyList().size() - 1) + " more steps.");
                        return;
                    }
                } else {
                    for(String sg : addedServerGroups) {
                        final Property prop = steps.next();
                        stepResponse = prop.getValue();
                        if(stepResponse.has(prop.getName())) { // TODO remove when the structure is consistent
                            stepResponse = stepResponse.get(prop.getName());
                        }

                        if(stepResponse.hasDefined(Util.RESULT)) {
                            final ModelNode stepResult = stepResponse.get(Util.RESULT);
                            if(stepResult.hasDefined(Util.ENABLED)) {
                                groups.addLine(new String[]{sg, stepResult.get(Util.ENABLED).asBoolean() ? Util.ENABLED : "added"});
                            } else {
                                groups.addLine(new String[]{sg, "n/a"});
                            }
                        } else {
                            groups.addLine(new String[]{sg, "no response"});
                        }
                    }
                }

                if(otherServerGroups != null) {
                    for(String sg : otherServerGroups) {
                        groups.addLine(new String[]{sg, "not added"});
                    }
                }
                ctx.printLine(groups.toString(true));
        } else {
            final StrictSizeTable table = new StrictSizeTable(1);
            table.addCell(Util.NAME, result.get(Util.NAME).asString());
            table.addCell(Util.RUNTIME_NAME, result.get(Util.RUNTIME_NAME).asString());
            table.addCell(Util.PERSISTENT, result.get(Util.PERSISTENT).asString());
            table.addCell(Util.ENABLED, result.get(Util.ENABLED).asString());
            table.addCell(Util.STATUS, result.get(Util.STATUS).asString());
            ctx.printLine(table.toString());
        }
        } finally {
            addedServerGroups = null;
            otherServerGroups = null;
        }
View Full Code Here

        final List<String> names = Util.getDeployments(client);
        if(names.isEmpty()) {
            return;
        }

        final StrictSizeTable table = new StrictSizeTable(names.size());
        final List<Property> descriptions = getDeploymentDescriptions(ctx, names).asPropertyList();
        for(Property prop : descriptions) {
            final ModelNode step = prop.getValue();
            if(step.hasDefined(Util.RESULT)) {
                final ModelNode result = step.get(Util.RESULT);
                table.addCell(Util.NAME, result.get(Util.NAME).asString());
                table.addCell(Util.RUNTIME_NAME, result.get(Util.RUNTIME_NAME).asString());
                if(result.has(Util.ENABLED)) {
                    table.addCell(Util.ENABLED, result.get(Util.ENABLED).asString());
                }
                if(result.has(Util.STATUS)) {
                    table.addCell(Util.STATUS, result.get(Util.STATUS).asString());
                }
            }
            if(!table.isAtLastRow()) {
                table.nextRow();
            }
        }
        ctx.error(table.toString());
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.cli.util.StrictSizeTable$Column

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.