Skip to content

Commit

Permalink
Merge tag 'vufind-10.0' of github.com:vufind-org/vufind-browse-handle…
Browse files Browse the repository at this point in the history
…r into tuefind-10.0
  • Loading branch information
mtrojan-ub committed Aug 20, 2024
2 parents 9ef632c + 61f367b commit b429d96
Show file tree
Hide file tree
Showing 38 changed files with 661 additions and 397 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.3'
extensions: intl, xsl
tools: composer:2

- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: ${{ matrix.java-version }}

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up VuFind environment
run: |
echo VUFIND_HOME=~/vufind >> $GITHUB_ENV
echo VUFIND_LOCAL_DIR=$VUFIND_HOME/local >> $GITHUB_ENV
- name: Cache VuFind data
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/vufind
key: "vufind-${{ github.sha }}"
Expand Down
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Original author: Mark Triggs <mark@dishevelled.net>. Please feel free
Original author: Mark Triggs <mark@teaspoon-consulting.com>. Please feel free
to get in touch if you have any queries.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ should give you the two required jar files:
browse-handler.jar
browse-indexing.jar



2. Creating your browse indexes
--------------------------------
Expand All @@ -49,8 +49,8 @@ file with lines of the form:

Running it:

java -cp browse-indexing.jar PrintBrowseHeadings /path/to/your/bib/data/index subject-browse authority.index subjects.tmp
java -cp browse-indexing.jar PrintBrowseHeadings /path/to/your/bib/data/index author-browse authority.index names.tmp
java -cp browse-indexing.jar org.vufind.solr.indexing.PrintBrowseHeadings /path/to/your/bib/data/index subject-browse authority.index subjects.tmp
java -cp browse-indexing.jar org.vufind.solr.indexing.PrintBrowseHeadings /path/to/your/bib/data/index author-browse authority.index names.tmp

By default this assumes you're using my default field names in your authority index, which are:

Expand Down Expand Up @@ -78,8 +78,8 @@ The last step is to load all the headings into an SQLite database
(which acts as the browse index, effectively). CreateBrowseSQLite
does this:

java -cp browse-indexing.jar CreateBrowseSQLite sorted-names.tmp namesbrowse.db
java -cp browse-indexing.jar CreateBrowseSQLite sorted-subjects.tmp subjectsbrowse.db
java -cp browse-indexing.jar org.vufind.solr.indexing.CreateBrowseSQLite sorted-names.tmp namesbrowse.db
java -cp browse-indexing.jar org.vufind.solr.indexing.CreateBrowseSQLite sorted-subjects.tmp subjectsbrowse.db


And that's the indexing process. At the end of this you should have
Expand Down Expand Up @@ -160,3 +160,17 @@ Coding style is One True Brace style. In astyle:

astyle --mode=java --style=1tbs -U -H -I -R 'browse-handler/*' 'browse-indexing/*' 'common/*' 'tests/org/*'


6. Migration from earlier releases
-----------------------------------

Versions of the browse handler included in VuFind® 9.x and earlier
used different names for certain components. The table below
summarizes the changes:

| Former name | Current name |
| ------------------------------- | -------------------------------------------- |
| BIBLEECH (environment variable) | BIB_FIELD_ITERATOR |
| bibleech (Java System property) | bib_field_iterator |
| PrintBrowseHeadings (Class) | org.vufind.solr.indexing.PrintBrowseHeadings |
| CreateBrowseSQLite (Class) | org.vufind.solr.indexing.CreateBrowseSQLite |
9 changes: 0 additions & 9 deletions browse-indexing/Predicate.java

This file was deleted.

83 changes: 25 additions & 58 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@
<property name="ant.build.javac.target" value="1.8"/>

<path id="classpath">
<pathelement location="${builddir}/common"/>
<pathelement location="${builddir}"/>
<fileset dir="${builddir}/deps/">
<include name="**/*.jar"/>
</fileset>
<fileset dir="libs">
<include name="**/*.jar"/>
</fileset>
<fileset dir="tests/lib">
<include name="**/*.jar"/>
</fileset>
Expand Down Expand Up @@ -64,7 +61,6 @@
<target name="setup">
<mkdir dir="${builddir}"/>
<mkdir dir="${builddir}/deps"/>
<mkdir dir="${builddir}/bundled-deps"/>
<antcall target="setup-solr-deps"/>
</target>

Expand All @@ -77,73 +73,38 @@
<unwar src="${absolute.vufind.dir}/solr/jetty/webapps/solr.war" dest="${builddir}/deps/"/>
</target>

<target name="build" depends="clean, setup, build-common, build-handler, build-indexing">
<target name="build" depends="clean, setup">
<!-- Can be useful for debugging -->
<!-- <pathconvert property="classpathProp" refid="classpath"/> -->
<!-- <echo>Classpath: ${classpathProp}</echo> -->
</target>

<target name="build-common">
<mkdir dir="${builddir}/common"/>
<javac debug="on" srcdir="common/java" destdir="${builddir}/common">
<mkdir dir="${builddir}"/>
<javac debug="on" srcdir="src/main/java" destdir="${builddir}">
<classpath refid="classpath"/>
<compilerarg value="-Xlint"/>
</javac>
<exec executable="sh" output="${builddir}/common/VERSION">
<exec executable="sh" output="${builddir}/VERSION">
<arg value="-c"/>
<arg value="which git >/dev/null 2>&amp;1 &amp;&amp; git log --oneline -1"/>
</exec>
</target>


