diff --git a/build.xml b/build.xml index 9c22fa3f..3245b7b4 100644 --- a/build.xml +++ b/build.xml @@ -75,6 +75,7 @@ + diff --git a/config/applicationSetup.n3 b/config/applicationSetup.n3 new file mode 100644 index 00000000..8f7ccf8e --- /dev/null +++ b/config/applicationSetup.n3 @@ -0,0 +1,35 @@ +@prefix : . + +:application + a , + ; + :hasSearchEngine :searchEngineWrapper ; + :hasImageProcessor :imageProcessor ; + :hasFileStorage :fileStorage ; + :hasContentTripleSource :contentTripleSource ; + :hasConfigurationTripleSource :configurationTripleSource . + +:imageProcessor + a , + . + +:fileStorage + a , + . + +:searchEngineWrapper + a , + ; + :wraps :searchEngine . + +:searchEngine + a , + . + +:contentTripleSource + a , + . + +:configurationTripleSource + a , + . \ No newline at end of file diff --git a/doc/README.txt b/doc/README.txt index 93084c2c..0486acaa 100644 --- a/doc/README.txt +++ b/doc/README.txt @@ -8,9 +8,9 @@ find these files in this directory: Instructions for installing VIVO on your machine, including a simple installation and several options. - Upgrade Instructions for VIVO release 1.7.pdf + Upgrade Instructions for VIVO release 1.8.pdf Instructions for migrating a VIVO installation from release - 1.6 to release 1.7 + 1.7 to release 1.8 If these files are not present, or to obtain the latest version of the instructions, go to: diff --git a/productMods/WEB-INF/resources/startup_listeners.txt b/productMods/WEB-INF/resources/startup_listeners.txt index 2871e488..9514f2bf 100644 --- a/productMods/WEB-INF/resources/startup_listeners.txt +++ b/productMods/WEB-INF/resources/startup_listeners.txt @@ -7,6 +7,8 @@ edu.cornell.mannlib.vitro.webapp.servlet.setup.JvmSmokeTests +edu.cornell.mannlib.vitro.webapp.application.ApplicationSetup + edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesSetup edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesSmokeTests @@ -16,15 +18,12 @@ edu.cornell.mannlib.vitro.webapp.servlet.setup.GuardAgainstUnmigratedRDB edu.cornell.mannlib.vitro.webapp.utils.developer.DeveloperSettings$Setup -edu.cornell.mannlib.vitro.webapp.application.ApplicationImpl$Setup +edu.cornell.mannlib.vitro.webapp.application.ApplicationImpl$ComponentsSetup edu.cornell.mannlib.vitro.webapp.config.RevisionInfoSetup edu.cornell.mannlib.vitro.webapp.email.FreemarkerEmailFactory$Setup -# In 1.8, this should replace JenaPersistentDataSourceSetup, RDFServiceSetup, and maybe more. -edu.cornell.mannlib.vitro.webapp.servlet.setup.rdfsetup.RDFSetup - edu.cornell.mannlib.vitro.webapp.servlet.setup.ConfigurationModelsSetup edu.cornell.mannlib.vitro.webapp.servlet.setup.ContentModelSetup @@ -64,9 +63,6 @@ edu.ucsf.vitro.opensocial.OpenSocialSmokeTests # For multiple language support edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionSetup -# Add VIVO specific DocumentModifers, this must come before SearchIndexerSetup -edu.cornell.mannlib.vitro.webapp.search.documentBuilding.VivoDocumentModifiers - # The search indexer uses a "public" permission, so the PropertyRestrictionPolicyHelper # and the PermissionRegistry must already be set up. edu.cornell.mannlib.vitro.webapp.searchindex.SearchIndexerSetup diff --git a/productMods/templates/freemarker/edit/forms/addEditorRoleToPerson.ftl b/productMods/templates/freemarker/edit/forms/addEditorRoleToPerson.ftl index e0e97118..4e5a2e0f 100644 --- a/productMods/templates/freemarker/edit/forms/addEditorRoleToPerson.ftl +++ b/productMods/templates/freemarker/edit/forms/addEditorRoleToPerson.ftl @@ -20,7 +20,7 @@ roleExamples--> <#--Variable assignments for Add Clinical Role To Person--> <#assign roleDescriptor = "${i18n().collection_series_editor_role}" /> <#assign typeSelectorLabel = "${i18n().editor_role_in}" /> -<#assign genericLabel = "Collection" /> +<#assign genericLabel = "Collection or Series" /> <#assign acTypes = "{activity: 'http://purl.org/ontology/bibo/Collection'}" /> diff --git a/productMods/templates/freemarker/edit/forms/addUserDefinedConcept.ftl b/productMods/templates/freemarker/edit/forms/addUserDefinedConcept.ftl index 5956d3eb..4eb91608 100644 --- a/productMods/templates/freemarker/edit/forms/addUserDefinedConcept.ftl +++ b/productMods/templates/freemarker/edit/forms/addUserDefinedConcept.ftl @@ -53,7 +53,8 @@ editMode: 'add', typeName: 'Concept', defaultTypeName: 'concept', // used in repair mode to generate button text - baseHref: '${urls.base}/individual?uri=' + baseHref: '${urls.base}/individual?uri=', + limitToConceptClasses:["http://www.w3.org/2004/02/skos/core#Concept"] }; var i18nStrings = { selectAnExisting: '${i18n().select_an_existing}', diff --git a/productMods/templates/freemarker/edit/forms/js/addAuthorsToInformationResource.js b/productMods/templates/freemarker/edit/forms/js/addAuthorsToInformationResource.js index 7c2ab7c8..922f1bd8 100644 --- a/productMods/templates/freemarker/edit/forms/js/addAuthorsToInformationResource.js +++ b/productMods/templates/freemarker/edit/forms/js/addAuthorsToInformationResource.js @@ -113,7 +113,7 @@ var addAuthorForm = { // after hitting 'cancel.' initAuthorListOnlyView: function() { - if ($('.authorship').length) { // make sure we have at least one author + if ($('li.authorship').length) { // make sure we have at least one author // Reorder authors on page load so that previously unranked authors get a rank. Otherwise, // when we add a new author, it will get put ahead of any previously unranked authors, instead // of at the end of the list. (It is also helpful to normalize the data before we get started.) @@ -282,7 +282,7 @@ var addAuthorForm = { setAcFilter: function() { this.acFilter = []; - $('.authorship').each(function() { + $('li.authorship').each(function() { var uri = $(this).data('authorUri'); addAuthorForm.acFilter.push(uri); }); @@ -404,7 +404,7 @@ var addAuthorForm = { type: 'POST', success: function(data, status, request) { var pos; - $('.authorship').each(function(index){ + $('li.authorship').each(function(index){ pos = index + 1; // Set the new position for this element. The only function of this value // is so we can reset an element to its original position in case reordering fails. @@ -440,7 +440,7 @@ var addAuthorForm = { // have to keep retrieving data from or modifying the DOM as we manipulate the // authorships. initAuthorshipData: function() { - $('.authorship').each(function(index) { + $('li.authorship').each(function(index) { $(this).data(authorshipData[index]); // RY We might still need position to put back an element after reordering @@ -462,7 +462,7 @@ var addAuthorForm = { findAuthorship: function(key, value) { var matchingAuthorship = $(); // if we don't find one, return an empty jQuery set - $('.authorship').each(function() { + $('li.authorship').each(function() { var authorship = $(this); if ( authorship.data(key) === value ) { matchingAuthorship = authorship; @@ -644,7 +644,7 @@ var addAuthorForm = { url: $(link).attr('href'), type: 'POST', data: { - deletion: $(link).parents('.authorship').data('authorshipUri') + deletion: $(link).parents('li.authorship').data('authorshipUri') }, dataType: 'json', context: link, // context for callback @@ -654,7 +654,7 @@ var addAuthorForm = { if (status === 'success') { - authorship = $(this).parents('.authorship'); + authorship = $(this).parents('li.authorship'); // Clear autocomplete cache entries matching this author's name, else // autocomplete will be retrieved from the cache, which excludes the removed author. @@ -673,7 +673,7 @@ var addAuthorForm = { $(this).remove(); // Actions that depend on the author having been removed from the DOM: - numAuthors = $('.authorship').length; // retrieve the length after removing authorship from the DOM + numAuthors = $('li.authorship').length; // retrieve the length after removing authorship from the DOM // If removed item not last, reorder to remove any gaps if (numAuthors > 0 && ! removeLast) { diff --git a/rdf/display/everytime/PropertyConfig.n3 b/rdf/display/everytime/PropertyConfig.n3 index 1d408364..0e3e5e32 100644 --- a/rdf/display/everytime/PropertyConfig.n3 +++ b/rdf/display/everytime/PropertyConfig.n3 @@ -953,6 +953,54 @@ local:webpageInfoConfig a :ObjectPropertyDisplayConfig ; vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator"^^ ; :propertyGroup . +local:webpageSoftwareContext a :ConfigContext ; + :hasConfiguration local:webpageSoftwareConfig ; + :configContextFor ; + :qualifiedByDomain ; + :qualifiedByRoot ; + :qualifiedBy . + +local:webpageSoftwareConfig a :ObjectPropertyDisplayConfig ; + :listViewConfigFile "listViewConfig-webpage.xml"^^xsd:string ; + :displayName "webpage" ; + vitro:displayRankAnnot 40; + vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator"^^ ; + :propertyGroup . + +local:webpageFacilityContext a :ConfigContext ; + :hasConfiguration local:webpageFacilityConfig ; + :configContextFor ; + :qualifiedByDomain ; + :qualifiedByRoot ; + :qualifiedBy . + +local:webpageFacilityConfig a :ObjectPropertyDisplayConfig ; + :listViewConfigFile "listViewConfig-webpage.xml"^^xsd:string ; + :displayName "webpage" ; + vitro:displayRankAnnot 40; + vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator"^^ ; + :propertyGroup . + +local:webpageProjectContext a :ConfigContext ; + :hasConfiguration local:webpageProjectConfig ; + :configContextFor ; + :qualifiedByDomain ; + :qualifiedByRoot ; + :qualifiedBy . + +local:webpageProjectConfig a :ObjectPropertyDisplayConfig ; + :listViewConfigFile "listViewConfig-webpage.xml"^^xsd:string ; + :displayName "webpage" ; + vitro:displayRankAnnot 40; + vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator"^^ ; + :propertyGroup . + local:webpageEventContext a :ConfigContext ; :hasConfiguration local:webpageEventConfig ; :configContextFor ; @@ -1746,7 +1794,7 @@ local:bfo_0000055Config a :ObjectPropertyDisplayConfig ; :displayName "participant" ; vitro:displayRankAnnot 17; vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; - vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:nobody ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ProjectHasParticipantGenerator"^^ ; :propertyGroup . diff --git a/rdf/display/everytime/VivoSearchIndexerConfiguration.n3 b/rdf/display/everytime/VivoSearchIndexerConfiguration.n3 new file mode 100644 index 00000000..52c0ada2 --- /dev/null +++ b/rdf/display/everytime/VivoSearchIndexerConfiguration.n3 @@ -0,0 +1,46 @@ +@prefix : . + +# +# Specify the SearchIndexExcluders and DocumentModifiers for VIVO. +# These are in addition to the ones specified for VIVO. +# + +:vivoSearchExcluder_namespaceExcluder + a , + ; + :excludes + "http://purl.obolibrary.org/obo/" . + +# ------------------------------------ + +:vivodocumentModifier_calculateParameters + a , + . + +:vivodocumentModifier_valuesFromVcards + a , + . + +:vivodocumentModifier_ISFBasicFields + a , + . + +:vivodocumentModifier_ISFAdvisingFields + a , + . + +:vivodocumentModifier_ISFEducationFields + a , + . + +:vivodocumentModifier_ISFGrantFields + a , + . + +:vivodocumentModifier_ISFMemberFields + a , + . + +:vivodocumentModifier_informationResourceContextNodeFields + a , + . diff --git a/rdf/tbox/filegraph/vitroPublic.owl b/rdf/tbox/filegraph/vitroPublic.owl deleted file mode 100644 index 75abe76d..00000000 --- a/rdf/tbox/filegraph/vitroPublic.owl +++ /dev/null @@ -1,68 +0,0 @@ - - - -]> - - - - - - - 0.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java b/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java index 548b9c68..aa3cdf00 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java +++ b/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java @@ -34,6 +34,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; @@ -213,13 +214,8 @@ public class FileHarvestController extends FreemarkerHttpServlet { */ private static String getUploadPathBase(ServletContext context) throws Exception { - String vitroHomeDirectoryName = ConfigurationProperties.getBean(context).getProperty(FileStorageImplWrapper.PROPERTY_VITRO_HOME_DIR); - if (vitroHomeDirectoryName == null) { - throw new Exception("Vitro home directory name could not be found."); - } - - String pathBase = vitroHomeDirectoryName + "/" + FileStorageImplWrapper.FILE_STORAGE_SUBDIRECTORY + "/" + PATH_TO_UPLOADS; - return pathBase; + String vitroHomeDirectoryName = ApplicationUtils.instance().getHomeDirectory().getPath().toString(); + return vitroHomeDirectoryName + "/" + FileStorageImplWrapper.FILE_STORAGE_SUBDIRECTORY + "/" + PATH_TO_UPLOADS; } /** diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java index f2eb0e3d..36721a5e 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java @@ -53,7 +53,7 @@ public class AddEditorRoleToPersonGenerator extends AddRoleToPersonTwoStageGener /** Do not show the role label field for the AddEditorRoleToPerson form */ @Override - boolean isShowRoleLabelField() { return false; } + boolean isShowRoleLabelField() { return true; } /* * Use the methods below to change the date/time precision in the diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/CalculateParameters.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/CalculateParameters.java index 4e0542e8..e3169436 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/CalculateParameters.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/CalculateParameters.java @@ -12,6 +12,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.hp.hpl.jena.query.Dataset; +import com.hp.hpl.jena.query.DatasetFactory; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; @@ -26,12 +27,13 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.shared.Lock; import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccess; import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument; import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames; -import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier; +import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser; -public class CalculateParameters implements DocumentModifier { +public class CalculateParameters implements DocumentModifier, ContextModelsUser { private boolean shutdown = false; private Dataset dataset; @@ -60,15 +62,11 @@ public class CalculateParameters implements DocumentModifier { private static Log log = LogFactory.getLog(CalculateParameters.class); - public CalculateParameters(Dataset dataset){ - this.dataset =dataset; - // new Thread(new TotalInd(this.dataset,totalCountQuery)).start(); + @Override + public void setContextModels(ContextModelAccess models) { + this.dataset = DatasetFactory.create(models.getOntModel()); } - - public CalculateParameters(){ - super(); - } - + public float calculateBeta(String uri){ float beta=0; int Conn=0; @@ -241,7 +239,7 @@ public class CalculateParameters implements DocumentModifier { } @Override - public void modifyDocument(Individual individual, SearchInputDocument doc, StringBuffer addUri) { + public void modifyDocument(Individual individual, SearchInputDocument doc) { // TODO Auto-generated method stub // calculate beta value. log.debug("Parameter calculation starts.."); diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VIVOValuesFromVcards.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VIVOValuesFromVcards.java index 27fa9411..7d9849bc 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VIVOValuesFromVcards.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VIVOValuesFromVcards.java @@ -15,11 +15,11 @@ import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.RDFNode; import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccess; import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; -import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier; +import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser; /** * If there are any VCards on this Individual with Title objects, store the text @@ -28,7 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier * If there are any VCards on this Individual with EMail objects, store the text * in the ALL_TEXT field. */ -public class VIVOValuesFromVcards implements DocumentModifier { +public class VIVOValuesFromVcards implements DocumentModifier, ContextModelsUser { private static final Log log = LogFactory .getLog(VIVOValuesFromVcards.class); @@ -77,16 +77,16 @@ public class VIVOValuesFromVcards implements DocumentModifier { } }}; - private RDFServiceFactory rdfServiceFactory; + private RDFService rdfService; private boolean shutdown = false; - public VIVOValuesFromVcards(RDFServiceFactory rdfServiceFactory) { - this.rdfServiceFactory = rdfServiceFactory; + @Override + public void setContextModels(ContextModelAccess models) { + this.rdfService = models.getRDFService(); } @Override - public void modifyDocument(Individual individual, SearchInputDocument doc, - StringBuffer addUri) { + public void modifyDocument(Individual individual, SearchInputDocument doc) { if (individual == null) return; @@ -101,7 +101,6 @@ public class VIVOValuesFromVcards implements DocumentModifier { String query = queryTemplate.replaceAll("\\?uri", uri); try { - RDFService rdfService = rdfServiceFactory.getRDFService(); ResultSet results = RDFServiceUtils.sparqlSelectQuery(query, rdfService); if (results != null) { diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFields.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFields.java index 440d2599..3e325a66 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFields.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFields.java @@ -4,9 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding; import java.util.ArrayList; import java.util.List; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields; - /** * Class that adds text from context nodes to Search Documents for * foaf:Agent individuals. @@ -15,8 +12,8 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{ static List queriesForAgent = new ArrayList(); - public VivoAgentContextNodeFields(RDFServiceFactory rdfServiceFactory){ - super(queriesForAgent,rdfServiceFactory); + public VivoAgentContextNodeFields(){ + super(queriesForAgent); } protected static final String prefix = diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoDocumentModifiers.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoDocumentModifiers.java deleted file mode 100644 index 51bc5049..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoDocumentModifiers.java +++ /dev/null @@ -1,72 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.search.documentBuilding; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; - -import com.hp.hpl.jena.query.Dataset; -import com.hp.hpl.jena.query.DatasetFactory; - -import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; - -public class VivoDocumentModifiers implements javax.servlet.ServletContextListener{ - - /** - * Exclude from the search index individuals who's URIs start with these namespaces. - */ - private static final String[] INDIVIDUAL_NS_EXCLUDES={ - //bdc34: seems that there are a lot of odd OBO things in the search, exclude them - "http://purl.obolibrary.org/obo/" - }; - - @SuppressWarnings("unchecked") - @Override - public void contextInitialized(ServletContextEvent sce) { - - ServletContext context = sce.getServletContext(); - RDFServiceFactory rdfServiceFactory = RDFServiceUtils.getRDFServiceFactory(context); - - Dataset dataset = DatasetFactory.create(ModelAccess.on(context).getOntModel()); - - /* Put DocumentModifiers into servlet context for use later in startup by SearchSetup - * This adds the code for VIVO specific additions to the building - * of search input Documents. */ - List modifiers = (List)context.getAttribute("DocumentModifiers"); - if( modifiers == null ){ - modifiers = new ArrayList(); - context.setAttribute("DocumentModifiers", modifiers); - } - - modifiers.add(new CalculateParameters(dataset)); - modifiers.add( new VIVOValuesFromVcards( rdfServiceFactory )); - modifiers.add( new VivoISFBasicFields( rdfServiceFactory )); - modifiers.add( new VivoISFAdvisingFields( rdfServiceFactory )); - modifiers.add( new VivoISFEducationFields( rdfServiceFactory )); - modifiers.add( new VivoISFGrantFields( rdfServiceFactory )); - modifiers.add( new VivoISFMemberFields( rdfServiceFactory )); - modifiers.add(new VivoInformationResourceContextNodeFields(rdfServiceFactory)); - - /* - * Add VIVO specific code that excludes Individuals from the search index. - */ - List excludes = - (List)context.getAttribute("SearchIndexExcludes"); - - if( excludes == null ){ - excludes = new ArrayList(); - context.setAttribute("SearchIndexExcludes", excludes); - } - - excludes.add(new ExcludeBasedOnNamespace(INDIVIDUAL_NS_EXCLUDES )); - } - - @Override - public void contextDestroyed(ServletContextEvent arg0) { - // do nothing. - } -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFAdvisingFields.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFAdvisingFields.java index c2f26778..600feb4d 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFAdvisingFields.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFAdvisingFields.java @@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding; import java.util.ArrayList; import java.util.List; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields; - /** * DocumentModifier for adding rdfs:labels of individuals related via * a advising relationship. @@ -31,8 +28,8 @@ public class VivoISFAdvisingFields extends ContextNodeFields { queries.add( makeQueryForPeople() ); } - public VivoISFAdvisingFields(RDFServiceFactory rdfServiceFactory){ - super(queries,rdfServiceFactory); + public VivoISFAdvisingFields(){ + super(queries); } /** diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFBasicFields.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFBasicFields.java index 23856b5a..010fbc82 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFBasicFields.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFBasicFields.java @@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding; import java.util.ArrayList; import java.util.List; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields; - /** * DocumentModifier to populate Search index fields for the basic ISF relationships. * @@ -23,8 +20,7 @@ public class VivoISFBasicFields extends ContextNodeFields { * Subtypes of vivo:Relationship that get handled by this class. */ private static String[] RELATIONSHIP_TYPES = { - //VIVONS + "Relationship", - VIVONS + "Postion", + VIVONS + "Position", VIVONS + "Authorship", VIVONS + "Collaboration", VIVONS + "Affiliation" @@ -32,8 +28,8 @@ public class VivoISFBasicFields extends ContextNodeFields { static List queries = new ArrayList(); - public VivoISFBasicFields(RDFServiceFactory rdfServiceFactory){ - super(queries,rdfServiceFactory); + public VivoISFBasicFields(){ + super(queries); } protected static final String prefix = diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFEducationFields.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFEducationFields.java index 8ba9cc3e..a4655805 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFEducationFields.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFEducationFields.java @@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding; import java.util.ArrayList; import java.util.List; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields; - public class VivoISFEducationFields extends ContextNodeFields { private static String VIVONS = "http://vivoweb.org/ontology/core#"; @@ -18,8 +15,8 @@ public class VivoISFEducationFields extends ContextNodeFields { + " prefix rdfs: \n" + " prefix obo: \n" ; - public VivoISFEducationFields(RDFServiceFactory rdfServiceFactory){ - super(queries,rdfServiceFactory); + public VivoISFEducationFields(){ + super(queries); } /** diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFGrantFields.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFGrantFields.java index c36fde17..edcb4368 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFGrantFields.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFGrantFields.java @@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding; import java.util.ArrayList; import java.util.List; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields; - /* * This DocumentModifier is for the ISF style grants. * It will @@ -30,8 +27,8 @@ public class VivoISFGrantFields extends ContextNodeFields { + " prefix rdfs: \n" + " prefix obo: \n" ; - public VivoISFGrantFields(RDFServiceFactory rdfServiceFactory){ - super(queries,rdfServiceFactory); + public VivoISFGrantFields(){ + super(queries); } /** diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFMemberFields.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFMemberFields.java index 9ae1c566..4e7251c3 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFMemberFields.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoISFMemberFields.java @@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding; import java.util.ArrayList; import java.util.List; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields; - /** * This class will: * add people's names to organization's search Documents. @@ -26,8 +23,8 @@ public class VivoISFMemberFields extends ContextNodeFields { + " prefix rdfs: \n" + " prefix obo: \n" ; - public VivoISFMemberFields(RDFServiceFactory rdfServiceFactory){ - super(queries,rdfServiceFactory); + public VivoISFMemberFields(){ + super(queries); } /** @@ -37,7 +34,7 @@ public class VivoISFMemberFields extends ContextNodeFields { prefix + "SELECT (str(?rawresult) as ?result) WHERE {\n" + " ?uri rdf:type foaf:Organization . \n" + - " ?role core:roleContrigutesTo ?uri . \n" + + " ?role core:roleContributesTo ?uri . \n" + " ?person obo:RO_0000053 ?role . \n" + " ?person rdfs:label ?rawresult .\n" + "}"; @@ -49,7 +46,7 @@ public class VivoISFMemberFields extends ContextNodeFields { prefix + "SELECT (str(?rawresult) as ?result) WHERE {\n" + " ?uri rdf:type foaf:Person . \n" + - " ?uri obo:RO_0000053 / core:roleContrigutesTo / rdfs:label ?rawresult . \n" + + " ?uri obo:RO_0000053 / core:roleContributesTo / rdfs:label ?rawresult . \n" + "}"; diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoInformationResourceContextNodeFields.java b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoInformationResourceContextNodeFields.java index 54ef0dad..c34815b2 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoInformationResourceContextNodeFields.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoInformationResourceContextNodeFields.java @@ -4,9 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding; import java.util.ArrayList; import java.util.List; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields; - /** * Class that adds text from context nodes to search index Documents for * obo:IAO_0000030 individuals. @@ -18,8 +15,8 @@ public class VivoInformationResourceContextNodeFields extends ContextNodeFields{ static List queriesForInformationResource = new ArrayList(); - public VivoInformationResourceContextNodeFields(RDFServiceFactory rdfServiceFactory){ - super(queriesForInformationResource, rdfServiceFactory); + public VivoInformationResourceContextNodeFields(){ + super(queriesForInformationResource); } protected static final String prefix = diff --git a/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFieldsTest.java b/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFieldsTest.java index e4ab7c20..e418e2ff 100644 --- a/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFieldsTest.java +++ b/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFieldsTest.java @@ -9,6 +9,8 @@ import java.io.InputStream; import org.junit.BeforeClass; import org.junit.Test; +import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub; + import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Property; @@ -18,17 +20,14 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory; import edu.cornell.mannlib.vitro.testing.AbstractTestClass; import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle; +import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel; public class VivoAgentContextNodeFieldsTest extends AbstractTestClass{ static String SPCA = "http://vivo.mydomain.edu/individual/n8087"; - - static RDFServiceFactory rdfServiceFactory; + static ContextModelAccessStub contextModels; @BeforeClass public static void setup(){ @@ -44,8 +43,8 @@ public class VivoAgentContextNodeFieldsTest extends AbstractTestClass{ assertTrue("expect statements about SPCA", m.contains(ResourceFactory.createResource(SPCA),(Property) null,(RDFNode) null)); - RDFService rdfService = new RDFServiceModel(m); - rdfServiceFactory = new RDFServiceFactorySingle(rdfService); + contextModels = new ContextModelAccessStub(); + contextModels.setRDFService(WhichService.CONTENT, new RDFServiceModel(m)); } @Test @@ -53,7 +52,8 @@ public class VivoAgentContextNodeFieldsTest extends AbstractTestClass{ Individual ind = new IndividualImpl(); ind.setURI(SPCA); - VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(rdfServiceFactory); + VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(); + vacnf.setContextModels(contextModels); StringBuffer sb = vacnf.getValues( ind ); assertNotNull( sb ); @@ -68,7 +68,8 @@ public class VivoAgentContextNodeFieldsTest extends AbstractTestClass{ Individual ind = new IndividualImpl(); ind.setURI(SPCA); - VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(rdfServiceFactory); + VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(); + vacnf.setContextModels(contextModels); StringBuffer sb = vacnf.getValues( ind ); assertNotNull( sb ); @@ -83,7 +84,8 @@ public class VivoAgentContextNodeFieldsTest extends AbstractTestClass{ Individual ind = new IndividualImpl(); ind.setURI(SPCA); - VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(rdfServiceFactory); + VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(); + vacnf.setContextModels(contextModels); StringBuffer sb = vacnf.getValues( ind ); assertNotNull( sb ); diff --git a/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFieldsTest2.java b/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFieldsTest2.java index 1d641e92..f3973ef1 100644 --- a/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFieldsTest2.java +++ b/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoAgentContextNodeFieldsTest2.java @@ -10,6 +10,8 @@ import org.apache.commons.lang.StringUtils; import org.junit.BeforeClass; import org.junit.Test; +import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub; + import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Property; @@ -19,9 +21,7 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory; import edu.cornell.mannlib.vitro.testing.AbstractTestClass; import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle; +import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel; /** @@ -32,9 +32,8 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceMod public class VivoAgentContextNodeFieldsTest2 extends AbstractTestClass{ static String HISTORY_DEPT = "http://vivo.colorado.edu/deptid_10238" ; - - static RDFServiceFactory rdfServiceFactory; - + static ContextModelAccessStub contextModels; + @BeforeClass public static void setup(){ Model m = ModelFactory.createDefaultModel(); @@ -52,8 +51,8 @@ public class VivoAgentContextNodeFieldsTest2 extends AbstractTestClass{ assertTrue("expect statements about HISTORY_DEPT", m.contains(ResourceFactory.createResource(HISTORY_DEPT),(Property) null,(RDFNode) null)); - RDFService rdfService = new RDFServiceModel(m); - rdfServiceFactory = new RDFServiceFactorySingle(rdfService); + contextModels = new ContextModelAccessStub(); + contextModels.setRDFService(WhichService.CONTENT, new RDFServiceModel(m)); } /** @@ -65,7 +64,8 @@ public class VivoAgentContextNodeFieldsTest2 extends AbstractTestClass{ Individual ind = new IndividualImpl(); ind.setURI(HISTORY_DEPT); - VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(rdfServiceFactory); + VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(); + vacnf.setContextModels(contextModels); StringBuffer sb = vacnf.getValues( ind ); assertNotNull( sb ); diff --git a/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoInformationResourceContextNodeFieldsTest.java b/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoInformationResourceContextNodeFieldsTest.java index c95c0c6d..6691121d 100644 --- a/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoInformationResourceContextNodeFieldsTest.java +++ b/test/edu/cornell/mannlib/vitro/webapp/search/documentBuilding/VivoInformationResourceContextNodeFieldsTest.java @@ -9,6 +9,7 @@ import java.util.Collection; import org.junit.Assert; import org.junit.Test; +import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub; import stubs.edu.cornell.mannlib.vitro.webapp.modules.ApplicationStub; import stubs.edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineStub; import stubs.javax.servlet.ServletContextStub; @@ -23,10 +24,8 @@ import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils; import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; +import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService; import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; -import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel; public class VivoInformationResourceContextNodeFieldsTest extends AbstractTestClass { @@ -54,22 +53,25 @@ public class VivoInformationResourceContextNodeFieldsTest extends AbstractTestCl WebappDaoFactory wadf = new WebappDaoFactoryJena(ontModel); Individual ind = wadf.getIndividualDao().getIndividualByURI(DOCUMENT_URI); Assert.assertNotNull(ind); - - RDFService rdfService = new RDFServiceModel(ontModel); - RDFServiceFactory rdfServiceFactory = new RDFServiceFactorySingle(rdfService); + + ContextModelAccessStub contextModels = new ContextModelAccessStub(); + contextModels.setRDFService(WhichService.CONTENT, new RDFServiceModel(ontModel)); + SearchInputDocument doc = ApplicationUtils.instance().getSearchEngine().createInputDocument(); doc.addField("ALLTEXT", ""); - VivoInformationResourceContextNodeFields vircnf = new VivoInformationResourceContextNodeFields(rdfServiceFactory); - vircnf.modifyDocument(ind, doc, new StringBuffer()); + VivoInformationResourceContextNodeFields vircnf = new VivoInformationResourceContextNodeFields(); + vircnf.setContextModels(contextModels); + vircnf.modifyDocument(ind, doc); Collection values = doc.getField("ALLTEXT").getValues(); for( Object value : values){ Assert.assertFalse("rdf:label erroneously added by document modifier:", value.toString().contains(RDFS_LABEL_VALUE)); } - VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(rdfServiceFactory); - vacnf.modifyDocument(ind, doc, new StringBuffer()); + VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(); + vacnf.setContextModels(contextModels); + vacnf.modifyDocument(ind, doc); }