public NewResultsSearchListVoCollection listNewResults(NewResultsCriteriaVo criteria) { if (criteria == null || criteria.getFromDate() == null) throw new CodingRuntimeException("Invalid start date"); // Search for OrderInvestigation ID matching the search criteria by intervals List<Integer> investigations = getInvestigationsByCriteria(criteria); // If no OrderInvestigation ID was found in the interval, then return null if (investigations == null || investigations.size() == 0) return null; // StringBuilder query = new StringBuilder(getBaseSelectQuery(investigations)); StringBuilder query = new StringBuilder("SELECT oi "); query.append(" FROM OrderInvestigation AS oi WHERE oi.id IN ("); for (int i = 0; i < investigations.size(); i++) { query.append(investigations.get(i)); if (i != investigations.size() - 1) query.append(", "); } query.append(")"); query.append(" ORDER BY oi.resultSortDate"); if (Boolean.TRUE.equals(criteria.getNewestFirst())) query.append(" DESC"); query.append(", oi.ordInvSeq"); long startTime = System.currentTimeMillis(); // List<?> searchResults = getDomainFactory().find(query.toString()); // // if (searchResults == null || searchResults.size() == 0) // return null; // NewResultsSearchListVoCollection results = NewResultsSearchListVoAssembler.createNewResultsSearchListVoCollectionFromOrderInvestigation(getDomainFactory().find(query.toString())); // NewResultsSearchListVoCollection results = new NewResultsSearchListVoCollection(); // // for (int i = 0; i < searchResults.size(); i++) // { // Object[] result = (Object[]) searchResults.get(i); // // if (result[0] instanceof OrderInvestigation) // { // NewResultsSearchListVo newResult = NewResultsSearchListVoAssembler.create((OrderInvestigation) result[0]); // // if (result[1] instanceof Long && (Long)result[1] > 0) // newResult.setAbnormalResults(Boolean.TRUE); // else // newResult.setAbnormalResults(Boolean.FALSE); // // results.add(newResult); // } // } long endTime = System.currentTimeMillis(); System.out.println("Time elapsed to retrive record data (ms): " + (endTime - startTime)); // List<?> resultsCustomConstructor = getDomainFactory().find(query.toString()); // // NewResultSearchListVoCollection resultsCollection = new NewResultSearchListVoCollection(); // // for (int i = 0; i < results.size(); i++) // { // if (resultsCustomConstructor.get(i) instanceof NewResultSearchListVo) // resultsCollection.add((NewResultSearchListVo) resultsCustomConstructor.get(i)); // } return results; }