From 77b408e699159fbddb612a6fcf53d17593690569 Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Wed, 6 Nov 2013 09:11:03 -0500 Subject: [PATCH 1/5] VIVO-496 and VIVO-497 hiding inheres in and cleaning up has expertise --- rdf/tbox/filegraph/research-resource.owl | 30 -------------------- rdf/tbox/firsttime/initialTBoxAnnotations.n3 | 18 ++++++------ 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/rdf/tbox/filegraph/research-resource.owl b/rdf/tbox/filegraph/research-resource.owl index 795cdeb9..5d90bd3a 100644 --- a/rdf/tbox/filegraph/research-resource.owl +++ b/rdf/tbox/filegraph/research-resource.owl @@ -296,36 +296,6 @@ - - - - - - - - - A technique used for identification, assessment, and prioritization of risks followed by coordinated and economical application of resources to minimize, monitor, and control the probability and/or impact of unfortunate events or to maximize the realization of opportunities. - PERSON: Nicole Vasilevsky - http://en.wikipedia.org/wiki/Risk_management - - - - - - - - - - - - - A technique designed for the collection of clinical data in electronic format for use mainly in human clinical trials. - Electronic health records. - PERSON: Nicole Vasilevsky - clinical database development - http://en.wikipedia.org/wiki/Electronic_data_capture - - diff --git a/rdf/tbox/firsttime/initialTBoxAnnotations.n3 b/rdf/tbox/firsttime/initialTBoxAnnotations.n3 index 672d3388..32f22456 100644 --- a/rdf/tbox/firsttime/initialTBoxAnnotations.n3 +++ b/rdf/tbox/firsttime/initialTBoxAnnotations.n3 @@ -1774,9 +1774,6 @@ vivo:hasGoverningAuthority vitro:selectFromExistingAnnot "true"^^xsd:boolean . -obo:ERO_0000715 - rdfs:label "Risk Management"@en-US . - vcard:additionalName rdfs:label "additional name"@en-US . @@ -2798,7 +2795,11 @@ vivo:GraduateAdvisingRelationship . obo:RO_0000052 - rdfs:label "inheres in"@en-US . + rdfs:label "inheres in"@en-US ; + vitro:hiddenFromDisplayBelowRoleLevelAnnot + ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot + . obo:OBI_0000299 rdfs:label "has specified output"@en-US . @@ -5568,9 +5569,6 @@ geo:countryAreaUnit vitro:prohibitedFromUpdateBelowRoleLevelAnnot . -obo:ERO_0000742 - rdfs:label "Research Electronic Datacapture"@en-US . - vcard:geo rdfs:label "geo"@en-US . @@ -6053,7 +6051,11 @@ obo:RO_0001018 rdfs:label "contained in"@en-US . obo:ERO_0000033 - rdfs:label "has expertise"@en-US . + rdfs:label "has expertise in technique"@en-US ; + vitro:selectFromExistingAnnot + "true"^^xsd:boolean ; + vitro:offerCreateNewOptionAnnot + "true"^^xsd:boolean . bibo:peerReviewed rdfs:label "peer reviewed"@en-US . From 5b5bc34d1a9209803a32ab3f79ad88d07d6b49c9 Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Wed, 6 Nov 2013 11:31:17 -0500 Subject: [PATCH 2/5] VIVO-491 migrating hasGeographicLocation on Addresses --- .../update/sparqlConstructs/additions/vcard8.sparql | 3 +++ .../update/sparqlConstructs/deletions/vcardDel.sparql | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard8.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard8.sparql index 1f1dddce..a1a53389 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard8.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard8.sparql @@ -11,12 +11,15 @@ CONSTRUCT { _:address v:region ?addressState . _:address v:postalCode ?addressPostalCode . _:address v:country ?addressCountry . + _:address ?location . + ?location _:address . } WHERE { ?s vivo:mailingAddress ?address . OPTIONAL { ?address vivo:addressCity ?addressCity } OPTIONAL { ?address vivo:addressState ?addressState } OPTIONAL { ?address vivo:addressPostalCode ?addressPostalCode } OPTIONAL { ?address vivo:addressCountry ?addressCountry } + OPTIONAL { ?address vivo:hasGeographicLocation ?location } ?s arg:ARG_2000028 ?vcard . OPTIONAL { ?address vivo:address1 ?address1 . diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/deletions/vcardDel.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/deletions/vcardDel.sparql index d31781cf..1eb00279 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/deletions/vcardDel.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/deletions/vcardDel.sparql @@ -17,6 +17,7 @@ CONSTRUCT { ?s vivo:faxNumber ?faxNumber . ?s vivo:mailingAddress ?address . ?address ?addressP ?addressO . + ?addressS ?addressQ ?address . ?s vivo:webpage ?webpage . ?webpage ?webpageP ?webpageO . } WHERE { @@ -58,6 +59,10 @@ CONSTRUCT { ?s vivo:mailingAddress ?address . ?address ?addressP ?addressO } + UNION { + ?s vivo:mailingAddress ?address . + ?addressS ?addressQ ?address + } UNION { ?s vivo:webpage ?webpage } From b83807a6cb923003658261fc85d26d6a19823dc0 Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Wed, 6 Nov 2013 11:36:32 -0500 Subject: [PATCH 3/5] VIVO-420 change VivoInformationResourceContextNodeFields.java to use foaf:Agent in getting related authors/editors instead of foaf:Person --- .../search/solr/VivoInformationResourceContextNodeFields.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/solr/VivoInformationResourceContextNodeFields.java b/src/edu/cornell/mannlib/vitro/webapp/search/solr/VivoInformationResourceContextNodeFields.java index 31334700..2fcf6798 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/solr/VivoInformationResourceContextNodeFields.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/solr/VivoInformationResourceContextNodeFields.java @@ -48,7 +48,7 @@ public class VivoInformationResourceContextNodeFields extends ContextNodeFields{ + "?uri core:relatedBy ?a . " + "?a rdf:type core:Authorship ." + "?a core:relates ?b ." - + "?b rdf:type foaf:Person ." + + "?b rdf:type foaf:Agent ." + "?b rdfs:label ?ContextNodeProperty .}"); /* features */ @@ -69,7 +69,7 @@ public class VivoInformationResourceContextNodeFields extends ContextNodeFields{ + "?uri core:relatedBy ?e . " + "?e rdf:type core:Editorship ." + "?e core:relates ?i ." - + "?i rdf:type foaf:Person ." + + "?i rdf:type foaf:Agent ." + "?i rdfs:label ?ContextNodeProperty ." + "}"); From 741ea08f980e09031172531db226872db6f90bd1 Mon Sep 17 00:00:00 2001 From: j2blake Date: Wed, 6 Nov 2013 12:24:56 -0500 Subject: [PATCH 4/5] A quick script to check the deployed language properties files. --- utilities/languageSupport/i18nChecker/check | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 utilities/languageSupport/i18nChecker/check diff --git a/utilities/languageSupport/i18nChecker/check b/utilities/languageSupport/i18nChecker/check new file mode 100755 index 00000000..5d133e93 --- /dev/null +++ b/utilities/languageSupport/i18nChecker/check @@ -0,0 +1,2 @@ +ruby i18nChecker.rb '/Library/Tomcat/webapps/vivo/i18n/*.properties' complete +ruby i18nChecker.rb '/Library/Tomcat/webapps/vivo/themes/wilma/i18n/*.properties' complete From 4a3937e78c0b82acabb8a0bb9acd5b135bceaab5 Mon Sep 17 00:00:00 2001 From: j2blake Date: Wed, 6 Nov 2013 12:26:46 -0500 Subject: [PATCH 5/5] VIVO-483 Adjust indexing code for the ISF This class should not have been in Vitro, since it uses VIVO URIs and is never referenced in Vitro. Also, it needed updating to match the ISF. --- .../search/solr/CalculateParameters.java | 298 ++++++++++++++++++ .../search/solr/VivoDocumentModifiers.java | 1 - 2 files changed, 298 insertions(+), 1 deletion(-) create mode 100644 src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculateParameters.java diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculateParameters.java b/src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculateParameters.java new file mode 100644 index 00000000..432c3573 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/search/solr/CalculateParameters.java @@ -0,0 +1,298 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.search.solr; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.solr.common.SolrInputDocument; + +import com.hp.hpl.jena.query.Dataset; +import com.hp.hpl.jena.query.Query; +import com.hp.hpl.jena.query.QueryExecution; +import com.hp.hpl.jena.query.QueryExecutionFactory; +import com.hp.hpl.jena.query.QueryFactory; +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.QuerySolutionMap; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.Syntax; +import com.hp.hpl.jena.rdf.model.RDFNode; +import com.hp.hpl.jena.rdf.model.Resource; +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.search.VitroSearchTermNames; +import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.DocumentModifier; + + +public class CalculateParameters implements DocumentModifier { + + private boolean shutdown = false; + private Dataset dataset; + // public static int totalInd=1; + + private static final String prefix = "prefix owl: " + + " prefix vitroDisplay: " + + " prefix rdf: " + + " prefix core: " + + " prefix foaf: " + + " prefix rdfs: " + + " prefix localNav: " + + " prefix obo: " + + " prefix bibo: "; + + private static final String betaQuery = prefix + " SELECT count(distinct ?inLinks) " + + " WHERE { " + + " ?uri rdf:type owl:Thing . " + + " ?inLinks ?prop ?uri . " + + " } "; + + private static final String totalCountQuery = prefix + " SELECT count(distinct ?ind) " + + " WHERE { " + + " ?ind rdf:type owl:Thing . " + + " } "; + + private static Log log = LogFactory.getLog(CalculateParameters.class); + + public CalculateParameters(Dataset dataset){ + this.dataset =dataset; + // new Thread(new TotalInd(this.dataset,totalCountQuery)).start(); + } + + public CalculateParameters(){ + super(); + } + + public float calculateBeta(String uri){ + float beta=0; + int Conn=0; + Query query; + QuerySolutionMap initialBinding = new QuerySolutionMap(); + QuerySolution soln = null; + Resource uriResource = ResourceFactory.createResource(uri); + initialBinding.add("uri", uriResource); + dataset.getLock().enterCriticalSection(Lock.READ); + QueryExecution qexec=null; + try{ + query = QueryFactory.create(betaQuery,Syntax.syntaxARQ); + qexec = QueryExecutionFactory.create(query,dataset,initialBinding); + ResultSet results = qexec.execSelect(); + List resultVars = results.getResultVars(); + if(resultVars!=null && resultVars.size()!=0){ + soln = results.next(); + Conn = Integer.parseInt(soln.getLiteral(resultVars.get(0)).getLexicalForm()); + } + }catch(Throwable t){ + if( ! shutdown ) + log.error(t,t); + }finally{ + if( qexec != null ) + qexec.close(); + dataset.getLock().leaveCriticalSection(); + } + + beta = (float)Conn; + //beta *= 100; + beta += 1; + + // sigmoid function to keep beta between 0 to 1; + + beta = (float) (1 / ( 1 + Math.pow(Math.E,(-beta)))); + + if(beta > 1) + log.info("Beta higher than 1 : " + beta); + else if(beta <= 0) + log.info("Beta lower < = 0 : " + beta); + return beta; + } + + + public String[] getAdjacentNodes(String uri){ + + List queryList = new ArrayList(); + Set adjacentNodes = new HashSet(); + Set coauthorNames = new HashSet(); + String[] info = new String[]{"",""}; + StringBuffer adjacentNodesConcat = new StringBuffer(); + StringBuffer coauthorBuff = new StringBuffer(); + adjacentNodesConcat.append(""); + coauthorBuff.append(""); + + queryList.add(prefix + + " SELECT ?adjobj (str(?adjobjLabel) as ?coauthor) " + + " WHERE { " + + " ?uri rdf:type . " + + " ?uri ?prop ?obj . " + + " ?obj rdf:type . " + + " ?obj ?prop2 ?obj2 . " + + " ?obj2 rdf:type obo:IAO_0000030 . " + + " ?obj2 ?prop3 ?obj3 . " + + " ?obj3 rdf:type . " + + " ?obj3 ?prop4 ?adjobj . " + + " ?adjobj rdfs:label ?adjobjLabel . " + + " ?adjobj rdf:type . " + + + " FILTER (?prop !=rdf:type) . " + + " FILTER (?prop2!=rdf:type) . " + + " FILTER (?prop3!=rdf:type) . " + + " FILTER (?prop4!=rdf:type) . " + + " FILTER (?adjobj != ?uri) . " + + "}"); + + queryList.add(prefix + + " SELECT ?adjobj " + + " WHERE{ " + + + " ?uri rdf:type foaf:Agent . " + + " ?uri ?prop ?obj . " + + " ?obj ?prop2 ?adjobj . " + + + + " FILTER (?prop !=rdf:type) . " + + " FILTER isURI(?obj) . " + + + " FILTER (?prop2!=rdf:type) . " + + " FILTER (?adjobj != ?uri) . " + + " FILTER isURI(?adjobj) . " + + + " { ?adjobj rdf:type . } " + + " UNION " + + " { ?adjobj rdf:type . } " + + " UNION " + + " { ?adjobj rdf:type obo:IAO_0000030 . } " + + " UNION " + + " { ?adjobj rdf:type . } ." + + "}"); + + Query query; + + QuerySolution soln; + QuerySolutionMap initialBinding = new QuerySolutionMap(); + Resource uriResource = ResourceFactory.createResource(uri); + + initialBinding.add("uri", uriResource); + + Iterator queryItr = queryList.iterator(); + + dataset.getLock().enterCriticalSection(Lock.READ); + Resource adjacentIndividual = null; + RDFNode coauthor = null; + try{ + while(queryItr.hasNext()){ + /*if(!isPerson){ + queryItr.next(); // we don't want first query to execute if the ind is not a person. + }*/ + query = QueryFactory.create(queryItr.next(),Syntax.syntaxARQ); + QueryExecution qexec = QueryExecutionFactory.create(query,dataset,initialBinding); + try{ + ResultSet results = qexec.execSelect(); + while(results.hasNext()){ + soln = results.nextSolution(); + + adjacentIndividual = (Resource)soln.get("adjobj"); + if(adjacentIndividual!=null){ + adjacentNodes.add(adjacentIndividual.getURI()); + } + + coauthor = soln.get("coauthor"); + if(coauthor!=null){ + coauthorNames.add(" co-authors " + coauthor.toString() + " co-authors "); + } + } + }catch(Exception e){ + if( ! shutdown ) + log.error("Error found in getAdjacentNodes method of SearchQueryHandler"); + }finally{ + qexec.close(); + } + } + queryList = null; + Iterator itr = adjacentNodes.iterator(); + while(itr.hasNext()){ + adjacentNodesConcat.append(itr.next() + " "); + } + + info[0] = adjacentNodesConcat.toString(); + + itr = coauthorNames.iterator(); + while(itr.hasNext()){ + coauthorBuff.append(itr.next()); + } + + info[1] = coauthorBuff.toString(); + + } + catch(Throwable t){ + if( ! shutdown ) + log.error(t,t); + }finally{ + dataset.getLock().leaveCriticalSection(); + adjacentNodes = null; + adjacentNodesConcat = null; + coauthorBuff = null; + } + return info; + } + + @Override + public void modifyDocument(Individual individual, SolrInputDocument doc, StringBuffer addUri) { + // TODO Auto-generated method stub + // calculate beta value. + log.debug("Parameter calculation starts.."); + float beta = calculateBeta(individual.getURI()); + doc.addField(VitroSearchTermNames.BETA, beta); + doc.setDocumentBoost(beta + doc.getDocumentBoost() ); + log.debug("Parameter calculation is done"); + } + + + public void shutdown(){ + shutdown=true; + } +} + +class TotalInd implements Runnable{ + private Dataset dataset; + private String totalCountQuery; + private static Log log = LogFactory.getLog(TotalInd.class); + + public TotalInd(Dataset dataset,String totalCountQuery){ + this.dataset = dataset; + this.totalCountQuery = totalCountQuery; + + } + public void run(){ + int totalInd=0; + Query query; + QuerySolution soln = null; + dataset.getLock().enterCriticalSection(Lock.READ); + QueryExecution qexec = null; + + try{ + query = QueryFactory.create(totalCountQuery,Syntax.syntaxARQ); + qexec = QueryExecutionFactory.create(query,dataset); + ResultSet results = qexec.execSelect(); + List resultVars = results.getResultVars(); + + if(resultVars!=null && resultVars.size()!=0){ + soln = results.next(); + totalInd = Integer.parseInt(soln.getLiteral(resultVars.get(0)).getLexicalForm()); + } + //CalculateParameters.totalInd = totalInd; + //log.info("Total number of individuals in the system are : " + CalculateParameters.totalInd); + }catch(Throwable t){ + log.error(t,t); + }finally{ + if( qexec != null ) + qexec.close(); + dataset.getLock().leaveCriticalSection(); + } + + } +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/search/solr/VivoDocumentModifiers.java b/src/edu/cornell/mannlib/vitro/webapp/search/solr/VivoDocumentModifiers.java index 927ae69d..b27bfbad 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/search/solr/VivoDocumentModifiers.java +++ b/src/edu/cornell/mannlib/vitro/webapp/search/solr/VivoDocumentModifiers.java @@ -13,7 +13,6 @@ import com.hp.hpl.jena.query.DatasetFactory; import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; -import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.CalculateParameters; import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.DocumentModifier; import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnNamespace; import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.SearchIndexExcluder;