Skip to content

Commit

Permalink
Fixed bug CSM-104
Browse files Browse the repository at this point in the history
  • Loading branch information
k-joseph committed Jun 17, 2015
1 parent a3a9a58 commit ee4bdfd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
Expand Up @@ -46,15 +46,9 @@ public class GeneratingJson {

final String DATEFORMAT = "dd/MM/yyyy HH:mm:ss";

private static ChartSearchService chartSearchService;
private static ChartSearchService chartSearchService = getComponent(ChartSearchService.class);

public static ChartSearchService getChartSearchService() {
try {
chartSearchService = Context.getService(ChartSearchService.class);
}
catch (APIAuthenticationException e) {
System.out.println("Not Authenticated!!!");
}
return chartSearchService;
}

Expand All @@ -67,6 +61,8 @@ public static String generateJson(boolean wholePageIsToBeLoaded) {
JSONObject noResults = new JSONObject();
String searchPhrase = SearchAPI.getInstance().getSearchPhrase().getPhrase();

jsonToReturn.put("search_phrase", searchPhrase);

if (returnedResults == null || returnedResults.isEmpty()) {
foundNoResults = true;
noResults.put("foundNoResults", foundNoResults);
Expand All @@ -84,8 +80,6 @@ public static String generateJson(boolean wholePageIsToBeLoaded) {
addObjectsToJsonToReturnElseAddFailedPrivilegesMessages(jsonToReturn, arr_of_groups, arr_of_locations,
arr_of_providers, arr_of_datatypes, failedPrivilegeMessages);

jsonToReturn.put("search_phrase", searchPhrase);

addFacetsToJSONObjectToReturn(jsonToReturn);

//add failed privileges to json to be returned to the view
Expand Down Expand Up @@ -643,4 +637,11 @@ private static String appendBackwardSlashBeforeDoubleQuotes(String str) {
}
return str;
}

private static <T> T getComponent(Class<T> clazz) {
List<T> list = Context.getRegisteredComponents(clazz);
if (list == null || list.size() == 0)
throw new RuntimeException("Cannot find component of " + clazz);
return list.get(0);
}
}
Expand Up @@ -18,11 +18,11 @@
import org.apache.solr.client.solrj.response.FacetField;
import org.apache.solr.client.solrj.response.FacetField.Count;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Ignore;

public class GeneratingJsonTest {

@Test
@Ignore
public void generateFacetsJson_shouldreturnJSONWithNameAndCount() {

Count countObject = new Count(new FacetField("TestFacetField"), "test", 34);
Expand Down
1 change: 0 additions & 1 deletion omod/.settings/org.eclipse.core.resources.prefs
Expand Up @@ -3,6 +3,5 @@ encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/main/webapp=UTF-8
encoding//src/main/webapp/commands.jsp=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
1 change: 0 additions & 1 deletion omod/src/main/webapp/fragments/topArea.gsp
Expand Up @@ -9,7 +9,6 @@
jq(document).ready(function() {
jq('#searchText').focus();
jq("#chart-previous-searches-display").hide();
showHistorySuggestionsOnLoad();
Expand Down
2 changes: 2 additions & 0 deletions omod/src/main/webapp/resources/scripts/views_factory.js
Expand Up @@ -928,7 +928,9 @@ function filterOptions_datatypes() {


function refresh_data() {
$('#searchText').val(jsonAfterParse.search_phrase);
var searchText = document.getElementById('searchText');

$("#time_anchor").text('Any Time');
$("#location_anchor").text('All Locations');
$("#provider_anchor").text('All Providers');
Expand Down

0 comments on commit ee4bdfd

Please sign in to comment.