Commit e4127ce6 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

ajout getAlternateHref à ZoteroItem

parent 448f3cf8
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -26,11 +26,13 @@ public class ZoteroClient {
                JSONArray jsonResponseArray = response.getBody().getArray();
                for (int i = 0; i < jsonResponseArray.length(); i++) {
                    String href = jsonResponseArray.getJSONObject(i).getJSONObject("links").getJSONObject("self").getString("href");
                    //alternate href = url vers la fiche zotero en ligne
                    String alternateHref = jsonResponseArray.getJSONObject(i).getJSONObject("links").getJSONObject("alternate").getString("href");
                    JSONObject dataObject = jsonResponseArray.getJSONObject(i).getJSONObject("data");
                    ObjectMapper mapper = new ObjectMapper();
                    Map<String, Object> map = mapper.readValue(dataObject.toString(), new TypeReference<Map<String, Object>>(){});
                    String key = readDataValue("key", dataObject);
                    ZoteroItem currentItem = new ZoteroItem(key, href, map, library);
                    ZoteroItem currentItem = new ZoteroItem(key, href, alternateHref, map, library);
                    items.add(currentItem);
                }
                return items;
@@ -70,7 +72,7 @@ public class ZoteroClient {
                e.printStackTrace();
            }
            for (fr.unicaen.pdncertic.zotero.ZoteroItem it : items) {
                System.err.println(it.getKey() + " -> " + it.getDataValue("publisher")+"/"+ it.getDataValue("date"));
                System.err.println(it.getKey() + " -> " + it.getDataValue("publisher")+"/"+ it.getDataValue("date") + "/" + it.getAlternateHref());
            }
        }
    }
+7 −1
Original line number Diff line number Diff line
@@ -8,10 +8,12 @@ public class ZoteroItem {
    private ZoteroLibrary library;
    private Map<String, Object> dataMap;
    private String href;
    private String alternateHref;

    public ZoteroItem(String key, String href, Map<String, Object> dataMap, ZoteroLibrary library){
    public ZoteroItem(String key, String href, String alternateHref, Map<String, Object> dataMap, ZoteroLibrary library){
        this.key = key;
        this.href = href;
        this.alternateHref = alternateHref;
        this.dataMap = dataMap;
        this.library = library;
    }
@@ -24,6 +26,10 @@ public class ZoteroItem {
        return this.href;
    }

    public String getAlternateHref() {
        return this.alternateHref;
    }

    public ZoteroLibrary getLibrary() {
        return library;
    }