Removing RDFServiceGraph
This commit is contained in:
parent
3605888ad3
commit
75203eb716
18 changed files with 271 additions and 245 deletions
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.ModelFactoryInterface;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationAssociatedPeopleModelWithTypesFactory;
|
||||
|
@ -50,4 +51,9 @@ public class ModelConstructorUtilities {
|
|||
throws MalformedQueryParametersException {
|
||||
return modelTypeIdentifierToFactory.get(modelType).getOrCreateModel(uri, dataset);
|
||||
}
|
||||
|
||||
public static Model getOrConstructModel(String uri, String modelType, RDFService rdfService)
|
||||
throws MalformedQueryParametersException {
|
||||
return modelTypeIdentifierToFactory.get(modelType).getOrCreateModel(uri, rdfService);
|
||||
}
|
||||
}
|
|
@ -4,14 +4,10 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
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;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.Syntax;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
@ -24,7 +20,7 @@ public class PersonToGrantsModelConstructor implements ModelConstructor {
|
|||
|
||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||
|
||||
private Dataset dataset;
|
||||
private RDFService rdfService;
|
||||
|
||||
public static final String MODEL_TYPE = "PERSON_TO_GRANTS";
|
||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for specific person via all roles";
|
||||
|
@ -35,9 +31,9 @@ public class PersonToGrantsModelConstructor implements ModelConstructor {
|
|||
|
||||
private long before, after;
|
||||
|
||||
public PersonToGrantsModelConstructor(String personURI, Dataset dataset) {
|
||||
public PersonToGrantsModelConstructor(String personURI, RDFService rdfService) {
|
||||
this.personURI = personURI;
|
||||
this.dataset = dataset;
|
||||
this.rdfService = rdfService;
|
||||
}
|
||||
|
||||
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleType) {
|
||||
|
@ -138,33 +134,20 @@ private Set<String> constructPersonGrantsQueryTemplate(String constructProperty,
|
|||
}
|
||||
|
||||
private Model executeQuery(Set<String> constructQueries) {
|
||||
|
||||
Model constructedModel = ModelFactory.createDefaultModel();
|
||||
|
||||
before = System.currentTimeMillis();
|
||||
log.debug("CONSTRUCT query string : " + constructQueries);
|
||||
|
||||
for (String currentQuery : constructQueries) {
|
||||
|
||||
|
||||
Query query = null;
|
||||
|
||||
try {
|
||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
|
||||
rdfService.sparqlConstructQuery(QueryConstants.getSparqlPrefixQuery() + currentQuery, constructedModel);
|
||||
} catch (Throwable th) {
|
||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
||||
+ "string. " + th.getMessage());
|
||||
log.error(currentQuery);
|
||||
}
|
||||
|
||||
|
||||
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
||||
|
||||
try {
|
||||
qe.execConstruct(constructedModel);
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
}
|
||||
|
||||
after = System.currentTimeMillis();
|
||||
|
|
|
@ -4,10 +4,12 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
|
||||
public interface ModelFactoryInterface {
|
||||
|
||||
public Model getOrCreateModel(String uri, Dataset dataset) throws MalformedQueryParametersException;
|
||||
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationAssociatedPeopleModelWithTypesConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||
|
@ -43,4 +44,9 @@ public class OrganizationAssociatedPeopleModelWithTypesFactory implements
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationModelWithTypesConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||
|
@ -39,4 +40,9 @@ public class OrganizationModelWithTypesFactory implements ModelFactoryInterface
|
|||
return constructedModel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToGrantsForSubOrganizationsModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||
|
@ -43,4 +44,9 @@ public class OrganizationToGrantsForSubOrganizationsFactory implements
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||
|
@ -59,6 +60,11 @@ public class OrganizationToPublicationsForSubOrganizationsFactory implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToGrantsModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||
|
@ -40,4 +41,9 @@ public class PeopleToGrantsFactory implements ModelFactoryInterface {
|
|||
return constructedModel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToPublicationsModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||
|
@ -42,4 +43,9 @@ public class PeopleToPublicationsFactory implements ModelFactoryInterface {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToGrantsModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||
|
@ -12,7 +13,12 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|||
public class PersonToGrantsFactory implements ModelFactoryInterface {
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, Dataset dataset)
|
||||
public Model getOrCreateModel(String uri, Dataset dataset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService)
|
||||
throws MalformedQueryParametersException {
|
||||
|
||||
Model candidateModel = ConstructedModelTracker.getModel(
|
||||
|
@ -27,7 +33,7 @@ public class PersonToGrantsFactory implements ModelFactoryInterface {
|
|||
|
||||
} else {
|
||||
|
||||
ModelConstructor model = new PersonToGrantsModelConstructor(uri, dataset);
|
||||
ModelConstructor model = new PersonToGrantsModelConstructor(uri, rdfService);
|
||||
|
||||
Model constructedModel = model.getConstructedModel();
|
||||
ConstructedModelTracker.trackModel(
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToPublicationsModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||
|
@ -42,4 +43,9 @@ public class PersonToPublicationsFactory implements ModelFactoryInterface {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.SubOrganizationWithinModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||
|
@ -39,4 +40,9 @@ public class SubOrganizationWithinModelFactory implements ModelFactoryInterface
|
|||
return constructedModel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
|
|||
personURI,
|
||||
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI));
|
||||
|
||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(dataset, person, false);
|
||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -96,7 +96,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
|
|||
personURI,
|
||||
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI));
|
||||
|
||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(dataset, person, false);
|
||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false);
|
||||
|
||||
/*
|
||||
* Create a map from the year to number of grants. Use the Grant's
|
||||
|
@ -147,7 +147,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
|
|||
personURI,
|
||||
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI));
|
||||
|
||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(dataset, person, false);
|
||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false);
|
||||
|
||||
/*
|
||||
* Create a map from the year to number of grants. Use the Grant's
|
||||
|
|
|
@ -123,7 +123,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
|
|||
UtilityFunctions
|
||||
.getIndividualLabelFromDAO(vitroRequest, egoURI));
|
||||
|
||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(dataset, person, false);
|
||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false);
|
||||
|
||||
/*
|
||||
* Create a map from the year to number of grants. Use the Grant's
|
||||
|
|
|
@ -5,6 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.visualization.utilities;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ResultSetConsumer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.jena.iri.IRI;
|
||||
|
@ -71,10 +73,10 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
+ " || ?predicate = rdfs:label "
|
||||
+ " || ?predicate = <http://www.w3.org/2006/vcard/ns#title>";
|
||||
|
||||
QueryRunner<GenericQueryMap> profileQueryHandler =
|
||||
AllPropertiesQueryRunner profileQueryHandler =
|
||||
new AllPropertiesQueryRunner(individualURI,
|
||||
filterRule,
|
||||
dataset,
|
||||
vitroRequest.getRDFService(),
|
||||
log);
|
||||
|
||||
GenericQueryMap profilePropertiesToValues =
|
||||
|
@ -104,15 +106,16 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
|
||||
|
||||
|
||||
QueryRunner<ResultSet> imageQueryHandler =
|
||||
GenericQueryRunner imageQueryHandler =
|
||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||
"",
|
||||
whereClause,
|
||||
"",
|
||||
dataset);
|
||||
|
||||
return getThumbnailInformation(imageQueryHandler.getQueryResult(),
|
||||
fieldLabelToOutputFieldLabel, vitroRequest);
|
||||
ThumbnailInformationConsumer consumer = new ThumbnailInformationConsumer(vitroRequest, fieldLabelToOutputFieldLabel);
|
||||
imageQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
|
||||
return consumer.getInformation();
|
||||
|
||||
} else if (VisualizationFrameworkConstants.ARE_PUBLICATIONS_AVAILABLE_UTILS_VIS_MODE
|
||||
.equalsIgnoreCase(visMode)) {
|
||||
|
@ -130,7 +133,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
|
||||
String groupOrderClause = "GROUP BY ?" + QueryFieldLabels.AUTHOR_URL + " \n";
|
||||
|
||||
QueryRunner<ResultSet> numberOfPublicationsQueryHandler =
|
||||
GenericQueryRunner numberOfPublicationsQueryHandler =
|
||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||
aggregationRules,
|
||||
whereClause,
|
||||
|
@ -139,8 +142,9 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
|
||||
Gson publicationsInformation = new Gson();
|
||||
|
||||
return publicationsInformation.toJson(getNumberOfPublicationsForIndividual(
|
||||
numberOfPublicationsQueryHandler.getQueryResult()));
|
||||
NumPubsForIndividualConsumer consumer = new NumPubsForIndividualConsumer();
|
||||
numberOfPublicationsQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
|
||||
return publicationsInformation.toJson(consumer.getMap());
|
||||
|
||||
} else if (VisualizationFrameworkConstants.ARE_GRANTS_AVAILABLE_UTILS_VIS_MODE
|
||||
.equalsIgnoreCase(visMode)) {
|
||||
|
@ -170,7 +174,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
+ "FILTER (?subclass != core:PrincipalInvestigatorRole && "
|
||||
+ "?subclass != core:CoPrincipalInvestigatorRole)}";
|
||||
|
||||
QueryRunner<ResultSet> numberOfGrantsQueryHandler =
|
||||
GenericQueryRunner numberOfGrantsQueryHandler =
|
||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||
aggregationRules,
|
||||
whereClause,
|
||||
|
@ -179,8 +183,10 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
|
||||
Gson grantsInformation = new Gson();
|
||||
|
||||
return grantsInformation.toJson(getNumberOfGrantsForIndividual(
|
||||
numberOfGrantsQueryHandler.getQueryResult()));
|
||||
NumGrantsForIndividualConsumer consumer = new NumGrantsForIndividualConsumer();
|
||||
numberOfGrantsQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
|
||||
|
||||
return grantsInformation.toJson(consumer.getMap());
|
||||
|
||||
} else if (VisualizationFrameworkConstants.COAUTHOR_UTILS_VIS_MODE
|
||||
.equalsIgnoreCase(visMode)) {
|
||||
|
@ -319,17 +325,16 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
+ "ORDER BY DESC(?numOfChildren)\n"
|
||||
+ "LIMIT 1\n";
|
||||
|
||||
QueryRunner<ResultSet> highestLevelOrganizationQueryHandler =
|
||||
GenericQueryRunner highestLevelOrganizationQueryHandler =
|
||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||
aggregationRules,
|
||||
whereClause,
|
||||
groupOrderClause,
|
||||
dataset);
|
||||
|
||||
return getHighestLevelOrganizationTemporalGraphVisURL(
|
||||
highestLevelOrganizationQueryHandler.getQueryResult(),
|
||||
fieldLabelToOutputFieldLabel,
|
||||
vitroRequest);
|
||||
HighetTopLevelOrgTemporalGraphURLConsumer consumer = new HighetTopLevelOrgTemporalGraphURLConsumer(vitroRequest, fieldLabelToOutputFieldLabel);
|
||||
highestLevelOrganizationQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
|
||||
return consumer.getTopLevelURL();
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -343,110 +348,136 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
|
||||
}
|
||||
|
||||
private String getHighestLevelOrganizationTemporalGraphVisURL(ResultSet resultSet,
|
||||
Map<String, String> fieldLabelToOutputFieldLabel,
|
||||
VitroRequest vitroRequest) {
|
||||
private class HighetTopLevelOrgTemporalGraphURLConsumer extends ResultSetConsumer {
|
||||
private VitroRequest vitroRequest;
|
||||
private Map<String, String> fieldLabelToOutputFieldLabel;
|
||||
private String topLevelURL = null;
|
||||
private GenericQueryMap queryResult = new GenericQueryMap();
|
||||
|
||||
GenericQueryMap queryResult = new GenericQueryMap();
|
||||
HighetTopLevelOrgTemporalGraphURLConsumer(VitroRequest vitroRequest, Map<String, String> fieldLabelToOutputFieldLabel) {
|
||||
this.vitroRequest = vitroRequest;
|
||||
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processQuerySolution(QuerySolution qs) {
|
||||
if (topLevelURL != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (resultSet.hasNext()) {
|
||||
QuerySolution solution = resultSet.nextSolution();
|
||||
|
||||
|
||||
RDFNode organizationNode = solution.get(
|
||||
fieldLabelToOutputFieldLabel
|
||||
.get("organization"));
|
||||
RDFNode organizationNode = qs.get(fieldLabelToOutputFieldLabel.get("organization"));
|
||||
|
||||
if (organizationNode != null) {
|
||||
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"),
|
||||
organizationNode.toString());
|
||||
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"), organizationNode.toString());
|
||||
|
||||
String individualLocalName = UtilityFunctions.getIndividualLocalName(
|
||||
organizationNode.toString(),
|
||||
vitroRequest);
|
||||
String individualLocalName = UtilityFunctions.getIndividualLocalName(organizationNode.toString(), vitroRequest);
|
||||
|
||||
if (StringUtils.isNotBlank(individualLocalName)) {
|
||||
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.PUBLICATION_TEMPORAL_VIS_SHORT_URL
|
||||
+ "/" + individualLocalName;
|
||||
}
|
||||
topLevelURL = UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.PUBLICATION_TEMPORAL_VIS_SHORT_URL
|
||||
+ "/" + individualLocalName;
|
||||
} else {
|
||||
|
||||
ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(
|
||||
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
|
||||
organizationNode.toString(),
|
||||
VisualizationFrameworkConstants.VIS_TYPE_KEY,
|
||||
VisualizationFrameworkConstants.ENTITY_COMPARISON_VIS);
|
||||
ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(
|
||||
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
|
||||
organizationNode.toString(),
|
||||
VisualizationFrameworkConstants.VIS_TYPE_KEY,
|
||||
VisualizationFrameworkConstants.ENTITY_COMPARISON_VIS);
|
||||
|
||||
return UrlBuilder.getUrl(
|
||||
topLevelURL = UrlBuilder.getUrl(
|
||||
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
|
||||
highestLevelOrganizationTemporalGraphVisURLParams);
|
||||
|
||||
}
|
||||
} else {
|
||||
RDFNode organizationLabelNode = qs.get(fieldLabelToOutputFieldLabel.get("organizationLabel"));
|
||||
|
||||
}
|
||||
if (organizationLabelNode != null) {
|
||||
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organizationLabel"), organizationLabelNode.toString());
|
||||
}
|
||||
|
||||
RDFNode organizationLabelNode = solution.get(
|
||||
fieldLabelToOutputFieldLabel
|
||||
.get("organizationLabel"));
|
||||
RDFNode numberOfChildrenNode = qs.getLiteral("numOfChildren");
|
||||
|
||||
if (organizationLabelNode != null) {
|
||||
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organizationLabel"),
|
||||
organizationLabelNode.toString());
|
||||
}
|
||||
|
||||
RDFNode numberOfChildrenNode = solution.getLiteral("numOfChildren");
|
||||
|
||||
if (numberOfChildrenNode != null) {
|
||||
queryResult.addEntry("numOfChildren",
|
||||
String.valueOf(numberOfChildrenNode.asLiteral().getInt()));
|
||||
if (numberOfChildrenNode != null) {
|
||||
queryResult.addEntry("numOfChildren",
|
||||
String.valueOf(numberOfChildrenNode.asLiteral().getInt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
public String getTopLevelURL() {
|
||||
return topLevelURL == null ? "" : topLevelURL;
|
||||
}
|
||||
}
|
||||
|
||||
private GenericQueryMap getNumberOfGrantsForIndividual(ResultSet resultSet) {
|
||||
|
||||
private static class NumGrantsForIndividualConsumer extends ResultSetConsumer {
|
||||
GenericQueryMap queryResult = new GenericQueryMap();
|
||||
|
||||
|
||||
while (resultSet.hasNext()) {
|
||||
QuerySolution solution = resultSet.nextSolution();
|
||||
|
||||
RDFNode numberOfGrantsNode = solution.getLiteral("numOfGrants");
|
||||
@Override
|
||||
protected void processQuerySolution(QuerySolution qs) {
|
||||
RDFNode numberOfGrantsNode = qs.getLiteral("numOfGrants");
|
||||
|
||||
if (numberOfGrantsNode != null) {
|
||||
queryResult.addEntry("numOfGrants",
|
||||
String.valueOf(numberOfGrantsNode.asLiteral().getInt()));
|
||||
queryResult.addEntry("numOfGrants", String.valueOf(numberOfGrantsNode.asLiteral().getInt()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GenericQueryMap getMap() {
|
||||
return queryResult;
|
||||
}
|
||||
}
|
||||
|
||||
private static class NumPubsForIndividualConsumer extends ResultSetConsumer {
|
||||
GenericQueryMap queryResult = new GenericQueryMap();
|
||||
|
||||
@Override
|
||||
protected void processQuerySolution(QuerySolution qs) {
|
||||
RDFNode numberOfPublicationsNode = qs.getLiteral("numOfPublications");
|
||||
|
||||
if (numberOfPublicationsNode != null) {
|
||||
queryResult.addEntry("numOfPublications", String.valueOf(numberOfPublicationsNode.asLiteral().getInt()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GenericQueryMap getMap() {
|
||||
return queryResult;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ThumbnailInformationConsumer extends ResultSetConsumer {
|
||||
private VitroRequest vitroRequest;
|
||||
private Map<String, String> fieldLabelToOutputFieldLabel;
|
||||
private String finalThumbNailLocation = "";
|
||||
|
||||
ThumbnailInformationConsumer(VitroRequest vitroRequest, Map<String, String> fieldLabelToOutputFieldLabel) {
|
||||
this.vitroRequest = vitroRequest;
|
||||
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processQuerySolution(QuerySolution qs) {
|
||||
RDFNode downloadLocationNode = qs.get(
|
||||
fieldLabelToOutputFieldLabel
|
||||
.get("downloadLocation"));
|
||||
RDFNode fileNameNode = qs.get(fieldLabelToOutputFieldLabel.get("fileName"));
|
||||
|
||||
if (downloadLocationNode != null && fileNameNode != null) {
|
||||
finalThumbNailLocation =
|
||||
FileServingHelper
|
||||
.getBytestreamAliasUrl(downloadLocationNode.toString(),
|
||||
fileNameNode.toString(),
|
||||
vitroRequest.getSession().getServletContext());
|
||||
}
|
||||
}
|
||||
|
||||
return queryResult;
|
||||
}
|
||||
|
||||
|
||||
private GenericQueryMap getNumberOfPublicationsForIndividual(ResultSet resultSet) {
|
||||
|
||||
GenericQueryMap queryResult = new GenericQueryMap();
|
||||
|
||||
|
||||
while (resultSet.hasNext()) {
|
||||
QuerySolution solution = resultSet.nextSolution();
|
||||
|
||||
RDFNode numberOfPublicationsNode = solution.getLiteral("numOfPublications");
|
||||
|
||||
if (numberOfPublicationsNode != null) {
|
||||
queryResult.addEntry(
|
||||
"numOfPublications",
|
||||
String.valueOf(numberOfPublicationsNode.asLiteral().getInt()));
|
||||
}
|
||||
public String getInformation() {
|
||||
return finalThumbNailLocation;
|
||||
}
|
||||
|
||||
return queryResult;
|
||||
}
|
||||
|
||||
|
||||
private String getThumbnailInformation(ResultSet resultSet,
|
||||
Map<String, String> fieldLabelToOutputFieldLabel,
|
||||
VitroRequest vitroRequest) {
|
||||
|
@ -457,18 +488,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
QuerySolution solution = resultSet.nextSolution();
|
||||
|
||||
|
||||
RDFNode downloadLocationNode = solution.get(
|
||||
fieldLabelToOutputFieldLabel
|
||||
.get("downloadLocation"));
|
||||
RDFNode fileNameNode = solution.get(fieldLabelToOutputFieldLabel.get("fileName"));
|
||||
|
||||
if (downloadLocationNode != null && fileNameNode != null) {
|
||||
finalThumbNailLocation =
|
||||
FileServingHelper
|
||||
.getBytestreamAliasUrl(downloadLocationNode.toString(),
|
||||
fileNameNode.toString(),
|
||||
vitroRequest.getSession().getServletContext());
|
||||
}
|
||||
}
|
||||
return finalThumbNailLocation;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ResultSetConsumer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -37,53 +40,22 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
|
|||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||
|
||||
private String filterRule, individualURI;
|
||||
private Dataset dataset;
|
||||
private RDFService rdfService;
|
||||
|
||||
private Log log = LogFactory.getLog(AllPropertiesQueryRunner.class.getName());
|
||||
|
||||
public AllPropertiesQueryRunner(String individualURI,
|
||||
String filterRule,
|
||||
Dataset dataset,
|
||||
RDFService rdfService,
|
||||
Log log) {
|
||||
|
||||
this.individualURI = individualURI;
|
||||
this.filterRule = filterRule;
|
||||
this.dataset = dataset;
|
||||
this.rdfService = rdfService;
|
||||
this.log = log;
|
||||
|
||||
}
|
||||
|
||||
private GenericQueryMap createJavaValueObjects(ResultSet resultSet) {
|
||||
|
||||
GenericQueryMap queryResult = new GenericQueryMap();
|
||||
|
||||
while (resultSet.hasNext()) {
|
||||
QuerySolution solution = resultSet.nextSolution();
|
||||
|
||||
|
||||
RDFNode predicateNode = solution.get(QueryFieldLabels.PREDICATE);
|
||||
RDFNode objectNode = solution.get(QueryFieldLabels.OBJECT);
|
||||
|
||||
if (predicateNode != null && objectNode != null) {
|
||||
queryResult.addEntry(predicateNode.toString(),
|
||||
objectNode.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return queryResult;
|
||||
}
|
||||
|
||||
private ResultSet executeQuery(String queryText,
|
||||
Dataset dataset) {
|
||||
|
||||
QueryExecution queryExecution = null;
|
||||
Query query = QueryFactory.create(queryText, SYNTAX);
|
||||
|
||||
queryExecution = QueryExecutionFactory.create(query, dataset);
|
||||
return queryExecution.execSelect();
|
||||
}
|
||||
|
||||
private String generateGenericSparqlQuery(String queryURI, String filterRule) {
|
||||
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
||||
String filterClause;
|
||||
|
@ -130,11 +102,35 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
|
|||
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
||||
}
|
||||
|
||||
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(
|
||||
this.individualURI,
|
||||
this.filterRule),
|
||||
this.dataset);
|
||||
CreateJavaVOConsumer consumer = new CreateJavaVOConsumer();
|
||||
try {
|
||||
rdfService.sparqlSelectQuery(generateGenericSparqlQuery(
|
||||
this.individualURI,
|
||||
this.filterRule),
|
||||
consumer);
|
||||
} catch (RDFServiceException e) {
|
||||
log.error("Unable to execute query", e);
|
||||
throw new MalformedQueryParametersException(e);
|
||||
}
|
||||
return consumer.getMap();
|
||||
}
|
||||
|
||||
return createJavaValueObjects(resultSet);
|
||||
private class CreateJavaVOConsumer extends ResultSetConsumer {
|
||||
GenericQueryMap queryResult = new GenericQueryMap();
|
||||
|
||||
@Override
|
||||
protected void processQuerySolution(QuerySolution qs) {
|
||||
RDFNode predicateNode = qs.get(QueryFieldLabels.PREDICATE);
|
||||
RDFNode objectNode = qs.get(QueryFieldLabels.OBJECT);
|
||||
|
||||
if (predicateNode != null && objectNode != null) {
|
||||
queryResult.addEntry(predicateNode.toString(),
|
||||
objectNode.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public GenericQueryMap getMap() {
|
||||
return queryResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ResultSetConsumer;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -101,4 +104,13 @@ public class GenericQueryRunner implements QueryRunner<ResultSet> {
|
|||
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
public void sparqlSelectQuery(RDFService rdfService, ResultSetConsumer consumer) throws MalformedQueryParametersException {
|
||||
try {
|
||||
rdfService.sparqlSelectQuery(generateGenericSparqlQuery(), consumer);
|
||||
} catch (RDFServiceException e) {
|
||||
log.error("Unable to execute: [" + generateGenericSparqlQuery() + "]", e);
|
||||
throw new MalformedQueryParametersException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
|
@ -75,53 +76,6 @@ public class SelectOnModelUtilities {
|
|||
return entityWithSubOrganizations;
|
||||
}
|
||||
|
||||
public static Entity getSubjectPersonEntity(Dataset dataset,
|
||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
||||
|
||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||
fieldLabelToOutputFieldLabel.put("authorLabel", QueryFieldLabels.AUTHOR_LABEL);
|
||||
|
||||
String whereClause = ""
|
||||
+ " <" + subjectEntityURI + "> rdfs:label ?authorLabel . ";
|
||||
|
||||
QueryRunner<ResultSet> personQuery =
|
||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||
"",
|
||||
whereClause,
|
||||
"",
|
||||
dataset);
|
||||
|
||||
Entity personEntity = new Entity(subjectEntityURI);
|
||||
|
||||
ResultSet queryResult = personQuery.getQueryResult();
|
||||
|
||||
while (queryResult.hasNext()) {
|
||||
|
||||
QuerySolution solution = queryResult.nextSolution();
|
||||
|
||||
RDFNode personLabelNode = solution.get(QueryFieldLabels.AUTHOR_LABEL);
|
||||
if (personLabelNode != null) {
|
||||
personEntity.setEntityLabel(personLabelNode.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* We are adding A person as it's own subentity in order to make our code for geenrating csv, json
|
||||
* & other data as streamlined as possible between entities of type Organization & Person.
|
||||
* */
|
||||
SubEntity subEntity = new SubEntity(subjectEntityURI, personEntity.getEntityLabel());
|
||||
subEntity.setEntityClass(VOConstants.EntityClassType.PERSON);
|
||||
|
||||
personEntity.addSubEntity(subEntity);
|
||||
|
||||
// Entity entityWithParentOrganizations = getAllParentOrganizations(dataset, subjectEntityURI);
|
||||
//
|
||||
// personEntity.addParents(entityWithParentOrganizations.getParents());
|
||||
|
||||
return personEntity;
|
||||
}
|
||||
|
||||
public static Entity getAllParentOrganizations(Dataset dataset,
|
||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
||||
Model organizationModel = ModelConstructorUtilities
|
||||
|
@ -757,7 +711,7 @@ public class SelectOnModelUtilities {
|
|||
}
|
||||
|
||||
public static Map<String, Activity> getGrantsForPerson(
|
||||
Dataset dataset, SubEntity person, boolean doCache)
|
||||
RDFService rdfService, SubEntity person, boolean doCache)
|
||||
throws MalformedQueryParametersException {
|
||||
|
||||
Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>();
|
||||
|
@ -775,10 +729,10 @@ public class SelectOnModelUtilities {
|
|||
.getOrConstructModel(
|
||||
person.getIndividualURI(),
|
||||
PersonToGrantsModelConstructor.MODEL_TYPE,
|
||||
dataset);
|
||||
rdfService);
|
||||
} else {
|
||||
|
||||
ModelConstructor model = new PersonToGrantsModelConstructor(person.getIndividualURI(), dataset);
|
||||
ModelConstructor model = new PersonToGrantsModelConstructor(person.getIndividualURI(), rdfService);
|
||||
personGrantsModel = model.getConstructedModel();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue