use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class SISIS method search.
@Override
public SearchRequestResult search(List<SearchQuery> query) throws IOException, OpacErrorException, JSONException {
List<NameValuePair> params = new ArrayList<>();
int index = 0;
int restrictionIndex = 0;
start();
params.add(new BasicNameValuePair("methodToCall", "submit"));
params.add(new BasicNameValuePair("CSId", CSId));
params.add(new BasicNameValuePair("methodToCallParameter", "submitSearch"));
for (SearchQuery entry : query) {
if (entry.getValue().equals("")) {
continue;
}
if (entry.getSearchField() instanceof DropdownSearchField) {
JSONObject data = entry.getSearchField().getData();
if (data.optBoolean("restriction", false)) {
params.add(new BasicNameValuePair("searchRestrictionID[" + restrictionIndex + "]", entry.getSearchField().getId()));
params.add(new BasicNameValuePair("searchRestrictionValue1[" + restrictionIndex + "]", entry.getValue()));
restrictionIndex++;
} else {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
} else {
if (index != 0) {
params.add(new BasicNameValuePair("combinationOperator[" + index + "]", "AND"));
}
params.add(new BasicNameValuePair("searchCategories[" + index + "]", entry.getKey()));
params.add(new BasicNameValuePair("searchString[" + index + "]", entry.getValue()));
index++;
}
}
if (index == 0) {
throw new OpacErrorException(stringProvider.getString(StringProvider.NO_CRITERIA_INPUT));
}
if (index > 4) {
throw new OpacErrorException(stringProvider.getQuantityString(StringProvider.LIMITED_NUM_OF_CRITERIA, 4, 4));
}
params.add(new BasicNameValuePair("submitSearch", "Suchen"));
params.add(new BasicNameValuePair("callingPage", "searchParameters"));
params.add(new BasicNameValuePair("numberOfHits", "10"));
String html = httpGet(opac_url + "/search.do?" + URLEncodedUtils.format(params, "UTF-8"), ENCODING);
return parse_search_wrapped(html, 1);
}
use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class TouchPoint method search.
@Override
public SearchRequestResult search(List<SearchQuery> query) throws IOException, OpacErrorException, JSONException {
List<NameValuePair> params = new ArrayList<>();
boolean selectDatabase = false;
int index = 0;
start();
params.add(new BasicNameValuePair("methodToCall", "submitButtonCall"));
params.add(new BasicNameValuePair("CSId", CSId));
params.add(new BasicNameValuePair("refine", "false"));
params.add(new BasicNameValuePair("numberOfHits", "10"));
for (SearchQuery entry : query) {
if (entry.getValue().equals("")) {
continue;
}
if (entry.getSearchField() instanceof DropdownSearchField) {
if (entry.getKey().equals("_database")) {
String[] parts = entry.getValue().split("=", 2);
params.add(new BasicNameValuePair(parts[0], parts[1]));
selectDatabase = true;
} else {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
} else {
if (index != 0) {
params.add(new BasicNameValuePair("combinationOperator[" + index + "]", "AND"));
}
params.add(new BasicNameValuePair("searchCategories[" + index + "]", entry.getKey()));
params.add(new BasicNameValuePair("searchString[" + index + "]", entry.getValue()));
index++;
}
}
if (index == 0) {
throw new OpacErrorException(stringProvider.getString(StringProvider.NO_CRITERIA_INPUT));
}
if (index > 4) {
throw new OpacErrorException(stringProvider.getQuantityString(StringProvider.LIMITED_NUM_OF_CRITERIA, 4, 4));
}
if (selectDatabase) {
List<NameValuePair> selectParams = new ArrayList<>();
selectParams.addAll(params);
selectParams.add(new BasicNameValuePair("methodToCallParameter", "selectDatabase"));
httpGet(opac_url + "/search.do?" + URLEncodedUtils.format(selectParams, "UTF-8"), ENCODING);
}
params.add(new BasicNameValuePair("submitButtonCall_submitSearch", "Suchen"));
params.add(new BasicNameValuePair("methodToCallParameter", "submitSearch"));
String html = httpGet(opac_url + "/search.do?" + URLEncodedUtils.format(params, "UTF-8"), ENCODING);
return parse_search_wrapped(html, 1);
}
use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class BiBer1992 method search.
@Override
public SearchRequestResult search(List<SearchQuery> queryList) throws IOException {
if (!initialised) {
start();
}
nameValuePairs.clear();
int count = 1;
for (SearchQuery query : queryList) {
if ((query.getSearchField() instanceof TextSearchField || query.getSearchField() instanceof BarcodeSearchField) && !query.getValue().equals("")) {
nameValuePairs.add(new BasicNameValuePair("CNN" + count, "AND"));
nameValuePairs.add(new BasicNameValuePair("FLD" + count, query.getValue()));
nameValuePairs.add(new BasicNameValuePair("REG" + count, query.getKey()));
count++;
} else if (query.getSearchField() instanceof DropdownSearchField) {
nameValuePairs.add(new BasicNameValuePair(query.getKey(), query.getValue()));
}
}
nameValuePairs.add(new BasicNameValuePair("FUNC", "qsel"));
nameValuePairs.add(new BasicNameValuePair("LANG", "de"));
// but
nameValuePairs.add(new BasicNameValuePair("SHOW", "20"));
// result
// gives 50
nameValuePairs.add(new BasicNameValuePair("SHOWSTAT", "N"));
nameValuePairs.add(new BasicNameValuePair("FROMPOS", "1"));
return searchGetPage(1);
}
use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class LibraryApiTestCases method testEmptySearch.
@Test
public void testEmptySearch() throws IOException, OpacErrorException, JSONException {
List<SearchQuery> query = new ArrayList<>();
SearchField field = findFreeSearchOrTitle(fields);
if (field == null) {
throw new // TODO: prevent this
OpacErrorException("There is no free or title search field");
}
query.add(new SearchQuery(field, "fasgeadstrehdaxydsfstrgdfjxnvgfhdtnbfgn"));
try {
SearchRequestResult res = api.search(query);
assertTrue(res.getTotal_result_count() == 0);
} catch (OpacErrorException e) {
// Expected, should be an empty result.
}
}
use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class SearchFragment method saveSearchQuery.
public List<SearchQuery> saveSearchQuery() {
saveHomeBranch();
List<SearchQuery> query = new ArrayList<>();
if (fields == null || view == null) {
return null;
}
for (SearchField field : fields) {
if (!field.isVisible()) {
continue;
}
ViewGroup v = (ViewGroup) view.findViewWithTag(field.getId());
if (field instanceof TextSearchField) {
EditText text;
if (((TextSearchField) field).isFreeSearch()) {
text = etSimpleSearch;
} else {
if (v == null)
continue;
text = (EditText) v.findViewById(R.id.edittext);
}
query.add(new SearchQuery(field, text.getEditableText().toString().trim()));
} else if (field instanceof BarcodeSearchField) {
if (v == null)
continue;
EditText text = (EditText) v.findViewById(R.id.edittext);
query.add(new SearchQuery(field, text.getEditableText().toString().trim()));
} else if (field instanceof DropdownSearchField) {
if (v == null)
continue;
Spinner spinner = (Spinner) v.findViewById(R.id.spinner);
if (spinner.getSelectedItemPosition() != -1) {
String key = ((DropdownSearchField) field).getDropdownValues().get(spinner.getSelectedItemPosition()).getKey();
if (!key.equals("")) {
query.add(new SearchQuery(field, key));
}
}
} else if (field instanceof CheckboxSearchField) {
if (v == null)
continue;
CheckBox checkbox = (CheckBox) v.findViewById(R.id.checkbox);
query.add(new SearchQuery(field, String.valueOf(checkbox.isChecked())));
}
}
return query;
}
Aggregations