diff --git a/browse-handler/java/org/vufind/solr/handler/BibDB.java b/browse-handler/java/org/vufind/solr/handler/BibDB.java index c8ae45c..038f9da 100644 --- a/browse-handler/java/org/vufind/solr/handler/BibDB.java +++ b/browse-handler/java/org/vufind/solr/handler/BibDB.java @@ -60,96 +60,6 @@ public int recordCount(String heading) return counter.getTotalHits(); } - /** - * - * Function to retrieve the doc ids when there is a building limit - * This retrieves the doc ids for an individual heading - * - * Need to add a filter query to limit the results from Solr - * - * Includes functionality to retrieve additional info - * like titles for call numbers, possibly ISBNs - * - * @param heading string of the heading to use for finding matching - * @param extras docs colon-separated string of Solr fields - * to return for use in the browse display - * @param maxBibListSize maximum numbers of records to check for fields - * @return return a map of Solr ids and extra bib info - */ - @Deprecated - public Map>> matchingIDs(String heading, - String extras, - int maxBibListSize) - throws Exception - { - TermQuery q = new TermQuery(new Term(field, heading)); - - // bibinfo values are List because some extra fields - // may be multi-valued. - // Note: it may be time for bibinfo to become a class... - final Map>> bibinfo = new HashMap<> (); - bibinfo.put("ids", new ArrayList> ()); - final String[] bibExtras = extras.split(":"); - for (String bibField : bibExtras) { - bibinfo.put(bibField, new ArrayList> ()); - } - - db.search(q, new SimpleCollector() { - private LeafReaderContext context; - - public void setScorer(Scorer scorer) { - } - - // Will only be used by other classes - @SuppressWarnings("unused") - public boolean acceptsDocsOutOfOrder() { - return true; - } - - public boolean needsScores() { - return false; - } - - public ScoreMode scoreMode() { - return ScoreMode.COMPLETE_NO_SCORES; - } - - public void doSetNextReader(LeafReaderContext context) { - this.context = context; - } - - - public void collect(int docnum) { - int docid = docnum + context.docBase; - try { - Document doc = db.getIndexReader().document(docid); - - String[] vals = doc.getValues("id"); - Collection id = new HashSet<> (); - id.add(vals[0]); - bibinfo.get("ids").add(id); - for (String bibField : bibExtras) { - vals = doc.getValues(bibField); - if (vals.length > 0) { - Collection valSet = new LinkedHashSet<> (); - for (String val : vals) { - valSet.add(val); - } - bibinfo.get(bibField).add(valSet); - } - } - } catch (org.apache.lucene.index.CorruptIndexException e) { - Log.info("CORRUPT INDEX EXCEPTION. EEK! - " + e); - } catch (Exception e) { - Log.info("Exception thrown: " + e); - } - - } - }); - - return bibinfo; - } - /** * Function to retrieve the extra fields needed for building the browse display. *

diff --git a/browse-handler/java/org/vufind/solr/handler/BrowseItem.java b/browse-handler/java/org/vufind/solr/handler/BrowseItem.java index a3c0a5c..302269d 100644 --- a/browse-handler/java/org/vufind/solr/handler/BrowseItem.java +++ b/browse-handler/java/org/vufind/solr/handler/BrowseItem.java @@ -121,27 +121,6 @@ public void setNote(String note) this.put("note", note); } - /** - * Set the list of IDs of bibs that match this heading. - *

- * Bib IDs are gathered into {@code List>}. - * That is, IDs are passed in as a List of Collections, but stored - * as on flat List of IDs. - *

see bibinfo in - * BibDB.matchingIDs() and populateItem(). - * - * @param idList List of Collection of bib IDs. - */ - @Deprecated - public void setIds(List> idList) - { - Listids = new ArrayList (); - for (Collection idCol : idList) { - ids.addAll(idCol); - } - this.put("ids", ids); - } - public void setExtras(Map>> extras) { this.put("extras", extras); @@ -189,13 +168,6 @@ public String getNote() return optString((String) this.get("note")); } - @Deprecated - @SuppressWarnings("unchecked") - public List getIds() - { - return optListString((List) this.get("ids")); - } - @SuppressWarnings("unchecked") public Map>> getExtras() { diff --git a/tests/org/vufind/solr/handler/BibDBTest.java b/tests/org/vufind/solr/handler/BibDBTest.java index d41b22d..8ea9b36 100644 --- a/tests/org/vufind/solr/handler/BibDBTest.java +++ b/tests/org/vufind/solr/handler/BibDBTest.java @@ -122,32 +122,6 @@ public void testRecordCount() searcherRef.decref(); } - /** - * Test method for {@link org.vufind.solr.handler.BibDB#matchingIDs(java.lang.String, java.lang.String, int)}. - */ - @Test - public void testMatchingIDs() - { - //Log.info("Entering testMatchingIDs"); - String title = "A common title"; - int idCount = 3; - RefCounted searcherRef = bibCore.getSearcher(); - IndexSearcher searcher = searcherRef.get(); - try { - BibDB bibDbForTitle = new BibDB(searcher, "title_fullStr"); - List ids = bibDbForTitle.matchingIDs(title, "id", 10).get("id") - .stream() - .flatMap(Collection::stream) - .collect(Collectors.toList()); - assertEquals(idCount, ids.size()); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - searcherRef.decref(); - } - } - /** * Test method for {@link org.vufind.solr.handler.BibDB#matchingExtras(java.lang.String, java.lang.String, int)}. */ diff --git a/tests/org/vufind/solr/handler/BrowseItemTest.java b/tests/org/vufind/solr/handler/BrowseItemTest.java index 6ae6993..73cb164 100644 --- a/tests/org/vufind/solr/handler/BrowseItemTest.java +++ b/tests/org/vufind/solr/handler/BrowseItemTest.java @@ -91,33 +91,6 @@ public void testSetNote() assertEquals(note, item.get("note")); } - @Test - public void testSetIds() - { - Collection ids1 = new ArrayList(); - ids1.add("id-1"); - ids1.add("id-2"); - - Collection ids2 = new ArrayList(); - ids2.add("id-3"); - - // This is what we expect to store, a list containing all IDs - List allIds = new ArrayList(); - allIds.addAll(ids1); - allIds.addAll(ids2); - - // This is what setIds expects, a list of collections - List> idList = new ArrayList>(); - idList.add(ids1); - idList.add(ids2); - - BrowseItem item = new BrowseItem("", ""); - item.setIds(idList); - - // IDs are stored as the concatenation of the list of collections - assertEquals(allIds, item.get("ids")); - } - @Test public void testSetExtras() { @@ -214,30 +187,6 @@ public void testGetNote() assertEquals(note, item.getNote()); } - @Test - public void testGetIds() - { - Collection ids1 = new ArrayList(); - ids1.add("id-1"); - Collection ids2 = new ArrayList(); - ids1.add("id-2"); - // This is what we expect to store, a list containing all IDs - List allIds = new ArrayList(); - allIds.addAll(ids1); - allIds.addAll(ids2); - - // This is what setIds expects, a list of collections - List> idList = new ArrayList>(); - idList.add(ids1); - idList.add(ids2); - - BrowseItem item = new BrowseItem("", ""); - item.setIds(idList); - - // IDs are stored as the concatenation of the list of collections - assertEquals(allIds, item.getIds()); - } - @Test public void testGetExtras() {