Search in sources :

Example 1 with Argument

use of com.yahoo.elide.modelconfig.model.Argument in project elide by yahoo.

the class TableType method getArgumentDefinitions.

private static ArgumentDefinition[] getArgumentDefinitions(List<Argument> arguments) {
    int numArguments = arguments == null ? 0 : arguments.size();
    ArgumentDefinition[] definitions = new ArgumentDefinition[numArguments];
    for (int idx = 0; idx < numArguments; idx++) {
        Argument argument = arguments.get(idx);
        definitions[idx] = new ArgumentDefinition() {

            @Override
            public String name() {
                return argument.getName();
            }

            @Override
            public String description() {
                return argument.getDescription();
            }

            @Override
            public ValueType type() {
                return ValueType.valueOf(argument.getType().toUpperCase(Locale.ROOT));
            }

            @Override
            public TableSource tableSource() {
                return buildTableSource(argument.getTableSource());
            }

            @Override
            public String[] values() {
                return argument.getValues().toArray(new String[0]);
            }

            @Override
            public String defaultValue() {
                Object value = argument.getDefaultValue();
                return value == null ? null : value.toString();
            }

            @Override
            public Class<? extends Annotation> annotationType() {
                return ArgumentDefinition.class;
            }
        };
    }
    return definitions;
}
Also used : TableSource(com.yahoo.elide.datastores.aggregation.annotation.TableSource) Argument(com.yahoo.elide.modelconfig.model.Argument) ValueType(com.yahoo.elide.datastores.aggregation.metadata.enums.ValueType) ArgumentDefinition(com.yahoo.elide.datastores.aggregation.annotation.ArgumentDefinition) Annotation(java.lang.annotation.Annotation)

Example 2 with Argument

use of com.yahoo.elide.modelconfig.model.Argument in project elide by yahoo.

the class DynamicConfigValidator method validateArguments.

private void validateArguments(Table table, List<Argument> arguments, String requiredFilter) {
    List<Argument> allArguments = new ArrayList<>(arguments);
    /* Check for table arguments added in the required filter template */
    if (requiredFilter != null) {
        Matcher matcher = FILTER_VARIABLE_PATTERN.matcher(requiredFilter);
        while (matcher.find()) {
            allArguments.add(Argument.builder().name(matcher.group(1)).build());
        }
    }
    validateNameUniqueness(allArguments, "Multiple Arguments found with the same name: ");
    arguments.forEach(arg -> validateTableSource(arg.getTableSource()));
}
Also used : Argument(com.yahoo.elide.modelconfig.model.Argument) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList)

Example 3 with Argument

use of com.yahoo.elide.modelconfig.model.Argument in project elide by yahoo.

the class DynamicConfigValidator method populateInheritance.

private void populateInheritance(Table table, Set<Table> processed) {
    if (processed.contains(table)) {
        return;
    }
    processed.add(table);
    if (!table.hasParent()) {
        return;
    }
    Table parent = table.getParent(this.elideTableConfig);
    if (!processed.contains(parent)) {
        populateInheritance(parent, processed);
    }
    Map<String, Measure> measures = getInheritedMeasures(parent, attributesListToMap(table.getMeasures()));
    table.setMeasures(new ArrayList<>(measures.values()));
    Map<String, Dimension> dimensions = getInheritedDimensions(parent, attributesListToMap(table.getDimensions()));
    table.setDimensions(new ArrayList<>(dimensions.values()));
    Map<String, Join> joins = getInheritedJoins(parent, attributesListToMap(table.getJoins()));
    table.setJoins(new ArrayList<>(joins.values()));
    String schema = getInheritedSchema(parent, table.getSchema());
    table.setSchema(schema);
    String dbConnectionName = getInheritedConnection(parent, table.getDbConnectionName());
    table.setDbConnectionName(dbConnectionName);
    String sql = getInheritedSql(parent, table.getSql());
    table.setSql(sql);
    String tableName = getInheritedTable(parent, table.getTable());
    table.setTable(tableName);
    List<Argument> arguments = getInheritedArguments(parent, table.getArguments());
    table.setArguments(arguments);
// isFact, isHidden, ReadAccess, namespace have default Values in schema, so can not be inherited.
// Other properties (tags, cardinality, etc.) have been categorized as non-inheritable too.
}
Also used : Table(com.yahoo.elide.modelconfig.model.Table) Argument(com.yahoo.elide.modelconfig.model.Argument) Measure(com.yahoo.elide.modelconfig.model.Measure) Join(com.yahoo.elide.modelconfig.model.Join) Dimension(com.yahoo.elide.modelconfig.model.Dimension)

Aggregations

Argument (com.yahoo.elide.modelconfig.model.Argument)3 ArgumentDefinition (com.yahoo.elide.datastores.aggregation.annotation.ArgumentDefinition)1 TableSource (com.yahoo.elide.datastores.aggregation.annotation.TableSource)1 ValueType (com.yahoo.elide.datastores.aggregation.metadata.enums.ValueType)1 Dimension (com.yahoo.elide.modelconfig.model.Dimension)1 Join (com.yahoo.elide.modelconfig.model.Join)1 Measure (com.yahoo.elide.modelconfig.model.Measure)1 Table (com.yahoo.elide.modelconfig.model.Table)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1