Search in sources :

Example 6 with LentItem

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

the class AccountDataSource method getLentItem.

public LentItem getLentItem(long id) {
    String[] selA = { "" + id };
    Cursor cursor = database.query(AccountDatabase.TABLENAME_LENT, AccountDatabase.COLUMNS_LENT, "id = ?", selA, null, null, null);
    LentItem item = null;
    cursor.moveToFirst();
    if (!cursor.isAfterLast()) {
        item = cursorToLentItem(cursor);
    }
    // Make sure to close the cursor
    cursor.close();
    return item;
}
Also used : LentItem(de.geeksfactory.opacclient.objects.LentItem) Cursor(android.database.Cursor)

Example 7 with LentItem

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

the class AccountDataSource method cursorToLentItem.

private LentItem cursorToLentItem(Cursor cursor) {
    LentItem item = new LentItem();
    setAccountItemAttributes(cursor, item);
    item.setBarcode(cursor.getString(7));
    item.setDeadline(cursor.getString(8));
    item.setHomeBranch(cursor.getString(9));
    item.setLendingBranch(cursor.getString(10));
    item.setProlongData(cursor.getString(11));
    item.setRenewable(cursor.getInt(12) == 1);
    item.setDownloadData(cursor.getString(13));
    item.setEbook(cursor.getInt(14) == 1);
    return item;
}
Also used : LentItem(de.geeksfactory.opacclient.objects.LentItem)

Example 8 with LentItem

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

the class AccountDataSource method getAllLentItems.

public List<LentItem> getAllLentItems() {
    List<LentItem> items = new ArrayList<>();
    Cursor cursor = database.query(AccountDatabase.TABLENAME_LENT, AccountDatabase.COLUMNS_LENT, null, null, null, null, null);
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        LentItem item = cursorToLentItem(cursor);
        items.add(item);
        cursor.moveToNext();
    }
    cursor.close();
    return items;
}
Also used : ArrayList(java.util.ArrayList) LentItem(de.geeksfactory.opacclient.objects.LentItem) Cursor(android.database.Cursor)

Example 9 with LentItem

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

the class PicaLBSAccountTest method testParseMediaList.

@Test
public void testParseMediaList() throws OpacApi.OpacErrorException {
    String html = readResource("/pica_lbs/medialist/" + file);
    // we may not have all files for all libraries
    if (html == null)
        return;
    List<LentItem> media = PicaLBS.parseMediaList(Jsoup.parse(html), new DummyStringProvider());
    assertTrue(media.size() > 0);
    for (LentItem item : media) {
        assertNotNull(item.getTitle());
        assertNotNull(item.getDeadline());
    }
}
Also used : DummyStringProvider(de.geeksfactory.opacclient.i18n.DummyStringProvider) LentItem(de.geeksfactory.opacclient.objects.LentItem) Test(org.junit.Test)

Example 10 with LentItem

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

the class SISISAccountTest method testParseMediaList.

@Test
public void testParseMediaList() throws OpacApi.OpacErrorException {
    String html = readResource("/sisis/medialist/" + file);
    // we may not have all files for all libraries
    if (html == null)
        return;
    List<LentItem> media = new ArrayList<LentItem>();
    Document doc = Jsoup.parse(html);
    SISIS.parse_medialist(media, doc, 0, new JSONObject());
    if (!file.equals("dresden.html")) {
        assertTrue(media.size() > 0);
    }
    // The test is still useful: Before 4.5.10 we actually had a bug with empty accounts.
    for (LentItem item : media) {
        assertNotNull(item.getTitle());
        assertNotNull(item.getDeadline());
    }
    Map<String, Integer> links = SISIS.getAccountPageLinks(doc);
    if (file.equals("erfurt.html")) {
        // here we have two pages
        assertTrue(links.size() == 1);
        assertTrue(links.get("https://opac.erfurt.de/webOPACClient/userAccount" + ".do?methodToCall=pos&accountTyp=AUSLEIHEN&anzPos=11").equals(11));
    }
}
Also used : JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) LentItem(de.geeksfactory.opacclient.objects.LentItem) Document(org.jsoup.nodes.Document) Test(org.junit.Test)

Aggregations

LentItem (de.geeksfactory.opacclient.objects.LentItem)43 ArrayList (java.util.ArrayList)26 ReservedItem (de.geeksfactory.opacclient.objects.ReservedItem)16 Element (org.jsoup.nodes.Element)16 AccountData (de.geeksfactory.opacclient.objects.AccountData)14 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)12 Test (org.junit.Test)10 JSONObject (org.json.JSONObject)9 Document (org.jsoup.nodes.Document)8 Elements (org.jsoup.select.Elements)8 NotReachableException (de.geeksfactory.opacclient.networking.NotReachableException)7 Pattern (java.util.regex.Pattern)5 Intent (android.content.Intent)4 Cursor (android.database.Cursor)4 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Matcher (java.util.regex.Matcher)4 LocalDate (org.joda.time.LocalDate)4 JSONException (org.json.JSONException)4 Account (de.geeksfactory.opacclient.objects.Account)3