Skip to content

Commit

Permalink
Merge pull request #4700 from IQSS/4671-guestbook-question-order
Browse files Browse the repository at this point in the history
preserve order of custom questions #4671
  • Loading branch information
kcondon authored May 23, 2018
2 parents cc2909c + 9ab3a4d commit 94a0ed5
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public void streamResponsesByDataverseIdAndGuestbookId(OutputStream out, Long da
}

queryString += ";";
logger.fine("stream responses query: " + queryString);

List<Object[]> guestbookResults = em.createNativeQuery(queryString).getResultList();

Expand Down Expand Up @@ -247,7 +248,7 @@ public List<Object[]> findArrayByGuestbookIdAndDataverseId (Long guestbookId, Lo

queryString += ";";

logger.info("search query: "+queryString);
logger.fine("search query: " + queryString);

List<Object[]> guestbookResults = em.createNativeQuery(queryString).getResultList();

Expand Down Expand Up @@ -333,7 +334,7 @@ private Map<Integer, Object> selectCustomQuestionAnswers(Long dataverseId, Long
+ "and o.owner_id = " + dataverseId;

if (guestbookId != null) {
cqString += ( "and g.guestbook_id = " + guestbookId);
cqString += ( " and g.guestbook_id = " + guestbookId);
}

if (firstResponse != null) {
Expand All @@ -344,7 +345,11 @@ private Map<Integer, Object> selectCustomQuestionAnswers(Long dataverseId, Long
cqString += (" and r.guestbookResponse_id <= " + lastResponse);
}

// Preserve the order of the question/answer pairs.
cqString += " order by g.id, q.id";

cqString += ";";
logger.fine("custom questions query: " + cqString);

List<Object[]> customResponses = em.createNativeQuery(cqString).getResultList();

Expand Down Expand Up @@ -375,7 +380,7 @@ private Map<Integer, Object> selectCustomQuestionAnswers(Long dataverseId, Long
}
}

logger.info("Found " + count + " responses to custom questions");
logger.fine("Found " + count + " responses to custom questions");

return ret;
}
Expand Down

0 comments on commit 94a0ed5

Please sign in to comment.