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;
}
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()));
}
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.
}
Aggregations