use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class StarredFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHasOptionsMenu(true);
view = inflater.inflate(R.layout.fragment_starred, container, false);
app = (OpacClient) getActivity().getApplication();
adapter = new ItemListAdapter();
listView = (ListView) view.findViewById(R.id.lvStarred);
tvWelcome = (TextView) view.findViewById(R.id.tvWelcome);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Starred item = (Starred) view.findViewById(R.id.ivDelete).getTag();
if (item.getMNr() == null || item.getMNr().equals("null") || item.getMNr().equals("")) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
List<SearchQuery> query = new ArrayList<>();
List<SearchField> fields = new JsonSearchFieldDataSource(app).getSearchFields(app.getLibrary().getIdent());
if (fields != null) {
SearchField title_field = null, free_field = null;
for (SearchField field : fields) {
if (field.getMeaning() == Meaning.TITLE) {
title_field = field;
} else if (field.getMeaning() == Meaning.FREE) {
free_field = field;
} else if (field.getMeaning() == Meaning.HOME_BRANCH) {
query.add(new SearchQuery(field, sp.getString(OpacClient.PREF_HOME_BRANCH_PREFIX + app.getAccount().getId(), null)));
}
}
if (title_field != null) {
query.add(new SearchQuery(title_field, item.getTitle()));
} else if (free_field != null) {
query.add(new SearchQuery(free_field, item.getTitle()));
}
app.startSearch(getActivity(), query);
} else {
Toast.makeText(getActivity(), R.string.no_search_cache, Toast.LENGTH_LONG).show();
}
} else {
callback.showDetail(item.getMNr());
}
}
});
listView.setClickable(true);
listView.setTextFilterEnabled(true);
getActivity().getSupportLoaderManager().initLoader(0, null, this);
listView.setAdapter(adapter);
// Restore the previously serialized activated item position.
if (savedInstanceState != null && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
}
setActivateOnItemClick(((OpacActivity) getActivity()).isTablet());
return view;
}
use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class LibraryApiTestCases method scrollTestHelper.
public void scrollTestHelper(String q) throws OpacErrorException, IOException, 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, q));
SearchRequestResult res = api.search(query);
assertTrue(res.getTotal_result_count() == -1 || res.getResults().size() <= res.getTotal_result_count());
assertTrue(res.getResults().size() > 0);
SearchResult third;
if (res.getResults().size() >= 3) {
third = res.getResults().get(2);
} else {
third = res.getResults().get(res.getResults().size() - 1);
}
DetailedItem detail;
if (third.getId() != null) {
detail = api.getResultById(third.getId(), "");
} else {
detail = api.getResult(third.getNr());
}
assertNotNull(detail);
confirmDetail(third, detail);
if (res.getResults().size() < res.getTotal_result_count()) {
api.searchGetPage(2);
SearchResult second = res.getResults().get(1);
DetailedItem detail2;
if (second.getId() != null) {
detail2 = api.getResultById(second.getId(), "");
} else {
detail2 = api.getResult(second.getNr());
}
confirmDetail(second, detail2);
}
}
use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class Pica method search.
@Override
public SearchRequestResult search(List<SearchQuery> query) throws IOException, OpacErrorException, JSONException {
if (!initialised) {
start();
}
List<NameValuePair> params = new ArrayList<>();
int index = 0;
start();
params.add(new BasicNameValuePair("ACT", "SRCHM"));
params.add(new BasicNameValuePair("MATCFILTER", "Y"));
params.add(new BasicNameValuePair("MATCSET", "Y"));
params.add(new BasicNameValuePair("NOSCAN", "Y"));
params.add(new BasicNameValuePair("PARSE_MNEMONICS", "N"));
params.add(new BasicNameValuePair("PARSE_OPWORDS", "N"));
params.add(new BasicNameValuePair("PARSE_OLDSETS", "N"));
for (SearchQuery singleQuery : query) {
index = addParameters(singleQuery, params, 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));
}
String html = httpGet(opac_url + "/LNG=" + getLang() + "/DB=" + db + "/SET=1/TTL=1/CMD?" + URLEncodedUtils.format(params, getDefaultEncoding()), getDefaultEncoding(), false, cookieStore);
return parse_search(html, 1);
}
use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class VuFind method buildSearchParams.
protected List<NameValuePair> buildSearchParams(List<SearchQuery> query) {
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("sort", "relevance"));
params.add(new BasicNameValuePair("join", "AND"));
for (SearchQuery singleQuery : query) {
if (singleQuery.getValue().equals(""))
continue;
if (singleQuery.getKey().contains("filter[]")) {
params.add(new BasicNameValuePair("filter[]", singleQuery.getValue()));
} else {
params.add(new BasicNameValuePair("type0[]", singleQuery.getKey()));
params.add(new BasicNameValuePair("bool0[]", "AND"));
params.add(new BasicNameValuePair("lookfor0[]", singleQuery.getValue()));
}
}
return params;
}
use of de.geeksfactory.opacclient.searchfields.SearchQuery in project opacclient by opacapp.
the class WebOpacNet method buildParams.
private int buildParams(List<SearchQuery> queryList, List<NameValuePair> params, int page) throws JSONException {
int index = 0;
StringBuilder queries = new StringBuilder();
queries.append("erw:0");
for (SearchQuery query : queryList) {
if (!query.getSearchField().getData().getBoolean("filter")) {
index = addParameters(query, queries, index);
}
}
for (SearchQuery query : queryList) {
if (query.getSearchField().getData().getBoolean("filter") && !query.getValue().equals("")) {
queries.append("&").append(query.getKey()).append("=").append(query.getValue());
}
}
params.add(new BasicNameValuePair("q", queries.toString()));
params.add(new BasicNameValuePair("p", String.valueOf(page - 1)));
params.add(new BasicNameValuePair("t", "1"));
return index;
}
Aggregations