use of com.yahoo.elide.datastores.aggregation.query.MetricProjectionMaker in project elide by yahoo.
the class TableType method buildAnnotations.
private static Map<Class<? extends Annotation>, Annotation> buildAnnotations(Measure measure) {
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<>();
annotations.put(ColumnMeta.class, new ColumnMeta() {
@Override
public Class<? extends Annotation> annotationType() {
return ColumnMeta.class;
}
@Override
public String friendlyName() {
return measure.getFriendlyName();
}
@Override
public String description() {
return measure.getDescription();
}
@Override
public String category() {
return measure.getCategory();
}
@Override
public TableSource tableSource() {
return buildTableSource(null);
}
@Override
public String[] tags() {
return measure.getTags().toArray(new String[0]);
}
@Override
public String[] values() {
return new String[0];
}
@Override
public boolean isHidden() {
return measure.getHidden() != null && measure.getHidden();
}
@Override
public String filterTemplate() {
return measure.getFilterTemplate();
}
@Override
public CardinalitySize size() {
return CardinalitySize.UNKNOWN;
}
});
annotations.put(MetricFormula.class, new MetricFormula() {
@Override
public ArgumentDefinition[] arguments() {
return getArgumentDefinitions(measure.getArguments());
}
@Override
public Class<? extends Annotation> annotationType() {
return MetricFormula.class;
}
@Override
public String value() {
if (measure.getDefinition() != null) {
return trimColumnReferences(measure.getDefinition());
} else {
return "";
}
}
@Override
public Class<? extends MetricProjectionMaker> maker() {
if (measure.getMaker() == null || measure.getMaker().isEmpty()) {
return DefaultMetricProjectionMaker.class;
}
try {
return (Class<? extends MetricProjectionMaker>) Class.forName(measure.getMaker());
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
}
});
String readPermission = measure.getReadAccess();
if (StringUtils.isNotEmpty(readPermission)) {
annotations.put(ReadPermission.class, new ReadPermission() {
@Override
public Class<? extends Annotation> annotationType() {
return ReadPermission.class;
}
@Override
public String expression() {
return readPermission;
}
});
}
return annotations;
}
Aggregations