use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.
the class PicaLBSAccountTest method testParseResList.
@Test
public void testParseResList() throws OpacApi.OpacErrorException {
String html = readResource("/pica_lbs/reslist/" + file);
// we may not have all files for all libraries
if (html == null)
return;
List<ReservedItem> media = PicaLBS.parseResList(Jsoup.parse(html), new DummyStringProvider());
assertTrue(media.size() > 0);
}
use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.
the class AdisAccountTest method testParseReservationList.
@Test
public void testParseReservationList() throws OpacApi.OpacErrorException, JSONException {
String html = readResource("/adis/reslist/" + file);
// we may not have all files for all libraries
if (html == null)
return;
List<ReservedItem> res = new ArrayList<>();
DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN);
String[] rlink = new String[] { "Vormerkungen zeigen oder löschen", "https://opac.sbs.stuttgart.de/aDISWeb/app;" + "jsessionid=98AAE50B33FC5A0C191319D406D1564E?service=direct/1/POOLM02Q" + "@@@@@@@@_4B032E00_349DAD80/Tabelle_Z1LW01.cellInternalLink" + ".directlink&sp=SRGLINK_3&sp=SZM&requestCount=2" };
Adis.parseReservationList(Jsoup.parse(html), rlink, true, res, fmt, new DummyStringProvider());
assertTrue(res.size() > 0);
for (ReservedItem item : res) {
assertNotNull(item.getTitle());
}
}
use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.
the class BiBer1992AccountTest method testParseResList.
@Test
public void testParseResList() throws OpacApi.OpacErrorException, JSONException {
String html = readResource("/biber1992/reslist/" + file);
// we may not have all files for all libraries
if (html == null)
return;
List<ReservedItem> media = BiBer1992.parseResList(new Account(), Jsoup.parse(html), new JSONObject(), reportHandler, new JSONObject(readResource("/biber1992/headers_reservations.json")));
assertTrue(media.size() > 0);
}
use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.
the class BibliothecaAccountTest method testParseReservationList.
@Test
public void testParseReservationList() throws OpacApi.OpacErrorException, JSONException, NotReachableException {
String html = readResource("/bibliotheca/account/" + file);
// we may not have all files for all libraries
if (html == null)
return;
if (file.equals("gladbeck.html") || file.equals("halle.html") || file.equals("albstadt.html") || file.equals("bernau.html"))
return;
AccountData data = Bibliotheca.parse_account(new Account(), Jsoup.parse(html), new JSONObject(), reportHandler, new JSONObject(readResource("/bibliotheca/headers_lent.json")), new JSONObject(readResource("/bibliotheca/headers_reservations.json")));
assertTrue(data.getReservations().size() > 0);
for (ReservedItem item : data.getReservations()) {
assertContainsData(item.getTitle());
assertNullOrNotEmpty(item.getAuthor());
}
}
use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.
the class PicaLBS method parseResList.
static List<ReservedItem> parseResList(Document doc, StringProvider stringProvider) {
List<ReservedItem> reservations = new ArrayList<>();
for (Element tr : doc.select(".resultset > tbody > tr:has(.rec_title)")) {
ReservedItem item = new ReservedItem();
if (tr.select("input[name=volumeReservationsToCancel]").size() > 0) {
item.setCancelData(tr.select("input[name=volumeReservationsToCancel]").val());
}
String[] titleAndAuthor = extractTitleAndAuthor(tr);
item.setTitle(titleAndAuthor[0]);
if (titleAndAuthor[1] != null)
item.setAuthor(titleAndAuthor[1]);
item.setBranch(extractAccountInfo(tr, "Destination", "Theke"));
// not supported: extractAccountInfo(tr, "Shelf mark", "Signatur")
StringBuilder status = new StringBuilder();
String numberOfReservations = extractAccountInfo(tr, "Vormerkung", "Number of reservations");
if (numberOfReservations != null) {
try {
status.append(stringProvider.getQuantityString(StringProvider.RESERVATIONS_NUMBER, Integer.parseInt(numberOfReservations.trim()), Integer.parseInt(numberOfReservations.trim())));
} catch (NumberFormatException e) {
status.append(numberOfReservations);
}
}
String reservationDate = extractAccountInfo(tr, "Reservationdate", "Vormerkungsdatum");
if (reservationDate != null) {
if (status.length() > 0) {
status.append(", ");
}
status.append(stringProvider.getFormattedString(StringProvider.RESERVED_AT_DATE, reservationDate));
}
if (status.length() > 0)
item.setStatus(status.toString());
// TODO: I don't know how reservations are marked that are already available
reservations.add(item);
}
return reservations;
}
Aggregations