|
21 | 21 | import java.util.List;
|
22 | 22 | import java.util.Map;
|
23 | 23 | import java.util.Set;
|
| 24 | +import javax.persistence.EntityManager; |
| 25 | +import javax.persistence.PersistenceContext; |
24 | 26 |
|
25 | 27 | import javax.servlet.ServletContext;
|
26 | 28 | import javax.transaction.Transactional;
|
@@ -103,6 +105,9 @@ public class CohortDefinitionService extends AbstractDaoService {
|
103 | 105 | @Autowired
|
104 | 106 | private JobTemplate jobTemplate;
|
105 | 107 |
|
| 108 | + @PersistenceContext |
| 109 | + protected EntityManager entityManager; |
| 110 | + |
106 | 111 | private final RowMapper<InclusionRuleReport.Summary> summaryMapper = new RowMapper<InclusionRuleReport.Summary>() {
|
107 | 112 | @Override
|
108 | 113 | public InclusionRuleReport.Summary mapRow(ResultSet rs, int rowNum) throws SQLException {
|
@@ -326,17 +331,17 @@ public GenerateSqlResult generateSql(GenerateSqlRequest request) {
|
326 | 331 | @Produces(MediaType.APPLICATION_JSON)
|
327 | 332 | public List<CohortDefinitionListItem> getCohortDefinitionList() {
|
328 | 333 | ArrayList<CohortDefinitionListItem> result = new ArrayList<>();
|
329 |
| - Iterable<CohortDefinition> defs = this.cohortDefinitionRepository.list(); |
330 |
| - for (CohortDefinition d : defs) { |
| 334 | + List<Object[]> defs = entityManager.createQuery("SELECT cd.id, cd.name, cd.description, cd.expressionType, cd.createdBy, cd.createdDate, cd.modifiedBy, cd.modifiedDate FROM CohortDefinition cd").getResultList(); |
| 335 | + for (Object[] d : defs) { |
331 | 336 | CohortDefinitionListItem item = new CohortDefinitionListItem();
|
332 |
| - item.id = d.getId(); |
333 |
| - item.name = d.getName(); |
334 |
| - item.description = d.getDescription(); |
335 |
| - item.expressionType = d.getExpressionType(); |
336 |
| - item.createdBy = d.getCreatedBy(); |
337 |
| - item.createdDate = d.getCreatedDate(); |
338 |
| - item.modifiedBy = d.getModifiedBy(); |
339 |
| - item.modifiedDate = d.getModifiedDate(); |
| 337 | + item.id = (Integer)d[0]; |
| 338 | + item.name = (String)d[1]; |
| 339 | + item.description = (String)d[2]; |
| 340 | + item.expressionType = (ExpressionType)d[3]; |
| 341 | + item.createdBy = (String)d[4]; |
| 342 | + item.createdDate = (Date)d[5]; |
| 343 | + item.modifiedBy = (String)d[6]; |
| 344 | + item.modifiedDate = (Date)d[7]; |
340 | 345 | result.add(item);
|
341 | 346 | }
|
342 | 347 | return result;
|
|
0 commit comments