Merge branch 'maint-rel-1.6' into develop

This commit is contained in:
hudajkhan 2013-11-11 18:43:24 -05:00
commit c832112628
18 changed files with 14689 additions and 14529 deletions

View file

@ -240,11 +240,22 @@ public class AddEditWebpageFormGenerator extends BaseEditConfigurationGenerator
private String getUrlPatternToReturnTo(VitroRequest vreq) {
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
//Also add domain and range uris if they exist to enable cancel to work properly
String domainUri = (String) vreq.getParameter("domainUri");
String rangeUri = (String) vreq.getParameter("rangeUri");
String generatorName = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator";
String editUrl = EditConfigurationUtils.getEditUrlWithoutContext(vreq);
return editUrl + "?subjectUri=" + UrlBuilder.urlEncode(subjectUri) +
String returnPath = editUrl + "?subjectUri=" + UrlBuilder.urlEncode(subjectUri) +
"&predicateUri=" + UrlBuilder.urlEncode(predicateUri) +
"&editForm=" + UrlBuilder.urlEncode(generatorName);
if(domainUri != null && !domainUri.isEmpty()) {
returnPath += "&domainUri=" + UrlBuilder.urlEncode(domainUri);
}
if(rangeUri != null && !rangeUri.isEmpty()) {
returnPath += "&rangeUri=" + UrlBuilder.urlEncode(rangeUri);
}
return returnPath;
}
private String getLinkUri(VitroRequest vreq) {

View file

@ -35,6 +35,7 @@ public class AddOutreachProviderRoleToPersonGenerator extends AddRoleToPersonTwo
"http://vivoweb.org/ontology/core#CoreLaboratory","Core Laboratory",
"http://vivoweb.org/ontology/core#Department","Department",
"http://vivoweb.org/ontology/core#Division","Division",
"http://purl.org/NET/c4dm/event.owl#Event","Event",
"http://vivoweb.org/ontology/core#ExtensionUnit","Extension Unit",
"http://vivoweb.org/ontology/core#Foundation","Foundation",
"http://vivoweb.org/ontology/core#FundingOrganization","Funding Organization",

View file

@ -12,26 +12,21 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.ontology.OntModel;
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.rdf.model.Statement;
import com.hp.hpl.jena.shared.Lock;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate {
private OntModel model;
private final RDFService rdfService;
private Set<String> alreadyChecked;
private long accumulatedTime = 0;
@ -43,8 +38,8 @@ public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate {
private Log log = LogFactory.getLog(AdditionalURIsForContextNodes.class);
public AdditionalURIsForContextNodes( OntModel jenaOntModel){
this.model = jenaOntModel;
public AdditionalURIsForContextNodes( RDFService rdfService){
this.rdfService = rdfService;
}
@Override
@ -93,42 +88,27 @@ public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate {
List<String> uriList = new ArrayList<String>();
for(String query : queryList){
//log.info("Executing query: "+ query);
QuerySolutionMap initialBinding = new QuerySolutionMap();
Resource uriResource = ResourceFactory.createResource(uri);
initialBinding.add("uri", uriResource);
Query sparqlQuery = QueryFactory.create( query, Syntax.syntaxARQ);
model.getLock().enterCriticalSection(Lock.READ);
try{
QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, model, initialBinding);
try{
ResultSet results = qExec.execSelect();
while(results.hasNext()){
QuerySolution soln = results.nextSolution();
Iterator<String> iter = soln.varNames() ;
while( iter.hasNext()){
String name = iter.next();
RDFNode node = soln.get( name );
if( node != null ){
uriList.add("" + node.toString());
}else{
log.debug(name + " is null");
}
}
}
}catch(Throwable t){
log.error(t,t);
} finally{
qExec.close();
}
}finally{
model.getLock().leaveCriticalSection();
}
}
for (String query : queryList) {
QuerySolutionMap initialBinding = new QuerySolutionMap();
Resource uriResource = ResourceFactory.createResource(uri);
initialBinding.add("uri", uriResource);
ResultSet results = QueryUtils.getQueryResults(query,
initialBinding, rdfService);
while (results.hasNext()) {
QuerySolution soln = results.nextSolution();
Iterator<String> iter = soln.varNames();
while (iter.hasNext()) {
String name = iter.next();
RDFNode node = soln.get(name);
if (node != null) {
uriList.add("" + node.toString());
} else {
log.debug(name + " is null");
}
}
}
}
if( log.isDebugEnabled() )
log.debug( "additional uris for " + uri + " are " + uriList);

View file

@ -5,9 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.search.indexing;
import java.util.ArrayList;
import java.util.List;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
/**
@ -16,12 +15,12 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
*/
public class AdditionalUriFinders {
public static List<StatementToURIsToUpdate> getList(OntModel jenaOntModel,
public static List<StatementToURIsToUpdate> getList(RDFService rdfService,
IndividualDao indDao) {
List<StatementToURIsToUpdate> uriFinders = new ArrayList<>();
uriFinders.add(new AdditionalURIsForDataProperties());
uriFinders.add(new AdditionalURIsForObjectProperties(jenaOntModel));
uriFinders.add(new AdditionalURIsForContextNodes(jenaOntModel));
uriFinders.add(new AdditionalURIsForObjectProperties(rdfService));
uriFinders.add(new AdditionalURIsForContextNodes(rdfService));
uriFinders.add(new AdditionalURIsForTypeStatements());
uriFinders.add(new URIsForClassGroupChange(indDao));
return uriFinders;

View file

@ -29,7 +29,8 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
+ " prefix foaf: <http://xmlns.com/foaf/0.1/> "
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
+ " prefix localNav: <http://vitro.mannlib.cornell.edu/ns/localnav#> "
+ " prefix bibo: <http://purl.org/ontology/bibo/> ";
+ " prefix bibo: <http://purl.org/ontology/bibo/> "
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n" ;
//queries for foaf:Agent
@ -49,14 +50,9 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
" ?uri rdf:type foaf:Agent . " +
" ?uri ?b ?c . " +
" ?c rdf:type core:Position . " +
" ?c core:involvedOrganizationName ?ContextNodeProperty . }");
queriesForAgent.add(prefix + "SELECT " +
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
" ?uri rdf:type foaf:Agent . " +
" ?uri ?b ?c . " +
" ?c rdf:type core:Position . " +
" ?c core:positionInOrganization ?i . ?i rdfs:label ?ContextNodeProperty . }");
" ?c core:relates ?i . " +
" ?i rdf:type foaf:Organization . " +
" ?i rdfs:label ?ContextNodeProperty . }");
queriesForAgent.add(prefix + "SELECT " +
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
@ -70,7 +66,6 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
queriesForAgent.add(prefix +
"SELECT " +
"(str(?HRJobTitle) as ?hrJobTitle) " +
"(str(?InvolvedOrganizationName) as ?involvedOrganizationName) " +
"(str(?PositionInOrganization) as ?positionInOrganization) " +
"(str(?TitleOrRole) as ?titleOrRole) WHERE {"
@ -78,8 +73,7 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
+ " ?c rdf:type core:Position . "
+ " OPTIONAL { ?c core:hrJobTitle ?HRJobTitle . } . "
+ " OPTIONAL { ?c core:involvedOrganizationName ?InvolvedOrganizationName . } ."
+ " OPTIONAL { ?c core:positionInOrganization ?i . ?i rdfs:label ?PositionInOrganization . } . "
+ " OPTIONAL { ?c core:relates ?i . ?i rdf:type foaf:Organization . ?i rdfs:label ?PositionInOrganization . } . "
+ " OPTIONAL { ?c core:titleOrRole ?TitleOrRole . } . "
+ " }");
@ -88,36 +82,49 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
queriesForAgent.add(prefix + "SELECT " +
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
" ?uri rdf:type foaf:Agent ; ?b ?c . " +
" ?c rdf:type core:Relationship . " +
" ?c core:advisee ?d . ?d rdfs:label ?ContextNodeProperty . }");
" ?c rdf:type core:AdvisingRelationship . " +
" ?c rdfs:label ?ContextNodeProperty . }");
queriesForAgent.add(prefix + "SELECT " +
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
" ?uri rdf:type foaf:Agent ; ?b ?c . " +
" ?c rdf:type core:Relationship . " +
" ?c rdf:type core:AdvisingRelationship . " +
" ?c core:degreeCandidacy ?e . ?e rdfs:label ?ContextNodeProperty . }");
queriesForAgent.add(prefix + "SELECT " +
"(str(?label) as ?adviseeLabel) WHERE {" +
" ?uri rdf:type foaf:Agent ." +
" ?c rdf:type core:Relationship . " +
" ?c core:advisor ?uri . " +
" ?c core:advisee ?d . ?d rdfs:label ?label .}" );
" ?c rdf:type core:AdvisingRelationship . " +
" ?c core:relates ?uri . " +
" ?uri obo:RO_0000053 ?advisorRole . " +
" ?advisorRole rdf:type core:AdvisorRole . " +
" ?c core:relates ?d . " +
" ?d rdf:type foaf:Person . " +
" ?d obo:RO_0000053 ?adviseeRole . " +
" ?adviseeRole rdf:type core:AdviseeRole . " +
" ?d rdfs:label ?ContextNodeProperty . }");
queriesForAgent.add(prefix + "SELECT " +
"(str(?label) as ?advisorLabel) WHERE {" +
" ?uri rdf:type foaf:Agent ." +
" ?c rdf:type core:Relationship . " +
" ?c core:advisee ?uri . " +
" ?c core:advisor ?d . ?d rdfs:label ?label .}" );
" ?c rdf:type core:AdvisingRelationship . " +
" ?c core:relates ?uri . " +
" ?uri obo:RO_0000053 ?adviseeRole . " +
" ?adviseeRole rdf:type core:AdviseeRole . " +
" ?c core:relates ?d . " +
" ?d rdf:type foaf:Person . " +
" ?d obo:RO_0000053 ?advisorRole . " +
" ?advisorRole rdf:type core:AdvisorRole . " +
" ?d rdfs:label ?ContextNodeProperty . }");
/* Author */
queriesForAgent.add(prefix + "SELECT " +
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
" ?uri rdf:type foaf:Agent ; ?b ?c . " +
" ?c rdf:type core:Relationship . " +
" ?c core:linkedAuthor ?f . " +
" ?c rdf:type core:Authorship . " +
" ?c core:relates ?f . " +
" ?f rdf:type foaf:Person . " +
" ?f rdfs:label ?ContextNodeProperty . " +
" FILTER( ?f != ?uri ) " +
"}");
@ -125,8 +132,9 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
queriesForAgent.add(prefix + "SELECT " +
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
" ?uri rdf:type foaf:Agent ; ?b ?c . " +
" ?c rdf:type core:Relationship . " +
" ?c core:linkedInformationResource ?h . ?h rdfs:label ?ContextNodeProperty . }");
" ?c rdf:type core:Authorship . " +
" ?c core:relates ?h . " +
" ?h rdf:type obo:IAO_0000030 . ?h rdfs:label ?ContextNodeProperty . }");
/* Award */
@ -138,8 +146,8 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
"WHERE {"
+ " ?uri rdf:type foaf:Agent ; ?b ?c . "
+ " ?c rdf:type core:AwardReceipt . "
+ " OPTIONAL { ?c rdfs:label ?AwardLabel . } . "
+ " OPTIONAL { ?c core:awardConferredBy ?d . ?d rdfs:label ?AwardConferredBy . } . "
+ " OPTIONAL { ?c core:relates ?e . ?e rdf:type core:Award . ?e rdfs:label ?AwardLabel . } . "
+ " OPTIONAL { ?c core:assignedBy ?d . ?d rdf:type foaf:Organization . ?d rdfs:label ?AwardConferredBy . } . "
+ " OPTIONAL { ?c core:description ?Description . } . "
+ " }");
@ -147,8 +155,9 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
queriesForAgent.add(prefix +
"SELECT (str(?OrganizationLabel) as ?organizationLabel) WHERE {"
+ "?uri rdf:type foaf:Agent ; ?b ?c . "
+ " ?c rdf:type core:Role ; core:roleIn ?Organization ."
+ " ?uri rdf:type foaf:Agent ; ?b ?c . "
+ " ?c rdf:type obo:BFO_0000023 ; core:roleContributesTo ?Organization ."
+ " ?Organization rdf:type core:Organization . "
+ " ?Organization rdfs:label ?OrganizationLabel . "
+ " }");
@ -163,12 +172,16 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
"(str(?TrainingAtOrganizationLabel) as ?trainingAtOrganizationLabel) WHERE {"
+ " ?uri rdf:type foaf:Agent ; ?b ?c . "
+ " ?c rdf:type core:EducationalTraining . "
+ " ?c rdf:type core:EducationalProcess . "
+ "OPTIONAL { ?c core:degreeEarned ?d . ?d rdfs:label ?AcademicDegreeLabel ; core:abbreviation ?AcademicDegreeAbbreviation . } . "
+ "OPTIONAL { ?c core:relates ?d . "
+ " ?d rdf:type core:AwardedDegree . "
+ " ?d core:relates ?e . "
+ " ?e rdf:type core:AcademicDegree . "
+ " ?e rdfs:label ?AcademicDegreeLabel . } . "
+ "OPTIONAL { ?c core:majorField ?MajorField .} ."
+ " OPTIONAL { ?c core:departmentOrSchool ?DepartmentOrSchool . }"
+ " OPTIONAL { ?c core:trainingAtOrganization ?e . ?e rdfs:label ?TrainingAtOrganizationLabel . } . "
+ " OPTIONAL { ?c obo:RO_0000057 ?f . ?f rdf:type foaf:organization . ?f rdfs:label ?TrainingAtOrganizationLabel . } . "
+"}");
}
}

View file

@ -47,7 +47,8 @@ public class VivoISFAdvisingFields extends ContextNodeFields {
" ?uri core:relatedBy ?rel . \n" +
" ?rel rdf:type core:AdvisingRelationship . \n" +
" ?rel core:relates ?other . \n" +
" ?other rdfs:label ?result . \n" +
" ?other rdfs:label ?result . \n" +
" FILTER( ?other != ?uri ) \n" +
"}";
}