[
https://issues.apache.org/jira/browse/UNOMI-167?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Serge Huber closed UNOMI-167.
-----------------------------
Resolution: Duplicate
Assignee: Serge Huber
Fix Version/s: 1.3.0-incubating
> 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
> Assignee: Serge Huber
> Priority: Minor
> Fix For: 1.3.0-incubating
>
>
> 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)