[VIVO-1120] Remove deprecated visualisation model code
This commit is contained in:
parent
d77e45f557
commit
e1b5e2448e
24 changed files with 221 additions and 2444 deletions
|
@ -9,7 +9,6 @@ import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
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.PersonToGrantsFactory;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation,serial")
|
@SuppressWarnings("deprecation,serial")
|
||||||
public class ModelConstructorUtilities {
|
public class ModelConstructorUtilities {
|
||||||
|
@ -18,40 +17,12 @@ public class ModelConstructorUtilities {
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
private static final Map<String, ModelFactoryInterface> modelTypeIdentifierToFactory = new HashMap<String, ModelFactoryInterface>() {{
|
private static final Map<String, ModelFactoryInterface> modelTypeIdentifierToFactory = new HashMap<String, ModelFactoryInterface>() {{
|
||||||
// Currently in use, but probably should be deprecated with the others
|
|
||||||
put(PersonToGrantsModelConstructor.MODEL_TYPE, new PersonToGrantsFactory());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The following models are deprecated and will be removed
|
|
||||||
*/
|
|
||||||
put(PersonToPublicationsModelConstructor.MODEL_TYPE, new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.PersonToPublicationsFactory());
|
|
||||||
put(PeopleToPublicationsModelConstructor.MODEL_TYPE, new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.PeopleToPublicationsFactory());
|
|
||||||
put(PeopleToGrantsModelConstructor.MODEL_TYPE, new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.PeopleToGrantsFactory());
|
|
||||||
put(OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationToPublicationsForSubOrganizationsFactory());
|
|
||||||
put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationToGrantsForSubOrganizationsFactory());
|
|
||||||
put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationAssociatedPeopleModelWithTypesFactory());
|
|
||||||
put(OrganizationModelWithTypesConstructor.MODEL_TYPE, new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationModelWithTypesFactory());
|
|
||||||
put(SubOrganizationWithinModelConstructor.MODEL_TYPE, new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.SubOrganizationWithinModelFactory());
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public static final Map<String, String> modelTypeToHumanReadableName = new HashMap<String, String>() {{
|
public static final Map<String, String> modelTypeToHumanReadableName = new HashMap<String, String>() {{
|
||||||
// Currently in use, but probably should be deprecated with the others
|
|
||||||
put(PersonToGrantsModelConstructor.MODEL_TYPE, PersonToGrantsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The following models are deprecated and will be removed
|
|
||||||
*/
|
|
||||||
put(PersonToPublicationsModelConstructor.MODEL_TYPE, PersonToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
|
||||||
put(PeopleToPublicationsModelConstructor.MODEL_TYPE, PeopleToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
|
||||||
put(PeopleToGrantsModelConstructor.MODEL_TYPE, PeopleToGrantsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
|
||||||
put(OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
|
||||||
put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
|
||||||
put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE_HUMAN_READABLE);
|
|
||||||
put(OrganizationModelWithTypesConstructor.MODEL_TYPE, OrganizationModelWithTypesConstructor.MODEL_TYPE_HUMAN_READABLE);
|
|
||||||
put(SubOrganizationWithinModelConstructor.MODEL_TYPE, SubOrganizationWithinModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
public static Model getOrConstructModel(String uri, String modelType, RDFService rdfService)
|
public static Model getOrConstructModel(String uri, String modelType, RDFService rdfService)
|
||||||
|
|
|
@ -1,107 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
|
||||||
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;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class OrganizationAssociatedPeopleModelWithTypesConstructor implements ModelConstructor {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "ORGANIZATION_ASSOCIATED_MODEL_WITH_TYPES";
|
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "People for specific organization";
|
|
||||||
|
|
||||||
private RDFService rdfService;
|
|
||||||
|
|
||||||
private Model constructedModel;
|
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(OrganizationAssociatedPeopleModelWithTypesConstructor.class.getName());
|
|
||||||
|
|
||||||
private long before, after;
|
|
||||||
|
|
||||||
private String organizationURI;
|
|
||||||
|
|
||||||
public OrganizationAssociatedPeopleModelWithTypesConstructor(String organizationURI, RDFService rdfService) {
|
|
||||||
this.rdfService = rdfService;
|
|
||||||
this.organizationURI = organizationURI;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String constructAssociatedPeopleForOrganizationWithTypesQuery() {
|
|
||||||
return ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " <" + organizationURI + "> rdf:type foaf:Organization . "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> vivosocnet:hasPersonWithActivity ?Person . "
|
|
||||||
+ " ?Person rdfs:label ?personLabel. "
|
|
||||||
+ " ?Person rdf:type ?personType . "
|
|
||||||
+ " ?personType rdfs:label ?personTypeLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " <" + organizationURI + "> rdf:type foaf:Organization . "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " <" + organizationURI + "> core:relatedBy ?Position . "
|
|
||||||
+ " ?Position rdf:type core:Position . "
|
|
||||||
+ " ?Position core:relates ?Person . "
|
|
||||||
+ " ?Person rdfs:label ?personLabel. "
|
|
||||||
+ " ?Person rdf:type ?personType . "
|
|
||||||
+ " ?personType rdfs:label ?personTypeLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model executeQuery(String constructQuery) {
|
|
||||||
|
|
||||||
log.debug("in constructed model for associated people for organization");
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
log.debug("CONSTRUCT query string : " + constructQuery);
|
|
||||||
|
|
||||||
try {
|
|
||||||
rdfService.sparqlConstructQuery(QueryConstants.getSparqlPrefixQuery() + constructQuery, constructedModel);
|
|
||||||
} catch (Throwable th) {
|
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query string. " + th.getMessage());
|
|
||||||
log.error(constructQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
|
||||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
|
||||||
+ (after - before));
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
if (constructedModel != null && !constructedModel.isEmpty()) {
|
|
||||||
return constructedModel;
|
|
||||||
} else {
|
|
||||||
constructedModel = executeQuery(constructAssociatedPeopleForOrganizationWithTypesQuery());
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,102 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class OrganizationModelWithTypesConstructor implements ModelConstructor {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "ORGANIZATION_MODEL_WITH_TYPES";
|
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Organization hierarchy";
|
|
||||||
|
|
||||||
private RDFService rdfService;
|
|
||||||
|
|
||||||
private Model constructedModel;
|
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(OrganizationModelWithTypesConstructor.class.getName());
|
|
||||||
|
|
||||||
private long before, after;
|
|
||||||
|
|
||||||
public OrganizationModelWithTypesConstructor(RDFService rdfService) {
|
|
||||||
this.rdfService = rdfService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String constructAllSubOrganizationsWithTypesQuery() {
|
|
||||||
return ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " ?organization rdf:type foaf:Organization . "
|
|
||||||
+ " ?organization rdfs:label ?organizationLabel . "
|
|
||||||
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000051> ?subOrganization . "
|
|
||||||
+ " ?subOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
|
||||||
+ " ?subOrganization rdf:type ?subOrganizationType . "
|
|
||||||
+ " ?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " ?organization rdf:type foaf:Organization . "
|
|
||||||
+ " ?organization rdfs:label ?organizationLabel . "
|
|
||||||
+ " "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000051> ?subOrganization . "
|
|
||||||
+ " ?subOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
|
||||||
+ " ?subOrganization rdf:type ?subOrganizationType . "
|
|
||||||
+ " ?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model executeQuery(String constructQuery) {
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
log.debug("CONSTRUCT query string : " + constructQuery);
|
|
||||||
|
|
||||||
try {
|
|
||||||
rdfService.sparqlConstructQuery(QueryConstants.getSparqlPrefixQuery() + constructQuery, constructedModel);
|
|
||||||
} catch (Throwable th) {
|
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query string. " + th.getMessage());
|
|
||||||
log.error(constructQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
|
||||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
|
||||||
+ (after - before));
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
if (constructedModel != null && !constructedModel.isEmpty()) {
|
|
||||||
return constructedModel;
|
|
||||||
} else {
|
|
||||||
constructedModel = executeQuery(constructAllSubOrganizationsWithTypesQuery());
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,198 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
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;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class OrganizationToGrantsForSubOrganizationsModelConstructor implements ModelConstructor {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
|
||||||
|
|
||||||
private RDFService rdfService;
|
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "ORGANIZATION_TO_GRANTS_FOR_SUBORGANIZATIONS";
|
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for specific organization via all descendants";
|
|
||||||
|
|
||||||
private String organizationURI;
|
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(OrganizationToGrantsForSubOrganizationsModelConstructor.class.getName());
|
|
||||||
|
|
||||||
private long before, after;
|
|
||||||
|
|
||||||
public OrganizationToGrantsForSubOrganizationsModelConstructor(String organizationURI, RDFService rdfService) {
|
|
||||||
this.organizationURI = organizationURI;
|
|
||||||
this.rdfService = rdfService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> constructOrganizationGrantsQueryTemplate(String constructProperty, String roleType) {
|
|
||||||
|
|
||||||
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
|
||||||
|
|
||||||
String justGrantsQuery = ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
|
||||||
+ " <" + organizationURI + "> vivosocnet:" + constructProperty + " ?Grant . "
|
|
||||||
+ " "
|
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
|
||||||
+ " "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
|
|
||||||
+ " ?subOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?subOrganization core:relatedBy ?Position . "
|
|
||||||
+ " ?Position rdf:type core:Position . "
|
|
||||||
+ " ?Position core:relates ?Person . "
|
|
||||||
+ " ?Person rdf:type foaf:Person . "
|
|
||||||
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
|
||||||
+ " ?Role rdf:type core:" + roleType + " . "
|
|
||||||
+ " ?Role core:relatedBy ?Grant . "
|
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
|
||||||
+ " "
|
|
||||||
+ " LET(?now := now()) "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
String justDateTimeOnGrantsQuery = ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
|
||||||
+ " "
|
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
|
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
|
|
||||||
+ " "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
|
|
||||||
+ " ?subOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?subOrganization core:relatedBy ?Position . "
|
|
||||||
+ " ?Position rdf:type core:Position . "
|
|
||||||
+ " ?Position core:relates ?Person . "
|
|
||||||
+ " ?Person rdf:type foaf:Person . "
|
|
||||||
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
|
||||||
+ " ?Role rdf:type core:" + roleType + " . "
|
|
||||||
+ " ?Role core:relatedBy ?Grant . "
|
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
|
||||||
+ " "
|
|
||||||
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
|
||||||
// + " OPTIONAL { "
|
|
||||||
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
|
||||||
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
|
||||||
// + " } "
|
|
||||||
// + " OPTIONAL { "
|
|
||||||
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
|
||||||
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
|
|
||||||
// + " } "
|
|
||||||
+ " "
|
|
||||||
+ " LET(?now := now()) "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
String justDateTimeOnRolesQuery = ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
|
||||||
+ " "
|
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
|
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
|
|
||||||
+ " ?subOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?subOrganization core:relatedBy ?Position . "
|
|
||||||
+ " ?Position rdf:type core:Position . "
|
|
||||||
+ " ?Position core:relates ?Person . "
|
|
||||||
+ " ?Person rdf:type foaf:Person . "
|
|
||||||
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
|
||||||
+ " ?Role rdf:type core:" + roleType + " . "
|
|
||||||
+ " ?Role core:relatedBy ?Grant . "
|
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
|
||||||
+ " "
|
|
||||||
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
|
||||||
// + " OPTIONAL { "
|
|
||||||
+ " ?dateTimeIntervalValue core:start ?startDate . "
|
|
||||||
+ " ?startDate core:dateTime ?startDateTimeValue . "
|
|
||||||
// + " } "
|
|
||||||
// + " "
|
|
||||||
// + " OPTIONAL { "
|
|
||||||
// + " ?dateTimeIntervalValue core:end ?endDate . "
|
|
||||||
// + " ?endDate core:dateTime ?endDateTimeValue . "
|
|
||||||
// + " } "
|
|
||||||
+ " "
|
|
||||||
+ " LET(?now := now()) "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
differentPerspectiveQueries.add(justGrantsQuery);
|
|
||||||
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
|
|
||||||
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
|
|
||||||
|
|
||||||
return differentPerspectiveQueries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> constructOrganizationToGrantsQuery() {
|
|
||||||
|
|
||||||
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
|
|
||||||
|
|
||||||
Set<String> investigatorRoleQuery = constructOrganizationGrantsQueryTemplate("hasInvestigatorWithGrant", "InvestigatorRole");
|
|
||||||
Set<String> piRoleQuery = constructOrganizationGrantsQueryTemplate("hasPIWithGrant", "PrincipalInvestigatorRole");
|
|
||||||
Set<String> coPIRoleQuery = constructOrganizationGrantsQueryTemplate("hascoPIWithGrant", "CoPrincipalInvestigatorRole");
|
|
||||||
|
|
||||||
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
|
|
||||||
differentInvestigatorTypeQueries.addAll(piRoleQuery);
|
|
||||||
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
|
|
||||||
|
|
||||||
return differentInvestigatorTypeQueries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model executeQuery(Set<String> constructQueries) {
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
log.debug("CONSTRUCT query string : " + constructQueries);
|
|
||||||
|
|
||||||
for (String currentQuery : constructQueries) {
|
|
||||||
try {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
|
||||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
|
||||||
+ (after - before));
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
|
||||||
return executeQuery(constructOrganizationToGrantsQuery());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,115 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class OrganizationToPublicationsForSubOrganizationsModelConstructor implements ModelConstructor {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
|
||||||
|
|
||||||
private RDFService rdfService;
|
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "ORGANIZATION_TO_PUBLICATIONS_FOR_SUBORGANIZATIONS";
|
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Publications for specific organization via all descendants";
|
|
||||||
|
|
||||||
private String organizationURI;
|
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(OrganizationToPublicationsForSubOrganizationsModelConstructor.class.getName());
|
|
||||||
|
|
||||||
private long before, after;
|
|
||||||
|
|
||||||
public OrganizationToPublicationsForSubOrganizationsModelConstructor(String organizationURI, RDFService rdfService) {
|
|
||||||
this.organizationURI = organizationURI;
|
|
||||||
this.rdfService = rdfService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String constructOrganizationToPublicationsPublicationInformationQuery() {
|
|
||||||
|
|
||||||
return ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
|
||||||
+ " <" + organizationURI + "> vivosocnet:hasPersonWithPublication ?Document . "
|
|
||||||
+ " ?Document rdf:type bibo:Document . "
|
|
||||||
+ " ?Document rdfs:label ?DocumentLabel . "
|
|
||||||
+ " ?Document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?publicationDate . "
|
|
||||||
+ " ?Document core:hasPublicationVenue ?journal ."
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
|
|
||||||
+ " ?subOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?subOrganization core:relatedBy ?Position . "
|
|
||||||
+ " ?Position rdf:type core:Position . "
|
|
||||||
+ " ?Position core:relates ?Person . "
|
|
||||||
+ " ?Person rdf:type foaf:Person . "
|
|
||||||
+ " ?Person core:relatedBy ?Resource . "
|
|
||||||
+ " ?Resource rdf:type core:Authorship . "
|
|
||||||
+ " ?Resource core:relates ?Document . "
|
|
||||||
+ " ?Document rdf:type bibo:Document . "
|
|
||||||
+ " ?Document rdfs:label ?DocumentLabel . "
|
|
||||||
+ " "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?Document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?publicationDate . "
|
|
||||||
+ " } "
|
|
||||||
+ " "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?Document core:hasPublicationVenue ?journal ."
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " "
|
|
||||||
+ " LET(?now := now()) "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model executeQuery(String constructQuery) {
|
|
||||||
|
|
||||||
log.debug("[VIS CACHE] SubOrganizations Publications" + organizationURI);
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
log.debug("CONSTRUCT query string : " + constructQuery);
|
|
||||||
|
|
||||||
try {
|
|
||||||
rdfService.sparqlConstructQuery(QueryConstants.getSparqlPrefixQuery() + constructQuery, constructedModel);
|
|
||||||
} catch (Throwable th) {
|
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
|
||||||
+ "string. " + th.getMessage());
|
|
||||||
log.error(constructQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
|
||||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
|
||||||
+ (after - before));
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
|
||||||
return executeQuery(constructOrganizationToPublicationsPublicationInformationQuery());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,169 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
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;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class PeopleToGrantsModelConstructor implements ModelConstructor {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
|
||||||
|
|
||||||
private RDFService rdfService;
|
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "PEOPLE_TO_GRANTS";
|
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for all people via all roles";
|
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(PeopleToGrantsModelConstructor.class.getName());
|
|
||||||
|
|
||||||
private long before, after;
|
|
||||||
|
|
||||||
public PeopleToGrantsModelConstructor(RDFService rdfService) {
|
|
||||||
this.rdfService = rdfService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleType) {
|
|
||||||
|
|
||||||
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
|
||||||
|
|
||||||
String justGrantsQuery = ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " ?Person vivosocnet:lastCachedAt ?now . "
|
|
||||||
+ " ?Person vivosocnet:" + constructProperty + " ?Grant . "
|
|
||||||
+ " "
|
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
|
||||||
+ " "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
|
||||||
+ " ?Role rdf:type core:" + roleType + " . "
|
|
||||||
+ " ?Role core:relatedBy ?Grant . "
|
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
|
||||||
+ " "
|
|
||||||
+ " LET(?now := now()) "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
String justDateTimeOnGrantsQuery = ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " ?Person vivosocnet:lastCachedAt ?now . "
|
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
|
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
|
|
||||||
+ " "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
|
||||||
+ " ?Role rdf:type core:" + roleType + " . "
|
|
||||||
+ " ?Role core:relatedBy ?Grant . "
|
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
|
||||||
+ " "
|
|
||||||
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
|
||||||
// + " OPTIONAL { "
|
|
||||||
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
|
||||||
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
|
||||||
// + " } "
|
|
||||||
// + " OPTIONAL { "
|
|
||||||
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
|
||||||
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
|
|
||||||
// + " } "
|
|
||||||
+ " "
|
|
||||||
+ " LET(?now := now()) "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
String justDateTimeOnRolesQuery = ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " ?Person vivosocnet:lastCachedAt ?now . "
|
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
|
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
|
||||||
+ " ?Role rdf:type core:" + roleType + " . "
|
|
||||||
+ " ?Role core:relatedBy ?Grant . "
|
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
|
||||||
+ " "
|
|
||||||
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
|
||||||
// + " OPTIONAL { "
|
|
||||||
+ " ?dateTimeIntervalValue core:start ?startDate . "
|
|
||||||
+ " ?startDate core:dateTime ?startDateTimeValue . "
|
|
||||||
// + " } "
|
|
||||||
// + " "
|
|
||||||
// + " OPTIONAL { "
|
|
||||||
// + " ?dateTimeIntervalValue core:end ?endDate . "
|
|
||||||
// + " ?endDate core:dateTime ?endDateTimeValue . "
|
|
||||||
// + " } "
|
|
||||||
+ " "
|
|
||||||
+ " LET(?now := now()) "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
differentPerspectiveQueries.add(justGrantsQuery);
|
|
||||||
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
|
|
||||||
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
|
|
||||||
|
|
||||||
return differentPerspectiveQueries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> constructPeopleToGrantsQuery() {
|
|
||||||
|
|
||||||
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
|
|
||||||
|
|
||||||
Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "InvestigatorRole");
|
|
||||||
Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "PrincipalInvestigatorRole");
|
|
||||||
Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "CoPrincipalInvestigatorRole");
|
|
||||||
|
|
||||||
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
|
|
||||||
differentInvestigatorTypeQueries.addAll(piRoleQuery);
|
|
||||||
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
|
|
||||||
|
|
||||||
return differentInvestigatorTypeQueries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model executeQuery(Set<String> constructQueries) {
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
log.debug("CONSTRUCT query string : " + constructQueries);
|
|
||||||
|
|
||||||
for (String currentQuery : constructQueries) {
|
|
||||||
try {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
|
||||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
|
||||||
+ (after - before));
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
|
||||||
return executeQuery(constructPeopleToGrantsQuery());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,104 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class PeopleToPublicationsModelConstructor implements ModelConstructor {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
|
||||||
|
|
||||||
private RDFService rdfService;
|
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "PEOPLE_TO_PUBLICATIONS";
|
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Publications for all people";
|
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(PeopleToPublicationsModelConstructor.class.getName());
|
|
||||||
|
|
||||||
private long before, after;
|
|
||||||
|
|
||||||
public PeopleToPublicationsModelConstructor(RDFService rdfService) {
|
|
||||||
this.rdfService = rdfService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String constructPeopleToPublicationsQuery() {
|
|
||||||
|
|
||||||
return ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " ?person vivosocnet:lastCachedAt ?now . "
|
|
||||||
+ " ?person vivosocnet:hasPublication ?Document . "
|
|
||||||
+ " ?Document rdf:type bibo:Document . "
|
|
||||||
+ " ?Document rdfs:label ?DocumentLabel . "
|
|
||||||
+ " ?Document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?publicationDate . "
|
|
||||||
+ " ?Document core:hasPublicationVenue ?journal ."
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " ?person core:relatedBy ?Resource . "
|
|
||||||
+ " ?person rdf:type foaf:Person . "
|
|
||||||
+ " ?Resource rdf:type core:Authorship . "
|
|
||||||
+ " ?Resource core:relates ?Document . "
|
|
||||||
+ " ?Document rdf:type bibo:Document . "
|
|
||||||
+ " ?Document rdfs:label ?DocumentLabel . "
|
|
||||||
+ " "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?Document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?publicationDate . "
|
|
||||||
+ " } "
|
|
||||||
+ " "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?Document core:hasPublicationVenue ?journal ."
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " "
|
|
||||||
+ " LET(?now := now()) "
|
|
||||||
+ " } ";
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model executeQuery(String constructQuery) {
|
|
||||||
|
|
||||||
log.debug("in constructed model for ALL people publications ");
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
log.debug("CONSTRUCT query string : " + constructQuery);
|
|
||||||
|
|
||||||
try {
|
|
||||||
rdfService.sparqlConstructQuery(QueryConstants.getSparqlPrefixQuery() + constructQuery, constructedModel);
|
|
||||||
} catch (Throwable th) {
|
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
|
||||||
+ "string. " + th.getMessage());
|
|
||||||
log.error(constructQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
|
||||||
log.debug("Try to see Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
|
||||||
+ (after - before));
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
|
||||||
return executeQuery(constructPeopleToPublicationsQuery());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,106 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class PersonToPublicationsModelConstructor implements ModelConstructor {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
|
||||||
|
|
||||||
private RDFService rdfService;
|
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "PERSON_TO_PUBLICATIONS";
|
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Specific Person to Publications";
|
|
||||||
|
|
||||||
private String personURI;
|
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(PersonToPublicationsModelConstructor.class.getName());
|
|
||||||
|
|
||||||
private long before, after;
|
|
||||||
|
|
||||||
public PersonToPublicationsModelConstructor(String personURI, RDFService rdfService) {
|
|
||||||
this.personURI = personURI;
|
|
||||||
this.rdfService = rdfService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String constructPersonToPublicationsWithPublicationInformationQuery() {
|
|
||||||
|
|
||||||
return ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
|
|
||||||
+ " <" + personURI + "> vivosocnet:hasPublication ?Document . "
|
|
||||||
+ " ?Document rdf:type bibo:Document . "
|
|
||||||
+ " ?Document rdfs:label ?DocumentLabel . "
|
|
||||||
+ " ?Document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?publicationDate . "
|
|
||||||
+ " ?Document core:hasPublicationVenue ?journal ."
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " <" + personURI + "> core:relatedBy ?Resource . "
|
|
||||||
+ " ?Resource rdf:type core:Authorship . "
|
|
||||||
+ " ?Resource core:relates ?Document . "
|
|
||||||
+ " ?Document rdf:type bibo:Document . "
|
|
||||||
+ " ?Document rdfs:label ?DocumentLabel . "
|
|
||||||
+ " "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?Document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?publicationDate . "
|
|
||||||
+ " } "
|
|
||||||
+ " "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?Document core:hasPublicationVenue ?journal ."
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " "
|
|
||||||
+ " LET(?now := now()) "
|
|
||||||
+ " } ";
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model executeQuery(String constructQuery) {
|
|
||||||
|
|
||||||
log.debug("in constructed model for person to publications " + personURI);
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
log.debug("CONSTRUCT query string : " + constructQuery);
|
|
||||||
|
|
||||||
try {
|
|
||||||
rdfService.sparqlConstructQuery(QueryConstants.getSparqlPrefixQuery() + constructQuery, constructedModel);
|
|
||||||
} catch (Throwable th) {
|
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
|
||||||
+ "string. " + th.getMessage());
|
|
||||||
log.error(constructQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
|
||||||
log.debug("Try to see Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
|
||||||
+ (after - before));
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
|
||||||
return executeQuery(constructPersonToPublicationsWithPublicationInformationQuery());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class SubOrganizationWithinModelConstructor implements ModelConstructor {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "SUBORGANIZATION_WITHIN_HIERARCHY_MODEL";
|
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Bottom-up Organization hierarchy";
|
|
||||||
|
|
||||||
private RDFService rdfService;
|
|
||||||
|
|
||||||
private Model constructedModel;
|
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(SubOrganizationWithinModelConstructor.class.getName());
|
|
||||||
|
|
||||||
private long before, after;
|
|
||||||
|
|
||||||
public SubOrganizationWithinModelConstructor(RDFService rdfService) {
|
|
||||||
this.rdfService = rdfService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String constructAllSubOrganizationsWithinQuery() {
|
|
||||||
return ""
|
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " ?organization rdf:type foaf:Organization . "
|
|
||||||
+ " ?organization rdfs:label ?organizationLabel . "
|
|
||||||
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000050> ?parentOrganization . "
|
|
||||||
+ " ?parentOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " WHERE { "
|
|
||||||
+ " ?organization rdf:type foaf:Organization . "
|
|
||||||
+ " ?organization rdfs:label ?organizationLabel . "
|
|
||||||
+ " "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000050> ?parentOrganization . "
|
|
||||||
+ " ?parentOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
|
||||||
+ " } "
|
|
||||||
+ " } ";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model executeQuery(String constructQuery) {
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
log.debug("CONSTRUCT query string : " + constructQuery);
|
|
||||||
|
|
||||||
try {
|
|
||||||
rdfService.sparqlConstructQuery(QueryConstants.getSparqlPrefixQuery() + constructQuery, constructedModel);
|
|
||||||
} catch (Throwable th) {
|
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
|
||||||
+ "string. " + th.getMessage());
|
|
||||||
log.error(constructQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
|
||||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
|
||||||
+ (after - before));
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
if (constructedModel != null && !constructedModel.isEmpty()) {
|
|
||||||
return constructedModel;
|
|
||||||
} else {
|
|
||||||
constructedModel = executeQuery(constructAllSubOrganizationsWithinQuery());
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
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 com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|
||||||
|
|
||||||
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.valueobjects.ConstructedModelTracker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class OrganizationAssociatedPeopleModelWithTypesFactory implements ModelFactoryInterface {
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE));
|
|
||||||
|
|
||||||
if (candidateModel != null) {
|
|
||||||
|
|
||||||
return candidateModel;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationAssociatedPeopleModelWithTypesConstructor(uri, rdfService);
|
|
||||||
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
|
||||||
ConstructedModelTracker.trackModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE),
|
|
||||||
constructedModel);
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|
||||||
|
|
||||||
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.valueobjects.ConstructedModelTracker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class OrganizationModelWithTypesFactory implements ModelFactoryInterface {
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationModelWithTypesConstructor.MODEL_TYPE));
|
|
||||||
|
|
||||||
if (candidateModel != null) {
|
|
||||||
|
|
||||||
return candidateModel;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationModelWithTypesConstructor(rdfService);
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
|
||||||
|
|
||||||
ConstructedModelTracker.trackModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationModelWithTypesConstructor.MODEL_TYPE),
|
|
||||||
constructedModel);
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|
||||||
|
|
||||||
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.valueobjects.ConstructedModelTracker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class OrganizationToGrantsForSubOrganizationsFactory implements ModelFactoryInterface {
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE));
|
|
||||||
|
|
||||||
if (candidateModel != null) {
|
|
||||||
|
|
||||||
return candidateModel;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToGrantsForSubOrganizationsModelConstructor(uri, rdfService);
|
|
||||||
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
|
||||||
ConstructedModelTracker.trackModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE),
|
|
||||||
constructedModel);
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|
||||||
|
|
||||||
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.valueobjects.ConstructedModelTracker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import java.util.concurrent.locks.Lock;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.CustomLock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class OrganizationToPublicationsForSubOrganizationsFactory implements ModelFactoryInterface {
|
|
||||||
private Log log = LogFactory.getLog(OrganizationToPublicationsForSubOrganizationsFactory.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE));
|
|
||||||
|
|
||||||
if (candidateModel != null) {
|
|
||||||
|
|
||||||
return candidateModel;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Lock customLock = CustomLock.getLock();
|
|
||||||
if (customLock.tryLock()) //Acquiring lock if available to construct the model
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor(uri, rdfService);
|
|
||||||
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
|
||||||
ConstructedModelTracker.trackModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE),
|
|
||||||
constructedModel);
|
|
||||||
return constructedModel;
|
|
||||||
} finally {
|
|
||||||
customLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log.info("The Model construction process is going on");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|
||||||
|
|
||||||
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.valueobjects.ConstructedModelTracker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class PeopleToGrantsFactory implements ModelFactoryInterface {
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToGrantsModelConstructor.MODEL_TYPE));
|
|
||||||
|
|
||||||
if (candidateModel != null) {
|
|
||||||
|
|
||||||
return candidateModel;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToGrantsModelConstructor(rdfService);
|
|
||||||
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
|
||||||
ConstructedModelTracker.trackModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToGrantsModelConstructor.MODEL_TYPE),
|
|
||||||
constructedModel);
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|
||||||
|
|
||||||
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.valueobjects.ConstructedModelTracker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class PeopleToPublicationsFactory implements ModelFactoryInterface {
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToPublicationsModelConstructor.MODEL_TYPE));
|
|
||||||
|
|
||||||
if (candidateModel != null) {
|
|
||||||
|
|
||||||
return candidateModel;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToPublicationsModelConstructor(rdfService);
|
|
||||||
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
|
||||||
ConstructedModelTracker.trackModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToPublicationsModelConstructor.MODEL_TYPE),
|
|
||||||
constructedModel);
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
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;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
public class PersonToGrantsFactory implements ModelFactoryInterface {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
PersonToGrantsModelConstructor.MODEL_TYPE));
|
|
||||||
|
|
||||||
if (candidateModel != null) {
|
|
||||||
|
|
||||||
return candidateModel;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new PersonToGrantsModelConstructor(uri, rdfService);
|
|
||||||
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
|
||||||
ConstructedModelTracker.trackModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
PersonToGrantsModelConstructor.MODEL_TYPE),
|
|
||||||
constructedModel);
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|
||||||
|
|
||||||
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.valueobjects.ConstructedModelTracker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class PersonToPublicationsFactory implements ModelFactoryInterface {
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToPublicationsModelConstructor.MODEL_TYPE));
|
|
||||||
|
|
||||||
if (candidateModel != null) {
|
|
||||||
|
|
||||||
return candidateModel;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToPublicationsModelConstructor(uri, rdfService);
|
|
||||||
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
|
||||||
ConstructedModelTracker.trackModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
uri,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToPublicationsModelConstructor.MODEL_TYPE),
|
|
||||||
constructedModel);
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory;
|
|
||||||
|
|
||||||
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.valueobjects.ConstructedModelTracker;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No longer used - will be removed
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class SubOrganizationWithinModelFactory implements ModelFactoryInterface {
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException {
|
|
||||||
Model candidateModel = ConstructedModelTracker.getModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.SubOrganizationWithinModelConstructor.MODEL_TYPE));
|
|
||||||
|
|
||||||
if (candidateModel != null) {
|
|
||||||
|
|
||||||
return candidateModel;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.SubOrganizationWithinModelConstructor(rdfService);
|
|
||||||
Model constructedModel = model.getConstructedModel();
|
|
||||||
|
|
||||||
ConstructedModelTracker.trackModel(
|
|
||||||
ConstructedModelTracker
|
|
||||||
.generateModelIdentifier(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.SubOrganizationWithinModelConstructor.MODEL_TYPE),
|
|
||||||
constructedModel);
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,178 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.visualization.persongrantcount;
|
||||||
|
|
||||||
|
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.QuerySolution;
|
||||||
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
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 edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.jena.iri.IRI;
|
||||||
|
import org.apache.jena.iri.IRIFactory;
|
||||||
|
import org.apache.jena.iri.Violation;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This query runner is used to execute a sparql query that will fetch all the publications
|
||||||
|
* defined by bibo:Document property for a particular individual.
|
||||||
|
*
|
||||||
|
* @author cdtank
|
||||||
|
*/
|
||||||
|
public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>> {
|
||||||
|
|
||||||
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
|
private String personURI;
|
||||||
|
private RDFService rdfService;
|
||||||
|
|
||||||
|
private Log log;
|
||||||
|
|
||||||
|
public PersonGrantCountQueryRunner(String personURI,
|
||||||
|
RDFService rdfService, Log log) {
|
||||||
|
|
||||||
|
this.personURI = personURI;
|
||||||
|
this.rdfService = rdfService;
|
||||||
|
this.log = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSparqlConstruct(String queryURI) {
|
||||||
|
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||||
|
+ "CONSTRUCT \n"
|
||||||
|
+ "{\n"
|
||||||
|
+ " <" + queryURI + "> core:investigatorOn ?grant .\n"
|
||||||
|
+ " ?grant core:roleDate ?roleDate .\n"
|
||||||
|
+ " ?grant core:grantDate ?grantDate .\n"
|
||||||
|
+ "}\n"
|
||||||
|
+ "WHERE"
|
||||||
|
+ "{\n"
|
||||||
|
+ " {\n"
|
||||||
|
+ " <" + queryURI + "> rdf:type foaf:Person ;\n"
|
||||||
|
+ " <http://purl.obolibrary.org/obo/RO_0000053> ?role . \n"
|
||||||
|
+ " ?role core:relatedBy ?grant . \n"
|
||||||
|
+ " ?grant rdf:type core:Grant ; \n"
|
||||||
|
+ " rdfs:label ?grantLabel .\n"
|
||||||
|
+ " } UNION {\n"
|
||||||
|
+ " <" + queryURI + "> rdf:type foaf:Person ;\n"
|
||||||
|
+ " <http://purl.obolibrary.org/obo/RO_0000053> ?role . \n"
|
||||||
|
+ " ?role core:relatedBy ?grant . \n"
|
||||||
|
+ " ?grant rdf:type core:Grant .\n"
|
||||||
|
+ " ?role core:dateTimeInterval ?dateTimeInterval . \n"
|
||||||
|
+ " ?dateTimeInterval core:start ?dateTimeValue . \n"
|
||||||
|
+ " ?dateTimeValue core:dateTime ?roleDate .\n"
|
||||||
|
+ " } UNION {\n"
|
||||||
|
+ " <" + queryURI + "> rdf:type foaf:Person ;\n"
|
||||||
|
+ " <http://purl.obolibrary.org/obo/RO_0000053> ?role . \n"
|
||||||
|
+ " ?role core:relatedBy ?grant . \n"
|
||||||
|
+ " ?grant rdf:type core:Grant .\n"
|
||||||
|
+ " ?grant core:dateTimeInterval ?dateTimeInterval . \n"
|
||||||
|
+ " ?dateTimeInterval core:start ?dateTimeValue . \n"
|
||||||
|
+ " ?dateTimeValue core:dateTime ?grantDate .\n"
|
||||||
|
+ " }\n"
|
||||||
|
+ "}\n";
|
||||||
|
|
||||||
|
|
||||||
|
// Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "InvestigatorRole");
|
||||||
|
// Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "PrincipalInvestigatorRole");
|
||||||
|
// Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "CoPrincipalInvestigatorRole");
|
||||||
|
|
||||||
|
log.debug(sparqlQuery);
|
||||||
|
|
||||||
|
return sparqlQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSparqlQuery(String queryURI) {
|
||||||
|
|
||||||
|
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||||
|
+ "SELECT DISTINCT ?grant (SAMPLE(?sampleRoleDate) AS ?roleDate) (SAMPLE(?sampleGrantDate) AS ?grantDate)\n"
|
||||||
|
+ "WHERE { \n"
|
||||||
|
+ " <" + queryURI + "> core:investigatorOn ?grant . \n"
|
||||||
|
+ " OPTIONAL { ?grant core:roleDate ?sampleRoleDate . } .\n"
|
||||||
|
+ " OPTIONAL { ?grant core:grantDate ?sampleGrantDate . } .\n"
|
||||||
|
+ "} GROUP BY ?grant\n";
|
||||||
|
|
||||||
|
log.debug(sparqlQuery);
|
||||||
|
|
||||||
|
return sparqlQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Activity> getQueryResult()
|
||||||
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(this.personURI)) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To test for the validity of the URI submitted.
|
||||||
|
* */
|
||||||
|
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||||
|
IRI iri = iRIFactory.create(this.personURI);
|
||||||
|
if (iri.hasViolation(false)) {
|
||||||
|
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
||||||
|
log.error("Pub Count vis Query " + errorMsg);
|
||||||
|
throw new MalformedQueryParametersException(
|
||||||
|
"URI provided for an individual is malformed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new MalformedQueryParametersException("URL parameter is either null or empty.");
|
||||||
|
}
|
||||||
|
|
||||||
|
PersonGrantConsumer consumer = new PersonGrantConsumer();
|
||||||
|
try {
|
||||||
|
Model model = ModelFactory.createDefaultModel();
|
||||||
|
rdfService.sparqlConstructQuery(getSparqlConstruct(this.personURI), model);
|
||||||
|
|
||||||
|
Query q = QueryFactory.create(getSparqlQuery(this.personURI));
|
||||||
|
QueryExecution qe = QueryExecutionFactory.create(q, model);
|
||||||
|
try {
|
||||||
|
consumer.processResultSet(qe.execSelect());
|
||||||
|
} finally {
|
||||||
|
qe.close();
|
||||||
|
}
|
||||||
|
} catch (RDFServiceException r) {
|
||||||
|
throw new RuntimeException(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
return consumer.getAuthorGrants();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class PersonGrantConsumer extends ResultSetConsumer {
|
||||||
|
Set<Activity> authorGrants = new HashSet<Activity>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void processQuerySolution(QuerySolution qs) {
|
||||||
|
Activity biboDocument = new Activity(qs.get("grant").asResource().getURI());
|
||||||
|
|
||||||
|
RDFNode roleDateNode = qs.get("roleDate");
|
||||||
|
if (roleDateNode != null) {
|
||||||
|
biboDocument.setActivityDate(roleDateNode.asLiteral().getString());
|
||||||
|
} else {
|
||||||
|
RDFNode grantDateNode = qs.get("grantDate");
|
||||||
|
if (grantDateNode != null) {
|
||||||
|
biboDocument.setActivityDate(grantDateNode.asLiteral().getString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
authorGrants.add(biboDocument);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Activity> getAuthorGrants() {
|
||||||
|
return authorGrants;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,9 @@ package edu.cornell.mannlib.vitro.webapp.visualization.persongrantcount;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
|
||||||
import org.apache.commons.lang.StringEscapeUtils;
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -21,7 +23,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryP
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SparklineData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SparklineData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SubEntity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SubEntity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.SelectOnModelUtilities;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
||||||
|
|
||||||
|
@ -55,15 +56,19 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
|
||||||
personURI,
|
personURI,
|
||||||
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI));
|
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI));
|
||||||
|
|
||||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false);
|
QueryRunner<Set<Activity>> queryManager = new PersonGrantCountQueryRunner(
|
||||||
|
personURI,
|
||||||
|
vitroRequest.getRDFService(),
|
||||||
|
log);
|
||||||
|
|
||||||
|
Set<Activity> authorGrants = queryManager.getQueryResult();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a map from the year to number of grants. Use the Grant's
|
* Create a map from the year to number of publications. Use the
|
||||||
* parsedGrantYear to populate the data.
|
* BiboDocument's parsedPublicationYear to populate the data.
|
||||||
* */
|
*/
|
||||||
Map<String, Integer> yearToGrantCount =
|
Map<String, Integer> yearToGrantCount =
|
||||||
UtilityFunctions.getYearToActivityCount(grantsToURI.values());
|
UtilityFunctions.getYearToActivityCount(authorGrants);
|
||||||
|
|
||||||
return prepareDataResponse(person,
|
return prepareDataResponse(person,
|
||||||
yearToGrantCount);
|
yearToGrantCount);
|
||||||
|
@ -92,18 +97,19 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
|
||||||
String visContainer = vitroRequest
|
String visContainer = vitroRequest
|
||||||
.getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY);
|
.getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY);
|
||||||
|
|
||||||
SubEntity person = new SubEntity(
|
QueryRunner<Set<Activity>> queryManager = new PersonGrantCountQueryRunner(
|
||||||
personURI,
|
personURI,
|
||||||
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI));
|
vitroRequest.getRDFService(),
|
||||||
|
log);
|
||||||
|
|
||||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false);
|
Set<Activity> authorGrants = queryManager.getQueryResult();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a map from the year to number of grants. Use the Grant's
|
* Create a map from the year to number of publications. Use the
|
||||||
* parsedGrantYear to populate the data.
|
* BiboDocument's parsedPublicationYear to populate the data.
|
||||||
* */
|
*/
|
||||||
Map<String, Integer> yearToGrantCount =
|
Map<String, Integer> yearToGrantCount =
|
||||||
UtilityFunctions.getYearToActivityCount(grantsToURI.values());
|
UtilityFunctions.getYearToActivityCount(authorGrants);
|
||||||
|
|
||||||
|
|
||||||
boolean shouldVIVOrenderVis = yearToGrantCount.size() > 0 ? true : false;
|
boolean shouldVIVOrenderVis = yearToGrantCount.size() > 0 ? true : false;
|
||||||
|
@ -143,18 +149,19 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
|
||||||
String visContainer = vitroRequest
|
String visContainer = vitroRequest
|
||||||
.getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY);
|
.getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY);
|
||||||
|
|
||||||
SubEntity person = new SubEntity(
|
QueryRunner<Set<Activity>> queryManager = new PersonGrantCountQueryRunner(
|
||||||
personURI,
|
personURI,
|
||||||
UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI));
|
vitroRequest.getRDFService(),
|
||||||
|
log);
|
||||||
|
|
||||||
Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false);
|
Set<Activity> authorGrants = queryManager.getQueryResult();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a map from the year to number of grants. Use the Grant's
|
* Create a map from the year to number of publications. Use the
|
||||||
* parsedGrantYear to populate the data.
|
* BiboDocument's parsedPublicationYear to populate the data.
|
||||||
* */
|
*/
|
||||||
Map<String, Integer> yearToGrantCount =
|
Map<String, Integer> yearToGrantCount =
|
||||||
UtilityFunctions.getYearToActivityCount(grantsToURI.values());
|
UtilityFunctions.getYearToActivityCount(authorGrants);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Computations required to generate HTML for the sparkline & related context.
|
* Computations required to generate HTML for the sparkline & related context.
|
||||||
|
@ -240,7 +247,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
|
||||||
* page, e.g. profile page.
|
* page, e.g. profile page.
|
||||||
* @param vreq
|
* @param vreq
|
||||||
* @param valueObjectContainer
|
* @param valueObjectContainer
|
||||||
* @param yearToGrantCount
|
* @param shouldVIVOrenderVis
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private TemplateResponseValues prepareDynamicResponse(
|
private TemplateResponseValues prepareDynamicResponse(
|
||||||
|
|
|
@ -9,11 +9,9 @@ import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoAuthorshipData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoAuthorshipData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoInvestigationData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoInvestigationData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.CollaborationDataViewHelper;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.CollaborationDataViewHelper;
|
||||||
import org.apache.axis.utils.StringUtils;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -23,7 +21,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFr
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.CoAuthorshipQueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.CoAuthorshipQueryRunner;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.CoAuthorshipVisCodeGenerator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.CoAuthorshipVisCodeGenerator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.coprincipalinvestigator.CoPIGrantCountConstructQueryRunner;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.coprincipalinvestigator.CoPIGrantCountQueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.coprincipalinvestigator.CoPIGrantCountQueryRunner;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.coprincipalinvestigator.CoPIVisCodeGenerator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.coprincipalinvestigator.CoPIVisCodeGenerator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
|
@ -31,10 +28,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.persongrantcount.PersonGra
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.personpubcount.PersonPublicationCountVisCodeGenerator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.personpubcount.PersonPublicationCountVisCodeGenerator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SparklineData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SparklineData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SubEntity;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.SelectOnModelUtilities;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
||||||
|
|
||||||
|
|
|
@ -1,945 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.ModelConstructorUtilities;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Entity;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.MapOfScienceActivity;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SubEntity;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class SelectOnModelUtilities {
|
|
||||||
public static String getLastCachedAtForEntity(ResultSet queryResult) {
|
|
||||||
|
|
||||||
String lastCachedAtDateTime = null;
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
RDFNode lastCachedAtNode = solution.get(QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
|
||||||
if (lastCachedAtNode != null) {
|
|
||||||
lastCachedAtDateTime = lastCachedAtNode.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastCachedAtDateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void getGrantForEntity(
|
|
||||||
ResultSet queryResult,
|
|
||||||
SubEntity subEntity,
|
|
||||||
Map<String, Activity> allGrantURIToVO) {
|
|
||||||
|
|
||||||
Set<Activity> currentEntityGrants = new HashSet<Activity>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(subEntity.getLastCachedAtDateTime())) {
|
|
||||||
|
|
||||||
RDFNode lastCachedAtNode = solution.get(QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
|
||||||
if (lastCachedAtNode != null) {
|
|
||||||
subEntity.setLastCachedAtDateTime(lastCachedAtNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode grantNode = solution.get(QueryFieldLabels.GRANT_URL);
|
|
||||||
Activity coreGrant;
|
|
||||||
|
|
||||||
if (allGrantURIToVO.containsKey(grantNode.toString())) {
|
|
||||||
coreGrant = allGrantURIToVO.get(grantNode.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
coreGrant = new Activity(grantNode.toString());
|
|
||||||
allGrantURIToVO.put(grantNode.toString(), coreGrant);
|
|
||||||
|
|
||||||
RDFNode grantStartDateNode = solution.get(QueryFieldLabels.ROLE_START_DATE);
|
|
||||||
|
|
||||||
if (grantStartDateNode != null) {
|
|
||||||
coreGrant.setActivityDate(grantStartDateNode.toString());
|
|
||||||
} else {
|
|
||||||
grantStartDateNode = solution
|
|
||||||
.get(QueryFieldLabels.GRANT_START_DATE);
|
|
||||||
if (grantStartDateNode != null) {
|
|
||||||
coreGrant.setActivityDate(grantStartDateNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentEntityGrants.add(coreGrant);
|
|
||||||
}
|
|
||||||
|
|
||||||
subEntity.addActivities(currentEntityGrants);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
SubEntity entity, Model subOrganizationGrantsModel)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ "{"
|
|
||||||
+ " <" + entity.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> entityLastCachedAtQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
subOrganizationGrantsModel);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtForEntity(entityLastCachedAtQuery.getQueryResult());
|
|
||||||
return lastCachedAtForEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method side-effects person and the central grants map.
|
|
||||||
* @param person
|
|
||||||
* @param allGrantURIToVOs
|
|
||||||
* @param personGrantsModel
|
|
||||||
* @throws MalformedQueryParametersException
|
|
||||||
*/
|
|
||||||
private static void updateGrantsForPerson(SubEntity person,
|
|
||||||
Map<String, Activity> allGrantURIToVOs, Model personGrantsModel)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
|
|
||||||
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ "{"
|
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsAnInvestigator ?grant . "
|
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
|
||||||
+ "}"
|
|
||||||
+ "UNION"
|
|
||||||
+ "{"
|
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsPI ?grant . "
|
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
|
||||||
+ "}"
|
|
||||||
+ "UNION"
|
|
||||||
+ "{"
|
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsCoPI ?grant . "
|
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> personGrantsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
personGrantsModel);
|
|
||||||
|
|
||||||
getGrantForEntity(personGrantsQuery.getQueryResult(), person, allGrantURIToVOs);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
person,
|
|
||||||
personGrantsModel);
|
|
||||||
|
|
||||||
person.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Activity> getGrantsForPerson(
|
|
||||||
RDFService rdfService, SubEntity person, boolean doCache)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
Model personGrantsModel = null;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we dont want to cache the results then create the model directly without
|
|
||||||
* using the ModelConstructorUtilities. Use case is the co-pi ego-centric
|
|
||||||
* visualization.
|
|
||||||
* */
|
|
||||||
if (doCache) {
|
|
||||||
personGrantsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
person.getIndividualURI(),
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToGrantsModelConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToGrantsModelConstructor(person.getIndividualURI(), rdfService);
|
|
||||||
personGrantsModel = model.getConstructedModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
updateGrantsForPerson(person, allGrantURIToVOs, personGrantsModel);
|
|
||||||
|
|
||||||
|
|
||||||
return allGrantURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Entity getSubjectOrganizationHierarchy(RDFService rdfService,
|
|
||||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
|
||||||
Model organizationModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationModelWithTypesConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("subOrganization", QueryFieldLabels.SUBORGANIZATION_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("subOrganizationLabel", QueryFieldLabels.SUBORGANIZATION_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("subOrganizationTypeLabel", QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + subjectEntityURI + "> <http://purl.obolibrary.org/obo/BFO_0000051> ?subOrganization . "
|
|
||||||
+ " ?subOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
|
||||||
+ " ?subOrganization rdf:type ?subOrgType . "
|
|
||||||
+ " ?subOrgType rdfs:label ?subOrganizationTypeLabel . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationsWithTypesQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
organizationModel);
|
|
||||||
|
|
||||||
Entity entityWithSubOrganizations = getEntityWithSubOrganizations(subjectEntityURI,
|
|
||||||
subOrganizationsWithTypesQuery.getQueryResult());
|
|
||||||
|
|
||||||
Entity entityWithParentOrganizations = getAllParentOrganizations(rdfService, subjectEntityURI);
|
|
||||||
|
|
||||||
entityWithSubOrganizations.addParents(entityWithParentOrganizations.getParents());
|
|
||||||
|
|
||||||
return entityWithSubOrganizations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
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(rdfService, subjectEntityURI);
|
|
||||||
//
|
|
||||||
// personEntity.addParents(entityWithParentOrganizations.getParents());
|
|
||||||
|
|
||||||
return personEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Entity getAllParentOrganizations(RDFService rdfService,
|
|
||||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
|
||||||
Model organizationModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.SubOrganizationWithinModelConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("parentOrganization", QueryFieldLabels.PARENT_ORGANIZATION_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("parentOrganizationLabel", QueryFieldLabels.PARENT_ORGANIZATION_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + subjectEntityURI + "> <http://purl.obolibrary.org/obo/BFO_0000050> ?parentOrganization . "
|
|
||||||
+ " ?parentOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> parentOrganizationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
organizationModel);
|
|
||||||
|
|
||||||
return getEntityWithParentOrganizations(subjectEntityURI,
|
|
||||||
parentOrganizationsQuery.getQueryResult());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static Entity getEntityWithParentOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
|
||||||
|
|
||||||
Entity entity = new Entity(subjectEntityURI);
|
|
||||||
Map<String, Individual> parentOrganizationURIToVO = new HashMap<String, Individual>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
if (organizationLabelNode != null) {
|
|
||||||
entity.setIndividualLabel(organizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode parentOrganizationNode = solution.get(QueryFieldLabels.PARENT_ORGANIZATION_URL);
|
|
||||||
|
|
||||||
Individual parent;
|
|
||||||
|
|
||||||
if (!parentOrganizationURIToVO.containsKey(parentOrganizationNode.toString())) {
|
|
||||||
|
|
||||||
parent = new Individual(parentOrganizationNode.toString());
|
|
||||||
|
|
||||||
parentOrganizationURIToVO.put(parentOrganizationNode.toString(), parent);
|
|
||||||
|
|
||||||
RDFNode parentOrganizationLabelNode = solution.get(QueryFieldLabels.PARENT_ORGANIZATION_LABEL);
|
|
||||||
if (parentOrganizationLabelNode != null) {
|
|
||||||
parent.setIndividualLabel(parentOrganizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.addParents(parentOrganizationURIToVO.values());
|
|
||||||
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static Entity getEntityWithSubOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
|
||||||
|
|
||||||
Entity entity = new Entity(subjectEntityURI);
|
|
||||||
Map<String, SubEntity> subOrganizationURIToVO = new HashMap<String, SubEntity>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
if (organizationLabelNode != null) {
|
|
||||||
|
|
||||||
entity.setEntityLabel(organizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode subOrganizationNode = solution.get(QueryFieldLabels.SUBORGANIZATION_URL);
|
|
||||||
|
|
||||||
SubEntity subEntity;
|
|
||||||
|
|
||||||
if (subOrganizationURIToVO.containsKey(subOrganizationNode.toString())) {
|
|
||||||
|
|
||||||
subEntity = subOrganizationURIToVO.get(subOrganizationNode.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
subEntity = new SubEntity(subOrganizationNode.toString());
|
|
||||||
|
|
||||||
subEntity.setEntityClass(VOConstants.EntityClassType.ORGANIZATION);
|
|
||||||
|
|
||||||
subOrganizationURIToVO.put(subOrganizationNode.toString(), subEntity);
|
|
||||||
|
|
||||||
RDFNode subOrganizationLabelNode = solution.get(QueryFieldLabels.SUBORGANIZATION_LABEL);
|
|
||||||
if (subOrganizationLabelNode != null) {
|
|
||||||
subEntity.setIndividualLabel(subOrganizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode subOrganizationTypeLabelNode = solution.get(QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL);
|
|
||||||
if (subOrganizationTypeLabelNode != null) {
|
|
||||||
subEntity.addEntityTypeLabel(subOrganizationTypeLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.addSubEntitities(subOrganizationURIToVO.values());
|
|
||||||
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Entity getSubjectOrganizationAssociatedPeople(RDFService rdfService,
|
|
||||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
|
||||||
Model associatedPeopleModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
subjectEntityURI,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("person", QueryFieldLabels.PERSON_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("personLabel", QueryFieldLabels.PERSON_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("personTypeLabel", QueryFieldLabels.PERSON_TYPE_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + subjectEntityURI + "> vivosocnet:hasPersonWithActivity ?person . "
|
|
||||||
+ " ?person rdfs:label ?personLabel . "
|
|
||||||
+ " ?person rdf:type ?personType . "
|
|
||||||
+ " ?personType rdfs:label ?personTypeLabel . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> associatedPeopleWithTypesQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
associatedPeopleModel);
|
|
||||||
|
|
||||||
return getEntityWithAssociatedPeopleSubEntitities(subjectEntityURI, associatedPeopleWithTypesQuery.getQueryResult());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static Entity getEntityWithAssociatedPeopleSubEntitities(
|
|
||||||
String subjectEntityURI, ResultSet queryResult) {
|
|
||||||
|
|
||||||
Entity entity = new Entity(subjectEntityURI);
|
|
||||||
Map<String, SubEntity> associatedPeopleURIToVO = new HashMap<String, SubEntity>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
if (organizationLabelNode != null) {
|
|
||||||
entity.setIndividualLabel(organizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode personNode = solution.get(QueryFieldLabels.PERSON_URL);
|
|
||||||
|
|
||||||
SubEntity subEntity;
|
|
||||||
|
|
||||||
if (associatedPeopleURIToVO.containsKey(personNode.toString())) {
|
|
||||||
|
|
||||||
subEntity = associatedPeopleURIToVO.get(personNode.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
subEntity = new SubEntity(personNode.toString());
|
|
||||||
subEntity.setEntityClass(VOConstants.EntityClassType.PERSON);
|
|
||||||
associatedPeopleURIToVO.put(personNode.toString(), subEntity);
|
|
||||||
|
|
||||||
RDFNode personLabelNode = solution.get(QueryFieldLabels.PERSON_LABEL);
|
|
||||||
if (personLabelNode != null) {
|
|
||||||
subEntity.setIndividualLabel(personLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode personTypeLabelNode = solution.get(QueryFieldLabels.PERSON_TYPE_LABEL);
|
|
||||||
if (personTypeLabelNode != null) {
|
|
||||||
subEntity.addEntityTypeLabel(personTypeLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.addSubEntitities(associatedPeopleURIToVO.values());
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Map<String, Activity> getPublicationsForAllSubOrganizations(
|
|
||||||
RDFService rdfService, Entity organizationEntity)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
|
||||||
|
|
||||||
Model subOrganizationPublicationsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
subOrganization.getIndividualURI(),
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
|
|
||||||
// System.out.println("getting publications for " + subOrganization.getIndividualLabel());
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPersonWithPublication ?document . "
|
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationPublicationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
subOrganizationPublicationsModel);
|
|
||||||
|
|
||||||
getPublicationForEntity(subOrganizationPublicationsQuery.getQueryResult(),
|
|
||||||
subOrganization,
|
|
||||||
allDocumentURIToVOs);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
subOrganization,
|
|
||||||
subOrganizationPublicationsModel);
|
|
||||||
|
|
||||||
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
|
|
||||||
}
|
|
||||||
return allDocumentURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Map<String, Activity> getPublicationsWithJournalForAllSubOrganizations(
|
|
||||||
RDFService rdfService, Entity organizationEntity)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
|
||||||
|
|
||||||
Model subOrganizationPublicationsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
subOrganization.getIndividualURI(),
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
|
|
||||||
// System.out.println("getting publications for " + subOrganization.getIndividualLabel());
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
fieldLabelToOutputFieldLabel.put("journalLabel", QueryFieldLabels.DOCUMENT_JOURNAL_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPersonWithPublication ?document . "
|
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:hasPublicationVenue ?journal . "
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . } ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationPublicationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
subOrganizationPublicationsModel);
|
|
||||||
|
|
||||||
getPublicationWithJournalForEntity(subOrganizationPublicationsQuery.getQueryResult(),
|
|
||||||
subOrganization,
|
|
||||||
allDocumentURIToVOs);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
subOrganization,
|
|
||||||
subOrganizationPublicationsModel);
|
|
||||||
|
|
||||||
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
|
|
||||||
}
|
|
||||||
return allDocumentURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static void getPublicationForEntity(
|
|
||||||
ResultSet queryResult,
|
|
||||||
SubEntity subEntity,
|
|
||||||
Map<String, Activity> allDocumentURIToVOs) {
|
|
||||||
|
|
||||||
Set<Activity> currentEntityPublications = new HashSet<Activity>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(subEntity.getLastCachedAtDateTime())) {
|
|
||||||
|
|
||||||
RDFNode lastCachedAtNode = solution.get(QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
|
||||||
if (lastCachedAtNode != null) {
|
|
||||||
subEntity.setLastCachedAtDateTime(lastCachedAtNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
Activity biboDocument;
|
|
||||||
|
|
||||||
if (allDocumentURIToVOs.containsKey(documentNode.toString())) {
|
|
||||||
biboDocument = allDocumentURIToVOs.get(documentNode.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
biboDocument = new Activity(documentNode.toString());
|
|
||||||
allDocumentURIToVOs.put(documentNode.toString(), biboDocument);
|
|
||||||
|
|
||||||
RDFNode publicationDateNode = solution.get(QueryFieldLabels
|
|
||||||
.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
if (publicationDateNode != null) {
|
|
||||||
biboDocument.setActivityDate(publicationDateNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentEntityPublications.add(biboDocument);
|
|
||||||
}
|
|
||||||
subEntity.addActivities(currentEntityPublications);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static void getPublicationWithJournalForEntity(
|
|
||||||
ResultSet queryResult,
|
|
||||||
SubEntity subEntity,
|
|
||||||
Map<String, Activity> allDocumentURIToVOs) {
|
|
||||||
|
|
||||||
Set<Activity> currentEntityPublications = new HashSet<Activity>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(subEntity.getLastCachedAtDateTime())) {
|
|
||||||
|
|
||||||
RDFNode lastCachedAtNode = solution.get(QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
|
||||||
if (lastCachedAtNode != null) {
|
|
||||||
subEntity.setLastCachedAtDateTime(lastCachedAtNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
Activity biboDocument;
|
|
||||||
|
|
||||||
if (allDocumentURIToVOs.containsKey(documentNode.toString())) {
|
|
||||||
biboDocument = allDocumentURIToVOs.get(documentNode.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
biboDocument = new MapOfScienceActivity(documentNode.toString());
|
|
||||||
allDocumentURIToVOs.put(documentNode.toString(), biboDocument);
|
|
||||||
|
|
||||||
RDFNode publicationDateNode = solution.get(QueryFieldLabels
|
|
||||||
.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
if (publicationDateNode != null) {
|
|
||||||
biboDocument.setActivityDate(publicationDateNode.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode publicationJournalNode = solution.get(QueryFieldLabels
|
|
||||||
.DOCUMENT_JOURNAL_LABEL);
|
|
||||||
|
|
||||||
if (publicationJournalNode != null) {
|
|
||||||
((MapOfScienceActivity) biboDocument).setPublishedInJournal(publicationJournalNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentEntityPublications.add(biboDocument);
|
|
||||||
|
|
||||||
}
|
|
||||||
subEntity.addActivities(currentEntityPublications);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Map<String, Activity> getGrantsForAllSubOrganizations(
|
|
||||||
RDFService rdfService, Entity organizationEntity)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allGrantURIToVO = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
|
||||||
|
|
||||||
// System.out.println("constructing grants for " + subOrganization.getIndividualLabel() + " :: " + subOrganization.getIndividualURI());
|
|
||||||
|
|
||||||
long before = System.currentTimeMillis();
|
|
||||||
|
|
||||||
Model subOrganizationGrantsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
subOrganization.getIndividualURI(),
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
|
|
||||||
// System.out.println("\t construct -> " + (System.currentTimeMillis() - before));
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
|
|
||||||
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ "{"
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasInvestigatorWithGrant ?grant . "
|
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
|
||||||
+ "}"
|
|
||||||
+ "UNION"
|
|
||||||
+ "{"
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPIWithGrant ?grant . "
|
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
|
||||||
+ "}"
|
|
||||||
+ "UNION"
|
|
||||||
+ "{"
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hascoPIWithGrant ?grant . "
|
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationGrantsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
subOrganizationGrantsModel);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This method side-affects the subOrganization entity & the map containing all the grants for
|
|
||||||
* the subject organization.
|
|
||||||
* */
|
|
||||||
getGrantForEntity(subOrganizationGrantsQuery.getQueryResult(), subOrganization, allGrantURIToVO);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
subOrganization,
|
|
||||||
subOrganizationGrantsModel);
|
|
||||||
|
|
||||||
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
|
|
||||||
// System.out.println("\t select -> " + (System.currentTimeMillis() - before));
|
|
||||||
}
|
|
||||||
return allGrantURIToVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Map<String, Activity> getGrantsForAssociatedPeople(
|
|
||||||
RDFService rdfService, Collection<SubEntity> people)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
Model peopleGrantsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToGrantsModelConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
|
|
||||||
for (SubEntity person : people) {
|
|
||||||
updateGrantsForPerson(person, allGrantURIToVOs, peopleGrantsModel);
|
|
||||||
}
|
|
||||||
return allGrantURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Map<String, Activity> getPublicationsForPerson(
|
|
||||||
RDFService rdfService, SubEntity person, boolean doCache)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
Map<String, Activity> allPublicationURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
Model personPublicationsModel = null;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we dont want to cache the results then create the model directly without
|
|
||||||
* using the ModelConstructorUtilities. Use case is the co-author ego-centric
|
|
||||||
* visualization.
|
|
||||||
* */
|
|
||||||
if (doCache) {
|
|
||||||
personPublicationsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
person.getIndividualURI(),
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToPublicationsModelConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PersonToPublicationsModelConstructor(person.getIndividualURI(), rdfService);
|
|
||||||
personPublicationsModel = model.getConstructedModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
updatePublicationsForPerson(person, allPublicationURIToVOs, personPublicationsModel);
|
|
||||||
|
|
||||||
return allPublicationURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Activity> getPublicationsForAssociatedPeople(
|
|
||||||
RDFService rdfService, Collection<SubEntity> people)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
Model peoplePublicationsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToPublicationsModelConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
|
|
||||||
for (SubEntity person : people) {
|
|
||||||
|
|
||||||
updatePublicationsForPerson(person, allDocumentURIToVOs,
|
|
||||||
peoplePublicationsModel);
|
|
||||||
|
|
||||||
}
|
|
||||||
return allDocumentURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method side-effects the person and the central documents map.
|
|
||||||
* @param person
|
|
||||||
* @param allDocumentURIToVOs
|
|
||||||
* @param peoplePublicationsModel
|
|
||||||
* @throws MalformedQueryParametersException
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
private static void updatePublicationsForPerson(SubEntity person,
|
|
||||||
Map<String, Activity> allDocumentURIToVOs,
|
|
||||||
Model peoplePublicationsModel)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasPublication ?document . "
|
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> personPublicationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
peoplePublicationsModel);
|
|
||||||
|
|
||||||
getPublicationForEntity(personPublicationsQuery.getQueryResult(),
|
|
||||||
person,
|
|
||||||
allDocumentURIToVOs);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
person,
|
|
||||||
peoplePublicationsModel);
|
|
||||||
|
|
||||||
person.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Map<String, Activity> getPublicationsWithJournalForAssociatedPeople(
|
|
||||||
RDFService rdfService, Collection<SubEntity> people)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
Model peoplePublicationsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
null,
|
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.PeopleToPublicationsModelConstructor.MODEL_TYPE,
|
|
||||||
rdfService);
|
|
||||||
|
|
||||||
for (SubEntity person : people) {
|
|
||||||
|
|
||||||
// System.out.println("getting publications for " + person.getIndividualLabel());
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
fieldLabelToOutputFieldLabel.put("journalLabel", QueryFieldLabels.DOCUMENT_JOURNAL_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasPublication ?document . "
|
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:hasPublicationVenue ?journal . "
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . } ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> personPublicationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
peoplePublicationsModel);
|
|
||||||
|
|
||||||
getPublicationWithJournalForEntity(personPublicationsQuery.getQueryResult(),
|
|
||||||
person,
|
|
||||||
allDocumentURIToVOs);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
person,
|
|
||||||
peoplePublicationsModel);
|
|
||||||
|
|
||||||
person.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
|
|
||||||
}
|
|
||||||
return allDocumentURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -12,7 +12,7 @@ var visualization = {
|
||||||
url: url,
|
url: url,
|
||||||
data: {
|
data: {
|
||||||
'render_mode': 'dynamic',
|
'render_mode': 'dynamic',
|
||||||
'vis': 'person_pub_count',
|
'vis': 'person_grant_count',
|
||||||
'vis_mode': 'short',
|
'vis_mode': 'short',
|
||||||
'container': containerIdCoAuthor
|
'container': containerIdCoAuthor
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue