Skip to content

Instantly share code, notes, and snippets.

@fge
Created February 5, 2015 00:57
Show Gist options
  • Select an option

  • Save fge/e069a703d43c83de47fd to your computer and use it in GitHub Desktop.

Select an option

Save fge/e069a703d43c83de47fd to your computer and use it in GitHub Desktop.
@Override
public List<RuleInvocationStatistics> getRuleInvocationStatistics()
{
final Field<Integer> emptyMatches = DSL.decode()
.when(EMPTY_MATCHES_CONDITION, 1).otherwise(0);
final Field<Integer> nonEmptyMatches = DSL.decode()
.when(NONEMPTY_MATCHES_CONDITION, 1).otherwise(0);
final Field<Integer> failedMatches = DSL.decode()
.when(FAILED_MATCHES_CONDITION, 1).otherwise(0);
final List<RuleInvocationStatistics> list = new ArrayList<>();
jooq.select(MATCHERS.NAME, MATCHERS.MATCHER_TYPE, MATCHERS.CLASS_NAME,
DSL.sum(emptyMatches).as("emptyMatches"),
DSL.sum(nonEmptyMatches).as("nonEmptyMatches"),
DSL.sum(failedMatches).as("failedMatches"))
.from(MATCHERS, NODES)
.where(MATCHERS.ID.eq(NODES.MATCHER_ID))
.groupBy(MATCHERS.NAME, MATCHERS.MATCHER_TYPE, MATCHERS.CLASS_NAME)
.fetch()
.map(new RuleInvocationStatisticsMapper())
.forEach(list::add);
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment