Skip to content

Commit

Permalink
VUFIND-1341 Remove deprecated methods (#49)
Browse files Browse the repository at this point in the history
- BrowseItem.setIds, BrowseItem.getIds (replaced by BrowseItem.getExtras/BrowseItem.setExtras)
- BibDB.matchingIDs (superseded by with BibDB.matchingExtras)
  • Loading branch information
marktriggs committed Dec 12, 2023
1 parent 63b4998 commit f3e5905
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 195 deletions.
90 changes: 0 additions & 90 deletions browse-handler/java/org/vufind/solr/handler/BibDB.java
Expand Up @@ -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<String, List<Collection<String>>> matchingIDs(String heading,
String extras,
int maxBibListSize)
throws Exception
{
TermQuery q = new TermQuery(new Term(field, heading));

// bibinfo values are List<Collection> because some extra fields
// may be multi-valued.
// Note: it may be time for bibinfo to become a class...
final Map<String, List<Collection<String>>> bibinfo = new HashMap<> ();
bibinfo.put("ids", new ArrayList<Collection<String>> ());
final String[] bibExtras = extras.split(":");
for (String bibField : bibExtras) {
bibinfo.put(bibField, new ArrayList<Collection<String>> ());
}

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<String> 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<String> 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.
* <p>
Expand Down
28 changes: 0 additions & 28 deletions browse-handler/java/org/vufind/solr/handler/BrowseItem.java
Expand Up @@ -121,27 +121,6 @@ public void setNote(String note)
this.put("note", note);
}

/**
* Set the list of IDs of bibs that match this heading.
* <p>
* Bib IDs are gathered into {@code List<Collection<String>>}.
* That is, IDs are passed in as a List of Collections, but stored
* as on flat List of IDs.
* <p> see bibinfo in
* BibDB.matchingIDs() and populateItem().
*
* @param idList List of Collection of bib IDs.
*/
@Deprecated
public void setIds(List<Collection<String>> idList)
{
List<String>ids = new ArrayList<String> ();
for (Collection<String> idCol : idList) {
ids.addAll(idCol);
}
this.put("ids", ids);
}

public void setExtras(Map<String, List<Collection<String>>> extras)
{
this.put("extras", extras);
Expand Down Expand Up @@ -189,13 +168,6 @@ public String getNote()
return optString((String) this.get("note"));
}

@Deprecated
@SuppressWarnings("unchecked")
public List<String> getIds()
{
return optListString((List<String>) this.get("ids"));
}

@SuppressWarnings("unchecked")
public Map<String, List<Collection<String>>> getExtras()
{
Expand Down
26 changes: 0 additions & 26 deletions tests/org/vufind/solr/handler/BibDBTest.java
Expand Up @@ -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<SolrIndexSearcher> searcherRef = bibCore.getSearcher();
IndexSearcher searcher = searcherRef.get();
try {
BibDB bibDbForTitle = new BibDB(searcher, "title_fullStr");
List<String> 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)}.
*/
Expand Down
51 changes: 0 additions & 51 deletions tests/org/vufind/solr/handler/BrowseItemTest.java
Expand Up @@ -91,33 +91,6 @@ public void testSetNote()
assertEquals(note, item.get("note"));
}

@Test
public void testSetIds()
{
Collection<String> ids1 = new ArrayList<String>();
ids1.add("id-1");
ids1.add("id-2");

Collection<String> ids2 = new ArrayList<String>();
ids2.add("id-3");

// This is what we expect to store, a list containing all IDs
List<String> allIds = new ArrayList<String>();
allIds.addAll(ids1);
allIds.addAll(ids2);

// This is what setIds expects, a list of collections
List<Collection<String>> idList = new ArrayList<Collection<String>>();
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()
{
Expand Down Expand Up @@ -214,30 +187,6 @@ public void testGetNote()
assertEquals(note, item.getNote());
}

@Test
public void testGetIds()
{
Collection<String> ids1 = new ArrayList<String>();
ids1.add("id-1");
Collection<String> ids2 = new ArrayList<String>();
ids1.add("id-2");
// This is what we expect to store, a list containing all IDs
List<String> allIds = new ArrayList<String>();
allIds.addAll(ids1);
allIds.addAll(ids2);

// This is what setIds expects, a list of collections
List<Collection<String>> idList = new ArrayList<Collection<String>>();
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()
{
Expand Down

0 comments on commit f3e5905

Please sign in to comment.