Search in sources :

Example 1 with ReservedItem

use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.

the class AccountItemDetailActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
    Intent intent = new Intent();
    int resultCode;
    int item_id = menuItem.getItemId();
    if (item_id == R.id.action_prolong) {
        resultCode = RESULT_PROLONG;
        intent.putExtra(EXTRA_DATA, ((LentItem) item).getProlongData());
    } else if (item_id == R.id.action_download) {
        resultCode = RESULT_DOWNLOAD;
        intent.putExtra(EXTRA_DATA, ((LentItem) item).getDownloadData());
    } else if (item_id == R.id.action_cancel) {
        resultCode = RESULT_CANCEL;
        intent.putExtra(EXTRA_DATA, ((ReservedItem) item).getCancelData());
    } else if (item_id == R.id.action_booking) {
        resultCode = RESULT_BOOKING;
        intent.putExtra(EXTRA_DATA, ((ReservedItem) item).getBookingData());
    } else {
        return super.onOptionsItemSelected(menuItem);
    }
    setResult(resultCode, intent);
    supportFinishAfterTransition();
    return true;
}
Also used : Intent(android.content.Intent) ReservedItem(de.geeksfactory.opacclient.objects.ReservedItem) LentItem(de.geeksfactory.opacclient.objects.LentItem)

Example 2 with ReservedItem

use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.

the class IOpacAccountTest method testParseResList.

@Test
public void testParseResList() throws OpacApi.OpacErrorException {
    String html = readResource("/iopac/" + file);
    List<ReservedItem> media = new ArrayList<>();
    IOpac.parseResList(media, Jsoup.parse(html), new JSONObject());
}
Also used : JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) ReservedItem(de.geeksfactory.opacclient.objects.ReservedItem) Test(org.junit.Test)

Example 3 with ReservedItem

use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.

the class PicaOldAccountTest method testParseResList.

@Test
public void testParseResList() throws OpacApi.OpacErrorException {
    String html = readResource("/pica_old/reslist/" + file);
    // we may not have all files for all libraries
    if (html == null)
        return;
    List<ReservedItem> media = new ArrayList<>();
    PicaOld.parseResList(media, Jsoup.parse(html), new DummyStringProvider());
    assertTrue(media.size() > 0);
}
Also used : DummyStringProvider(de.geeksfactory.opacclient.i18n.DummyStringProvider) ArrayList(java.util.ArrayList) ReservedItem(de.geeksfactory.opacclient.objects.ReservedItem) Test(org.junit.Test)

Example 4 with ReservedItem

use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.

the class WinBiapAccountTest method testParseResList.

@Test
public void testParseResList() throws OpacApi.OpacErrorException {
    String html = readResource("/winbiap/reslist/" + file);
    // we may not have all files for all libraries
    if (html == null)
        return;
    List<ReservedItem> media = WinBiap.parseResList(Jsoup.parse(html), new DummyStringProvider(), new JSONObject());
    for (ReservedItem item : media) {
        assertNotNull(item.getMediaType());
        assertContainsData(item.getCover());
    }
    assertTrue(media.size() > 0);
}
Also used : DummyStringProvider(de.geeksfactory.opacclient.i18n.DummyStringProvider) JSONObject(org.json.JSONObject) ReservedItem(de.geeksfactory.opacclient.objects.ReservedItem) Test(org.junit.Test)

Example 5 with ReservedItem

use of de.geeksfactory.opacclient.objects.ReservedItem in project opacclient by opacapp.

the class Heidi method parse_reservations.

protected List<ReservedItem> parse_reservations(String html) {
    Document doc = Jsoup.parse(html);
    List<ReservedItem> reservations = new ArrayList<>();
    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN);
    for (Element tr : doc.select("table.kontopos tr")) {
        ReservedItem item = new ReservedItem();
        Element desc = tr.child(1).select("label").first();
        Element pos = tr.child(3);
        if (tr.child(1).select("a").size() > 0) {
            String kk = getQueryParamsFirst(tr.child(1).select("a").first().absUrl("href")).get("katkey");
            item.setId(kk);
        }
        if (tr.child(0).select("input").size() > 0) {
            item.setCancelData(tr.child(0).select("input").first().val());
        }
        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);
                }
                i++;
            }
        }
        i = 0;
        for (Node node : pos.childNodes()) {
            if (node instanceof TextNode) {
                String text = ((TextNode) node).text().trim();
                if (i == 0 && text.contains("")) {
                    try {
                        item.setReadyDate(fmt.parseLocalDate(text));
                    } catch (IllegalArgumentException e) {
                        item.setStatus(text);
                    }
                } else if (i == 1) {
                    item.setBranch(text);
                }
                i++;
            }
        }
        reservations.add(item);
    }
    return reservations;
}
Also used : Element(org.jsoup.nodes.Element) TextNode(org.jsoup.nodes.TextNode) Node(org.jsoup.nodes.Node) ArrayList(java.util.ArrayList) ReservedItem(de.geeksfactory.opacclient.objects.ReservedItem) TextNode(org.jsoup.nodes.TextNode) Document(org.jsoup.nodes.Document) DateTimeFormatter(org.joda.time.format.DateTimeFormatter)

Aggregations

ReservedItem (de.geeksfactory.opacclient.objects.ReservedItem)34 ArrayList (java.util.ArrayList)20 Element (org.jsoup.nodes.Element)17 LentItem (de.geeksfactory.opacclient.objects.LentItem)16 AccountData (de.geeksfactory.opacclient.objects.AccountData)13 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)8 Document (org.jsoup.nodes.Document)8 Elements (org.jsoup.select.Elements)8 JSONObject (org.json.JSONObject)7 Test (org.junit.Test)7 NotReachableException (de.geeksfactory.opacclient.networking.NotReachableException)6 DummyStringProvider (de.geeksfactory.opacclient.i18n.DummyStringProvider)4 HashMap (java.util.HashMap)4 IOException (java.io.IOException)3 Pattern (java.util.regex.Pattern)3 JSONException (org.json.JSONException)3 Intent (android.content.Intent)2 Account (de.geeksfactory.opacclient.objects.Account)2 Report (de.geeksfactory.opacclient.reporting.Report)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2