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" /> <jar basedir="${build.dir}/war" destfile="${build.dir}/${webapp.name}.war" />
</target> </target>
<!-- ================================= <!-- =================================
target: licenser target: licenser

View file

@ -1,305 +1,312 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ --> <!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!-- ====================================================================== <!-- ======================================================================
Build script for the Vivo Products. Build script for the Vivo Products.
jeb228 jeb228
====================================================================== --> ======================================================================-->
<project name="vivoProduct" default="describe"> <project name="vivoProduct" default="describe">
<!-- <!--
This script should not be run on its own. This script should not be run on its own.
It should only be run from the build script of an individual Product. It should only be run from the build script of an individual Product.
--> -->
<fail> <fail>
<condition> <condition>
<equals arg1="${ant.file.vivoProduct}" arg2="${ant.file}" /> <equals arg1="${ant.file.vivoProduct}" arg2="${ant.file}" />
</condition> </condition>
This script should not be run by itself. This script should not be run by itself.
It should be invoked from the build script of a Vivo product. It should be invoked from the build script of a Vivo product.
</fail> </fail>
<fail unless="inner.basedir" <fail unless="inner.basedir"
message="The build script for the product must define a value for inner.basedir" /> message="The build script for the product must define a value for inner.basedir" />
<!-- <!--
The build directory goes in the product directory. The build directory goes in the product directory.
Everything else hangs from the build directory. Everything else hangs from the build directory.
--> -->
<property name="build.dir" location="./.build" /> <property name="build.dir" location="./.build" />
<property name="war.dir" location="${build.dir}/war" /> <property name="war.dir" location="${build.dir}/war" />
<property name="war-webinf.dir" location="${war.dir}/WEB-INF" /> <property name="war-webinf.dir" location="${war.dir}/WEB-INF" />
<property name="war-classes.dir" location="${war-webinf.dir}/classes" /> <property name="war-classes.dir" location="${war-webinf.dir}/classes" />
<property name="war-resources.dir" location="${war-webinf.dir}/resources" /> <property name="war-resources.dir" location="${war-webinf.dir}/resources" />
<property name="war-lib.dir" location="${war-webinf.dir}/lib" /> <property name="war-lib.dir" location="${war-webinf.dir}/lib" />
<property name="test-classes.dir" location="${build.dir}/testclasses" /> <property name="test-classes.dir" location="${build.dir}/testclasses" />
<property name="servletjars.dir" location="${build.dir}/servletjars" /> <property name="servletjars.dir" location="${build.dir}/servletjars" />
<property name="javac.deprecation" value="true" /> <property name="javac.deprecation" value="true" />
<!-- Is there a "src" directory in the product? --> <!-- Is there a "src" directory in the product? -->
<property name="product.source.dir" location="./src" /> <property name="product.source.dir" location="./src" />
<available property="product.sources.exist" file="${product.source.dir}" /> <available property="product.sources.exist" file="${product.source.dir}" />
<!-- Is there a "test" directory in the product? --> <!-- Is there a "test" directory in the product? -->
<property name="product.test.dir" location="./test" /> <property name="product.test.dir" location="./test" />
<available property="product.tests.exist" file="${product.test.dir}" /> <available property="product.tests.exist" file="${product.test.dir}" />
<!-- Is there a "themes" directory in the product? --> <!-- Is there a "themes" directory in the product? -->
<property name="product.themes.dir" location="./themes" /> <property name="product.themes.dir" location="./themes" />
<available property="product.themes.exist" file="${product.themes.dir}" /> <available property="product.themes.exist" file="${product.themes.dir}" />
<!-- Is there a modifications directory in the product? --> <!-- Is there a modifications directory in the product? -->
<property name="product.modifications.dir" location="./modifications" /> <property name="product.modifications.dir" location="./modifications" />
<available property="product.modifications.exist" file="${product.modifications.dir}" /> <available property="product.modifications.exist" file="${product.modifications.dir}" />
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
paths: for compiling and running paths: for compiling and running
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<path id="compile.classpath"> <path id="compile.classpath">
<fileset dir="${war-lib.dir}"> <fileset dir="${war-lib.dir}">
<include name="**/*.jar" /> <include name="**/*.jar" />
</fileset> </fileset>
<fileset dir="${servletjars.dir}"> <fileset dir="${servletjars.dir}">
<include name="**/*.jar" /> <include name="**/*.jar" />
</fileset> </fileset>
</path> </path>
<path id="test.compile.classpath"> <path id="test.compile.classpath">
<pathelement location="${product.test.dir}"/> <pathelement location="${product.test.dir}"/>
<pathelement location="${war-classes.dir}" /> <pathelement location="${war-classes.dir}" />
<path refid="compile.classpath" /> <path refid="compile.classpath" />
</path> </path>
<path id="test.run.classpath"> <path id="test.run.classpath">
<pathelement location="${test-classes.dir}" /> <pathelement location="${test-classes.dir}" />
<path refid="test.compile.classpath" /> <path refid="test.compile.classpath" />
</path> </path>
<!-- ================================= <!-- =================================
target: describe target: describe
================================= --> ================================= -->
<target name="describe" description="--> Describe the targets (this is the default)."> <target name="describe" description="--> Describe the targets (this is the default).">
<innercall target="describe" /> <innercall target="describe" />
</target> </target>
<!-- ================================= <!-- =================================
target: all target: all
================================= --> ================================= -->
<target name="all" depends="clean, deploy" description="--> Run 'clean', then 'deploy'" /> <target name="all" depends="clean, deploy" description="--> Run 'clean', then 'deploy'" />
<!-- ================================= <!-- =================================
target: clean target: clean
================================= --> ================================= -->
<target name="clean" description="--> Delete all artifacts."> <target name="clean" description="--> Delete all artifacts.">
<innercall target="clean" /> <innercall target="clean" />
</target> </target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: productPrepare target: productPrepare
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="productPrepare"> <target name="productPrepare">
<antcall target="prepareThemes" /> <antcall target="prepareThemes" />
<antcall target="prepareModifications" /> <antcall target="prepareModifications" />
</target> </target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: prepareThemes target: prepareThemes
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="prepareThemes" if="product.themes.exist"> <target name="prepareThemes" if="product.themes.exist">
<copy todir="${build.dir}/war/themes" overwrite="true"> <copy todir="${build.dir}/war/themes" overwrite="true">
<fileset dir="${product.themes.dir}" /> <fileset dir="${product.themes.dir}" />
</copy> </copy>
</target> </target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: prepareModifications target: prepareModifications
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="prepareModifications" if="product.modifications.exist"> <target name="prepareModifications" if="product.modifications.exist">
<copy todir="${build.dir}/war" overwrite="true"> <copy todir="${build.dir}/war" overwrite="true">
<fileset dir="${product.modifications.dir}" /> <fileset dir="${product.modifications.dir}" />
</copy> </copy>
</target>
<!-- =================================
target: compile
================================= -->
<target name="compile" description="--> Compile Java sources.">
<innercall target="compile" />
<antcall target="productCompile" />
</target> </target>
<!-- =================================
target: compile
================================= -->
<target name="compile" description="--> Compile Java sources.">
<innercall target="compile" />
<antcall target="productCompile" />
</target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: productCompile target: productCompile
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="productCompile" depends="productPrepare" if="product.sources.exist"> <target name="productCompile" depends="productPrepare" if="product.sources.exist">
<property name="product.classes.dir" value="${build.dir}/${ant.project.name}/classes" /> <property name="product.classes.dir" value="${build.dir}/${ant.project.name}/classes" />
<mkdir dir="${product.classes.dir}" /> <mkdir dir="${product.classes.dir}" />
<javac srcdir="${product.source.dir}" <javac srcdir="${product.source.dir}"
destdir="${product.classes.dir}" destdir="${product.classes.dir}"
debug="true" debug="true"
deprecation="${javac.deprecation}" deprecation="${javac.deprecation}"
encoding="UTF8" encoding="UTF8"
includeantruntime="false" includeantruntime="false"
optimize="true" optimize="true"
source="1.6"> source="1.6">
<classpath> <classpath>
<path refid="compile.classpath" /> <path refid="compile.classpath" />
<pathelement location="${build.dir}/war/WEB-INF/classes"/> <pathelement location="${build.dir}/war/WEB-INF/classes"/>
</classpath> </classpath>
</javac> </javac>
<copy todir="${build.dir}/war/WEB-INF/classes" overwrite="true"> <copy todir="${build.dir}/war/WEB-INF/classes" overwrite="true">
<fileset dir="${product.classes.dir}" /> <fileset dir="${product.classes.dir}" />
</copy> </copy>
</target> </target>
<!-- ================================= <!-- =================================
target: test target: test
================================= --> ================================= -->
<target name="test" description="--> Run JUnit tests"> <target name="test" description="--> Run JUnit tests">
<innercall target="test" /> <innercall target="test" />
<antcall target="productTest" /> <antcall target="productTest" />
</target> </target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: productTest target: productTest
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="productTest" depends="productCompile" if="product.tests.exist" unless="skiptests"> <target name="productTest" depends="productCompile" if="product.tests.exist" unless="skiptests">
<javac srcdir="${product.test.dir}" <javac srcdir="${product.test.dir}"
destdir="${test-classes.dir}" destdir="${test-classes.dir}"
debug="true" debug="true"
deprecation="true" deprecation="true"
encoding="UTF8" encoding="UTF8"
includeantruntime="false" includeantruntime="false"
optimize="false" optimize="false"
source="1.6"> source="1.6">
<classpath refid="test.compile.classpath" /> <classpath refid="test.compile.classpath" />
</javac> </javac>
<java classname="edu.cornell.mannlib.vitro.testing.VitroTestRunner" <java classname="edu.cornell.mannlib.vitro.testing.VitroTestRunner"
fork="yes" fork="yes"
failonerror="true"> failonerror="true">
<classpath refid="test.run.classpath" /> <classpath refid="test.run.classpath" />
<arg file="${product.test.dir}" /> <arg file="${product.test.dir}" />
<arg value="${testlevel}" /> <arg value="${testlevel}" />
</java> </java>
</target> </target>
<!-- ================================= <!-- =================================
target: revisionInfo target: revisionInfo
================================= --> ================================= -->
<target name="revisionInfo" description="--> Store revision info in build"> <target name="revisionInfo" description="--> Store revision info in build">
<innercall target="revisionInfo" /> <innercall target="revisionInfo" />
<antcall target="productRevisionInfo" /> <antcall target="productRevisionInfo" />
</target> </target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: productRevisionInfo target: productRevisionInfo
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="productRevisionInfo" depends="productTest" unless="skipinfo"> <target name="productRevisionInfo" depends="productTest" unless="skipinfo">
<property name="revisionInfo.product.dir" location="${ant.file}/.." /> <property name="revisionInfo.product.dir" location="${ant.file}/.." />
<property name="revisionInfo.build.file" location="${war-resources.dir}/revisionInfo.txt" /> <property name="revisionInfo.build.file" location="${war-resources.dir}/revisionInfo.txt" />
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder" <java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
fork="no" fork="no"
failonerror="true"> failonerror="true">
<classpath refid="test.run.classpath" /> <classpath refid="test.run.classpath" />
<arg value="${ant.project.name}" /> <arg value="${ant.project.name}" />
<arg file="${revisionInfo.product.dir}" /> <arg file="${revisionInfo.product.dir}" />
<arg file="${revisionInfo.build.file}" /> <arg file="${revisionInfo.build.file}" />
</java> </java>
</target> </target>
<!-- ================================= <!-- =================================
target: deploy target: deploy
================================= --> ================================= -->
<target name="deploy" description="--> Build the app and install in Tomcat"> <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 --> <!-- the inner "deploy" would just do a sync that will be done by productDeploy -->
<innercall target="revisionInfo" /> <innercall target="revisionInfo" />
<innercall target="deploySolr" /> <innercall target="deploySolr" />
<antcall target="productDeploy" /> <antcall target="productDeploy" />
</target> </target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: productDeploy target: productDeploy
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="productDeploy" depends="productRevisionInfo"> <target name="productDeploy" depends="productRevisionInfo">
<property name="webapp.deploy.home" value="${tomcat.home}/webapps/${webapp.name}" /> <property name="webapp.deploy.home" value="${tomcat.home}/webapps/${webapp.name}" />
<mkdir dir="${webapp.deploy.home}" /> <mkdir dir="${webapp.deploy.home}" />
<sync todir="${webapp.deploy.home}" includeemptydirs="true"> <sync todir="${webapp.deploy.home}" includeemptydirs="true">
<fileset dir="${build.dir}/war" /> <fileset dir="${build.dir}/war" />
</sync> </sync>
</target> </target>
<!-- ================================= <!-- =================================
target: war target: war
================================= --> ================================= -->
<target name="war" description="--> Build the app and create a WAR file"> <target name="war" description="--> Build the app and create a WAR file">
<innercall target="revisionInfo" /> <innercall target="revisionInfo" />
<antcall target="productWar" /> <antcall target="productWar" />
</target> </target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: productWar target: productWar
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="productWar" depends="productRevisionInfo"> <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>
<!-- ================================= <!-- =================================
target: licenser target: jar
================================= -->
In regular use, checks that all appropriate source files have license tags. <target name="jar" depends="revisionInfo" description="--> Build the app and create a JAR file">
At release time, applies license text to source files. <jar basedir="${build.dir}/war/WEB-INF/classes" destfile="${build.dir}/${webapp.name}.jar" />
</target>
NOTE: don't override licenser.properties.file from the command line.
Instead, override licenser.core.properties.file and licenser.product.properties.file <!-- =================================
================================= --> target: licenser
<target name="licenser" description="--> Check source files for licensing tags">
<!-- Once for the product... --> In regular use, checks that all appropriate source files have license tags.
<innercall target="licenser"> At release time, applies license text to source files.
<property name="licenser.properties.file" value="${licenser.product.properties.file}" />
<property name="licenser.label" value="${ant.project.name}" /> NOTE: don't override licenser.properties.file from the command line.
</innercall> Instead, override licenser.core.properties.file and licenser.product.properties.file
================================= -->
<!-- ...and once for the core. --> <target name="licenser" description="--> Check source files for licensing tags">
<condition property="licenser.properties.file" value="${licenser.core.properties.file}"> <!-- Once for the product... -->
<isset property="licenser.core.properties.file" /> <innercall target="licenser">
</condition> <property name="licenser.properties.file" value="${licenser.product.properties.file}" />
<innercall target="licenser"> <property name="licenser.label" value="${ant.project.name}" />
<propertyset> </innercall>
<propertyref name="licenser.properties.file" />
</propertyset> <!-- ...and once for the core. -->
</innercall> <condition property="licenser.properties.file" value="${licenser.core.properties.file}">
</target> <isset property="licenser.core.properties.file" />
</condition>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <innercall target="licenser">
MACROS <propertyset>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <propertyref name="licenser.properties.file" />
</propertyset>
<!-- </innercall>
Call a target in the inner script. </target>
-->
<macrodef name="innercall"> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<attribute name="target" /> MACROS
<element name="additionalProperties" implicit="yes" optional="true" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<sequential>
<ant dir="${inner.basedir}" inheritall="false"> <!--
<!-- pass the properties that are needed. --> Call a target in the inner script.
<propertyset> -->
<propertyref name="build.dir" /> <macrodef name="innercall">
<propertyref name="skip.core.themes" /> <attribute name="target" />
<propertyref name="deploy.properties.file" /> <element name="additionalProperties" implicit="yes" optional="true" />
</propertyset> <sequential>
<additionalProperties /> <ant dir="${inner.basedir}" inheritall="false">
<target name="@{target}" /> <!-- pass the properties that are needed. -->
</ant> <propertyset>
</sequential> <propertyref name="build.dir" />
</macrodef> <propertyref name="skip.core.themes" />
</project> <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(); 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( public IndividualToSolrDocument(
ClassProhibitedFromSearch classesProhibitedFromSearch, 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{ throws SkipIndividualException{
//run the document modifiers //run the document modifiers
if( documentModifiers != null && !documentModifiers.isEmpty()){ 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(); String id = ind.getURI();
if(id == null){ if(id == null){
throw new SkipIndividualException("cannot add individuals without URIs to search index"); 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; String t=null;
//ALLTEXT, all of the 'full text' //ALLTEXT, all of the 'full text'
StringBuffer allTextValue = new StringBuffer(); StringBuffer allTextValue = new StringBuffer();
@ -191,7 +191,7 @@ public class IndividualToSolrDocument {
doc.addField(term.ALLTEXT_PHONETIC, alltext); doc.addField(term.ALLTEXT_PHONETIC, alltext);
} }
private void addLabel(Individual ind, SolrInputDocument doc) { protected void addLabel(Individual ind, SolrInputDocument doc) {
String value = ""; String value = "";
String label = ind.getRdfsLabel(); String label = ind.getRdfsLabel();
if (label != null) { if (label != null) {
@ -211,7 +211,7 @@ public class IndividualToSolrDocument {
/** /**
* Adds if the individual has a thumbnail image or not. * 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{ try{
if(ind.hasThumb()) if(ind.hasThumb())
doc.addField(term.THUMBNAIL, "1"); 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 rdfs:labes for objects of statements and put in objectNames.
* Get the URIs for objects of statements and put in addUri. * 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) { StringBuffer objectNames, StringBuffer addUri) {
List<ObjectPropertyStatement> objectPropertyStatements = ind.getObjectPropertyStatements(); List<ObjectPropertyStatement> objectPropertyStatements = ind.getObjectPropertyStatements();
if (objectPropertyStatements != null) { if (objectPropertyStatements != null) {