use of de.geeksfactory.opacclient.searchfields.TextSearchField in project opacclient by opacapp.
the class VuFind method parseSearchFields.
@Override
public List<SearchField> parseSearchFields() throws IOException, OpacErrorException, JSONException {
start();
String html = httpGet(opac_url + "/Search/Advanced?mylang = " + languageCode, getDefaultEncoding());
Document doc = Jsoup.parse(html);
List<SearchField> fields = new ArrayList<>();
Elements options = doc.select("select#search_type0_0 option");
for (Element option : options) {
TextSearchField field = new TextSearchField();
field.setDisplayName(option.text());
field.setId(option.val());
field.setHint("");
field.setData(new JSONObject());
field.getData().put("meaning", option.val());
fields.add(field);
}
if (fields.size() == 0) {
// Weird JavaScript, e.g. view-source:http://vopac.nlg.gr/Search/Advanced
Pattern pattern_key = Pattern.compile("searchFields\\[\"([^\"]+)\"\\] = \"([^\"]+)\";");
for (Element script : doc.select("script")) {
if (!script.html().contains("searchFields"))
continue;
for (String line : script.html().split("\n")) {
Matcher matcher = pattern_key.matcher(line);
if (matcher.find()) {
TextSearchField field = new TextSearchField();
field.setDisplayName(matcher.group(2));
field.setId(matcher.group(1));
field.setHint("");
field.setData(new JSONObject());
field.getData().put("meaning", field.getId());
fields.add(field);
}
}
}
}
Elements selects = doc.select("select");
for (Element select : selects) {
if (!select.attr("name").equals("filter[]"))
continue;
DropdownSearchField field = new DropdownSearchField();
if (select.parent().select("label").size() > 0) {
field.setDisplayName(select.parent().select("label").first().text());
} else if (select.parent().parent().select("label").size() == 1) {
field.setDisplayName(select.parent().parent().select("label").first().text());
}
field.setId(select.attr("name") + select.attr("id"));
String meaning = select.attr("id");
field.addDropdownValue("", "");
for (Element option : select.select("option")) {
if (option.val().contains(":")) {
meaning = option.val().split(":")[0];
}
field.addDropdownValue(option.val(), option.text());
}
field.setData(new JSONObject());
field.getData().put("meaning", meaning);
fields.add(field);
}
return fields;
}
use of de.geeksfactory.opacclient.searchfields.TextSearchField in project opacclient by opacapp.
the class Littera method addSimpleSearchField.
protected void addSimpleSearchField(List<SearchField> fields) throws IOException, JSONException {
final String html = httpGet(getApiUrl() + "&mode=s", getDefaultEncoding());
final Document doc = Jsoup.parse(html);
final Element simple = doc.select(".simple_search").first();
final TextSearchField field = new TextSearchField();
field.setFreeSearch(true);
field.setDisplayName(simple.select("h4").first().text());
field.setId(simple.select("#keyboard").first().attr("name"));
field.setHint("");
field.setData(new JSONObject());
field.getData().put("meaning", field.getId());
fields.add(field);
}
use of de.geeksfactory.opacclient.searchfields.TextSearchField in project opacclient by opacapp.
the class Pica method parseSearchFields.
@Override
public List<SearchField> parseSearchFields() throws IOException, JSONException {
if (!initialised) {
start();
}
String html = httpGet(opac_url + "/LNG=" + getLang() + "/DB=" + db + "/ADVANCED_SEARCHFILTER", getDefaultEncoding());
Document doc = Jsoup.parse(html);
List<SearchField> fields = new ArrayList<>();
Elements options = doc.select("select[name=IKT0] option");
for (Element option : options) {
TextSearchField field = new TextSearchField();
field.setDisplayName(option.text());
field.setId(option.attr("value"));
field.setHint("");
field.setData(new JSONObject("{\"ADI\": false}"));
Pattern pattern = Pattern.compile("(?: --- )?(\\[X?[A-Za-z]{2,3}:?\\]|\\(X?[A-Za-z]{2,3}:?\\))");
Matcher matcher = pattern.matcher(field.getDisplayName());
if (matcher.find()) {
field.getData().put("meaning", matcher.group(1).replace(":", "").toUpperCase());
field.setDisplayName(matcher.replaceFirst("").trim());
}
fields.add(field);
}
Elements sort = doc.select("select[name=SRT]");
if (sort.size() > 0) {
DropdownSearchField field = new DropdownSearchField();
field.setDisplayName(sort.first().parent().parent().select(".longval").first().text());
field.setId("SRT");
for (Element option : sort.select("option")) {
field.addDropdownValue(option.attr("value"), option.text());
}
fields.add(field);
}
for (Element input : doc.select("input[type=text][name^=ADI]")) {
TextSearchField field = new TextSearchField();
field.setDisplayName(input.parent().parent().select(".longkey").text());
field.setId(input.attr("name"));
field.setHint(input.parent().select("span").text());
field.setData(new JSONObject("{\"ADI\": true}"));
fields.add(field);
}
for (Element dropdown : doc.select("select[name^=ADI]")) {
DropdownSearchField field = new DropdownSearchField();
field.setDisplayName(dropdown.parent().parent().select(".longkey").text());
field.setId(dropdown.attr("name"));
for (Element option : dropdown.select("option")) {
field.addDropdownValue(option.attr("value"), option.text());
}
fields.add(field);
}
Elements fuzzy = doc.select("input[name=FUZZY]");
if (fuzzy.size() > 0) {
CheckboxSearchField field = new CheckboxSearchField();
field.setDisplayName(fuzzy.first().parent().parent().select(".longkey").first().text());
field.setId("FUZZY");
fields.add(field);
}
Elements mediatypes = doc.select("input[name=ADI_MAT]");
if (mediatypes.size() > 0) {
DropdownSearchField field = new DropdownSearchField();
field.setDisplayName("Materialart");
field.setId("ADI_MAT");
field.addDropdownValue("", "Alle");
for (Element mt : mediatypes) {
field.addDropdownValue(mt.attr("value"), mt.parent().nextElementSibling().text().replace("\u00a0", ""));
}
fields.add(field);
}
return fields;
}
use of de.geeksfactory.opacclient.searchfields.TextSearchField in project opacclient by opacapp.
the class TouchPoint 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(".accordion-body select")) {
parseDropdown(dropdown, fields);
}
if (doc.select(".selectDatabase").size() > 0) {
DropdownSearchField dropdown = new DropdownSearchField();
dropdown.setId("_database");
for (Element option : doc.select(".selectDatabase")) {
String label = option.parent().ownText().trim();
if (label.equals("")) {
for (Element a : option.siblingElements()) {
label += a.ownText().trim();
}
}
dropdown.addDropdownValue(option.attr("name") + "=" + option.attr("value"), label.trim());
}
dropdown.setDisplayName(doc.select(".dbselection h3").first().text().trim());
fields.add(dropdown);
}
return fields;
}
use of de.geeksfactory.opacclient.searchfields.TextSearchField 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);
}
Aggregations