/** * Bind the table name against a Logical table in the table dictionary. * * @param tableName Name of the logical table from the query * @param granularity The granularity for this request * @param logicalTableDictionary Dictionary to resolve logical tables against. * * @return A logical table */ protected LogicalTable bindLogicalTable( String tableName, Granularity granularity, LogicalTableDictionary logicalTableDictionary ) { TableIdentifier tableId = new TableIdentifier(tableName, granularity); // Logical table must be in the logical table dictionary return logicalTableDictionary.get(tableId); }
/** * Extracts a specific logical table object given a valid table name and a valid granularity. * * @param tableName logical table corresponding to the table name specified in the URL * @param granularity logical table corresponding to the table name specified in the URL * @param logicalTableDictionary Logical table dictionary contains the map of valid table names and table objects. * * @return Set of logical table objects. * @throws BadApiRequestException Invalid table exception if the table dictionary returns a null. */ protected LogicalTable generateTable( String tableName, Granularity granularity, LogicalTableDictionary logicalTableDictionary ) throws BadApiRequestException { LogicalTable generated = logicalTableDictionary.get(new TableIdentifier(tableName, granularity)); // check if requested logical table grain pair exists if (generated == null) { String msg = TABLE_GRANULARITY_MISMATCH.logFormat(granularity, tableName); LOG.error(msg); throw new BadApiRequestException(msg); } LOG.trace("Generated logical table: {} with granularity {}", generated, granularity); return generated; }
/** * Load a logical table into the logicalDictionary. * <p> * Note: This builds the logical table as well. * * @param logicalTableName The logical table name * @param nameGroup The table group information for the logical table * @param validGrains The accepted grains for the logical table * @param tableDictionary The dictionary to load the logical table into * @param metricDictionary The dictionary to use when looking up metrics for this table */ public void loadLogicalTableWithGranularities( String logicalTableName, TableGroup nameGroup, Set<? extends Granularity> validGrains, LogicalTableDictionary tableDictionary, MetricDictionary metricDictionary ) { // For every legal grain for (Granularity grain : validGrains) { // Build the logical table LogicalTable logicalTable = new LogicalTable(logicalTableName, grain, nameGroup, metricDictionary); // Load it into the dictionary tableDictionary.put(new TableIdentifier(logicalTable), logicalTable); } }
/** * Builder. * * @param request API Request for which to build a table identifier * * @return the table identifier for the request */ public static TableIdentifier create(DataApiRequest request) { return new TableIdentifier(request.getTable().getName(), getGranularityPeriod(request.getGranularity())); }