Fixing the code in ContextNodesInclusionFactory. getQueryFromModel() is commented out because there is nothing specified in search.n3 to be read into the model during the startup.
Eventually, all the contextnode queries willl be extracted out into search.n3
This commit is contained in:
parent
f7eb16b7c8
commit
5f8f5fa8f5
1 changed files with 52 additions and 41 deletions
|
@ -26,55 +26,66 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||||
public class ContextNodesInclusionFactory {
|
public class ContextNodesInclusionFactory {
|
||||||
|
|
||||||
private OntModel fullModel;
|
private OntModel fullModel;
|
||||||
private String contextNodeURI;
|
// private String contextNodeURI;
|
||||||
private String query = "";
|
//private String query = "";
|
||||||
|
|
||||||
private static final String queryForEducationalTraining = "SELECT ?query WHERE {" +
|
// private static final String queryForEducationalTraining = "SELECT ?query WHERE {" +
|
||||||
"?searchConfig <"+ DisplayVocabulary.QUERY_FOR_EDUCATIONAL_TRAINING + "> ?query . }";
|
// "?searchConfig <"+ DisplayVocabulary.QUERY_FOR_EDUCATIONAL_TRAINING + "> ?query . }";
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(ContextNodesInclusionFactory.class);
|
private static Log log = LogFactory.getLog(ContextNodesInclusionFactory.class);
|
||||||
|
|
||||||
public ContextNodesInclusionFactory(String contextNodeURI,
|
public ContextNodesInclusionFactory(String contextNodeURI,
|
||||||
OntModel displayOntModel, ServletContext context) {
|
OntModel displayOntModel, ServletContext context) {
|
||||||
this.fullModel = ModelContext.getJenaOntModel(context);
|
this.fullModel = ModelContext.getJenaOntModel(context);
|
||||||
this.contextNodeURI = contextNodeURI;
|
// this.contextNodeURI = contextNodeURI;
|
||||||
query = getQueryFromModel(contextNodeURI, displayOntModel);
|
//query = getQueryFromModel(contextNodeURI, displayOntModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getQueryFromModel(String uri, OntModel displayOntModel) {
|
/*
|
||||||
|
* bk392 : The original idea behind writing up this method was to check
|
||||||
String resultQuery = "";
|
* if I can read the queries from search.n3, write them to the displayOntModel(during startup) and
|
||||||
QuerySolutionMap initialBinding = new QuerySolutionMap();
|
* read them in this class.
|
||||||
Resource searchConfig = ResourceFactory.createResource(uri);
|
*
|
||||||
|
* Eventually, its going to be like that. All these hardcoded queries
|
||||||
initialBinding.add("searchConfig", searchConfig);
|
* will go into search.n3 and will be written into the display model.
|
||||||
|
* ContextNodesInclusionFactors gets the queries out from the display Model
|
||||||
Query query = QueryFactory.create(queryForEducationalTraining);
|
* and fires them, gets the values, concatenates them and passes them back to
|
||||||
displayOntModel.enterCriticalSection(Lock.READ);
|
* IndividualToSolrDoc.
|
||||||
try{
|
*/
|
||||||
QueryExecution qExec = QueryExecutionFactory.create(query, displayOntModel, initialBinding);
|
// private String getQueryFromModel(String uri, OntModel displayOntModel) {
|
||||||
try{
|
//
|
||||||
ResultSet results = qExec.execSelect();
|
// String resultQuery = "";
|
||||||
while(results.hasNext()){
|
// QuerySolutionMap initialBinding = new QuerySolutionMap();
|
||||||
QuerySolution soln = results.nextSolution();
|
// Resource searchConfig = ResourceFactory.createResource(uri);
|
||||||
Literal node = soln.getLiteral("query");
|
//
|
||||||
if(node.isLiteral()){
|
// initialBinding.add("searchConfig", searchConfig);
|
||||||
resultQuery = node.toString();
|
//
|
||||||
}else{
|
// Query query = QueryFactory.create(queryForEducationalTraining);
|
||||||
log.warn("unexpected literal in the object position for context node queries " + node.toString());
|
// displayOntModel.enterCriticalSection(Lock.READ);
|
||||||
}
|
// try{
|
||||||
}
|
// QueryExecution qExec = QueryExecutionFactory.create(query, displayOntModel, initialBinding);
|
||||||
}catch(Throwable t){
|
// try{
|
||||||
log.error(t,t);
|
// ResultSet results = qExec.execSelect();
|
||||||
} finally{
|
// while(results.hasNext()){
|
||||||
qExec.close();
|
// QuerySolution soln = results.nextSolution();
|
||||||
}
|
// Literal node = soln.getLiteral("query");
|
||||||
}finally{
|
// if(node.isLiteral()){
|
||||||
displayOntModel.leaveCriticalSection();
|
// resultQuery = node.toString();
|
||||||
}
|
// }else{
|
||||||
|
// log.warn("unexpected literal in the object position for context node queries " + node.toString());
|
||||||
return resultQuery.substring(0, resultQuery.length() - 3);
|
// }
|
||||||
}
|
// }
|
||||||
|
// }catch(Throwable t){
|
||||||
|
// log.error(t,t);
|
||||||
|
// } finally{
|
||||||
|
// qExec.close();
|
||||||
|
// }
|
||||||
|
// }finally{
|
||||||
|
// displayOntModel.leaveCriticalSection();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return resultQuery.substring(0, resultQuery.length() - 3);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
// public List<Field> getFieldValues(String uri, Model modelToQuery, List<String> queries){
|
// public List<Field> getFieldValues(String uri, Model modelToQuery, List<String> queries){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue