Adding JAR task to vitro. Changing visibility levels on IndividualToSolrDocument.

This commit is contained in:
briancaruso 2011-07-28 22:22:00 +00:00
parent a477c2face
commit fa8b6db07e
3 changed files with 284 additions and 275 deletions

View file

@ -370,6 +370,8 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
<jar basedir="${build.dir}/war" destfile="${build.dir}/${webapp.name}.war" />
</target>
<!-- =================================
target: licenser

View file

@ -1,305 +1,312 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!-- ======================================================================
Build script for the Vivo Products.
jeb228
====================================================================== -->
<project name="vivoProduct" default="describe">
<!--
This script should not be run on its own.
It should only be run from the build script of an individual Product.
-->
<fail>
<condition>
<equals arg1="${ant.file.vivoProduct}" arg2="${ant.file}" />
</condition>
This script should not be run by itself.
It should be invoked from the build script of a Vivo product.
</fail>
<fail unless="inner.basedir"
message="The build script for the product must define a value for inner.basedir" />
<!--
The build directory goes in the product directory.
Everything else hangs from the build directory.
-->
<property name="build.dir" location="./.build" />
<property name="war.dir" location="${build.dir}/war" />
<property name="war-webinf.dir" location="${war.dir}/WEB-INF" />
<property name="war-classes.dir" location="${war-webinf.dir}/classes" />
<property name="war-resources.dir" location="${war-webinf.dir}/resources" />
<property name="war-lib.dir" location="${war-webinf.dir}/lib" />
<property name="test-classes.dir" location="${build.dir}/testclasses" />
<property name="servletjars.dir" location="${build.dir}/servletjars" />
<property name="javac.deprecation" value="true" />
<!-- Is there a "src" directory in the product? -->
<property name="product.source.dir" location="./src" />
<available property="product.sources.exist" file="${product.source.dir}" />
<!-- Is there a "test" directory in the product? -->
<property name="product.test.dir" location="./test" />
<available property="product.tests.exist" file="${product.test.dir}" />
<!-- Is there a "themes" directory in the product? -->
<property name="product.themes.dir" location="./themes" />
<available property="product.themes.exist" file="${product.themes.dir}" />
<!-- Is there a modifications directory in the product? -->
<?xml version="1.0" encoding="UTF-8"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!-- ======================================================================
Build script for the Vivo Products.
jeb228
======================================================================-->
<project name="vivoProduct" default="describe">
<!--
This script should not be run on its own.
It should only be run from the build script of an individual Product.
-->
<fail>
<condition>
<equals arg1="${ant.file.vivoProduct}" arg2="${ant.file}" />
</condition>
This script should not be run by itself.
It should be invoked from the build script of a Vivo product.
</fail>
<fail unless="inner.basedir"
message="The build script for the product must define a value for inner.basedir" />
<!--
The build directory goes in the product directory.
Everything else hangs from the build directory.
-->
<property name="build.dir" location="./.build" />
<property name="war.dir" location="${build.dir}/war" />
<property name="war-webinf.dir" location="${war.dir}/WEB-INF" />
<property name="war-classes.dir" location="${war-webinf.dir}/classes" />
<property name="war-resources.dir" location="${war-webinf.dir}/resources" />
<property name="war-lib.dir" location="${war-webinf.dir}/lib" />
<property name="test-classes.dir" location="${build.dir}/testclasses" />
<property name="servletjars.dir" location="${build.dir}/servletjars" />
<property name="javac.deprecation" value="true" />
<!-- Is there a "src" directory in the product? -->
<property name="product.source.dir" location="./src" />
<available property="product.sources.exist" file="${product.source.dir}" />
<!-- Is there a "test" directory in the product? -->
<property name="product.test.dir" location="./test" />
<available property="product.tests.exist" file="${product.test.dir}" />
<!-- Is there a "themes" directory in the product? -->
<property name="product.themes.dir" location="./themes" />
<available property="product.themes.exist" file="${product.themes.dir}" />
<!-- Is there a modifications directory in the product? -->
<property name="product.modifications.dir" location="./modifications" />
<available property="product.modifications.exist" file="${product.modifications.dir}" />
<!-- - - - - - - - - - - - - - - - - -
paths: for compiling and running
- - - - - - - - - - - - - - - - - -->
<path id="compile.classpath">
<fileset dir="${war-lib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${servletjars.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.compile.classpath">
<available property="product.modifications.exist" file="${product.modifications.dir}" />
<!-- - - - - - - - - - - - - - - - - -
paths: for compiling and running
- - - - - - - - - - - - - - - - - -->
<path id="compile.classpath">
<fileset dir="${war-lib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${servletjars.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.compile.classpath">
<pathelement location="${product.test.dir}"/>
<pathelement location="${war-classes.dir}" />
<path refid="compile.classpath" />
</path>
<path id="test.run.classpath">
<pathelement location="${test-classes.dir}" />
<path refid="test.compile.classpath" />
</path>
<!-- =================================
target: describe
================================= -->
<target name="describe" description="--> Describe the targets (this is the default).">
<innercall target="describe" />
</target>
<!-- =================================
target: all
================================= -->
<target name="all" depends="clean, deploy" description="--> Run 'clean', then 'deploy'" />
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> Delete all artifacts.">
<innercall target="clean" />
</target>
<pathelement location="${war-classes.dir}" />
<path refid="compile.classpath" />
</path>
<path id="test.run.classpath">
<pathelement location="${test-classes.dir}" />
<path refid="test.compile.classpath" />
</path>
<!-- =================================
target: describe
================================= -->
<target name="describe" description="--> Describe the targets (this is the default).">
<innercall target="describe" />
</target>
<!-- =================================
target: all
================================= -->
<target name="all" depends="clean, deploy" description="--> Run 'clean', then 'deploy'" />
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> Delete all artifacts.">
<innercall target="clean" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: productPrepare
- - - - - - - - - - - - - - - - - -->
<target name="productPrepare">
<antcall target="prepareThemes" />
<antcall target="prepareModifications" />
<antcall target="prepareThemes" />
<antcall target="prepareModifications" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: prepareThemes
- - - - - - - - - - - - - - - - - -->
<target name="prepareThemes" if="product.themes.exist">
<copy todir="${build.dir}/war/themes" overwrite="true">
<fileset dir="${product.themes.dir}" />
</copy>
<copy todir="${build.dir}/war/themes" overwrite="true">
<fileset dir="${product.themes.dir}" />
</copy>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: prepareModifications
- - - - - - - - - - - - - - - - - -->
<target name="prepareModifications" if="product.modifications.exist">
<copy todir="${build.dir}/war" overwrite="true">
<fileset dir="${product.modifications.dir}" />
</copy>
<copy todir="${build.dir}/war" overwrite="true">
<fileset dir="${product.modifications.dir}" />
</copy>
</target>
<!-- =================================
target: compile
================================= -->
<target name="compile" description="--> Compile Java sources.">
<innercall target="compile" />
<antcall target="productCompile" />
</target>
<!-- =================================
target: compile
================================= -->
<target name="compile" description="--> Compile Java sources.">
<innercall target="compile" />
<antcall target="productCompile" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: productCompile
- - - - - - - - - - - - - - - - - -->
<target name="productCompile" depends="productPrepare" if="product.sources.exist">
<property name="product.classes.dir" value="${build.dir}/${ant.project.name}/classes" />
<mkdir dir="${product.classes.dir}" />
<javac srcdir="${product.source.dir}"
destdir="${product.classes.dir}"
debug="true"
deprecation="${javac.deprecation}"
encoding="UTF8"
includeantruntime="false"
optimize="true"
source="1.6">
<classpath>
<path refid="compile.classpath" />
<pathelement location="${build.dir}/war/WEB-INF/classes"/>
</classpath>
</javac>
<copy todir="${build.dir}/war/WEB-INF/classes" overwrite="true">
<fileset dir="${product.classes.dir}" />
</copy>
</target>
<!-- =================================
target: test
================================= -->
<target name="test" description="--> Run JUnit tests">
<innercall target="test" />
<antcall target="productTest" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: productTest
- - - - - - - - - - - - - - - - - -->
<target name="productTest" depends="productCompile" if="product.tests.exist" unless="skiptests">
<javac srcdir="${product.test.dir}"
destdir="${test-classes.dir}"
debug="true"
deprecation="true"
encoding="UTF8"
includeantruntime="false"
optimize="false"
source="1.6">
<classpath refid="test.compile.classpath" />
</javac>
<java classname="edu.cornell.mannlib.vitro.testing.VitroTestRunner"
fork="yes"
failonerror="true">
<classpath refid="test.run.classpath" />
<arg file="${product.test.dir}" />
<arg value="${testlevel}" />
</java>
</target>
<target name="productCompile" depends="productPrepare" if="product.sources.exist">
<property name="product.classes.dir" value="${build.dir}/${ant.project.name}/classes" />
<mkdir dir="${product.classes.dir}" />
<javac srcdir="${product.source.dir}"
destdir="${product.classes.dir}"
debug="true"
deprecation="${javac.deprecation}"
encoding="UTF8"
includeantruntime="false"
optimize="true"
source="1.6">
<classpath>
<path refid="compile.classpath" />
<pathelement location="${build.dir}/war/WEB-INF/classes"/>
</classpath>
</javac>
<copy todir="${build.dir}/war/WEB-INF/classes" overwrite="true">
<fileset dir="${product.classes.dir}" />
</copy>
</target>
<!-- =================================
target: test
================================= -->
<target name="test" description="--> Run JUnit tests">
<innercall target="test" />
<antcall target="productTest" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: productTest
- - - - - - - - - - - - - - - - - -->
<target name="productTest" depends="productCompile" if="product.tests.exist" unless="skiptests">
<javac srcdir="${product.test.dir}"
destdir="${test-classes.dir}"
debug="true"
deprecation="true"
encoding="UTF8"
includeantruntime="false"
optimize="false"
source="1.6">
<classpath refid="test.compile.classpath" />
</javac>
<java classname="edu.cornell.mannlib.vitro.testing.VitroTestRunner"
fork="yes"
failonerror="true">
<classpath refid="test.run.classpath" />
<arg file="${product.test.dir}" />
<arg value="${testlevel}" />
</java>
</target>
<!-- =================================
target: revisionInfo
================================= -->
<target name="revisionInfo" description="--> Store revision info in build">
<innercall target="revisionInfo" />
<innercall target="revisionInfo" />
<antcall target="productRevisionInfo" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: productRevisionInfo
- - - - - - - - - - - - - - - - - -->
<target name="productRevisionInfo" depends="productTest" unless="skipinfo">
<property name="revisionInfo.product.dir" location="${ant.file}/.." />
<property name="revisionInfo.build.file" location="${war-resources.dir}/revisionInfo.txt" />
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
fork="no"
failonerror="true">
<classpath refid="test.run.classpath" />
<arg value="${ant.project.name}" />
<arg file="${revisionInfo.product.dir}" />
<arg file="${revisionInfo.build.file}" />
</java>
<property name="revisionInfo.product.dir" location="${ant.file}/.." />
<property name="revisionInfo.build.file" location="${war-resources.dir}/revisionInfo.txt" />
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
fork="no"
failonerror="true">
<classpath refid="test.run.classpath" />
<arg value="${ant.project.name}" />
<arg file="${revisionInfo.product.dir}" />
<arg file="${revisionInfo.build.file}" />
</java>
</target>
<!-- =================================
target: deploy
================================= -->
<target name="deploy" description="--> Build the app and install in Tomcat">
<!-- the inner "deploy" would just do a sync that will be done by productDeploy -->
<innercall target="revisionInfo" />
<innercall target="deploySolr" />
<antcall target="productDeploy" />
</target>
<!-- =================================
target: deploy
================================= -->
<target name="deploy" description="--> Build the app and install in Tomcat">
<!-- the inner "deploy" would just do a sync that will be done by productDeploy -->
<innercall target="revisionInfo" />
<innercall target="deploySolr" />
<antcall target="productDeploy" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: productDeploy
- - - - - - - - - - - - - - - - - -->
<target name="productDeploy" depends="productRevisionInfo">
<property name="webapp.deploy.home" value="${tomcat.home}/webapps/${webapp.name}" />
<mkdir dir="${webapp.deploy.home}" />
<sync todir="${webapp.deploy.home}" includeemptydirs="true">
<fileset dir="${build.dir}/war" />
</sync>
<target name="productDeploy" depends="productRevisionInfo">
<property name="webapp.deploy.home" value="${tomcat.home}/webapps/${webapp.name}" />
<mkdir dir="${webapp.deploy.home}" />
<sync todir="${webapp.deploy.home}" includeemptydirs="true">
<fileset dir="${build.dir}/war" />
</sync>
</target>
<!-- =================================
target: war
================================= -->
<target name="war" description="--> Build the app and create a WAR file">
<innercall target="revisionInfo" />
<antcall target="productWar" />
</target>
<!-- =================================
target: war
================================= -->
<target name="war" description="--> Build the app and create a WAR file">
<innercall target="revisionInfo" />
<antcall target="productWar" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: productWar
- - - - - - - - - - - - - - - - - -->
<target name="productWar" depends="productRevisionInfo">
<jar basedir="${build.dir}/war" destfile="${build.dir}/${webapp.name}.war"/>
<jar basedir="${build.dir}/war" destfile="${build.dir}/${webapp.name}.war"/>
</target>
<!-- =================================
target: licenser
In regular use, checks that all appropriate source files have license tags.
At release time, applies license text to source files.
NOTE: don't override licenser.properties.file from the command line.
Instead, override licenser.core.properties.file and licenser.product.properties.file
================================= -->
<target name="licenser" description="--> Check source files for licensing tags">
<!-- Once for the product... -->
<innercall target="licenser">
<property name="licenser.properties.file" value="${licenser.product.properties.file}" />
<property name="licenser.label" value="${ant.project.name}" />
</innercall>
<!-- ...and once for the core. -->
<condition property="licenser.properties.file" value="${licenser.core.properties.file}">
<isset property="licenser.core.properties.file" />
</condition>
<innercall target="licenser">
<propertyset>
<propertyref name="licenser.properties.file" />
</propertyset>
</innercall>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MACROS
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!--
Call a target in the inner script.
-->
<macrodef name="innercall">
<attribute name="target" />
<element name="additionalProperties" implicit="yes" optional="true" />
<sequential>
<ant dir="${inner.basedir}" inheritall="false">
<!-- pass the properties that are needed. -->
<propertyset>
<propertyref name="build.dir" />
<propertyref name="skip.core.themes" />
<propertyref name="deploy.properties.file" />
</propertyset>
<additionalProperties />
<target name="@{target}" />
</ant>
</sequential>
</macrodef>
</project>
<!-- =================================
target: jar
================================= -->
<target name="jar" depends="revisionInfo" description="--> Build the app and create a JAR file">
<jar basedir="${build.dir}/war/WEB-INF/classes" destfile="${build.dir}/${webapp.name}.jar" />
</target>
<!-- =================================
target: licenser
In regular use, checks that all appropriate source files have license tags.
At release time, applies license text to source files.
NOTE: don't override licenser.properties.file from the command line.
Instead, override licenser.core.properties.file and licenser.product.properties.file
================================= -->
<target name="licenser" description="--> Check source files for licensing tags">
<!-- Once for the product... -->
<innercall target="licenser">
<property name="licenser.properties.file" value="${licenser.product.properties.file}" />
<property name="licenser.label" value="${ant.project.name}" />
</innercall>
<!-- ...and once for the core. -->
<condition property="licenser.properties.file" value="${licenser.core.properties.file}">
<isset property="licenser.core.properties.file" />
</condition>
<innercall target="licenser">
<propertyset>
<propertyref name="licenser.properties.file" />
</propertyset>
</innercall>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MACROS
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!--
Call a target in the inner script.
-->
<macrodef name="innercall">
<attribute name="target" />
<element name="additionalProperties" implicit="yes" optional="true" />
<sequential>
<ant dir="${inner.basedir}" inheritall="false">
<!-- pass the properties that are needed. -->
<propertyset>
<propertyref name="build.dir" />
<propertyref name="skip.core.themes" />
<propertyref name="deploy.properties.file" />
</propertyset>
<additionalProperties />
<target name="@{target}" />
</ant>
</sequential>
</macrodef>
</project>

View file

@ -34,15 +34,15 @@ public class IndividualToSolrDocument {
public static VitroSearchTermNames term = new VitroSearchTermNames();
private static String entClassName = Individual.class.getName();
protected static String entClassName = Individual.class.getName();
private ClassProhibitedFromSearch classesProhibitedFromSearch;
protected ClassProhibitedFromSearch classesProhibitedFromSearch;
private IndividualProhibitedFromSearch individualProhibitedFromSearch;
protected IndividualProhibitedFromSearch individualProhibitedFromSearch;
private final String label = "http://www.w3.org/2000/01/rdf-schema#label";
protected final String label = "http://www.w3.org/2000/01/rdf-schema#label";
public List<DocumentModifier> documentModifiers = new ArrayList<DocumentModifier>();
protected List<DocumentModifier> documentModifiers = new ArrayList<DocumentModifier>();
public IndividualToSolrDocument(
ClassProhibitedFromSearch classesProhibitedFromSearch,
@ -130,7 +130,7 @@ public class IndividualToSolrDocument {
}
private void runAdditionalDocModifers( Individual ind, SolrInputDocument doc, StringBuffer addUri )
protected void runAdditionalDocModifers( Individual ind, SolrInputDocument doc, StringBuffer addUri )
throws SkipIndividualException{
//run the document modifiers
if( documentModifiers != null && !documentModifiers.isEmpty()){
@ -140,7 +140,7 @@ public class IndividualToSolrDocument {
}
}
private void checkForSkipBasedOnNS(Individual ind) throws SkipIndividualException {
protected void checkForSkipBasedOnNS(Individual ind) throws SkipIndividualException {
String id = ind.getURI();
if(id == null){
throw new SkipIndividualException("cannot add individuals without URIs to search index");
@ -152,7 +152,7 @@ public class IndividualToSolrDocument {
}
}
private void addAllText(Individual ind, SolrInputDocument doc, StringBuffer classPublicNames, StringBuffer objectNames) {
protected void addAllText(Individual ind, SolrInputDocument doc, StringBuffer classPublicNames, StringBuffer objectNames) {
String t=null;
//ALLTEXT, all of the 'full text'
StringBuffer allTextValue = new StringBuffer();
@ -191,7 +191,7 @@ public class IndividualToSolrDocument {
doc.addField(term.ALLTEXT_PHONETIC, alltext);
}
private void addLabel(Individual ind, SolrInputDocument doc) {
protected void addLabel(Individual ind, SolrInputDocument doc) {
String value = "";
String label = ind.getRdfsLabel();
if (label != null) {
@ -211,7 +211,7 @@ public class IndividualToSolrDocument {
/**
* Adds if the individual has a thumbnail image or not.
*/
private void addThumbnailExistance(Individual ind, SolrInputDocument doc) {
protected void addThumbnailExistance(Individual ind, SolrInputDocument doc) {
try{
if(ind.hasThumb())
doc.addField(term.THUMBNAIL, "1");
@ -226,7 +226,7 @@ public class IndividualToSolrDocument {
* Get the rdfs:labes for objects of statements and put in objectNames.
* Get the URIs for objects of statements and put in addUri.
*/
private void addObjectPropertyText(Individual ind, SolrInputDocument doc,
protected void addObjectPropertyText(Individual ind, SolrInputDocument doc,
StringBuffer objectNames, StringBuffer addUri) {
List<ObjectPropertyStatement> objectPropertyStatements = ind.getObjectPropertyStatements();
if (objectPropertyStatements != null) {