/** * Constructor. * * @param key Initial key with which to populate the map * @param value Initial value with which to populate the map */ public TableView (String key, Object value) { this.put(key, value); } }
/** * Method to provide metadata of the table. * * @param logicalTable Logical Table Ex: Network, SpaceId * @param uriInfo Uri information to construct the uri's * * @return Meta data details of the given table */ @Override public TableView formatTable(LogicalTable logicalTable, UriInfo uriInfo) { TableView resultRow = new TableView(); resultRow.put("name", logicalTable.getName()); resultRow.put("longName", logicalTable.getLongName()); resultRow.put("description", logicalTable.getDescription()); resultRow.put("category", logicalTable.getCategory()); return resultRow; }
/** * Method to provide full view of the tables which includes grains, metrics and dimensions. * * @param logicalTables Set of logical tables * @param uriInfo Uri information to construct the uri's * * @return List of table details with all the associated meta info */ @Override public List<TableView> formatTables(Set<LogicalTable> logicalTables, UriInfo uriInfo) { //Map to keep meta info of the logical table Map<String, TableView> tablesMeta = new HashMap<>(); //Map to keep list of time grain details for the logical table Map<String, List<TableGrainView>> grainsData = new HashMap<>(); for (LogicalTable logicalTable : logicalTables) { //An array list to store grain level definition of given logical table List<TableGrainView> grains = grainsData .computeIfAbsent(logicalTable.getName(), (ignore) -> new ArrayList<>()); grains.add(formatTableGrain(logicalTable, logicalTable.getGranularity().getName(), uriInfo)); tablesMeta.computeIfAbsent(logicalTable.getName(), k -> formatTable(logicalTable, uriInfo)); } List<TableView> tableViewList = new ArrayList<>(); Set<Map.Entry<String, TableView>> entrySet = tablesMeta.entrySet(); for (Map.Entry<String, TableView> entry : entrySet) { TableView tableView = entry.getValue(); tableView.put("timeGrains", grainsData.get(entry.getKey())); tableViewList.add(tableView); } return tableViewList; }