diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ContextNodeFields.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ContextNodeFields.java index ea75c58bf..c676a75fd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ContextNodeFields.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ContextNodeFields.java @@ -2,13 +2,16 @@ package edu.cornell.mannlib.vitro.webapp.search.solr; +import java.util.ArrayList; +import java.util.List; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputField; -import com.hp.hpl.jena.assembler.Mode; import com.hp.hpl.jena.ontology.OntModel; +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; @@ -21,19 +24,15 @@ import com.hp.hpl.jena.rdf.model.Model; 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.sdb.script.QExec; import com.hp.hpl.jena.shared.Lock; import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.search.VitroTermNames; -import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames; public class ContextNodeFields implements DocumentModifier{ Model fullModel; - private Log log = LogFactory.getLog(ContextNodeFields.class); - private static final String prefix = "prefix owl: " + " prefix vitroDisplay: " + " prefix rdf: " @@ -43,9 +42,124 @@ public class ContextNodeFields implements DocumentModifier{ + " prefix localNav: " + " prefix bibo: "; + private static final List queryList = new ArrayList(); - public ContextNodeFields(OntModel fullModel){ - this.fullModel = fullModel; + static { + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Position . " + + " ?c core:hrJobTitle ?ContextNodeProperty . }"); + + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Position . " + + " ?c core:involvedOrganizationName ?ContextNodeProperty . }"); + + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Position . " + + " ?c core:positionForPerson ?f . ?f rdfs:label ?ContextNodeProperty . }"); + + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Position . " + + " ?c core:positionInOrganization ?i . ?i rdfs:label ?ContextNodeProperty . }"); + + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Position . " + + " ?c core:titleOrRole ?ContextNodeProperty . }"); + + queryList.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 . }"); + + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Relationship . " + + " ?c core:degreeCandidacy ?e . ?e rdfs:label ?ContextNodeProperty . }"); + + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Relationship . " + + " ?c core:linkedAuthor ?f . ?f rdfs:label ?ContextNodeProperty . }"); + + queryList.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 . }"); + + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:AwardReceipt . " + + " ?c core:awardConferredBy ?d . ?d rdfs:label ?ContextNodeProperty . }"); + + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:AwardReceipt . " + + " ?c core:awardOrHonorFor ?e . ?e rdfs:label ?ContextNodeProperty . }"); + + queryList.add(prefix + "SELECT " + + "(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:AwardReceipt . " + + " ?c core:description ?ContextNodeProperty . }"); + + queryList.add(prefix + "SELECT DISTINCT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Role ; core:roleIn ?Organization ." + + " ?Organization rdfs:label ?ContextNodeProperty . " + + " } ORDER BY ?ContextNodeProperty "); + + queryList.add(prefix + "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:EducationalTraining . " + + " ?c core:degreeEarned ?d . ?d rdfs:label ?ContextNodeProperty ." + + " }"); + + queryList.add(prefix + "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:EducationalTraining . " + + " ?c core:degreeEarned ?d . ?d core:abbreviation ?ContextNodeProperty ." + + " }"); + + queryList.add(prefix + "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:EducationalTraining . " + + " ?c core:majorField ?ContextNodeProperty ." + + " }"); + queryList.add(prefix + "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:EducationalTraining . " + + " ?c core:departmentOrSchool ?ContextNodeProperty ." + + " }"); + + queryList.add(prefix + "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:EducationalTraining . " + + " ?c core:trainingAtOrganization ?e . ?e rdfs:label ?ContextNodeProperty . " + + " }"); + } + + private Log log = LogFactory.getLog(ContextNodeFields.class); + + private Dataset dataset; + + + public ContextNodeFields(Dataset dataset){ + this.dataset = dataset; } @@ -63,73 +177,76 @@ public class ContextNodeFields implements DocumentModifier{ objectProperties.append(" "); + objectProperties.append(getPropertiesAssociatedWithContextNodes(individual.getURI())); // objectProperties.append(getPropertiesAssociatedWithEducationalTraining(individual.getURI())); // objectProperties.append(" "); // properties related to core:EducationalTraining - objectProperties.append(getAcademicDegreeLabelAndAbbreviation(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getMajorField(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getDepartmentOrSchool(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getTrainingAtOrganization(individual.getURI())); - objectProperties.append(" "); - - - objectProperties.append(getPropertiesAssociatedWithRole(individual.getURI())); - objectProperties.append(" "); +// objectProperties.append(getAcademicDegreeLabelAndAbbreviation(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getMajorField(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getDepartmentOrSchool(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getTrainingAtOrganization(individual.getURI())); +// objectProperties.append(" "); +// +// +// objectProperties.append(getPropertiesAssociatedWithRole(individual.getURI())); +// objectProperties.append(" "); // objectProperties.append(getPropertiesAssociatedWithPosition(individual.getURI())); // objectProperties.append(" "); //properties related to core:Position - objectProperties.append(getHRJobTitle(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getPositionForPerson(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getPositionInOrganization(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getTitleOrRole(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getInvolvedOrganizationName(individual.getURI())); - objectProperties.append(" "); +// objectProperties.append(getHRJobTitle(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getPositionForPerson(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getPositionInOrganization(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getTitleOrRole(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getInvolvedOrganizationName(individual.getURI())); +// objectProperties.append(" "); // objectProperties.append(getPropertiesAssociatedWithRelationship(individual.getURI())); // objectProperties.append(" "); //properties related to core:Relationship - objectProperties.append(getLinkedAuthor(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getLinkedInformationResource(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getAdvisee(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getDegreeCandidacy(individual.getURI())); - objectProperties.append(" "); +// objectProperties.append(getLinkedAuthor(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getLinkedInformationResource(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getAdvisee(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getDegreeCandidacy(individual.getURI())); +// objectProperties.append(" "); // objectProperties.append(getPropertiesAssociatedWithAwardReceipt(individual.getURI())); +// objectProperties.append(" "); + //properties related to core:AwardReceipt - objectProperties.append(getAwardConferredBy(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getAwardOrHonorFor(individual.getURI())); - objectProperties.append(" "); - - objectProperties.append(getDescription(individual.getURI())); - objectProperties.append(" "); +// objectProperties.append(getAwardConferredBy(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getAwardOrHonorFor(individual.getURI())); +// objectProperties.append(" "); +// +// objectProperties.append(getDescription(individual.getURI())); +// objectProperties.append(" "); } @@ -148,7 +265,54 @@ public class ContextNodeFields implements DocumentModifier{ } - //Position related Queries + private Object getPropertiesAssociatedWithContextNodes(String uri) { + + StringBuffer propertyValues = new StringBuffer(); + QuerySolutionMap initialBinding = new QuerySolutionMap(); + Resource uriResource = ResourceFactory.createResource(uri); + + initialBinding.add("uri", uriResource); + + Query sparqlQuery; + dataset.getLock().enterCriticalSection(Lock.READ); + // fullModel.enterCriticalSection(Lock.READ); + try{ + for(String thisQuery : queryList){ + + sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); + + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, dataset, initialBinding); + try{ + ResultSet results = qExec.execSelect(); + + while(results.hasNext()){ + + QuerySolution soln = results.nextSolution(); + RDFNode contextNodeProperty = soln.get("contextNodeProperty"); + if(contextNodeProperty != null){ + propertyValues.append(" " + contextNodeProperty.toString()); + }else{ + log.debug("contextNodeProperty is null "); + } + } + }catch(Throwable t){ + log.error("Error in getPropertiesAssociatedWithContextNodes() "); + } finally{ + qExec.close(); + } + } + }catch(Throwable t){ + log.error(t,t); + }finally{ + dataset.getLock().leaveCriticalSection(); + // fullModel.leaveCriticalSection(); + } + + return propertyValues.toString(); + } + + + //Position related Queries public String getHRJobTitle(String uri){ StringBuffer propertyValues = new StringBuffer(); @@ -164,6 +328,7 @@ public class ContextNodeFields implements DocumentModifier{ " ?c rdf:type core:Position . " + " ?c core:hrJobTitle ?HRJobTitle . }"; + Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); fullModel.enterCriticalSection(Lock.READ); @@ -210,6 +375,8 @@ public class ContextNodeFields implements DocumentModifier{ " ?c rdf:type core:Position . " + " ?c core:involvedOrganizationName ?InvolvedOrganizationName . }"; + + Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); fullModel.enterCriticalSection(Lock.READ); @@ -255,6 +422,7 @@ public class ContextNodeFields implements DocumentModifier{ " ?c rdf:type core:Position . " + " ?c core:positionForPerson ?f . ?f rdfs:label ?PositionForPerson . }"; + Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); fullModel.enterCriticalSection(Lock.READ); @@ -375,100 +543,100 @@ public class ContextNodeFields implements DocumentModifier{ return propertyValues.toString(); } -// public String getPropertiesAssociatedWithPosition(String uri){ -// -// StringBuffer propertyValues = new StringBuffer(); -// -// QuerySolutionMap initialBinding = new QuerySolutionMap(); -// Resource uriResource = ResourceFactory.createResource(uri); -// -// initialBinding.add("uri", uriResource); -// -// String thisQuery = prefix + -// "SELECT " + -// "(str(?HRJobTitle) as ?hrJobTitle) (str(?InvolvedOrganizationName) as ?involvedOrganizationName) " + -// " (str(?PositionForPerson) as ?positionForPerson) (str(?PositionInOrganization) as ?positionInOrganization) " + -// " (str(?TitleOrRole) as ?titleOrRole) WHERE {" //(str(?PositionLabel) as ?positionLabel) -// -// + "?uri rdf:type foaf:Agent ; ?b ?c . " -// + " ?c rdf:type core:Position . " -// -// + " OPTIONAL { ?c core:hrJobTitle ?HRJobTitle . } . " -// + " OPTIONAL { ?c core:involvedOrganizationName ?InvolvedOrganizationName . } ." -// + " OPTIONAL { ?c core:positionForPerson ?f . ?f rdfs:label ?PositionForPerson . } . " -// + " OPTIONAL { ?c core:positionInOrganization ?i . ?i rdfs:label ?PositionInOrganization . } . " -// + " OPTIONAL { ?c core:titleOrRole ?TitleOrRole . } . " -// //+ " OPTIONAL { ?c rdfs:label ?PositionLabel . } " -// -// + " } ORDER BY ?PositionLabel "; -// -// Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); -// fullModel.enterCriticalSection(Lock.READ); -// -// try{ -// QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); -// try{ -// -// ResultSet results = qExec.execSelect(); -// -// while(results.hasNext()){ -// -// QuerySolution soln = results.nextSolution(); -// -// RDFNode hrJobTitle = soln.get("hrJobTitle"); -// if(hrJobTitle != null){ -// propertyValues.append(" " + hrJobTitle.toString()); -// }else{ -// log.debug("hrJobTitle is null "); -// } -// -// RDFNode involvedOrganizationName = soln.get("involvedOrganizationName"); -// if(involvedOrganizationName != null){ -// propertyValues.append(" " + involvedOrganizationName.toString()); -// }else{ -// log.debug("involvedOrganizationName is null "); -// } -// -// RDFNode positionForPerson = soln.get("positionForPerson"); -// if(positionForPerson != null){ -// propertyValues.append(" " + positionForPerson.toString()); -// }else{ -// log.debug("positionForPerson is null "); -// } -// -// RDFNode positionInOrganization = soln.get("positionInOrganization"); -// if(positionInOrganization != null){ -// propertyValues.append(" " + positionInOrganization.toString()); -// }else{ -// log.debug("positionInOrganization is null "); -// } -// -// RDFNode titleOrRole = soln.get("titleOrRole"); -// if(titleOrRole != null){ -// propertyValues.append(" " + titleOrRole.toString()); -// }else{ -// log.debug("titleOrRole is null "); -// } -// -// /*RDFNode positionLabel = soln.get("positionLabel"); -// if(positionLabel != null){ -// propertyValues.append(" " + positionLabel.toString()); -// }else{ -// log.debug("positionLabel is null "); -// }*/ -// -// } -// }catch(Throwable t){ -// log.error(t,t); -// } finally{ -// qExec.close(); -// } -// }finally{ -// fullModel.leaveCriticalSection(); -// } -// -// return propertyValues.toString(); -// } + public String getPropertiesAssociatedWithPosition(String uri){ + + StringBuffer propertyValues = new StringBuffer(); + + QuerySolutionMap initialBinding = new QuerySolutionMap(); + Resource uriResource = ResourceFactory.createResource(uri); + + initialBinding.add("uri", uriResource); + + String thisQuery = prefix + + "SELECT " + + "(str(?HRJobTitle) as ?hrJobTitle) (str(?InvolvedOrganizationName) as ?involvedOrganizationName) " + + " (str(?PositionForPerson) as ?positionForPerson) (str(?PositionInOrganization) as ?positionInOrganization) " + + " (str(?TitleOrRole) as ?titleOrRole) WHERE {" //(str(?PositionLabel) as ?positionLabel) + + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Position . " + + + " OPTIONAL { ?c core:hrJobTitle ?HRJobTitle . } . " + + " OPTIONAL { ?c core:involvedOrganizationName ?InvolvedOrganizationName . } ." + + " OPTIONAL { ?c core:positionForPerson ?f . ?f rdfs:label ?PositionForPerson . } . " + + " OPTIONAL { ?c core:positionInOrganization ?i . ?i rdfs:label ?PositionInOrganization . } . " + + " OPTIONAL { ?c core:titleOrRole ?TitleOrRole . } . " + //+ " OPTIONAL { ?c rdfs:label ?PositionLabel . } " + + + " } ORDER BY ?PositionLabel "; + + Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); + fullModel.enterCriticalSection(Lock.READ); + + try{ + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); + try{ + + ResultSet results = qExec.execSelect(); + + while(results.hasNext()){ + + QuerySolution soln = results.nextSolution(); + + RDFNode hrJobTitle = soln.get("hrJobTitle"); + if(hrJobTitle != null){ + propertyValues.append(" " + hrJobTitle.toString()); + }else{ + log.debug("hrJobTitle is null "); + } + + RDFNode involvedOrganizationName = soln.get("involvedOrganizationName"); + if(involvedOrganizationName != null){ + propertyValues.append(" " + involvedOrganizationName.toString()); + }else{ + log.debug("involvedOrganizationName is null "); + } + + RDFNode positionForPerson = soln.get("positionForPerson"); + if(positionForPerson != null){ + propertyValues.append(" " + positionForPerson.toString()); + }else{ + log.debug("positionForPerson is null "); + } + + RDFNode positionInOrganization = soln.get("positionInOrganization"); + if(positionInOrganization != null){ + propertyValues.append(" " + positionInOrganization.toString()); + }else{ + log.debug("positionInOrganization is null "); + } + + RDFNode titleOrRole = soln.get("titleOrRole"); + if(titleOrRole != null){ + propertyValues.append(" " + titleOrRole.toString()); + }else{ + log.debug("titleOrRole is null "); + } + + /*RDFNode positionLabel = soln.get("positionLabel"); + if(positionLabel != null){ + propertyValues.append(" " + positionLabel.toString()); + }else{ + log.debug("positionLabel is null "); + }*/ + + } + }catch(Throwable t){ + log.error(t,t); + } finally{ + qExec.close(); + } + }finally{ + fullModel.leaveCriticalSection(); + } + + return propertyValues.toString(); + } @@ -659,82 +827,82 @@ public class ContextNodeFields implements DocumentModifier{ } -// public String getPropertiesAssociatedWithRelationship(String uri){ -// -// StringBuffer propertyValues = new StringBuffer(); -// -// QuerySolutionMap initialBinding = new QuerySolutionMap(); -// Resource uriResource = ResourceFactory.createResource(uri); -// -// initialBinding.add("uri", uriResource); -// -// String thisQuery = prefix + -// "SELECT (str(?Advisee) as ?advisee) (str(?DegreeCandidacy) as ?degreeCandidacy) " + -// " (str(?LinkedAuthor) as ?linkedAuthor) (str(?LinkedInformationResource) as ?linkedInformationResource) WHERE {" -// -// + "?uri rdf:type foaf:Agent ; ?b ?c . " -// + " ?c rdf:type core:Relationship . " -// -// + " OPTIONAL { ?c core:advisee ?d . ?d rdfs:label ?Advisee . } . " -// + " OPTIONAL { ?c core:degreeCandidacy ?e . ?e rdfs:label ?DegreeCandidacy . } ." -// + " OPTIONAL { ?c core:linkedAuthor ?f . ?f rdfs:label ?LinkedAuthor . } . " -// + " OPTIONAL { ?c core:linkedInformationResource ?h . ?h rdfs:label ?LinkedInformationResource . } . " -// -// + " } "; -// -// Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); -// fullModel.enterCriticalSection(Lock.READ); -// -// try{ -// QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); -// try{ -// -// ResultSet results = qExec.execSelect(); -// -// while(results.hasNext()){ -// -// QuerySolution soln = results.nextSolution(); -// -// RDFNode advisee = soln.get("advisee"); -// if(advisee != null){ -// propertyValues.append(" " + advisee.toString()); -// }else{ -// log.debug("advisee is null "); -// } -// -// RDFNode degreeCandidacy = soln.get("degreeCandidacy"); -// if(degreeCandidacy != null){ -// propertyValues.append(" " + degreeCandidacy.toString()); -// }else{ -// log.debug("degreeCandidacy is null "); -// } -// -// RDFNode linkedAuthor = soln.get("linkedAuthor"); -// if(linkedAuthor != null){ -// propertyValues.append(" " + linkedAuthor.toString()); -// }else{ -// log.debug("linkedAuthor is null "); -// } -// -// RDFNode linkedInformationResource = soln.get("linkedInformationResource"); -// if(linkedInformationResource != null){ -// propertyValues.append(" " + linkedInformationResource.toString()); -// }else{ -// log.debug("linkedInformationResource is null "); -// } -// -// } -// }catch(Throwable t){ -// log.error(t,t); -// } finally{ -// qExec.close(); -// } -// }finally{ -// fullModel.leaveCriticalSection(); -// } -// -// return propertyValues.toString(); -// } + public String getPropertiesAssociatedWithRelationship(String uri){ + + StringBuffer propertyValues = new StringBuffer(); + + QuerySolutionMap initialBinding = new QuerySolutionMap(); + Resource uriResource = ResourceFactory.createResource(uri); + + initialBinding.add("uri", uriResource); + + String thisQuery = prefix + + "SELECT (str(?Advisee) as ?advisee) (str(?DegreeCandidacy) as ?degreeCandidacy) " + + " (str(?LinkedAuthor) as ?linkedAuthor) (str(?LinkedInformationResource) as ?linkedInformationResource) WHERE {" + + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:Relationship . " + + + " OPTIONAL { ?c core:advisee ?d . ?d rdfs:label ?Advisee . } . " + + " OPTIONAL { ?c core:degreeCandidacy ?e . ?e rdfs:label ?DegreeCandidacy . } ." + + " OPTIONAL { ?c core:linkedAuthor ?f . ?f rdfs:label ?LinkedAuthor . } . " + + " OPTIONAL { ?c core:linkedInformationResource ?h . ?h rdfs:label ?LinkedInformationResource . } . " + + + " } "; + + Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); + fullModel.enterCriticalSection(Lock.READ); + + try{ + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); + try{ + + ResultSet results = qExec.execSelect(); + + while(results.hasNext()){ + + QuerySolution soln = results.nextSolution(); + + RDFNode advisee = soln.get("advisee"); + if(advisee != null){ + propertyValues.append(" " + advisee.toString()); + }else{ + log.debug("advisee is null "); + } + + RDFNode degreeCandidacy = soln.get("degreeCandidacy"); + if(degreeCandidacy != null){ + propertyValues.append(" " + degreeCandidacy.toString()); + }else{ + log.debug("degreeCandidacy is null "); + } + + RDFNode linkedAuthor = soln.get("linkedAuthor"); + if(linkedAuthor != null){ + propertyValues.append(" " + linkedAuthor.toString()); + }else{ + log.debug("linkedAuthor is null "); + } + + RDFNode linkedInformationResource = soln.get("linkedInformationResource"); + if(linkedInformationResource != null){ + propertyValues.append(" " + linkedInformationResource.toString()); + }else{ + log.debug("linkedInformationResource is null "); + } + + } + }catch(Throwable t){ + log.error(t,t); + } finally{ + qExec.close(); + } + }finally{ + fullModel.leaveCriticalSection(); + } + + return propertyValues.toString(); + } public String getAwardConferredBy(String uri){ @@ -877,82 +1045,82 @@ public class ContextNodeFields implements DocumentModifier{ } -// public String getPropertiesAssociatedWithAwardReceipt(String uri){ -// -// StringBuffer propertyValues = new StringBuffer(); -// -// QuerySolutionMap initialBinding = new QuerySolutionMap(); -// Resource uriResource = ResourceFactory.createResource(uri); -// -// initialBinding.add("uri", uriResource); -// -// String thisQuery = prefix + -// "SELECT (str(?AwardConferredBy) as ?awardConferredBy) (str(?AwardOrHonorFor) as ?awardOrHonorFor) " + -// " (str(?Description) as ?description) WHERE {" //(str(?AwardReceiptLabel) as ?awardReceiptLabel) -// -// + "?uri rdf:type foaf:Agent ; ?b ?c . " -// + " ?c rdf:type core:AwardReceipt . " -// -// + " OPTIONAL { ?c core:awardConferredBy ?d . ?d rdfs:label ?AwardConferredBy } . " -// + " OPTIONAL { ?c core:awardOrHonorFor ?e . ?e rdfs:label ?AwardOrHonorFor } ." -// + " OPTIONAL { ?c core:description ?Description . } . " -// //+ " OPTIONAL { ?c rdfs:label ?AwardReceiptLabel . } . " -// -// + " } ORDER BY ?AwardReceiptLabel"; -// -// Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); -// fullModel.enterCriticalSection(Lock.READ); -// -// try{ -// QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); -// try{ -// -// ResultSet results = qExec.execSelect(); -// -// while(results.hasNext()){ -// -// QuerySolution soln = results.nextSolution(); -// -// RDFNode awardConferredBy = soln.get("awardConferredBy"); -// if(awardConferredBy != null){ -// propertyValues.append(" " + awardConferredBy.toString()); -// }else{ -// log.debug("awardConferredBy is null "); -// } -// -// RDFNode awardOrHonorFor = soln.get("awardOrHonorFor"); -// if(awardOrHonorFor != null){ -// propertyValues.append(" " + awardOrHonorFor.toString()); -// }else{ -// log.debug("awardOrHonorFor is null "); -// } -// -// RDFNode description = soln.get("description"); -// if(description != null){ -// propertyValues.append(" " + description.toString()); -// }else{ -// log.debug("description is null "); -// } -// -// /*RDFNode awardReceiptLabel = soln.get("awardReceiptLabel"); -// if(awardReceiptLabel != null){ -// propertyValues.append(" " + awardReceiptLabel.toString()); -// }else{ -// log.debug("awardReceiptLabel is null "); -// }*/ -// -// } -// }catch(Throwable t){ -// log.error(t,t); -// } finally{ -// qExec.close(); -// } -// }finally{ -// fullModel.leaveCriticalSection(); -// } -// -// return propertyValues.toString(); -// } + public String getPropertiesAssociatedWithAwardReceipt(String uri){ + + StringBuffer propertyValues = new StringBuffer(); + + QuerySolutionMap initialBinding = new QuerySolutionMap(); + Resource uriResource = ResourceFactory.createResource(uri); + + initialBinding.add("uri", uriResource); + + String thisQuery = prefix + + "SELECT (str(?AwardConferredBy) as ?awardConferredBy) (str(?AwardOrHonorFor) as ?awardOrHonorFor) " + + " (str(?Description) as ?description) WHERE {" //(str(?AwardReceiptLabel) as ?awardReceiptLabel) + + + "?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:AwardReceipt . " + + + " OPTIONAL { ?c core:awardConferredBy ?d . ?d rdfs:label ?AwardConferredBy } . " + + " OPTIONAL { ?c core:awardOrHonorFor ?e . ?e rdfs:label ?AwardOrHonorFor } ." + + " OPTIONAL { ?c core:description ?Description . } . " + //+ " OPTIONAL { ?c rdfs:label ?AwardReceiptLabel . } . " + + + " } ORDER BY ?AwardReceiptLabel"; + + Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); + fullModel.enterCriticalSection(Lock.READ); + + try{ + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); + try{ + + ResultSet results = qExec.execSelect(); + + while(results.hasNext()){ + + QuerySolution soln = results.nextSolution(); + + RDFNode awardConferredBy = soln.get("awardConferredBy"); + if(awardConferredBy != null){ + propertyValues.append(" " + awardConferredBy.toString()); + }else{ + log.debug("awardConferredBy is null "); + } + + RDFNode awardOrHonorFor = soln.get("awardOrHonorFor"); + if(awardOrHonorFor != null){ + propertyValues.append(" " + awardOrHonorFor.toString()); + }else{ + log.debug("awardOrHonorFor is null "); + } + + RDFNode description = soln.get("description"); + if(description != null){ + propertyValues.append(" " + description.toString()); + }else{ + log.debug("description is null "); + } + + /*RDFNode awardReceiptLabel = soln.get("awardReceiptLabel"); + if(awardReceiptLabel != null){ + propertyValues.append(" " + awardReceiptLabel.toString()); + }else{ + log.debug("awardReceiptLabel is null "); + }*/ + + } + }catch(Throwable t){ + log.error(t,t); + } finally{ + qExec.close(); + } + }finally{ + fullModel.leaveCriticalSection(); + } + + return propertyValues.toString(); + } public String getPropertiesAssociatedWithRole(String uri){ @@ -1211,90 +1379,90 @@ public class ContextNodeFields implements DocumentModifier{ return propertyValues.toString(); } -// public String getPropertiesAssociatedWithEducationalTraining(String uri){ -// -// StringBuffer propertyValues = new StringBuffer(); -// -// QuerySolutionMap initialBinding = new QuerySolutionMap(); -// Resource uriResource = ResourceFactory.createResource(uri); -// -// initialBinding.add("uri", uriResource); -// -// String thisQuery = prefix + -// "SELECT (str(?AcademicDegreeLabel) as ?academicDegreeLabel) (str(?AcademicDegreeAbbreviation) as ?academicDegreeAbbreviation) " -// + "(str(?MajorField) as ?majorField) (str(?DepartmentOrSchool) as ?departmentOrSchool) " + -// "(str(?TrainingAtOrganizationLabel) as ?trainingAtOrganizationLabel) WHERE {" -// -// + " ?uri rdf:type foaf:Agent ; ?b ?c . " -// + " ?c rdf:type core:EducationalTraining . " -// -// + "OPTIONAL { ?c core:degreeEarned ?d . ?d rdfs:label ?AcademicDegreeLabel ; core:abbreviation ?AcademicDegreeAbbreviation . } . " -// + "OPTIONAL { ?c core:majorField ?MajorField .} ." -// + " OPTIONAL { ?c core:departmentOrSchool ?DepartmentOrSchool . }" -// + " OPTIONAL { ?c core:trainingAtOrganization ?e . ?e rdfs:label ?TrainingAtOrganizationLabel . } . " -// -// +"}"; -// -// Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); -// fullModel.enterCriticalSection(Lock.READ); -// -// try{ -// QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); -// try{ -// -// ResultSet results = qExec.execSelect(); -// -// while(results.hasNext()){ -// -// QuerySolution soln = results.nextSolution(); -// -// RDFNode academicDegreeLabel = soln.get("academicDegreeLabel"); -// if(academicDegreeLabel != null){ -// propertyValues.append(" " + academicDegreeLabel.toString()); -// }else{ -// log.debug("academicDegreeLabel is null "); -// } -// -// RDFNode academicDegreeAbbreviation = soln.get("academicDegreeAbbreviation"); -// if(academicDegreeAbbreviation != null){ -// propertyValues.append(" " + academicDegreeAbbreviation.toString()); -// }else{ -// log.debug("academicDegreeAbbreviation is null "); -// } -// -// RDFNode majorField = soln.get("majorField"); -// if(majorField != null){ -// propertyValues.append(" " + majorField.toString()); -// }else{ -// log.debug("majorField is null "); -// } -// -// RDFNode trainingAtDepartmentOrSchool = soln.get("departmentOrSchool"); -// if(trainingAtDepartmentOrSchool != null){ -// propertyValues.append(" " + trainingAtDepartmentOrSchool.toString()); -// }else{ -// log.debug("trainingAtDepartmentOrSchool is null "); -// } -// -// RDFNode trainingAtOrganizationLabel = soln.get("trainingAtOrganizationLabel"); -// if(trainingAtOrganizationLabel != null){ -// propertyValues.append(" " + trainingAtOrganizationLabel.toString()); -// }else{ -// log.debug("trainingAtOrganizationLabel is null "); -// } -// -// } -// }catch(Throwable t){ -// log.error(t,t); -// } finally{ -// qExec.close(); -// } -// }finally{ -// fullModel.leaveCriticalSection(); -// } -// return propertyValues.toString(); -// -// } + public String getPropertiesAssociatedWithEducationalTraining(String uri){ + + StringBuffer propertyValues = new StringBuffer(); + + QuerySolutionMap initialBinding = new QuerySolutionMap(); + Resource uriResource = ResourceFactory.createResource(uri); + + initialBinding.add("uri", uriResource); + + String thisQuery = prefix + + "SELECT (str(?AcademicDegreeLabel) as ?academicDegreeLabel) (str(?AcademicDegreeAbbreviation) as ?academicDegreeAbbreviation) " + + "(str(?MajorField) as ?majorField) (str(?DepartmentOrSchool) as ?departmentOrSchool) " + + "(str(?TrainingAtOrganizationLabel) as ?trainingAtOrganizationLabel) WHERE {" + + + " ?uri rdf:type foaf:Agent ; ?b ?c . " + + " ?c rdf:type core:EducationalTraining . " + + + "OPTIONAL { ?c core:degreeEarned ?d . ?d rdfs:label ?AcademicDegreeLabel ; core:abbreviation ?AcademicDegreeAbbreviation . } . " + + "OPTIONAL { ?c core:majorField ?MajorField .} ." + + " OPTIONAL { ?c core:departmentOrSchool ?DepartmentOrSchool . }" + + " OPTIONAL { ?c core:trainingAtOrganization ?e . ?e rdfs:label ?TrainingAtOrganizationLabel . } . " + + +"}"; + + Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); + fullModel.enterCriticalSection(Lock.READ); + + try{ + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); + try{ + + ResultSet results = qExec.execSelect(); + + while(results.hasNext()){ + + QuerySolution soln = results.nextSolution(); + + RDFNode academicDegreeLabel = soln.get("academicDegreeLabel"); + if(academicDegreeLabel != null){ + propertyValues.append(" " + academicDegreeLabel.toString()); + }else{ + log.debug("academicDegreeLabel is null "); + } + + RDFNode academicDegreeAbbreviation = soln.get("academicDegreeAbbreviation"); + if(academicDegreeAbbreviation != null){ + propertyValues.append(" " + academicDegreeAbbreviation.toString()); + }else{ + log.debug("academicDegreeAbbreviation is null "); + } + + RDFNode majorField = soln.get("majorField"); + if(majorField != null){ + propertyValues.append(" " + majorField.toString()); + }else{ + log.debug("majorField is null "); + } + + RDFNode trainingAtDepartmentOrSchool = soln.get("departmentOrSchool"); + if(trainingAtDepartmentOrSchool != null){ + propertyValues.append(" " + trainingAtDepartmentOrSchool.toString()); + }else{ + log.debug("trainingAtDepartmentOrSchool is null "); + } + + RDFNode trainingAtOrganizationLabel = soln.get("trainingAtOrganizationLabel"); + if(trainingAtOrganizationLabel != null){ + propertyValues.append(" " + trainingAtOrganizationLabel.toString()); + }else{ + log.debug("trainingAtOrganizationLabel is null "); + } + + } + }catch(Throwable t){ + log.error(t,t); + } finally{ + qExec.close(); + } + }finally{ + fullModel.leaveCriticalSection(); + } + return propertyValues.toString(); + + } @@ -1314,10 +1482,11 @@ public class ContextNodeFields implements DocumentModifier{ + "?b rdfs:label ?LinkedAuthor . ?d rdfs:label ?LinkedInformationResource . }"; Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); - fullModel.enterCriticalSection(Lock.READ); + dataset.getLock().enterCriticalSection(Lock.READ); + // fullModel.enterCriticalSection(Lock.READ); try{ - QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, dataset, initialBinding); try{ ResultSet results = qExec.execSelect(); @@ -1347,7 +1516,8 @@ public class ContextNodeFields implements DocumentModifier{ qExec.close(); } }finally{ - fullModel.leaveCriticalSection(); +// fullModel.leaveCriticalSection(); + dataset.getLock().leaveCriticalSection(); } return propertyValues.toString(); @@ -1370,10 +1540,11 @@ public class ContextNodeFields implements DocumentModifier{ + "}"; Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); - fullModel.enterCriticalSection(Lock.READ); + dataset.getLock().enterCriticalSection(Lock.READ); + // fullModel.enterCriticalSection(Lock.READ); try{ - QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, dataset, initialBinding); try{ ResultSet results = qExec.execSelect(); @@ -1396,7 +1567,8 @@ public class ContextNodeFields implements DocumentModifier{ qExec.close(); } }finally{ - fullModel.leaveCriticalSection(); + // fullModel.leaveCriticalSection(); + dataset.getLock().leaveCriticalSection(); } return propertyValues.toString(); @@ -1419,10 +1591,11 @@ public class ContextNodeFields implements DocumentModifier{ + "}"; Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); - fullModel.enterCriticalSection(Lock.READ); + dataset.getLock().enterCriticalSection(Lock.READ); + // fullModel.enterCriticalSection(Lock.READ); try{ - QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, dataset, initialBinding); try{ ResultSet results = qExec.execSelect(); @@ -1452,7 +1625,8 @@ public class ContextNodeFields implements DocumentModifier{ qExec.close(); } }finally{ - fullModel.leaveCriticalSection(); + dataset.getLock().leaveCriticalSection(); +// fullModel.leaveCriticalSection(); } return propertyValues.toString(); @@ -1474,10 +1648,11 @@ public class ContextNodeFields implements DocumentModifier{ + "}"; Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); - fullModel.enterCriticalSection(Lock.READ); + dataset.getLock().enterCriticalSection(Lock.READ); +// fullModel.enterCriticalSection(Lock.READ); try{ - QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, dataset, initialBinding); try{ ResultSet results = qExec.execSelect(); @@ -1500,103 +1675,105 @@ public class ContextNodeFields implements DocumentModifier{ qExec.close(); } }finally{ - fullModel.leaveCriticalSection(); + dataset.getLock().leaveCriticalSection(); +// fullModel.leaveCriticalSection(); } return propertyValues.toString(); } -// public String getPropertiesAssociatedWithInformationResource(String uri){ -// -// StringBuffer propertyValues = new StringBuffer(); -// -// QuerySolutionMap initialBinding = new QuerySolutionMap(); -// Resource uriResource = ResourceFactory.createResource(uri); -// -// initialBinding.add("uri", uriResource); -// -// String thisQuery = prefix + -// "SELECT (str(?LinkedAuthor) as ?linkedAuthor) (str(?LinkedInformationResource) as ?linkedInformationResource) " -// + "(str(?Editor) as ?editor) (str(?SubjectArea) as ?subjectArea) (str(?ResearchAreaOf) as ?researchAreaOf) " + -// "(str(?Features) as ?features) WHERE {" -// -// + " ?uri rdf:type core:InformationResource . " -// -// + "OPTIONAL { ?uri core:informationResourceInAuthorship ?a . ?a core:linkedAuthor ?b ; core:linkedInformationResource ?d ." + -// "?b rdfs:label ?LinkedAuthor . ?d rdfs:label ?LinkedInformationResource } . " -// + "OPTIONAL { ?uri bibo:editor ?e . ?e rdfs:label ?Editor . } ." -// + " OPTIONAL { ?uri core:hasSubjectArea ?f . ?f rdfs:label ?SubjectArea ; core:researchAreaOf ?h . ?h rdfs:label ?ResearchAreaOf . } " -// + " OPTIONAL { ?uri core:features ?i . ?i rdfs:label ?Features . } . " -// -// +"}"; -// -// Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); -// fullModel.enterCriticalSection(Lock.READ); -// -// try{ -// QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); -// try{ -// -// ResultSet results = qExec.execSelect(); -// -// while(results.hasNext()){ -// -// QuerySolution soln = results.nextSolution(); -// -// RDFNode linkedAuthor = soln.get("linkedAuthor"); -// if(linkedAuthor != null){ -// propertyValues.append(" publications " + linkedAuthor.toString() + " publications "); -// }else{ -// log.debug("linkedAuthor is null "); -// } -// -// RDFNode linkedInformationResource = soln.get("linkedInformationResource"); -// if(linkedInformationResource != null){ -// propertyValues.append(" " + linkedInformationResource.toString()); -// }else{ -// log.debug("linkedInformationResource is null "); -// } -// -// RDFNode editor = soln.get("editor"); -// if(editor != null){ -// propertyValues.append(" " + editor.toString()); -// }else{ -// log.debug("editor is null "); -// } -// -// RDFNode subjectArea = soln.get("subjectArea"); -// if(subjectArea != null){ -// propertyValues.append(" " + subjectArea.toString()); -// }else{ -// log.debug("subjectArea is null "); -// } -// -// RDFNode researchAreaOf = soln.get("researchAreaOf"); -// if(researchAreaOf != null){ -// propertyValues.append(" " + researchAreaOf.toString()); -// }else{ -// log.debug("researchAreaOf is null "); -// } -// -// RDFNode features = soln.get("features"); -// if(features != null){ -// propertyValues.append(" publications " + features.toString() + " publications "); -// }else{ -// log.debug("features is null "); -// } -// -// } -// }catch(Throwable t){ -// log.error(t,t); -// } finally{ -// qExec.close(); -// } -// }finally{ -// fullModel.leaveCriticalSection(); -// } -// return propertyValues.toString(); -// -// } + public String getPropertiesAssociatedWithInformationResource(String uri){ + + StringBuffer propertyValues = new StringBuffer(); + + QuerySolutionMap initialBinding = new QuerySolutionMap(); + Resource uriResource = ResourceFactory.createResource(uri); + + initialBinding.add("uri", uriResource); + + String thisQuery = prefix + + "SELECT (str(?LinkedAuthor) as ?linkedAuthor) (str(?LinkedInformationResource) as ?linkedInformationResource) " + + "(str(?Editor) as ?editor) (str(?SubjectArea) as ?subjectArea) (str(?ResearchAreaOf) as ?researchAreaOf) " + + "(str(?Features) as ?features) WHERE {" + + + " ?uri rdf:type core:InformationResource . " + + + "OPTIONAL { ?uri core:informationResourceInAuthorship ?a . ?a core:linkedAuthor ?b ; core:linkedInformationResource ?d ." + + "?b rdfs:label ?LinkedAuthor . ?d rdfs:label ?LinkedInformationResource } . " + + "OPTIONAL { ?uri bibo:editor ?e . ?e rdfs:label ?Editor . } ." + + " OPTIONAL { ?uri core:hasSubjectArea ?f . ?f rdfs:label ?SubjectArea ; core:researchAreaOf ?h . ?h rdfs:label ?ResearchAreaOf . } " + + " OPTIONAL { ?uri core:features ?i . ?i rdfs:label ?Features . } . " + + +"}"; + + Query sparqlQuery = QueryFactory.create(thisQuery, Syntax.syntaxARQ); + fullModel.enterCriticalSection(Lock.READ); + + try{ + QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, fullModel, initialBinding); + try{ + + ResultSet results = qExec.execSelect(); + + while(results.hasNext()){ + + QuerySolution soln = results.nextSolution(); + + RDFNode linkedAuthor = soln.get("linkedAuthor"); + if(linkedAuthor != null){ + propertyValues.append(" publications " + linkedAuthor.toString() + " publications "); + }else{ + log.debug("linkedAuthor is null "); + } + + RDFNode linkedInformationResource = soln.get("linkedInformationResource"); + if(linkedInformationResource != null){ + propertyValues.append(" " + linkedInformationResource.toString()); + }else{ + log.debug("linkedInformationResource is null "); + } + + RDFNode editor = soln.get("editor"); + if(editor != null){ + propertyValues.append(" " + editor.toString()); + }else{ + log.debug("editor is null "); + } + + RDFNode subjectArea = soln.get("subjectArea"); + if(subjectArea != null){ + propertyValues.append(" " + subjectArea.toString()); + }else{ + log.debug("subjectArea is null "); + } + + RDFNode researchAreaOf = soln.get("researchAreaOf"); + if(researchAreaOf != null){ + propertyValues.append(" " + researchAreaOf.toString()); + }else{ + log.debug("researchAreaOf is null "); + } + + RDFNode features = soln.get("features"); + if(features != null){ + propertyValues.append(" publications " + features.toString() + " publications "); + }else{ + log.debug("features is null "); + } + + } + }catch(Throwable t){ + log.error(t,t); + } finally{ + qExec.close(); + } + }finally{ + fullModel.leaveCriticalSection(); + } + return propertyValues.toString(); + + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java index 17fa5d840..30c3b9cba 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java @@ -14,6 +14,7 @@ import org.apache.solr.client.solrj.SolrServer; import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; import com.hp.hpl.jena.ontology.OntModel; +import com.hp.hpl.jena.query.Dataset; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; @@ -21,8 +22,10 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters; +import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDao; import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; import edu.cornell.mannlib.vitro.webapp.dao.jena.SearchReindexingListener; +import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; import edu.cornell.mannlib.vitro.webapp.search.beans.IndividualProhibitedFromSearchImpl; import edu.cornell.mannlib.vitro.webapp.search.beans.ObjectSourceIface; import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch; @@ -66,9 +69,14 @@ public class SolrSetup implements javax.servlet.ServletContextListener{ //first we need a ent2luceneDoc translator OntModel displayOntModel = (OntModel) sce.getServletContext().getAttribute("displayOntModel"); + OntModel abox = ModelContext.getBaseOntModelSelector(context).getABoxModel(); + + OntModel inferences = (OntModel)context.getAttribute( JenaBaseDao.INFERENCE_ONT_MODEL_ATTRIBUTE_NAME); + Dataset dataset = WebappDaoFactoryJena.makeInMemoryDataset(abox, inferences); + List modifiers = new ArrayList(); - modifiers.add(new CalculateParameters(ModelContext.getJenaOntModel(context))); - modifiers.add(new ContextNodeFields(ModelContext.getJenaOntModel(context))); + // modifiers.add(new CalculateParameters(ModelContext.getJenaOntModel(context))); + modifiers.add(new ContextNodeFields( dataset )); IndividualToSolrDocument indToSolrDoc = new IndividualToSolrDocument( new ProhibitedFromSearch(DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel),