Refactor large method into 4 methods

In trying to reuse some of the code in views, I realized that the get method
for SampleView is quite long.
This change breaks this method into 3 functions.
The get method now is responsible for parsing HTTP arguments and formatting
AJAX response. The other functionality has been pulled out.
One of these functions (query_data) can be used by other views in the future.

Change-Id: I9a71bf62eb871ac9c082208e991402f0c700c668
Closes-Bug: #1278654
Merge "Refactor large method into 4 methods"