private void buildComposite() { try { GfJsonObject content = getContent(); if (content != null) { Table resultTable = TableBuilder.newTable(); resultTable.setColumnSeparator(" : "); addHeaderInTable(resultTable, getGfJsonObject()); for (Iterator<String> it = content.keys(); it.hasNext();) { String key = it.next(); if (key.startsWith(ResultData.SECTION_DATA_ACCESSOR)) { GfJsonObject subSection = content.getJSONObject(key); buildSection(resultTable, null, subSection, 0); } else if (key.equals(CompositeResultData.SEPARATOR)) { String separatorString = content.getString(key); resultTable.newRowGroup().newRowSeparator(separatorString.charAt(0), true); } } addFooterInTable(resultTable, getGfJsonObject()); resultLines.addAll(resultTable.buildTableList()); } } catch (GfJsonException e) { resultLines .add("Error occurred while processing Command Result. Internal Error - Invalid Result."); logger.info( "Error occurred while processing Command Result. Internal Error - Invalid Result.", e); } finally { isDataBuilt = true; } }
private void buildData(TableBuilder.Table resultTable, DataResultModel section) { TableBuilder.RowGroup rowGroup = resultTable.newRowGroup(); rowGroup.setColumnSeparator(" : "); addRowInRowGroup(rowGroup, section.getHeader()); // finally process map values for (Map.Entry<String, String> entry : section.getContent().entrySet()) { TableBuilder.Row newRow = rowGroup.newRow(); String key = entry.getKey(); String value = entry.getValue(); String[] values = entry.getValue().split(GfshParser.LINE_SEPARATOR); if (values.length == 1) { newRow.newLeftCol(key).newLeftCol(values[0]); } else { if (values.length != 0) { // possible when object == CliConstants.LINE_SEPARATOR newRow.newLeftCol(key).newLeftCol(values[0]); for (int i = 1; i < values.length; i++) { newRow = rowGroup.newRow(); newRow.setColumnSeparator(" "); newRow.newLeftCol("").newLeftCol(values[i]); } } else { newRow.newLeftCol(key).newLeftCol(""); } } } addRowInRowGroup(rowGroup, section.getFooter()); }
private void buildData() { try { if (ResultData.TYPE_COMPOSITE.equals(resultData.getType())) { buildComposite(); } else { GfJsonObject content = getContent(); if (content != null) { Table resultTable = TableBuilder.newTable(); addHeaderInTable(resultTable, getGfJsonObject()); RowGroup rowGroup = resultTable.newRowGroup(); if (ResultData.TYPE_TABULAR.equals(resultData.getType())) { resultTable.setColumnSeparator(" "); resultTable.setTabularResult(true); buildTable(rowGroup, content); } else { buildInfoErrorData(rowGroup, content); } addFooterInTable(resultTable, getGfJsonObject()); resultLines.addAll(resultTable.buildTableList()); } } } catch (GfJsonException e) { resultLines .add("Error occurred while processing Command Result. Internal Error - Invalid Result."); } finally { isDataBuilt = true; } }
rowGroup = parentRowGroup; } else { rowGroup = table.newRowGroup(); RowGroup rowGroupForTable = table.newRowGroup(); buildTable(rowGroupForTable, tableObject.getJSONObject(ResultData.RESULT_CONTENT));
public void newBlankRow() { RowGroup rowGroup = newRowGroup(); rowGroup.newBlankRow(); }
public Row newRow() { RowGroup rowGroup = newRowGroup(); return rowGroup.newRow(); }
private void buildTabularCommandOutput(TableBuilder.Table resultTable, TabularResultModel model) { addSpacedRowInTable(resultTable, model.getHeader()); resultTable.setColumnSeparator(" "); resultTable.setTabularResult(true); TableBuilder.RowGroup rowGroup = resultTable.newRowGroup(); buildTable(rowGroup, model); addSpacedRowInTable(resultTable, model.getFooter()); }
private void buildInfoOrErrorCommandOutput(TableBuilder.Table resultTable, InfoResultModel model) { TableBuilder.RowGroup rowGroup = resultTable.newRowGroup(); addRowInRowGroup(rowGroup, model.getHeader()); model.getContent().forEach(c -> rowGroup.newRow().newLeftCol(c)); addRowInRowGroup(rowGroup, model.getFooter()); } }