Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,18 @@ open class SLUB : OkHttpBaseApi() {
branch = it.getString("location")
department = Parser.unescapeEntities(it.getString("sublocation"), false)
shelfmark = it.getString("shelfmark")
status = Jsoup.parse(it.getString("statusphrase")).text()
it.getString("statusphrase").run {
if (isNotEmpty()) {
status = Parser.unescapeEntities(this, false)
} else {
it.getString("link").run {
if(isNotEmpty()){
status = stringProvider.getFormattedString(
StringProvider.INQUIRE_AVAILABILITY, this )
}
}
}
}
statusCode = colorcodes.getOrElse(it.getString("colorcode")) { SearchResult.Status.UNKNOWN }
it.getString("duedate").run {
if (isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
* Copyright (C) 2013 by Johan von Forstner under the MIT license:
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software
* of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package de.geeksfactory.opacclient.i18n;
Expand Down Expand Up @@ -97,6 +97,7 @@ public interface StringProvider {
String RENEWED = "renewed";
String NOT_YET_RENEWABLE = "not_yet_renewable";
String RENEW_ILL_SEPARATELY = "renew_ill_separately";
String INQUIRE_AVAILABILITY = "inquire_availability";

/**
* Returns the translated string identified by identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ class SLUBAccountTest : BaseHtmlTest() {
class SLUBSearchTest : BaseHtmlTest() {
private var slub = SLUB()

init {
slub.stringProvider = DummyStringProvider()
}

@Test
fun testParseEmptySearchResults() {
val json = JSONObject(readResource("/slub/search/empty-search.json"))
Expand Down Expand Up @@ -284,6 +288,43 @@ class SLUBSearchTest : BaseHtmlTest() {
assertThat(HashSet(item.details), sameBeanAs(HashSet(expected.details)))
}

@Test
fun testParseResultByIdWithoutStatusphrase() {
val json = JSONObject(readResource("/slub/search/item_inquery_availability.json"))
val expected = DetailedItem().apply {
addDetail(Detail("Medientyp", "Buch"))
addDetail(Detail("Titel", "Astronomie: die kosmische Perspektive"))
title = "Astronomie: die kosmische Perspektive"
addDetail(Detail("Beteiligte",
"Bennett, Jeffrey O. [Sonstige Person, Familie und Körperschaft]; Lesch, Harald [Hrsg.]"))
addDetail(Detail("Erschienen", "München [u.a.] Pearson 2010 "))
addDetail(Detail("Erschienen in", "Always learning"))
addDetail(Detail("ISBN", "9783827373601; 3827373603"))
addDetail(Detail("Sprache", "Deutsch; Englisch"))
addDetail(Detail("Schlagwörter", "Astronomie"))
addDetail(Detail("Beschreibung",
"CD-ROM-Beil. enth.: Planetariumssoftware SkyGazer Educational-Edition; " +
"Hier auch später erschienene, unveränderte Nachdrucke; " +
"Auflagenzählung bezieht sich auf die engl. Orig.-Ausg"))
addDetail(Detail("Inhaltsverzeichnis", "http://d-nb.info/992365538/04"))
addDetail(Detail("Cover", "http://swbplus.bsz-bw.de/bsz304732311cov.htm"))
id = "id/0-590996231"
copies = arrayListOf(Copy().apply {
barcode = "34163775"
department = ""
branch = "Zentralbibliothek"
status = "inquire_availability https://tu-dresden.de/bu/umwelt/geo/ipg/astro"
statusCode = SearchResult.Status.UNKNOWN
shelfmark = "US 1020 B471(5)"
})
}

val item = slub.parseResultById(json)

assertThat(item, sameBeanAs(expected).ignoring("details"))
assertThat(HashSet(item.details), sameBeanAs(HashSet(expected.details)))
}

@Test
fun testParseResultByIdCoverAsMaterial() {
val json = JSONObject(readResource("/slub/search/detaill-cover-jpg-as-material.json"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"record": {
"format": "Buch",
"title": "Astronomie: die kosmische Perspektive",
"contributor": [
"Bennett, Jeffrey O. [Sonstige Person, Familie und Körperschaft]",
"Lesch, Harald [Hrsg.]"
],
"publisher": [
"München [u.a.] Pearson 2010 "
],
"ispartof": [
{
"title": "Always learning"
}
],
"identifier": [
"9783827373601",
"3827373603"
],
"language": [
"Deutsch",
"Englisch"
],
"subject": [
"Astronomie"
],
"description": [
"CD-ROM-Beil. enth.: Planetariumssoftware SkyGazer Educational-Edition",
"Hier auch später erschienene, unveränderte Nachdrucke",
"Auflagenzählung bezieht sich auf die engl. Orig.-Ausg"
],
"status": "",
"rvk": ""
},
"id": "0-590996231",
"oa": 0,
"thumbnail": "",
"links": [
{
"uri": "http://d-nb.info/992365538/04",
"note": "",
"material": "Inhaltsverzeichnis"
},
{
"uri": "http://swbplus.bsz-bw.de/bsz304732311cov.htm",
"note": "",
"material": "Cover"
}
],
"linksRelated": [
{
"uri": "http://d-nb.info/992365538/04",
"hostLabel": "",
"note": "",
"material": "Inhaltsverzeichnis"
},
{
"uri": "http://swbplus.bsz-bw.de/bsz304732311cov.htm",
"hostLabel": "",
"note": "",
"material": "Cover"
}
],
"linksAccess": [],
"linksGeneral": [],
"references": [],
"copies": [
{
"barcode": "34163775",
"location": "Zentralbibliothek",
"location_code": "zell1",
"sublocation": "",
"shelfmark": "US 1020 B471(5)",
"mediatype": "B",
"3d": "",
"3d_link": "",
"issue": "",
"colorcode": "0",
"statusphrase": "",
"link": "https://tu-dresden.de/bu/umwelt/geo/ipg/astro",
"status": "H",
"duedate": "",
"vormerken": "0",
"bestellen": "0"
}
],
"parts": {}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.geeksfactory.opacclient.frontend;

import android.content.Context;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -67,7 +69,8 @@ public void onBindViewHolder(ViewHolder holder, int position) {

private void setTextOrHide(String text, TextView tv) {
if (notEmpty(text)) {
tv.setText(text);
tv.setText(Html.fromHtml(text));
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setVisibility(View.VISIBLE);
} else {
tv.setVisibility(View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@
<string name="renewed">%dx verlängert</string>
<string name="not_yet_renewable">noch nicht verlängerbar</string>
<string name="renew_ill_separately">Fernleihmedien bitte einzeln verlängern.</string>
<string name="inquire_availability">Verfügbarkeit bitte &lt;a href="%s">hier&lt;/a> erfragen</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@
<string name="renewed">%dx renewed</string>
<string name="not_yet_renewable">not yet renewable</string>
<string name="renew_ill_separately">Please renew interlibrary loan items separately.</string>
<string name="inquire_availability">Please inquire about availability &lt;a href="%s">here&lt;/a></string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.junit.runner.RunWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;

import de.geeksfactory.opacclient.R;
Expand Down