use of de.geeksfactory.opacclient.searchfields.SearchField in project opacclient by opacapp.
the class WinBiap method parseSearchFields.
@Override
public List<SearchField> parseSearchFields() throws IOException {
// extract branches and categories
String html = httpGet(opac_url + "/search.aspx", getDefaultEncoding());
Document doc = Jsoup.parse(html);
Elements mediaGroupOptions = doc.select("[id$=ListBoxMediagroups_ListBoxMultiselection] option");
Elements branchOptions = doc.select("[id$=MultiSelectionBranch_ListBoxMultiselection] option");
final DropdownSearchField mediaGroups = new DropdownSearchField(KEY_SEARCH_QUERY_CATEGORY, "Mediengruppe", false, null);
mediaGroups.setMeaning(Meaning.CATEGORY);
final DropdownSearchField branches = new DropdownSearchField(KEY_SEARCH_QUERY_BRANCH, "Zweigstelle", false, null);
branches.setMeaning(Meaning.BRANCH);
mediaGroups.addDropdownValue("", "Alle");
branches.addDropdownValue("", "Alle");
for (Element option : mediaGroupOptions) {
mediaGroups.addDropdownValue(option.attr("value"), option.text());
}
for (Element option : branchOptions) {
branches.addDropdownValue(option.attr("value"), option.text());
}
List<SearchField> searchFields = new ArrayList<>();
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_FREE, "", false, false, "Beliebig", true, false);
field.setMeaning(Meaning.FREE);
searchFields.add(field);
field = new TextSearchField(KEY_SEARCH_QUERY_AUTHOR, "Autor", false, false, "Nachname, Vorname", false, false);
field.setMeaning(Meaning.AUTHOR);
searchFields.add(field);
field = new TextSearchField(KEY_SEARCH_QUERY_TITLE, "Titel", false, false, "Stichwort", false, false);
field.setMeaning(Meaning.TITLE);
searchFields.add(field);
field = new TextSearchField(KEY_SEARCH_QUERY_KEYWORDA, "Schlagwort", true, false, "", false, false);
field.setMeaning(Meaning.KEYWORD);
searchFields.add(field);
field = new TextSearchField(KEY_SEARCH_QUERY_AUDIENCE, "Interessenkreis", true, false, "", false, false);
field.setMeaning(Meaning.AUDIENCE);
searchFields.add(field);
field = new TextSearchField(KEY_SEARCH_QUERY_SYSTEM, "Systematik", true, false, "", false, false);
field.setMeaning(Meaning.SYSTEM);
searchFields.add(field);
field = new BarcodeSearchField(KEY_SEARCH_QUERY_ISBN, "Strichcode", false, false, "ISBN");
field.setMeaning(Meaning.ISBN);
searchFields.add(field);
field = new TextSearchField(KEY_SEARCH_QUERY_PUBLISHER, "Verlag", false, false, "", false, false);
field.setMeaning(Meaning.PUBLISHER);
searchFields.add(field);
field = new BarcodeSearchField(KEY_SEARCH_QUERY_BARCODE, "Strichcode", false, true, "Mediennummer");
field.setMeaning(Meaning.BARCODE);
searchFields.add(field);
field = new TextSearchField(KEY_SEARCH_QUERY_YEAR_RANGE_START, "Jahr", false, false, "von", false, true);
field.setMeaning(Meaning.YEAR);
searchFields.add(field);
field = new TextSearchField(KEY_SEARCH_QUERY_YEAR_RANGE_END, "Jahr", false, true, "bis", false, true);
field.setMeaning(Meaning.YEAR);
searchFields.add(field);
searchFields.add(branches);
searchFields.add(mediaGroups);
return searchFields;
}
use of de.geeksfactory.opacclient.searchfields.SearchField in project opacclient by opacapp.
the class Zones method parseSearchFields.
@Override
public List<SearchField> parseSearchFields() throws IOException {
if (!initialised)
start();
List<SearchField> fields = new ArrayList<>();
String html = httpGet(opac_url + "/APS_ZONES?fn=AdvancedSearch&Style=Portal3&SubStyle=&Lang=GER" + "&ResponseEncoding=utf-8", getDefaultEncoding());
Document doc = Jsoup.parse(html);
// find text fields
Elements txt_opts = doc.select("#formSelectTerm_1 option");
for (Element opt : txt_opts) {
TextSearchField field = new TextSearchField();
field.setId(opt.attr("value"));
field.setHint("");
field.setDisplayName(opt.text());
fields.add(field);
}
// find filters
String filtersQuery = version18 ? ".inSearchLimits .floatingBox" : ".TabRechAv .limitBlock";
Elements filters = doc.select(filtersQuery);
int i = 0;
for (Element filter : filters) {
DropdownSearchField dropdown = new DropdownSearchField();
dropdown.addDropdownValue("", "Alle");
// All dropdowns use "q.limits.limit" as URL param, but they must not have the same ID
dropdown.setId("dropdown_" + i);
if (version18) {
dropdown.setDisplayName(filter.select("tr").get(0).text().trim());
Elements opts = filter.select("tr").get(1).select("table td:has(input)");
for (Element opt : opts) {
dropdown.addDropdownValue(opt.select("input").attr("value"), opt.text().trim());
}
} else {
dropdown.setDisplayName(filter.parent().previousElementSibling().text().trim());
Elements opts = filter.select(".limitChoice label");
for (Element opt : opts) {
dropdown.addDropdownValue(opt.attr("for"), opt.text().trim());
}
}
fields.add(dropdown);
i++;
}
return fields;
}
use of de.geeksfactory.opacclient.searchfields.SearchField in project opacclient by opacapp.
the class Open method search.
@Override
public SearchRequestResult search(List<SearchQuery> queries) throws IOException, OpacErrorException, JSONException {
String url = opac_url + "/" + data.getJSONObject("urls").getString("advanced_search") + NO_MOBILE;
Document doc = Jsoup.parse(httpGet(url, getDefaultEncoding()));
doc.setBaseUri(url);
int selectableCount = 0;
for (SearchQuery query : queries) {
if (query.getValue().equals("") || query.getValue().equals("false"))
continue;
if (query.getSearchField() instanceof TextSearchField | query.getSearchField() instanceof BarcodeSearchField) {
SearchField field = query.getSearchField();
if (field.getData().getBoolean("selectable")) {
selectableCount++;
if (selectableCount > 3) {
throw new OpacErrorException(stringProvider.getQuantityString(StringProvider.LIMITED_NUM_OF_CRITERIA, 3, 3));
}
String number = numberToText(selectableCount);
Element searchField = doc.select("select[name$=" + number + "SearchField]").first();
Element searchValue = doc.select("input[name$=" + number + "SearchValue]").first();
setSelectValue(searchField, field.getId());
searchValue.val(query.getValue());
} else {
Element input = doc.select("input[name=" + field.getId() + "]").first();
input.val(query.getValue());
}
} else if (query.getSearchField() instanceof DropdownSearchField) {
DropdownSearchField field = (DropdownSearchField) query.getSearchField();
Element select = doc.select("select[name=" + field.getId() + "]").first();
setSelectValue(select, query.getValue());
} else if (query.getSearchField() instanceof CheckboxSearchField) {
CheckboxSearchField field = (CheckboxSearchField) query.getSearchField();
Element input = doc.select("input[name=" + field.getId() + "]").first();
input.attr("checked", query.getValue());
}
}
// Submit form
FormElement form = (FormElement) doc.select("form").first();
MultipartBody data = formData(form, "BtnSearch").build();
String postUrl = form.attr("abs:action");
String html = httpPost(postUrl, data, "UTF-8");
Document doc2 = Jsoup.parse(html);
doc2.setBaseUri(postUrl);
return parse_search(doc2, 0);
}
use of de.geeksfactory.opacclient.searchfields.SearchField in project opacclient by opacapp.
the class BaseApi method getSearchFields.
@Override
public List<SearchField> getSearchFields() throws JSONException, OpacErrorException, IOException {
List<SearchField> fields = parseSearchFields();
if (shouldUseMeaningDetector()) {
MeaningDetector md = new MeaningDetectorImpl(library);
for (int i = 0; i < fields.size(); i++) {
fields.set(i, md.detectMeaning(fields.get(i)));
}
Collections.sort(fields, new SearchField.OrderComparator());
}
return fields;
}
use of de.geeksfactory.opacclient.searchfields.SearchField in project opacclient by opacapp.
the class Heidi method parseSearchFields.
@Override
public List<SearchField> parseSearchFields() throws IOException, OpacErrorException, JSONException {
String html = httpGet(opac_url + "/search.cgi?art=f", ENCODING, false, cookieStore);
Document doc = Jsoup.parse(html);
doc.setBaseUri(opac_url);
List<SearchField> fields = new ArrayList<>();
Elements options = doc.select("select[name=kat1] option");
for (Element option : options) {
TextSearchField field = new TextSearchField();
field.setDisplayName(option.text());
field.setId(option.attr("value"));
field.setHint("");
fields.add(field);
}
DropdownSearchField field = new DropdownSearchField();
Elements zst_opts = doc.select("#teilk2 option");
for (int i = 0; i < zst_opts.size(); i++) {
Element opt = zst_opts.get(i);
field.addDropdownValue(opt.val(), opt.text());
}
field.setDisplayName("Einrichtung");
field.setId("f[teil2]");
field.setVisible(true);
field.setMeaning(SearchField.Meaning.BRANCH);
fields.add(field);
try {
field = new DropdownSearchField();
Document doc2 = Jsoup.parse(httpGet(opac_url + "/zweigstelle.cgi?sess=" + sessid, ENCODING, false, cookieStore));
Elements home_opts = doc2.select("#zweig option");
for (int i = 0; i < home_opts.size(); i++) {
Element opt = home_opts.get(i);
if (!opt.val().equals("")) {
Map<String, String> option = new HashMap<>();
option.put("key", opt.val());
option.put("value", opt.text());
field.addDropdownValue(opt.val(), opt.text());
}
}
field.setDisplayName("Leihstelle");
field.setId("_heidi_branch");
field.setVisible(true);
field.setMeaning(SearchField.Meaning.HOME_BRANCH);
fields.add(field);
} catch (IOException e) {
e.printStackTrace();
}
TextSearchField pagefield = new TextSearchField();
pagefield.setId("_heidi_page");
pagefield.setVisible(false);
pagefield.setDisplayName("Seite");
pagefield.setHint("");
fields.add(pagefield);
return fields;
}
Aggregations