[VIVO-1031] Performance improvements to editor management page
This commit is contained in:
parent
5a2b6ee114
commit
5c01cca0ab
1 changed files with 68 additions and 13 deletions
|
@ -12,6 +12,11 @@ import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -308,6 +313,44 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String EDITORSHIPS_MODEL = ""
|
||||||
|
+ "PREFIX core: <http://vivoweb.org/ontology/core#>\n"
|
||||||
|
+ "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>\n"
|
||||||
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
|
||||||
|
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n"
|
||||||
|
+ "CONSTRUCT\n"
|
||||||
|
+ "{\n"
|
||||||
|
+ " ?subject core:relatedBy ?editorshipURI .\n"
|
||||||
|
+ " ?editorshipURI a core:Editorship .\n"
|
||||||
|
+ " ?editorshipURI core:relates ?editorURI .\n"
|
||||||
|
+ " ?editorshipURI core:rank ?rank.\n"
|
||||||
|
+ " ?editorURI a foaf:Person .\n"
|
||||||
|
+ " ?editorURI rdfs:label ?editorName .\n"
|
||||||
|
+ "}\n"
|
||||||
|
+ "WHERE\n"
|
||||||
|
+ "{\n"
|
||||||
|
+ " {\n"
|
||||||
|
+ " ?subject core:relatedBy ?editorshipURI .\n"
|
||||||
|
+ " ?editorshipURI a core:Editorship .\n"
|
||||||
|
+ " ?editorshipURI core:relates ?editorURI .\n"
|
||||||
|
+ " ?editorURI a foaf:Person .\n"
|
||||||
|
+ " }\n"
|
||||||
|
+ " UNION\n"
|
||||||
|
+ " {\n"
|
||||||
|
+ " ?subject core:relatedBy ?editorshipURI .\n"
|
||||||
|
+ " ?editorshipURI a core:Editorship .\n"
|
||||||
|
+ " ?editorshipURI core:relates ?editorURI .\n"
|
||||||
|
+ " ?editorURI a foaf:Person .\n"
|
||||||
|
+ " ?editorURI rdfs:label ?editorName .\n"
|
||||||
|
+ " }\n"
|
||||||
|
+ " UNION\n"
|
||||||
|
+ " {\n"
|
||||||
|
+ " ?subject core:relatedBy ?editorshipURI .\n"
|
||||||
|
+ " ?editorshipURI a core:Editorship .\n"
|
||||||
|
+ " ?editorshipURI core:rank ?rank.\n"
|
||||||
|
+ " }\n"
|
||||||
|
+ "}\n";
|
||||||
|
|
||||||
private static String EDITORSHIPS_QUERY = ""
|
private static String EDITORSHIPS_QUERY = ""
|
||||||
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
||||||
+ "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> \n"
|
+ "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> \n"
|
||||||
|
@ -325,19 +368,31 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
|
|
||||||
|
|
||||||
private List<EditorshipInfo> getExistingEditorships(String subjectUri, VitroRequest vreq) {
|
private List<EditorshipInfo> getExistingEditorships(String subjectUri, VitroRequest vreq) {
|
||||||
|
RDFService rdfService = vreq.getRDFService();
|
||||||
String queryStr = QueryUtils.subUriForQueryVar(this.getEditorshipsQuery(), "subject", subjectUri);
|
|
||||||
log.debug("Query string is: " + queryStr);
|
List<Map<String, String>> editorships = new ArrayList<Map<String, String>>();
|
||||||
List<Map<String, String>> editorships = new ArrayList<Map<String, String>>();
|
try {
|
||||||
try {
|
String constructStr = QueryUtils.subUriForQueryVar(EDITORSHIPS_MODEL, "subject", subjectUri);
|
||||||
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
|
||||||
while (results.hasNext()) {
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
QuerySolution soln = results.nextSolution();
|
rdfService.sparqlConstructQuery(constructStr, constructedModel);
|
||||||
RDFNode node = soln.get("editorshipURI");
|
|
||||||
if (node.isURIResource()) {
|
String queryStr = QueryUtils.subUriForQueryVar(this.getEditorshipsQuery(), "subject", subjectUri);
|
||||||
editorships.add(QueryUtils.querySolutionToStringValueMap(soln));
|
log.debug("Query string is: " + queryStr);
|
||||||
}
|
|
||||||
}
|
QueryExecution qe = QueryExecutionFactory.create(queryStr, constructedModel);
|
||||||
|
try {
|
||||||
|
ResultSet results = qe.execSelect();
|
||||||
|
while (results.hasNext()) {
|
||||||
|
QuerySolution soln = results.nextSolution();
|
||||||
|
RDFNode node = soln.get("editorshipURI");
|
||||||
|
if (node.isURIResource()) {
|
||||||
|
editorships.add(QueryUtils.querySolutionToStringValueMap(soln));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
qe.close();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue