use of de.geeksfactory.opacclient.objects.LentItem in project opacclient by opacapp.
the class AdisAccountTest method testParseMediaList.
@Test
public void testParseMediaList() throws OpacApi.OpacErrorException, JSONException {
String html = readResource("/adis/medialist/" + file);
// we may not have all files for all libraries
if (html == null)
return;
List<LentItem> media = new ArrayList<>();
Adis.parseMediaList(Jsoup.parse(html), "", media, false);
assertTrue(media.size() > 0);
for (LentItem item : media) {
assertNotNull(item.getDeadline());
// sensible dates
assertTrue(item.getDeadline().isAfter(new LocalDate(2010, 1, 1)));
assertNotNull(item.getId());
}
}
use of de.geeksfactory.opacclient.objects.LentItem in project opacclient by opacapp.
the class IOpacAccountTest method testParseMediaList.
@Test
public void testParseMediaList() throws OpacApi.OpacErrorException {
String html = readResource("/iopac/" + file);
List<LentItem> media = new ArrayList<>();
IOpac.parseMediaList(media, Jsoup.parse(html), new JSONObject());
assertTrue(media.size() > 0);
for (LentItem item : media) {
assertNotNull(item.getTitle());
assertNotNull(item.getDeadline());
}
if (file.equals("heide.html")) {
assertEquals("0x verl., 1 x reserv.", media.get(1).getStatus());
}
}
use of de.geeksfactory.opacclient.objects.LentItem in project opacclient by opacapp.
the class WinBiapAccountTest method testParseMediaList.
@Test
public void testParseMediaList() throws OpacApi.OpacErrorException {
String html = readResource("/winbiap/medialist/" + file);
// we may not have all files for all libraries
if (html == null)
return;
List<LentItem> media = WinBiap.parseMediaList(Jsoup.parse(html), new JSONObject());
assertTrue(media.size() > 0);
for (LentItem item : media) {
assertNotNull(item.getTitle());
assertNotNull(item.getDeadline());
assertNotNull(item.getMediaType());
assertContainsData(item.getCover());
}
}
use of de.geeksfactory.opacclient.objects.LentItem in project opacclient by opacapp.
the class PicaLBS method parseMediaList.
static List<LentItem> parseMediaList(Document doc, StringProvider stringProvider) {
List<LentItem> lent = new ArrayList<>();
for (Element tr : doc.select(".resultset > tbody > tr:has(.rec_title)")) {
LentItem item = new LentItem();
if (tr.select("input[name=volumeNumbersToRenew]").size() > 0) {
item.setProlongData(tr.select("input[name=volumeNumbersToRenew]").val());
} else {
item.setRenewable(false);
}
String[] titleAndAuthor = extractTitleAndAuthor(tr);
item.setTitle(titleAndAuthor[0]);
if (titleAndAuthor[1] != null)
item.setAuthor(titleAndAuthor[1]);
String returndate = extractAccountInfo(tr, "Returndate", "ausgeliehen bis", "Ausleihfrist", "Leihfristende");
item.setDeadline(parseDate(returndate));
StringBuilder status = new StringBuilder();
String statusData = extractAccountInfo(tr, "Status", "Derzeit");
if (statusData != null)
status.append(statusData);
String prolong = extractAccountInfo(tr, "No of Renewals", "Anzahl Verlängerungen", "Verlängerungen");
if (prolong != null && !prolong.equals("0")) {
if (status.length() > 0)
status.append(", ");
status.append(prolong).append("x ").append(stringProvider.getString(StringProvider.PROLONGED_ABBR));
}
String reminder = extractAccountInfo(tr, "Remind.", "Mahnungen");
if (reminder != null && !reminder.equals("0")) {
if (status.length() > 0)
status.append(", ");
status.append(reminder).append(" ").append(stringProvider.getString(StringProvider.REMINDERS));
}
String error = tr.select(".error").text();
if (!error.equals("")) {
if (status.length() > 0)
status.append(", ");
status.append(error);
}
item.setStatus(status.toString());
item.setHomeBranch(extractAccountInfo(tr, "Counter", "Theke"));
item.setBarcode(extractAccountInfo(tr, "Shelf mark", "Signatur"));
lent.add(item);
}
return lent;
}
use of de.geeksfactory.opacclient.objects.LentItem in project opacclient by opacapp.
the class Heidi method account.
@Override
public AccountData account(Account account) throws IOException, JSONException, OpacErrorException {
login(account);
String html;
Document doc;
AccountData adata = new AccountData(account.getId());
DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN);
html = httpGet(opac_url + "/konto.cgi?sess=" + sessid, getDefaultEncoding());
doc = Jsoup.parse(html);
doc.setBaseUri(opac_url + "/");
for (Element td : doc.select("table.konto td")) {
if (td.text().contains("Offene")) {
String text = td.text().trim().replaceAll("Offene[^0-9]+Geb.+hren:[^0-9]+([0-9.," + "]+)[^0-9€A-Z]*(€|EUR|CHF|Fr.)", "$1 $2");
adata.setPendingFees(text);
}
}
List<LentItem> lent = new ArrayList<>();
for (Element tr : doc.select("table.kontopos tr")) {
LentItem item = new LentItem();
Element desc = tr.child(1).select("label").first();
String dates = tr.child(2).text().trim();
if (tr.child(1).select("a").size() > 0) {
String kk = getQueryParamsFirst(tr.child(1).select("a").first().absUrl("href")).get("katkey");
item.setId(kk);
}
int i = 0;
for (Node node : desc.childNodes()) {
if (node instanceof TextNode) {
String text = ((TextNode) node).text().trim();
if (i == 0) {
item.setAuthor(text);
} else if (i == 1) {
item.setTitle(text);
} else if (text.contains("Mediennummer")) {
item.setBarcode(text.replace("Mediennummer: ", ""));
}
i++;
}
}
if (tr.child(0).select("input").size() == 1) {
item.setProlongData(tr.child(0).select("input").first().val());
item.setRenewable(true);
} else {
item.setProlongData("§" + tr.child(0).select("span").first().attr("class"));
item.setRenewable(false);
}
String todate = dates;
if (todate.contains("-")) {
String[] datesplit = todate.split("-");
todate = datesplit[1].trim();
}
try {
item.setDeadline(fmt.parseLocalDate(todate.substring(0, 10)));
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
lent.add(item);
}
adata.setLent(lent);
List<ReservedItem> reservations = new ArrayList<>();
html = httpGet(opac_url + "/konto.cgi?konto=v&sess=" + sessid, getDefaultEncoding());
reservations.addAll(parse_reservations(html));
html = httpGet(opac_url + "/konto.cgi?konto=b&sess=" + sessid, getDefaultEncoding());
reservations.addAll(parse_reservations(html));
adata.setReservations(reservations);
return adata;
}
Aggregations