}
return rows;
}
protected List<Object[]> execute(TimeMachineQuery query, boolean selectAllFields, Set<Integer> metricIds) {
Resource resource = query.getResource();
if (resource != null && resource.getId() == null) {
resource = index.getResource(query.getResource());
}
if (resource == null) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
Map<String, Object> params = Maps.newHashMap();
if (selectAllFields) {
sb.append("SELECT m, s.createdAt ");
} else {
sb.append("SELECT s.createdAt, m.metricId, m.value ");
}
sb.append(" FROM ")
.append(MeasureModel.class.getSimpleName())
.append(" m, ")
.append(Snapshot.class.getSimpleName())
.append(" s WHERE m.snapshotId=s.id AND s.resourceId=:resourceId AND s.status=:status AND s.qualifier<>:lib");
params.put("resourceId", resource.getId());
params.put("status", Snapshot.STATUS_PROCESSED);
params.put("lib", Qualifiers.LIBRARY);
sb.append(" AND m.characteristicId IS NULL");
sb.append(" AND m.personId IS NULL");