app.println(Message.raw(name));
}
} else {
// Create a table of their properties.
TableBuilder builder = new TableBuilder();
builder.appendHeading(relation.getUserFriendlyName());
builder
.appendHeading(INFO_DSCFG_HEADING_COMPONENT_TYPE.get());
for (String propertyName : propertyNames) {
builder.appendHeading(Message.raw(propertyName));
}
builder.addSortKey(0);
String baseType = relation.getChildDefinition().getName();
String typeSuffix = "-" + baseType;
for (String name : children.keySet()) {
ManagedObject<?> child = children.get(name);
ManagedObjectDefinition<?, ?> d = child.getManagedObjectDefinition();
// Skip advanced and hidden components in non-advanced mode.
if (!app.isAdvancedMode()) {
if (d.hasOption(ManagedObjectOption.HIDDEN)) {
continue;
}
if (d.hasOption(ManagedObjectOption.ADVANCED)) {
continue;
}
}
// First output the name.
builder.startRow();
if (relation instanceof SetRelationDefinition) {
builder.appendCell(d.getUserFriendlyName());
} else {
builder.appendCell(name);
}
// Output the managed object type in the form used in
// create-xxx commands.
String childType = d.getName();
boolean isCustom = CLIProfile.getInstance().isForCustomization(d);
if (baseType.equals(childType)) {
if (isCustom) {
builder.appendCell(DSConfig.CUSTOM_TYPE);
} else {
builder.appendCell(DSConfig.GENERIC_TYPE);
}
} else if (childType.endsWith(typeSuffix)) {
String ctname = childType.substring(0, childType.length()
- typeSuffix.length());
if (isCustom) {
ctname = String.format("%s-%s", DSConfig.CUSTOM_TYPE, ctname);
}
builder.appendCell(ctname);
} else {
builder.appendCell(childType);
}
// Now any requested properties.
for (String propertyName : propertyNames) {
try {
PropertyDefinition<?> pd = d.getPropertyDefinition(propertyName);
displayProperty(app, builder, child, pd, valuePrinter);
} catch (IllegalArgumentException e) {
// Assume this child managed object does not support this
// property.
if (app.isScriptFriendly()) {
builder.appendCell();
} else {
builder.appendCell("-");
}
}
}
}
PrintStream out = app.getOutputStream();
if (app.isScriptFriendly()) {
TablePrinter printer = createScriptFriendlyTablePrinter(out);
builder.print(printer);
} else {
if (app.isInteractive()) {
// Make interactive mode prettier.
app.println();
app.println();
}
TextTablePrinter printer = new TextTablePrinter(out);
printer.setColumnSeparator(ToolConstants.LIST_TABLE_SEPARATOR);
builder.print(printer);
}
}
return MenuResult.success(0);
}