Search in sources :

Example 16 with TextSearchField

use of de.geeksfactory.opacclient.searchfields.TextSearchField in project opacclient by opacapp.

the class Pica method addParameters.

protected int addParameters(SearchQuery query, List<NameValuePair> params, int index) throws JSONException {
    if (query.getValue().equals("") || query.getValue().equals("false")) {
        return index;
    }
    if (query.getSearchField() instanceof TextSearchField || query.getSearchField() instanceof BarcodeSearchField) {
        if (query.getSearchField().getData().getBoolean("ADI")) {
            params.add(new BasicNameValuePair(query.getKey(), query.getValue()));
        } else {
            if (index == 0) {
                params.add(new BasicNameValuePair("ACT" + index, "SRCH"));
            } else {
                params.add(new BasicNameValuePair("ACT" + index, "*"));
            }
            params.add(new BasicNameValuePair("IKT" + index, query.getKey()));
            params.add(new BasicNameValuePair("TRM" + index, query.getValue()));
            return index + 1;
        }
    } else if (query.getSearchField() instanceof CheckboxSearchField) {
        boolean checked = Boolean.valueOf(query.getValue());
        if (checked) {
            params.add(new BasicNameValuePair(query.getKey(), "Y"));
        }
    } else if (query.getSearchField() instanceof DropdownSearchField) {
        params.add(new BasicNameValuePair(query.getKey(), query.getValue()));
    }
    return index;
}
Also used : CheckboxSearchField(de.geeksfactory.opacclient.searchfields.CheckboxSearchField) BarcodeSearchField(de.geeksfactory.opacclient.searchfields.BarcodeSearchField) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField) DropdownSearchField(de.geeksfactory.opacclient.searchfields.DropdownSearchField)

Example 17 with TextSearchField

use of de.geeksfactory.opacclient.searchfields.TextSearchField in project opacclient by opacapp.

the class SISIS method parseSearchFields.

public List<SearchField> parseSearchFields() throws IOException, JSONException {
    if (!initialised) {
        start();
    }
    String html = httpGet(opac_url + "/search.do?methodToCall=switchSearchPage&SearchType=2", ENCODING);
    Document doc = Jsoup.parse(html);
    List<SearchField> fields = new ArrayList<>();
    Elements options = doc.select("select[name=searchCategories[0]] option");
    for (Element option : options) {
        TextSearchField field = new TextSearchField();
        field.setDisplayName(option.text());
        field.setId(option.attr("value"));
        field.setHint("");
        fields.add(field);
    }
    for (Element dropdown : doc.select("#tab-content select")) {
        parseDropdown(dropdown, fields);
    }
    return fields;
}
Also used : SearchField(de.geeksfactory.opacclient.searchfields.SearchField) TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField) DropdownSearchField(de.geeksfactory.opacclient.searchfields.DropdownSearchField) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField)

Example 18 with TextSearchField

use of de.geeksfactory.opacclient.searchfields.TextSearchField 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;
}
Also used : TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField) CheckboxSearchField(de.geeksfactory.opacclient.searchfields.CheckboxSearchField) BarcodeSearchField(de.geeksfactory.opacclient.searchfields.BarcodeSearchField) SearchField(de.geeksfactory.opacclient.searchfields.SearchField) CheckboxSearchField(de.geeksfactory.opacclient.searchfields.CheckboxSearchField) BarcodeSearchField(de.geeksfactory.opacclient.searchfields.BarcodeSearchField) ArrayList(java.util.ArrayList) TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField)

Example 19 with TextSearchField

use of de.geeksfactory.opacclient.searchfields.TextSearchField in project opacclient by opacapp.

the class TestApi method parseSearchFields.

@Override
public List<SearchField> parseSearchFields() throws IOException, OpacErrorException, JSONException {
    List<SearchField> fields = new ArrayList<>();
    fields.add(new TextSearchField("free", "Freie Suche", false, false, "Freie Suche", true, false));
    return fields;
}
Also used : TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField) SearchField(de.geeksfactory.opacclient.searchfields.SearchField) ArrayList(java.util.ArrayList) TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField)

Example 20 with TextSearchField

use of de.geeksfactory.opacclient.searchfields.TextSearchField 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);
        }
    }
}
Also used : EditText(android.widget.EditText) BarcodeSearchField(de.geeksfactory.opacclient.searchfields.BarcodeSearchField) SearchField(de.geeksfactory.opacclient.searchfields.SearchField) TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField) CheckboxSearchField(de.geeksfactory.opacclient.searchfields.CheckboxSearchField) DropdownSearchField(de.geeksfactory.opacclient.searchfields.DropdownSearchField) CheckboxSearchField(de.geeksfactory.opacclient.searchfields.CheckboxSearchField) BarcodeSearchField(de.geeksfactory.opacclient.searchfields.BarcodeSearchField) ViewGroup(android.view.ViewGroup) Spinner(android.widget.Spinner) CheckBox(android.widget.CheckBox) TextSearchField(de.geeksfactory.opacclient.searchfields.TextSearchField) DropdownSearchField(de.geeksfactory.opacclient.searchfields.DropdownSearchField)

Aggregations

TextSearchField (de.geeksfactory.opacclient.searchfields.TextSearchField)32 DropdownSearchField (de.geeksfactory.opacclient.searchfields.DropdownSearchField)27 SearchField (de.geeksfactory.opacclient.searchfields.SearchField)23 Element (org.jsoup.nodes.Element)21 ArrayList (java.util.ArrayList)19 Document (org.jsoup.nodes.Document)18 Elements (org.jsoup.select.Elements)15 BarcodeSearchField (de.geeksfactory.opacclient.searchfields.BarcodeSearchField)13 CheckboxSearchField (de.geeksfactory.opacclient.searchfields.CheckboxSearchField)10 JSONObject (org.json.JSONObject)9 SearchQuery (de.geeksfactory.opacclient.searchfields.SearchQuery)6 ViewGroup (android.view.ViewGroup)5 CheckBox (android.widget.CheckBox)5 EditText (android.widget.EditText)5 Spinner (android.widget.Spinner)5 Matcher (java.util.regex.Matcher)4 Pattern (java.util.regex.Pattern)4 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)4 NotReachableException (de.geeksfactory.opacclient.networking.NotReachableException)3 HashMap (java.util.HashMap)3