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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.ModelFactoryInterface;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.ModelFactoryInterface;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationAssociatedPeopleModelWithTypesFactory;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationAssociatedPeopleModelWithTypesFactory;
|
||||||
|
@ -50,4 +51,9 @@ public class ModelConstructorUtilities {
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
return modelTypeIdentifierToFactory.get(modelType).getOrCreateModel(uri, dataset);
|
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.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
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.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
@ -24,7 +20,7 @@ public class PersonToGrantsModelConstructor implements ModelConstructor {
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
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 = "PERSON_TO_GRANTS";
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for specific person via all roles";
|
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;
|
private long before, after;
|
||||||
|
|
||||||
public PersonToGrantsModelConstructor(String personURI, Dataset dataset) {
|
public PersonToGrantsModelConstructor(String personURI, RDFService rdfService) {
|
||||||
this.personURI = personURI;
|
this.personURI = personURI;
|
||||||
this.dataset = dataset;
|
this.rdfService = rdfService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleType) {
|
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleType) {
|
||||||
|
@ -138,33 +134,20 @@ private Set<String> constructPersonGrantsQueryTemplate(String constructProperty,
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model executeQuery(Set<String> constructQueries) {
|
private Model executeQuery(Set<String> constructQueries) {
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
before = System.currentTimeMillis();
|
||||||
log.debug("CONSTRUCT query string : " + constructQueries);
|
log.debug("CONSTRUCT query string : " + constructQueries);
|
||||||
|
|
||||||
for (String currentQuery : constructQueries) {
|
for (String currentQuery : constructQueries) {
|
||||||
|
|
||||||
|
|
||||||
Query query = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
|
rdfService.sparqlConstructQuery(QueryConstants.getSparqlPrefixQuery() + currentQuery, constructedModel);
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
log.error("Could not create CONSTRUCT SPARQL query for query "
|
||||||
+ "string. " + th.getMessage());
|
+ "string. " + th.getMessage());
|
||||||
log.error(currentQuery);
|
log.error(currentQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
|
||||||
|
|
||||||
try {
|
|
||||||
qe.execConstruct(constructedModel);
|
|
||||||
} finally {
|
|
||||||
qe.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
|
|
||||||
public interface ModelFactoryInterface {
|
public interface ModelFactoryInterface {
|
||||||
|
|
||||||
public Model getOrCreateModel(String uri, Dataset dataset) throws MalformedQueryParametersException;
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationAssociatedPeopleModelWithTypesConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationAssociatedPeopleModelWithTypesConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationModelWithTypesConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationModelWithTypesConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||||
|
@ -39,4 +40,9 @@ public class OrganizationModelWithTypesFactory implements ModelFactoryInterface
|
||||||
return constructedModel;
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToGrantsForSubOrganizationsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToGrantsForSubOrganizationsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToGrantsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToGrantsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||||
|
@ -40,4 +41,9 @@ public class PeopleToGrantsFactory implements ModelFactoryInterface {
|
||||||
return constructedModel;
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToPublicationsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToPublicationsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToGrantsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToGrantsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
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 {
|
public class PersonToGrantsFactory implements ModelFactoryInterface {
|
||||||
|
|
||||||
@Override
|
@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 {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
Model candidateModel = ConstructedModelTracker.getModel(
|
||||||
|
@ -27,7 +33,7 @@ public class PersonToGrantsFactory implements ModelFactoryInterface {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ModelConstructor model = new PersonToGrantsModelConstructor(uri, dataset);
|
ModelConstructor model = new PersonToGrantsModelConstructor(uri, rdfService);
|
||||||
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
Model constructedModel = model.getConstructedModel();
|
||||||
ConstructedModelTracker.trackModel(
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToPublicationsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToPublicationsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
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.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.SubOrganizationWithinModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.SubOrganizationWithinModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker;
|
||||||
|
@ -39,4 +40,9 @@ public class SubOrganizationWithinModelFactory implements ModelFactoryInterface
|
||||||
return constructedModel;
|
return constructedModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
|
||||||
personURI,
|
personURI,
|
||||||
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, 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,
|
personURI,
|
||||||
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, 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
|
* Create a map from the year to number of grants. Use the Grant's
|
||||||
|
@ -147,7 +147,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
|
||||||
personURI,
|
personURI,
|
||||||
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, 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
|
* Create a map from the year to number of grants. Use the Grant's
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
|
||||||
UtilityFunctions
|
UtilityFunctions
|
||||||
.getIndividualLabelFromDAO(vitroRequest, egoURI));
|
.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
|
* 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.HashMap;
|
||||||
import java.util.Map;
|
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.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.jena.iri.IRI;
|
import org.apache.jena.iri.IRI;
|
||||||
|
@ -71,10 +73,10 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
+ " || ?predicate = rdfs:label "
|
+ " || ?predicate = rdfs:label "
|
||||||
+ " || ?predicate = <http://www.w3.org/2006/vcard/ns#title>";
|
+ " || ?predicate = <http://www.w3.org/2006/vcard/ns#title>";
|
||||||
|
|
||||||
QueryRunner<GenericQueryMap> profileQueryHandler =
|
AllPropertiesQueryRunner profileQueryHandler =
|
||||||
new AllPropertiesQueryRunner(individualURI,
|
new AllPropertiesQueryRunner(individualURI,
|
||||||
filterRule,
|
filterRule,
|
||||||
dataset,
|
vitroRequest.getRDFService(),
|
||||||
log);
|
log);
|
||||||
|
|
||||||
GenericQueryMap profilePropertiesToValues =
|
GenericQueryMap profilePropertiesToValues =
|
||||||
|
@ -104,15 +106,16 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> imageQueryHandler =
|
GenericQueryRunner imageQueryHandler =
|
||||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||||
"",
|
"",
|
||||||
whereClause,
|
whereClause,
|
||||||
"",
|
"",
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
return getThumbnailInformation(imageQueryHandler.getQueryResult(),
|
ThumbnailInformationConsumer consumer = new ThumbnailInformationConsumer(vitroRequest, fieldLabelToOutputFieldLabel);
|
||||||
fieldLabelToOutputFieldLabel, vitroRequest);
|
imageQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
|
||||||
|
return consumer.getInformation();
|
||||||
|
|
||||||
} else if (VisualizationFrameworkConstants.ARE_PUBLICATIONS_AVAILABLE_UTILS_VIS_MODE
|
} else if (VisualizationFrameworkConstants.ARE_PUBLICATIONS_AVAILABLE_UTILS_VIS_MODE
|
||||||
.equalsIgnoreCase(visMode)) {
|
.equalsIgnoreCase(visMode)) {
|
||||||
|
@ -130,7 +133,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
String groupOrderClause = "GROUP BY ?" + QueryFieldLabels.AUTHOR_URL + " \n";
|
String groupOrderClause = "GROUP BY ?" + QueryFieldLabels.AUTHOR_URL + " \n";
|
||||||
|
|
||||||
QueryRunner<ResultSet> numberOfPublicationsQueryHandler =
|
GenericQueryRunner numberOfPublicationsQueryHandler =
|
||||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||||
aggregationRules,
|
aggregationRules,
|
||||||
whereClause,
|
whereClause,
|
||||||
|
@ -139,8 +142,9 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
Gson publicationsInformation = new Gson();
|
Gson publicationsInformation = new Gson();
|
||||||
|
|
||||||
return publicationsInformation.toJson(getNumberOfPublicationsForIndividual(
|
NumPubsForIndividualConsumer consumer = new NumPubsForIndividualConsumer();
|
||||||
numberOfPublicationsQueryHandler.getQueryResult()));
|
numberOfPublicationsQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
|
||||||
|
return publicationsInformation.toJson(consumer.getMap());
|
||||||
|
|
||||||
} else if (VisualizationFrameworkConstants.ARE_GRANTS_AVAILABLE_UTILS_VIS_MODE
|
} else if (VisualizationFrameworkConstants.ARE_GRANTS_AVAILABLE_UTILS_VIS_MODE
|
||||||
.equalsIgnoreCase(visMode)) {
|
.equalsIgnoreCase(visMode)) {
|
||||||
|
@ -170,7 +174,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
+ "FILTER (?subclass != core:PrincipalInvestigatorRole && "
|
+ "FILTER (?subclass != core:PrincipalInvestigatorRole && "
|
||||||
+ "?subclass != core:CoPrincipalInvestigatorRole)}";
|
+ "?subclass != core:CoPrincipalInvestigatorRole)}";
|
||||||
|
|
||||||
QueryRunner<ResultSet> numberOfGrantsQueryHandler =
|
GenericQueryRunner numberOfGrantsQueryHandler =
|
||||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||||
aggregationRules,
|
aggregationRules,
|
||||||
whereClause,
|
whereClause,
|
||||||
|
@ -179,8 +183,10 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
Gson grantsInformation = new Gson();
|
Gson grantsInformation = new Gson();
|
||||||
|
|
||||||
return grantsInformation.toJson(getNumberOfGrantsForIndividual(
|
NumGrantsForIndividualConsumer consumer = new NumGrantsForIndividualConsumer();
|
||||||
numberOfGrantsQueryHandler.getQueryResult()));
|
numberOfGrantsQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
|
||||||
|
|
||||||
|
return grantsInformation.toJson(consumer.getMap());
|
||||||
|
|
||||||
} else if (VisualizationFrameworkConstants.COAUTHOR_UTILS_VIS_MODE
|
} else if (VisualizationFrameworkConstants.COAUTHOR_UTILS_VIS_MODE
|
||||||
.equalsIgnoreCase(visMode)) {
|
.equalsIgnoreCase(visMode)) {
|
||||||
|
@ -319,17 +325,16 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
+ "ORDER BY DESC(?numOfChildren)\n"
|
+ "ORDER BY DESC(?numOfChildren)\n"
|
||||||
+ "LIMIT 1\n";
|
+ "LIMIT 1\n";
|
||||||
|
|
||||||
QueryRunner<ResultSet> highestLevelOrganizationQueryHandler =
|
GenericQueryRunner highestLevelOrganizationQueryHandler =
|
||||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||||
aggregationRules,
|
aggregationRules,
|
||||||
whereClause,
|
whereClause,
|
||||||
groupOrderClause,
|
groupOrderClause,
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
return getHighestLevelOrganizationTemporalGraphVisURL(
|
HighetTopLevelOrgTemporalGraphURLConsumer consumer = new HighetTopLevelOrgTemporalGraphURLConsumer(vitroRequest, fieldLabelToOutputFieldLabel);
|
||||||
highestLevelOrganizationQueryHandler.getQueryResult(),
|
highestLevelOrganizationQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
|
||||||
fieldLabelToOutputFieldLabel,
|
return consumer.getTopLevelURL();
|
||||||
vitroRequest);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -343,110 +348,136 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHighestLevelOrganizationTemporalGraphVisURL(ResultSet resultSet,
|
private class HighetTopLevelOrgTemporalGraphURLConsumer extends ResultSetConsumer {
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel,
|
private VitroRequest vitroRequest;
|
||||||
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()) {
|
RDFNode organizationNode = qs.get(fieldLabelToOutputFieldLabel.get("organization"));
|
||||||
QuerySolution solution = resultSet.nextSolution();
|
|
||||||
|
|
||||||
|
|
||||||
RDFNode organizationNode = solution.get(
|
|
||||||
fieldLabelToOutputFieldLabel
|
|
||||||
.get("organization"));
|
|
||||||
|
|
||||||
if (organizationNode != null) {
|
if (organizationNode != null) {
|
||||||
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"),
|
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"), organizationNode.toString());
|
||||||
organizationNode.toString());
|
|
||||||
|
|
||||||
String individualLocalName = UtilityFunctions.getIndividualLocalName(
|
String individualLocalName = UtilityFunctions.getIndividualLocalName(organizationNode.toString(), vitroRequest);
|
||||||
organizationNode.toString(),
|
|
||||||
vitroRequest);
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(individualLocalName)) {
|
if (StringUtils.isNotBlank(individualLocalName)) {
|
||||||
|
|
||||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
topLevelURL = UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||||
+ "/" + VisualizationFrameworkConstants.PUBLICATION_TEMPORAL_VIS_SHORT_URL
|
+ "/" + VisualizationFrameworkConstants.PUBLICATION_TEMPORAL_VIS_SHORT_URL
|
||||||
+ "/" + individualLocalName;
|
+ "/" + individualLocalName;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(
|
ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(
|
||||||
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
|
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
|
||||||
organizationNode.toString(),
|
organizationNode.toString(),
|
||||||
VisualizationFrameworkConstants.VIS_TYPE_KEY,
|
VisualizationFrameworkConstants.VIS_TYPE_KEY,
|
||||||
VisualizationFrameworkConstants.ENTITY_COMPARISON_VIS);
|
VisualizationFrameworkConstants.ENTITY_COMPARISON_VIS);
|
||||||
|
|
||||||
return UrlBuilder.getUrl(
|
topLevelURL = UrlBuilder.getUrl(
|
||||||
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
|
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
|
||||||
highestLevelOrganizationTemporalGraphVisURLParams);
|
highestLevelOrganizationTemporalGraphVisURLParams);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RDFNode organizationLabelNode = qs.get(fieldLabelToOutputFieldLabel.get("organizationLabel"));
|
||||||
|
|
||||||
}
|
if (organizationLabelNode != null) {
|
||||||
|
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organizationLabel"), organizationLabelNode.toString());
|
||||||
|
}
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(
|
RDFNode numberOfChildrenNode = qs.getLiteral("numOfChildren");
|
||||||
fieldLabelToOutputFieldLabel
|
|
||||||
.get("organizationLabel"));
|
|
||||||
|
|
||||||
if (organizationLabelNode != null) {
|
if (numberOfChildrenNode != null) {
|
||||||
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organizationLabel"),
|
queryResult.addEntry("numOfChildren",
|
||||||
organizationLabelNode.toString());
|
String.valueOf(numberOfChildrenNode.asLiteral().getInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
RDFNode numberOfChildrenNode = solution.getLiteral("numOfChildren");
|
|
||||||
|
|
||||||
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();
|
GenericQueryMap queryResult = new GenericQueryMap();
|
||||||
|
|
||||||
|
@Override
|
||||||
while (resultSet.hasNext()) {
|
protected void processQuerySolution(QuerySolution qs) {
|
||||||
QuerySolution solution = resultSet.nextSolution();
|
RDFNode numberOfGrantsNode = qs.getLiteral("numOfGrants");
|
||||||
|
|
||||||
RDFNode numberOfGrantsNode = solution.getLiteral("numOfGrants");
|
|
||||||
|
|
||||||
if (numberOfGrantsNode != null) {
|
if (numberOfGrantsNode != null) {
|
||||||
queryResult.addEntry("numOfGrants",
|
queryResult.addEntry("numOfGrants", String.valueOf(numberOfGrantsNode.asLiteral().getInt()));
|
||||||
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;
|
public String getInformation() {
|
||||||
}
|
return finalThumbNailLocation;
|
||||||
|
|
||||||
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getThumbnailInformation(ResultSet resultSet,
|
private String getThumbnailInformation(ResultSet resultSet,
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel,
|
Map<String, String> fieldLabelToOutputFieldLabel,
|
||||||
VitroRequest vitroRequest) {
|
VitroRequest vitroRequest) {
|
||||||
|
@ -457,18 +488,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
QuerySolution solution = resultSet.nextSolution();
|
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;
|
return finalThumbNailLocation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
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.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -37,53 +40,22 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
private String filterRule, individualURI;
|
private String filterRule, individualURI;
|
||||||
private Dataset dataset;
|
private RDFService rdfService;
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(AllPropertiesQueryRunner.class.getName());
|
private Log log = LogFactory.getLog(AllPropertiesQueryRunner.class.getName());
|
||||||
|
|
||||||
public AllPropertiesQueryRunner(String individualURI,
|
public AllPropertiesQueryRunner(String individualURI,
|
||||||
String filterRule,
|
String filterRule,
|
||||||
Dataset dataset,
|
RDFService rdfService,
|
||||||
Log log) {
|
Log log) {
|
||||||
|
|
||||||
this.individualURI = individualURI;
|
this.individualURI = individualURI;
|
||||||
this.filterRule = filterRule;
|
this.filterRule = filterRule;
|
||||||
this.dataset = dataset;
|
this.rdfService = rdfService;
|
||||||
this.log = log;
|
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) {
|
private String generateGenericSparqlQuery(String queryURI, String filterRule) {
|
||||||
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
||||||
String filterClause;
|
String filterClause;
|
||||||
|
@ -130,11 +102,35 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
|
||||||
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(
|
CreateJavaVOConsumer consumer = new CreateJavaVOConsumer();
|
||||||
this.individualURI,
|
try {
|
||||||
this.filterRule),
|
rdfService.sparqlSelectQuery(generateGenericSparqlQuery(
|
||||||
this.dataset);
|
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 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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -101,4 +104,13 @@ public class GenericQueryRunner implements QueryRunner<ResultSet> {
|
||||||
|
|
||||||
return 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.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
@ -75,53 +76,6 @@ public class SelectOnModelUtilities {
|
||||||
return entityWithSubOrganizations;
|
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,
|
public static Entity getAllParentOrganizations(Dataset dataset,
|
||||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
String subjectEntityURI) throws MalformedQueryParametersException {
|
||||||
Model organizationModel = ModelConstructorUtilities
|
Model organizationModel = ModelConstructorUtilities
|
||||||
|
@ -757,7 +711,7 @@ public class SelectOnModelUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Activity> getGrantsForPerson(
|
public static Map<String, Activity> getGrantsForPerson(
|
||||||
Dataset dataset, SubEntity person, boolean doCache)
|
RDFService rdfService, SubEntity person, boolean doCache)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>();
|
Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>();
|
||||||
|
@ -775,10 +729,10 @@ public class SelectOnModelUtilities {
|
||||||
.getOrConstructModel(
|
.getOrConstructModel(
|
||||||
person.getIndividualURI(),
|
person.getIndividualURI(),
|
||||||
PersonToGrantsModelConstructor.MODEL_TYPE,
|
PersonToGrantsModelConstructor.MODEL_TYPE,
|
||||||
dataset);
|
rdfService);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ModelConstructor model = new PersonToGrantsModelConstructor(person.getIndividualURI(), dataset);
|
ModelConstructor model = new PersonToGrantsModelConstructor(person.getIndividualURI(), rdfService);
|
||||||
personGrantsModel = model.getConstructedModel();
|
personGrantsModel = model.getConstructedModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue