/** * 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()); }
/** * Validate that all metrics are part of the logical table. * * @param logicalMetrics The set of metrics being validated * @param table The logical table for the request * * @throws BadApiRequestException if the requested metrics are not in the logical table */ protected void validateMetrics(Set<LogicalMetric> logicalMetrics, LogicalTable table) throws BadApiRequestException { //get metric names from the logical table Set<String> validMetricNames = table.getLogicalMetrics().stream() .map(LogicalMetric::getName) .collect(Collectors.toSet()); //get metric names from logicalMetrics and remove all the valid metrics Set<String> invalidMetricNames = logicalMetrics.stream() .map(LogicalMetric::getName) .filter(it -> !validMetricNames.contains(it)) .collect(Collectors.toSet()); //requested metrics names are not present in the logical table metric names set if (!invalidMetricNames.isEmpty()) { LOG.debug(METRICS_NOT_IN_TABLE.logFormat(invalidMetricNames, table.getName())); throw new BadApiRequestException( METRICS_NOT_IN_TABLE.format(invalidMetricNames, table.getName()) ); } }
resultRow.put( "metrics", MetricsServlet.getLogicalMetricListSummaryView(logicalTable.getLogicalMetrics(), uriInfo) ); resultRow.put(
new SimpleImmutableEntry<>( "metrics", MetricsServlet.getLogicalMetricListSummaryView(logicalTable.getLogicalMetrics(), uriInfo) ), new SimpleImmutableEntry<>(
/** * Method to provide grain level details(with metrics and dimensions) of the given logical table. * * @param logicalTable Logical Table at the grain level * @param grain Table grain * @param uriInfo Uri information to construct the uri's * * @return logical table details at grain level with all the associated meta data */ @Override public TableGrainView formatTableGrain(LogicalTable logicalTable, String grain, UriInfo uriInfo) { TableGrainView resultRow = new TableGrainView(); resultRow.put("name", grain); resultRow.put("longName", StringUtils.capitalize(grain)); resultRow.put("description", "The " + logicalTable.getName() + " " + grain + " grain"); resultRow.put("retention", logicalTable.getRetention().toString()); resultRow.put("dimensions", getDimensionListFullView(logicalTable.getDimensions(), uriInfo)); resultRow.put( "metrics", MetricsServlet.getLogicalMetricListSummaryView(logicalTable.getLogicalMetrics(), uriInfo) ); return resultRow; }