use of de.geeksfactory.opacclient.searchfields.BarcodeSearchField in project opacclient by opacapp.
the class SRU method parseSearchFields.
@Override
public List<SearchField> parseSearchFields() throws OpacErrorException, NotReachableException {
List<SearchField> searchFields = new ArrayList<>();
Set<String> fieldsCompat = searchQueries.keySet();
if (fieldsCompat.contains(KEY_SEARCH_QUERY_FREE)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_FREE, "", false, false, "Freie Suche", true, false);
field.setMeaning(Meaning.FREE);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_TITLE)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_TITLE, "Titel", false, false, "Stichwort", false, false);
field.setMeaning(Meaning.TITLE);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_AUTHOR)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_AUTHOR, "Verfasser", false, false, "Nachname, Vorname", false, false);
field.setMeaning(Meaning.AUTHOR);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_PUBLISHER)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_PUBLISHER, "Verlag", false, false, "", false, false);
field.setMeaning(Meaning.PUBLISHER);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_DIGITAL)) {
SearchField field = new CheckboxSearchField(KEY_SEARCH_QUERY_DIGITAL, "nur digitale Medien", false);
field.setMeaning(Meaning.DIGITAL);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_AVAILABLE)) {
SearchField field = new CheckboxSearchField(KEY_SEARCH_QUERY_AVAILABLE, "nur verfügbare Medien", false);
field.setMeaning(Meaning.AVAILABLE);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_ISBN)) {
SearchField field = new BarcodeSearchField(KEY_SEARCH_QUERY_ISBN, "Strichcode", false, false, "ISBN");
field.setMeaning(Meaning.ISBN);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_BARCODE)) {
SearchField field = new BarcodeSearchField(KEY_SEARCH_QUERY_BARCODE, "Strichcode", false, true, "Buchungsnr.");
field.setMeaning(Meaning.BARCODE);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_YEAR)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_YEAR, "Jahr", false, false, "", false, true);
field.setMeaning(Meaning.YEAR);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_YEAR_RANGE_START)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_YEAR_RANGE_START, "Jahr", false, false, "von", false, true);
field.setMeaning(Meaning.YEAR);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_YEAR_RANGE_END)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_YEAR_RANGE_END, "Jahr", false, true, "bis", false, true);
field.setMeaning(Meaning.YEAR);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_PUBLISHER)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_PUBLISHER, "Verlag", false, false, "", false, false);
field.setMeaning(Meaning.PUBLISHER);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_KEYWORDA)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_KEYWORDA, "Schlagwort", true, false, "", false, false);
field.setMeaning(Meaning.KEYWORD);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_KEYWORDB)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_KEYWORDB, "Schlagwort", true, true, "", false, false);
field.setMeaning(Meaning.KEYWORD);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_SYSTEM)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_SYSTEM, "Systematik", true, false, "", false, false);
field.setMeaning(Meaning.SYSTEM);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_AUDIENCE)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_AUDIENCE, "Interessenkreis", true, false, "", false, false);
field.setMeaning(Meaning.AUDIENCE);
searchFields.add(field);
}
if (fieldsCompat.contains(KEY_SEARCH_QUERY_LOCATION)) {
SearchField field = new TextSearchField(KEY_SEARCH_QUERY_LOCATION, "Ort", false, false, "", false, false);
field.setMeaning(Meaning.LOCATION);
searchFields.add(field);
}
// noinspection StatementWithEmptyBody
if (fieldsCompat.contains(KEY_SEARCH_QUERY_ORDER)) {
// TODO: Implement this (was this even usable before?)
}
return searchFields;
}
use of de.geeksfactory.opacclient.searchfields.BarcodeSearchField in project opacclient by opacapp.
the class SearchFragment method clear.
public void clear() {
if (fields == null)
return;
for (SearchField field : fields) {
if (!field.isVisible()) {
continue;
}
if (field instanceof TextSearchField && ((TextSearchField) field).isFreeSearch()) {
etSimpleSearch.setText("");
}
ViewGroup v = (ViewGroup) view.findViewWithTag(field.getId());
if (v == null) {
continue;
}
if (field instanceof TextSearchField) {
EditText text = (EditText) v.findViewById(R.id.edittext);
text.setText("");
} else if (field instanceof BarcodeSearchField) {
EditText text = (EditText) v.findViewById(R.id.edittext);
text.setText("");
} else if (field instanceof DropdownSearchField) {
Spinner spinner = (Spinner) v.findViewById(R.id.spinner);
spinner.setSelection(0);
} else if (field instanceof CheckboxSearchField) {
CheckBox checkbox = (CheckBox) v.findViewById(R.id.checkbox);
checkbox.setChecked(false);
}
}
}
use of de.geeksfactory.opacclient.searchfields.BarcodeSearchField in project opacclient by opacapp.
the class SearchFragment method saveQuery.
public Map<String, String> saveQuery() {
if (app.getLibrary() == null) {
return null;
}
saveHomeBranch();
Map<String, String> query = new HashMap<>();
if (fields == null) {
SearchFieldDataSource dataSource = new JsonSearchFieldDataSource(app);
int versionCode = 0;
try {
versionCode = app.getPackageManager().getPackageInfo(app.getPackageName(), 0).versionCode;
} catch (NameNotFoundException e) {
// should not happen
e.printStackTrace();
}
if (dataSource.hasSearchFields(app.getLibrary().getIdent()) && dataSource.getLastSearchFieldUpdateVersion(app.getLibrary().getIdent()) == versionCode) {
if (task != null && !task.isCancelled()) {
task.cancel(true);
}
fields = dataSource.getSearchFields(app.getLibrary().getIdent());
if (fields == null) {
return null;
}
} else {
return null;
}
}
for (SearchField field : fields) {
if (!field.isVisible()) {
continue;
}
if (field instanceof TextSearchField && ((TextSearchField) field).isFreeSearch()) {
query.put(field.getId(), etSimpleSearch.getEditableText().toString());
continue;
}
ViewGroup v = (ViewGroup) view.findViewWithTag(field.getId());
if (v == null) {
continue;
}
if (field instanceof TextSearchField) {
EditText text = (EditText) v.findViewById(R.id.edittext);
query.put(field.getId(), text.getEditableText().toString());
} else if (field instanceof BarcodeSearchField) {
EditText text = (EditText) v.findViewById(R.id.edittext);
query.put(field.getId(), text.getEditableText().toString());
} else if (field instanceof DropdownSearchField) {
Spinner spinner = (Spinner) v.findViewById(R.id.spinner);
if (spinner.getSelectedItemPosition() > 0) {
query.put(field.getId(), ((DropdownSearchField) field).getDropdownValues().get(spinner.getSelectedItemPosition()).getKey());
}
} else if (field instanceof CheckboxSearchField) {
CheckBox checkbox = (CheckBox) v.findViewById(R.id.checkbox);
query.put(field.getId(), String.valueOf(checkbox.isChecked()));
}
}
return query;
}
use of de.geeksfactory.opacclient.searchfields.BarcodeSearchField 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.BarcodeSearchField 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);
}
Aggregations