You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by "Jarek Lipski (JIRA)" <ji...@apache.org> on 2018/02/20 11:32:01 UTC
[jira] [Created] (UNOMI-167) Avoid duplicating shell table
formatting code
Jarek Lipski created UNOMI-167:
----------------------------------
Summary: Avoid duplicating shell table formatting code
Key: UNOMI-167
URL: https://issues.apache.org/jira/browse/UNOMI-167
Project: Apache Unomi
Issue Type: Improvement
Reporter: Jarek Lipski
In every command formatting data to shell, we repeat very similar code. Example (from SegmentListCommand)
{code:java}
ShellTable shellTable = new ShellTable();
for (String header : headers) {
shellTable.column(header);
}
for (DataTable.Row dataTableRow : dataTable.getRows()) {
ArrayList<Object> rowData = new ArrayList<Object>();
for (int i=0 ; i < dataTable.getMaxColumns(); i++) {
rowData.add(dataTableRow.getData(i));
}
Row row = shellTable.addRow();
row.addContent(rowData);
}
shellTable.print(System.out);
{code}
In order to avoid this repetition we could add a toShell ot printToShell command to DataTable common data structure. However, in order to do that we would need to add a dependency on "org.apache.karaf.shell.console" to unomi-common, so I hesitated to do it immediately.
In order to find all similar code occurence, search where DataTable is being used.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)