<target name="build-handler">
<mkdir dir="${builddir}/browse-handler"/>
<javac debug="on" srcdir="browse-handler/java" destdir="${builddir}/browse-handler">
<classpath refid="classpath"/>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:unchecked"/>
<!-- sometimes useful for library or refective programming failures -->
<!-- <compilerarg value="-Xdiags:verbose"/> -->
</javac>
</target>

<target name="build-indexing">
<mkdir dir="${builddir}/browse-indexing"/>
<javac debug="on" srcdir="browse-indexing/" destdir="${builddir}/browse-indexing">
<classpath refid="classpath"/>
<compilerarg value="-Xlint"/>
</javac>
</target>


<target name="clean">
<delete dir="${builddir}"/>
<delete file="browse-handler.jar"/>
<delete file="browse-indexing.jar"/>
</target>

<target name="bundledeps" if="bundle.deps">
<copy todir="${builddir}/bundled-deps">
<fileset dir="libs">
<include name="icu4j-49.1.jar"/>
<include name="sqlitejdbc-v053.jar"/>
</fileset>
</copy>
</target>

<target name="jars" depends="build,bundledeps">
<target name="jars" depends="build">
<jar destfile="browse-handler.jar">
<fileset dir="${builddir}/browse-handler/"/>
<fileset dir="${builddir}/common/"/>
<fileset dir="${builddir}" includes="org/vufind/solr/handler/**/*"/>
<fileset dir="${builddir}" includes="org/vufind/util/**/*"/>
</jar>
<jar destfile="browse-indexing.jar">
<fileset dir="${builddir}/browse-indexing/"/>
<fileset dir="${builddir}/common/"/>
<fileset dir="${builddir}" includes="org/vufind/solr/indexing/**/*"/>
<fileset dir="${builddir}" includes="org/vufind/util/**/*"/>
<!-- These files added for backwards compatibility -->
<fileset dir="${builddir}" includes="*.class"/>
<zipgroupfileset dir="${builddir}/deps/" includes="**/lucene-core*.jar"/>
<zipgroupfileset dir="libs">
<include name="commons-codec-1.5.jar"/>
</zipgroupfileset>
<zipgroupfileset dir="${builddir}/bundled-deps" includes="*.jar"/>
</jar>
</target>

Expand Down Expand Up @@ -198,18 +159,24 @@
</exec>
</target>

<target name="build-tests"
description="Build the test files"
depends="build">
<mkdir dir="${testdir}"/>
<javac fork="true" debug="on" srcdir="tests/" destdir="${testdir}"
classpath="tests/lib/*:${toString:classpath}:${builddir}">
<compilerarg line="-encoding UTF-8" />
</javac>
</target>

<!-- =================================
target: test-main
================================= -->
<target name="test-main"
description="Run tests, assumes build is current and test cores are set up">
<mkdir dir="${testdir}"/>
description="Run tests, assumes build is current and test cores are set up"
depends="build-tests">
<mkdir dir="${testoutputdir}"/>
<mkdir dir="${testdir}/report"/>
<javac fork="true" debug="on" srcdir="tests/" destdir="${testdir}"
classpath="tests/lib/*:${toString:classpath}:${builddir}/browse-handler">
<compilerarg line="-encoding UTF-8" />
</javac>

<junit showoutput="yes" fork="true" haltonfailure="on">
<sysproperty key="absolute.vufind.dir" value="${absolute.vufind.dir}" />
Expand All @@ -220,7 +187,7 @@
<pathelement location="tests/lib/junit-4.11.jar"/>
<pathelement location="tests/lib/*"/>
<pathelement location="${testdir}"/>
<pathelement location="${builddir}/browse-handler"/>
<pathelement location="${builddir}"/>
<pathelement path="${toString:classpath}"/>
</classpath>
<!-- formatter type="plain" usefile="false"/-->
Expand Down
10 changes: 0 additions & 10 deletions common/java/org/vufind/util/Utils.java

This file was deleted.

Binary file removed libs/clojure-1.4.0.jar
Binary file not shown.
13 changes: 13 additions & 0 deletions src/main/java/compat/CreateBrowseSQLite.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import org.vufind.util.Utils;

public class CreateBrowseSQLite
{
public static void main(String args[]) throws Exception
{
Utils.printDeprecationWarning("You are using the 'CreateBrowseSQLite' class.",
"This still works, but it has been renamed to 'org.vufind.solr.indexing.CreateBrowseSQLite'",
"You should switch to avoid breakage in future versions.");

org.vufind.solr.indexing.CreateBrowseSQLite.main(args);
}
}
13 changes: 13 additions & 0 deletions src/main/java/compat/PrintBrowseHeadings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import org.vufind.util.Utils;

public class PrintBrowseHeadings
{
public static void main(String args[]) throws Exception
{
Utils.printDeprecationWarning("You are using the 'PrintBrowseHeadings' class.",
"This still works, but it has been renamed to 'org.vufind.solr.indexing.PrintBrowseHeadings'",
"You should switch to avoid breakage in future versions.");

org.vufind.solr.indexing.PrintBrowseHeadings.main(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term;
Expand Down Expand Up @@ -73,107 +74,6 @@ public int recordCount(String heading, String filterBy)
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,
String filterBy)
throws Exception
{
Query q;
if (filterBy != null) {
TermQuery tq = new TermQuery (new Term (this.field, heading));
TermQuery fq = new TermQuery (new Term (filterBy, "T"));
BooleanQuery.Builder qb = new BooleanQuery.Builder();
qb.add(tq, BooleanClause.Occur.MUST);
qb.add(fq, BooleanClause.Occur.MUST);
q = qb.build();
} else {
q = new TermQuery (new Term (this.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
Loading

0 comments on commit b429d96

Please sign in to comment.