[VIVO-1031] Performance improvement to manage webpages page
This commit is contained in:
parent
48273a8845
commit
5a2b6ee114
2 changed files with 94 additions and 20 deletions
|
@ -447,7 +447,6 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
|
||||
|
||||
private List<AuthorshipInfo> getExistingAuthorships(String subjectUri, VitroRequest vreq) {
|
||||
|
||||
RDFService rdfService = vreq.getRDFService();
|
||||
|
||||
List<Map<String, String>> authorships = new ArrayList<Map<String, String>>();
|
||||
|
@ -461,14 +460,18 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
|||
log.debug("Query string is: " + queryStr);
|
||||
|
||||
QueryExecution qe = QueryExecutionFactory.create(queryStr, constructedModel);
|
||||
ResultSet results = qe.execSelect();
|
||||
while (results.hasNext()) {
|
||||
QuerySolution soln = results.nextSolution();
|
||||
RDFNode node = soln.get("authorshipURI");
|
||||
if (node.isURIResource()) {
|
||||
authorships.add(QueryUtils.querySolutionToStringValueMap(soln));
|
||||
}
|
||||
}
|
||||
try {
|
||||
ResultSet results = qe.execSelect();
|
||||
while (results.hasNext()) {
|
||||
QuerySolution soln = results.nextSolution();
|
||||
RDFNode node = soln.get("authorshipURI");
|
||||
if (node.isURIResource()) {
|
||||
authorships.add(QueryUtils.querySolutionToStringValueMap(soln));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,11 @@ import java.util.Map;
|
|||
|
||||
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.LogFactory;
|
||||
|
||||
|
@ -89,6 +94,59 @@ public class ManageWebpagesForIndividualGenerator extends BaseEditConfigurationG
|
|||
return config;
|
||||
}
|
||||
|
||||
private static String WEBPAGE_MODEL = ""
|
||||
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
||||
+ "PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> \n"
|
||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#>\n"
|
||||
+ "CONSTRUCT\n"
|
||||
+ "{\n"
|
||||
+ " ?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?vcard .\n"
|
||||
+ " ?vcard vcard:hasURL ?link .\n"
|
||||
+ " ?link a vcard:URL .\n"
|
||||
+ " ?link vcard:url ?url .\n"
|
||||
+ " ?link rdfs:label ?linkLabel .\n"
|
||||
+ " ?link core:rank ?rank .\n"
|
||||
+ " ?link vitro:mostSpecificType ?type .\n"
|
||||
+ " ?type rdfs:label ?typeLabel .\n"
|
||||
+ "}\n"
|
||||
+ "WHERE\n"
|
||||
+ "{\n"
|
||||
+ " {\n"
|
||||
+ " ?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?vcard .\n"
|
||||
+ " ?vcard vcard:hasURL ?link .\n"
|
||||
+ " ?link a vcard:URL .\n"
|
||||
+ " }\n"
|
||||
+ " UNION\n"
|
||||
+ " {\n"
|
||||
+ " ?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?vcard .\n"
|
||||
+ " ?vcard vcard:hasURL ?link .\n"
|
||||
+ " ?link a vcard:URL .\n"
|
||||
+ " ?link vcard:url ?url .\n"
|
||||
+ " }\n"
|
||||
+ " UNION\n"
|
||||
+ " {\n"
|
||||
+ " ?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?vcard .\n"
|
||||
+ " ?vcard vcard:hasURL ?link .\n"
|
||||
+ " ?link a vcard:URL .\n"
|
||||
+ " ?link rdfs:label ?linkLabel .\n"
|
||||
+ " }\n"
|
||||
+ " UNION\n"
|
||||
+ " {\n"
|
||||
+ " ?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?vcard . \n"
|
||||
+ " ?vcard vcard:hasURL ?link .\n"
|
||||
+ " ?link a vcard:URL .\n"
|
||||
+ " ?link core:rank ?rank .\n"
|
||||
+ " }\n"
|
||||
+ " UNION\n"
|
||||
+ " {\n"
|
||||
+ " ?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?vcard .\n"
|
||||
+ " ?vcard vcard:hasURL ?link .\n"
|
||||
+ " ?link a vcard:URL .\n"
|
||||
+ " ?link vitro:mostSpecificType ?type .\n"
|
||||
+ " ?type rdfs:label ?typeLabel .\n"
|
||||
+ " }\n"
|
||||
+ "}\n";
|
||||
|
||||
private static String WEBPAGE_QUERY = ""
|
||||
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
||||
|
@ -109,18 +167,31 @@ public class ManageWebpagesForIndividualGenerator extends BaseEditConfigurationG
|
|||
|
||||
|
||||
private List<Map<String, String>> getWebpages(String subjectUri, VitroRequest vreq) {
|
||||
RDFService rdfService = vreq.getRDFService();
|
||||
|
||||
String queryStr = QueryUtils.subUriForQueryVar(this.getQuery(), "subject", subjectUri);
|
||||
log.debug("Query string is: " + queryStr);
|
||||
List<Map<String, String>> webpages = new ArrayList<Map<String, String>>();
|
||||
try {
|
||||
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
||||
while (results.hasNext()) {
|
||||
QuerySolution soln = results.nextSolution();
|
||||
RDFNode node = soln.get("link");
|
||||
if (node != null && node.isURIResource()) {
|
||||
webpages.add(QueryUtils.querySolutionToStringValueMap(soln));
|
||||
String constructStr = QueryUtils.subUriForQueryVar(WEBPAGE_MODEL, "subject", subjectUri);
|
||||
|
||||
Model constructedModel = ModelFactory.createDefaultModel();
|
||||
rdfService.sparqlConstructQuery(constructStr, constructedModel);
|
||||
|
||||
String queryStr = QueryUtils.subUriForQueryVar(this.getQuery(), "subject", subjectUri);
|
||||
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("link");
|
||||
if (node != null && node.isURIResource()) {
|
||||
webpages.add(QueryUtils.querySolutionToStringValueMap(soln));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
|
|
Loading…
Add table
Reference in a new issue