From e1b5e2448e2bcb5acd81362308e85a161046c3d6 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Fri, 27 May 2016 23:39:00 +0100 Subject: [PATCH] [VIVO-1120] Remove deprecated visualisation model code --- .../ModelConstructorUtilities.java | 29 - ...ciatedPeopleModelWithTypesConstructor.java | 107 -- ...OrganizationModelWithTypesConstructor.java | 102 -- ...tsForSubOrganizationsModelConstructor.java | 198 ---- ...nsForSubOrganizationsModelConstructor.java | 115 --- .../PeopleToGrantsModelConstructor.java | 169 ---- .../PeopleToPublicationsModelConstructor.java | 104 -- .../PersonToPublicationsModelConstructor.java | 106 -- ...SubOrganizationWithinModelConstructor.java | 99 -- .../factory/ModelFactoryInterface.java | 1 - ...AssociatedPeopleModelWithTypesFactory.java | 46 - .../OrganizationModelWithTypesFactory.java | 44 - ...ionToGrantsForSubOrganizationsFactory.java | 46 - ...ublicationsForSubOrganizationsFactory.java | 66 -- .../factory/PeopleToGrantsFactory.java | 44 - .../factory/PeopleToPublicationsFactory.java | 46 - .../factory/PersonToGrantsFactory.java | 44 - .../factory/PersonToPublicationsFactory.java | 46 - .../SubOrganizationWithinModelFactory.java | 44 - .../PersonGrantCountQueryRunner.java | 178 ++++ .../PersonGrantCountRequestHandler.java | 77 +- .../PersonLevelRequestHandler.java | 7 - .../visutils/SelectOnModelUtilities.java | 945 ------------------ .../main/webapp/js/visualization/sparkline.js | 2 +- 24 files changed, 221 insertions(+), 2444 deletions(-) delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationAssociatedPeopleModelWithTypesConstructor.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationModelWithTypesConstructor.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationToGrantsForSubOrganizationsModelConstructor.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationToPublicationsForSubOrganizationsModelConstructor.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PeopleToGrantsModelConstructor.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PeopleToPublicationsModelConstructor.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PersonToPublicationsModelConstructor.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/SubOrganizationWithinModelConstructor.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationAssociatedPeopleModelWithTypesFactory.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationModelWithTypesFactory.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToGrantsForSubOrganizationsFactory.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToPublicationsForSubOrganizationsFactory.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToGrantsFactory.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToPublicationsFactory.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToGrantsFactory.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToPublicationsFactory.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/SubOrganizationWithinModelFactory.java create mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/persongrantcount/PersonGrantCountQueryRunner.java delete mode 100644 api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/visutils/SelectOnModelUtilities.java diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorUtilities.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorUtilities.java index ad14eed9..fc470486 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorUtilities.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorUtilities.java @@ -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.visualization.exceptions.MalformedQueryParametersException; import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.ModelFactoryInterface; -import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.PersonToGrantsFactory; @SuppressWarnings("deprecation,serial") public class ModelConstructorUtilities { @@ -18,40 +17,12 @@ public class ModelConstructorUtilities { * @deprecated */ private static final Map modelTypeIdentifierToFactory = new HashMap() {{ - // 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 */ public static final Map modelTypeToHumanReadableName = new HashMap() {{ - // 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) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationAssociatedPeopleModelWithTypesConstructor.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationAssociatedPeopleModelWithTypesConstructor.java deleted file mode 100644 index 17c9b2d3..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationAssociatedPeopleModelWithTypesConstructor.java +++ /dev/null @@ -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; - } - - } - -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationModelWithTypesConstructor.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationModelWithTypesConstructor.java deleted file mode 100644 index 7b934f2b..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationModelWithTypesConstructor.java +++ /dev/null @@ -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 ?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 ?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; - } - - } - -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationToGrantsForSubOrganizationsModelConstructor.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationToGrantsForSubOrganizationsModelConstructor.java deleted file mode 100644 index f78a0073..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationToGrantsForSubOrganizationsModelConstructor.java +++ /dev/null @@ -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 constructOrganizationGrantsQueryTemplate(String constructProperty, String roleType) { - - Set differentPerspectiveQueries = new HashSet(); - - 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 + "> * ?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 ?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 + "> * ?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 ?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 + "> * ?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 ?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 constructOrganizationToGrantsQuery() { - - Set differentInvestigatorTypeQueries = new HashSet(); - - Set investigatorRoleQuery = constructOrganizationGrantsQueryTemplate("hasInvestigatorWithGrant", "InvestigatorRole"); - Set piRoleQuery = constructOrganizationGrantsQueryTemplate("hasPIWithGrant", "PrincipalInvestigatorRole"); - Set coPIRoleQuery = constructOrganizationGrantsQueryTemplate("hascoPIWithGrant", "CoPrincipalInvestigatorRole"); - - differentInvestigatorTypeQueries.addAll(investigatorRoleQuery); - differentInvestigatorTypeQueries.addAll(piRoleQuery); - differentInvestigatorTypeQueries.addAll(coPIRoleQuery); - - return differentInvestigatorTypeQueries; - } - - private Model executeQuery(Set 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()); - } -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationToPublicationsForSubOrganizationsModelConstructor.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationToPublicationsForSubOrganizationsModelConstructor.java deleted file mode 100644 index 89e441b8..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/OrganizationToPublicationsForSubOrganizationsModelConstructor.java +++ /dev/null @@ -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 + "> * ?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()); - } -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PeopleToGrantsModelConstructor.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PeopleToGrantsModelConstructor.java deleted file mode 100644 index 041ad73f..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PeopleToGrantsModelConstructor.java +++ /dev/null @@ -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 constructPersonGrantsQueryTemplate(String constructProperty, String roleType) { - - Set differentPerspectiveQueries = new HashSet(); - - String justGrantsQuery = "" - + " CONSTRUCT { " - + " ?Person vivosocnet:lastCachedAt ?now . " - + " ?Person vivosocnet:" + constructProperty + " ?Grant . " - + " " - + " ?Grant rdf:type core:Grant . " - + " ?Grant rdfs:label ?grantLabel . " - + " " - + " } " - + " WHERE { " - + " ?Person ?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 ?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 ?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 constructPeopleToGrantsQuery() { - - Set differentInvestigatorTypeQueries = new HashSet(); - - Set investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "InvestigatorRole"); - Set piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "PrincipalInvestigatorRole"); - Set coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "CoPrincipalInvestigatorRole"); - - differentInvestigatorTypeQueries.addAll(investigatorRoleQuery); - differentInvestigatorTypeQueries.addAll(piRoleQuery); - differentInvestigatorTypeQueries.addAll(coPIRoleQuery); - - return differentInvestigatorTypeQueries; - } - - private Model executeQuery(Set 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()); - } -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PeopleToPublicationsModelConstructor.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PeopleToPublicationsModelConstructor.java deleted file mode 100644 index 278946a4..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PeopleToPublicationsModelConstructor.java +++ /dev/null @@ -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()); - } -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PersonToPublicationsModelConstructor.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PersonToPublicationsModelConstructor.java deleted file mode 100644 index 988eeb05..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/PersonToPublicationsModelConstructor.java +++ /dev/null @@ -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()); - } -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/SubOrganizationWithinModelConstructor.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/SubOrganizationWithinModelConstructor.java deleted file mode 100644 index 15931e50..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/SubOrganizationWithinModelConstructor.java +++ /dev/null @@ -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 ?parentOrganization . " - + " ?parentOrganization rdf:type foaf:Organization . " - + " ?parentOrganization rdfs:label ?parentOrganizationLabel . " - + " } " - + " WHERE { " - + " ?organization rdf:type foaf:Organization . " - + " ?organization rdfs:label ?organizationLabel . " - + " " - + " OPTIONAL { " - + " ?organization ?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; - } - - } - -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/ModelFactoryInterface.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/ModelFactoryInterface.java index ea687fe9..c1a0cc80 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/ModelFactoryInterface.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/ModelFactoryInterface.java @@ -1,7 +1,6 @@ /* $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; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationAssociatedPeopleModelWithTypesFactory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationAssociatedPeopleModelWithTypesFactory.java deleted file mode 100644 index a9aa6a11..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationAssociatedPeopleModelWithTypesFactory.java +++ /dev/null @@ -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; - } - - } - -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationModelWithTypesFactory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationModelWithTypesFactory.java deleted file mode 100644 index 9664c003..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationModelWithTypesFactory.java +++ /dev/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 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; - } - } -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToGrantsForSubOrganizationsFactory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToGrantsForSubOrganizationsFactory.java deleted file mode 100644 index d0426c7b..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToGrantsForSubOrganizationsFactory.java +++ /dev/null @@ -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; - } - - } - -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToPublicationsForSubOrganizationsFactory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToPublicationsForSubOrganizationsFactory.java deleted file mode 100644 index ffdb26a0..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToPublicationsForSubOrganizationsFactory.java +++ /dev/null @@ -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; - } - } - } - - } - - diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToGrantsFactory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToGrantsFactory.java deleted file mode 100644 index 7a66e44b..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToGrantsFactory.java +++ /dev/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; - } - } -} \ No newline at end of file diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToPublicationsFactory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToPublicationsFactory.java deleted file mode 100644 index 0aa991b2..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToPublicationsFactory.java +++ /dev/null @@ -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; - } - - } - -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToGrantsFactory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToGrantsFactory.java deleted file mode 100644 index 20cc00b1..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToGrantsFactory.java +++ /dev/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.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; - } - } -} \ No newline at end of file diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToPublicationsFactory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToPublicationsFactory.java deleted file mode 100644 index b9a47752..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToPublicationsFactory.java +++ /dev/null @@ -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; - } - - } - -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/SubOrganizationWithinModelFactory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/SubOrganizationWithinModelFactory.java deleted file mode 100644 index 3f615f15..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/SubOrganizationWithinModelFactory.java +++ /dev/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 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; - } - } -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/persongrantcount/PersonGrantCountQueryRunner.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/persongrantcount/PersonGrantCountQueryRunner.java new file mode 100644 index 00000000..7951eeb0 --- /dev/null +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/persongrantcount/PersonGrantCountQueryRunner.java @@ -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> { + + 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" + + " ?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" + + " ?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" + + " ?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 investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "InvestigatorRole"); +// Set piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "PrincipalInvestigatorRole"); +// Set 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 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 authorGrants = new HashSet(); + + @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 getAuthorGrants() { + return authorGrants; + } + } +} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/persongrantcount/PersonGrantCountRequestHandler.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/persongrantcount/PersonGrantCountRequestHandler.java index d6c64ea6..30951355 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/persongrantcount/PersonGrantCountRequestHandler.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/persongrantcount/PersonGrantCountRequestHandler.java @@ -5,7 +5,9 @@ package edu.cornell.mannlib.vitro.webapp.visualization.persongrantcount; import java.util.HashMap; import java.util.Map; 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.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.SparklineData; 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.VisualizationRequestHandler; @@ -55,15 +56,19 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl personURI, UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI)); - Map grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false); - - + QueryRunner> queryManager = new PersonGrantCountQueryRunner( + personURI, + vitroRequest.getRDFService(), + log); + + Set authorGrants = queryManager.getQueryResult(); + /* - * Create a map from the year to number of grants. Use the Grant's - * parsedGrantYear to populate the data. - * */ - Map yearToGrantCount = - UtilityFunctions.getYearToActivityCount(grantsToURI.values()); + * Create a map from the year to number of publications. Use the + * BiboDocument's parsedPublicationYear to populate the data. + */ + Map yearToGrantCount = + UtilityFunctions.getYearToActivityCount(authorGrants); return prepareDataResponse(person, yearToGrantCount); @@ -91,20 +96,21 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl String visContainer = vitroRequest .getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY); - - SubEntity person = new SubEntity( - personURI, - UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI)); - Map grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false); - - /* - * Create a map from the year to number of grants. Use the Grant's - * parsedGrantYear to populate the data. - * */ - Map yearToGrantCount = - UtilityFunctions.getYearToActivityCount(grantsToURI.values()); - + QueryRunner> queryManager = new PersonGrantCountQueryRunner( + personURI, + vitroRequest.getRDFService(), + log); + + Set authorGrants = queryManager.getQueryResult(); + + /* + * Create a map from the year to number of publications. Use the + * BiboDocument's parsedPublicationYear to populate the data. + */ + Map yearToGrantCount = + UtilityFunctions.getYearToActivityCount(authorGrants); + boolean shouldVIVOrenderVis = yearToGrantCount.size() > 0 ? true : false; @@ -142,19 +148,20 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl String visContainer = vitroRequest .getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY); - - SubEntity person = new SubEntity( - personURI, - UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, personURI)); - Map grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false); - - /* - * Create a map from the year to number of grants. Use the Grant's - * parsedGrantYear to populate the data. - * */ - Map yearToGrantCount = - UtilityFunctions.getYearToActivityCount(grantsToURI.values()); + QueryRunner> queryManager = new PersonGrantCountQueryRunner( + personURI, + vitroRequest.getRDFService(), + log); + + Set authorGrants = queryManager.getQueryResult(); + + /* + * Create a map from the year to number of publications. Use the + * BiboDocument's parsedPublicationYear to populate the data. + */ + Map yearToGrantCount = + UtilityFunctions.getYearToActivityCount(authorGrants); /* * Computations required to generate HTML for the sparkline & related context. @@ -240,7 +247,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl * page, e.g. profile page. * @param vreq * @param valueObjectContainer - * @param yearToGrantCount + * @param shouldVIVOrenderVis * @return */ private TemplateResponseValues prepareDynamicResponse( diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/personlevel/PersonLevelRequestHandler.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/personlevel/PersonLevelRequestHandler.java index 273d25fc..f67e3f1e 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/personlevel/PersonLevelRequestHandler.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/personlevel/PersonLevelRequestHandler.java @@ -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.CoInvestigationData; import edu.cornell.mannlib.vitro.webapp.visualization.visutils.CollaborationDataViewHelper; -import org.apache.axis.utils.StringUtils; import org.apache.commons.logging.Log; 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.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.CoAuthorshipVisCodeGenerator; 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.CoPIVisCodeGenerator; 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.valueobjects.Activity; 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.VisualizationRequestHandler; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/visutils/SelectOnModelUtilities.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/visutils/SelectOnModelUtilities.java deleted file mode 100644 index 2fadea51..00000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/visutils/SelectOnModelUtilities.java +++ /dev/null @@ -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 allGrantURIToVO) { - - Set currentEntityGrants = new HashSet(); - - 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 fieldLabelToOutputFieldLabel = new HashMap(); - fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME); - - String whereClause = "" - + "{" - + " <" + entity.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . " - + "}"; - - QueryRunner 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 allGrantURIToVOs, Model personGrantsModel) - throws MalformedQueryParametersException { - - Map fieldLabelToOutputFieldLabel = new HashMap(); - 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 personGrantsQuery = - new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel, - "", - whereClause, - "", - personGrantsModel); - - getGrantForEntity(personGrantsQuery.getQueryResult(), person, allGrantURIToVOs); - - String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel( - person, - personGrantsModel); - - person.setLastCachedAtDateTime(lastCachedAtForEntity); - } - - public static Map getGrantsForPerson( - RDFService rdfService, SubEntity person, boolean doCache) - throws MalformedQueryParametersException { - - Map allGrantURIToVOs = new HashMap(); - - 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 fieldLabelToOutputFieldLabel = new HashMap(); - 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 + "> ?subOrganization . " - + " ?subOrganization rdf:type foaf:Organization . " - + " ?subOrganization rdfs:label ?subOrganizationLabel . " - + " ?subOrganization rdf:type ?subOrgType . " - + " ?subOrgType rdfs:label ?subOrganizationTypeLabel . "; - - QueryRunner 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 fieldLabelToOutputFieldLabel = new HashMap(); - fieldLabelToOutputFieldLabel.put("authorLabel", QueryFieldLabels.AUTHOR_LABEL); - - String whereClause = "" - + " <" + subjectEntityURI + "> rdfs:label ?authorLabel . "; - - QueryRunner 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 fieldLabelToOutputFieldLabel = new HashMap(); - 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 + "> ?parentOrganization . " - + " ?parentOrganization rdf:type foaf:Organization . " - + " ?parentOrganization rdfs:label ?parentOrganizationLabel . "; - - QueryRunner 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 parentOrganizationURIToVO = new HashMap(); - - 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 subOrganizationURIToVO = new HashMap(); - - 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 fieldLabelToOutputFieldLabel = new HashMap(); - 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 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 associatedPeopleURIToVO = new HashMap(); - - 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 getPublicationsForAllSubOrganizations( - RDFService rdfService, Entity organizationEntity) - throws MalformedQueryParametersException { - Map allDocumentURIToVOs = new HashMap(); - - 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 fieldLabelToOutputFieldLabel = new HashMap(); - 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 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 getPublicationsWithJournalForAllSubOrganizations( - RDFService rdfService, Entity organizationEntity) - throws MalformedQueryParametersException { - Map allDocumentURIToVOs = new HashMap(); - - 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 fieldLabelToOutputFieldLabel = new HashMap(); - 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 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 allDocumentURIToVOs) { - - Set currentEntityPublications = new HashSet(); - - 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 allDocumentURIToVOs) { - - Set currentEntityPublications = new HashSet(); - - 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 getGrantsForAllSubOrganizations( - RDFService rdfService, Entity organizationEntity) - throws MalformedQueryParametersException { - Map allGrantURIToVO = new HashMap(); - - 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 fieldLabelToOutputFieldLabel = new HashMap(); - 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 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 getGrantsForAssociatedPeople( - RDFService rdfService, Collection people) - throws MalformedQueryParametersException { - Map allGrantURIToVOs = new HashMap(); - - 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 getPublicationsForPerson( - RDFService rdfService, SubEntity person, boolean doCache) - throws MalformedQueryParametersException { - - Map allPublicationURIToVOs = new HashMap(); - - 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 getPublicationsForAssociatedPeople( - RDFService rdfService, Collection people) - throws MalformedQueryParametersException { - Map allDocumentURIToVOs = new HashMap(); - - 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 allDocumentURIToVOs, - Model peoplePublicationsModel) - throws MalformedQueryParametersException { - - Map fieldLabelToOutputFieldLabel = new HashMap(); - 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 personPublicationsQuery = - new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel, - "", - whereClause, - "", - peoplePublicationsModel); - - getPublicationForEntity(personPublicationsQuery.getQueryResult(), - person, - allDocumentURIToVOs); - - String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel( - person, - peoplePublicationsModel); - - person.setLastCachedAtDateTime(lastCachedAtForEntity); - } - - @Deprecated - public static Map getPublicationsWithJournalForAssociatedPeople( - RDFService rdfService, Collection people) - throws MalformedQueryParametersException { - Map allDocumentURIToVOs = new HashMap(); - - 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 fieldLabelToOutputFieldLabel = new HashMap(); - 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 personPublicationsQuery = - new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel, - "", - whereClause, - "", - peoplePublicationsModel); - - getPublicationWithJournalForEntity(personPublicationsQuery.getQueryResult(), - person, - allDocumentURIToVOs); - - String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel( - person, - peoplePublicationsModel); - - person.setLastCachedAtDateTime(lastCachedAtForEntity); - - } - return allDocumentURIToVOs; - } - -} diff --git a/webapp/src/main/webapp/js/visualization/sparkline.js b/webapp/src/main/webapp/js/visualization/sparkline.js index 36abc5f2..a7db56f4 100644 --- a/webapp/src/main/webapp/js/visualization/sparkline.js +++ b/webapp/src/main/webapp/js/visualization/sparkline.js @@ -12,7 +12,7 @@ var visualization = { url: url, data: { 'render_mode': 'dynamic', - 'vis': 'person_pub_count', + 'vis': 'person_grant_count', 'vis_mode': 'short', 'container': containerIdCoAuthor },