/** * Get the logical tables for which the given logical metric is valid. * * @param logicalMetric Logical Metric to look up Logical Tables by * * @return The list of logical tables that have the logical metric */ public List<LogicalTable> findByLogicalMetric(LogicalMetric logicalMetric) { return values() .stream() .filter(it -> it.getLogicalMetrics().contains(logicalMetric)) .collect(Collectors.toList()); }
/** * Get the logical tables for which the given logical dimension is valid. * * @param dimension Dimension to look up Logical Tables by * * @return The list of logical tables that have the dimension */ public List<LogicalTable> findByDimension(Dimension dimension) { return values() .stream() .filter(it -> it.getDimensions().contains(dimension)) .collect(Collectors.toList()); } }
/** * Extracts the list of logical table names from the url table path segment and generates a set of logical table * objects based on it. * * @param tableName logical table corresponding to the table name specified in the URL * @param tableDictionary Logical table dictionary contains the map of valid table names and table objects. * * @return Set of logical table objects. * @throws BadApiRequestException if an invalid table is requested or the logical table dictionary is empty. */ protected LinkedHashSet<LogicalTable> generateTables(String tableName, LogicalTableDictionary tableDictionary) throws BadApiRequestException { LinkedHashSet<LogicalTable> generated = tableDictionary.values().stream() .filter(logicalTable -> tableName == null || tableName.equals(logicalTable.getName())) .collect(Collectors.toCollection(LinkedHashSet::new)); // Check if logical tables exist with the requested logical table name if (generated.isEmpty()) { String msg; if (tableDictionary.isEmpty()) { msg = EMPTY_DICTIONARY.logFormat("Logical Table"); } else { msg = TABLE_UNDEFINED.logFormat(tableName); } LOG.error(msg); throw new BadApiRequestException(msg); } LOG.trace("Generated set of logical tables: {}", generated); return generated; }