diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/coauthorship/CoAuthorshipQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/coauthorship/CoAuthorshipQueryRunner.java index 77265876..04f907db 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/coauthorship/CoAuthorshipQueryRunner.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/coauthorship/CoAuthorshipQueryRunner.java @@ -52,7 +52,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator * * @author cdtank */ -public class CoAuthorshipQueryRunner implements QueryRunner { +public class CoAuthorshipQueryRunner implements QueryRunner { private static final int MAX_AUTHORS_PER_PAPER_ALLOWED = 100; @@ -221,7 +221,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner { edgeUniqueIdentifierToVO); } - public CollaborationData getCollaborationData() { + public CoAuthorshipData getCollaborationData() { return new CoAuthorshipData(egoNode, nodes, edges, biboDocumentURLToVO); } @@ -441,10 +441,10 @@ public class CoAuthorshipQueryRunner implements QueryRunner { return sparqlConstruct; } - public CollaborationData getQueryResult() + public CoAuthorshipData getQueryResult() throws MalformedQueryParametersException { - CollaborationData data = getCachedData(this.egoURI); + CoAuthorshipData data = getCachedData(this.egoURI); if (data != null) { return data; } @@ -452,7 +452,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner { return getQueryResultAndCache(); } - private CollaborationData getCachedData(String egoURI) { + private CoAuthorshipData getCachedData(String egoURI) { CollaborationDataCacheEntry entry = collaborationDataCache.get(egoURI); if (entry != null && !entry.hasExpired()) { entry.accessTime = new Date().getTime(); @@ -463,10 +463,10 @@ public class CoAuthorshipQueryRunner implements QueryRunner { return null; } - private synchronized CollaborationData getQueryResultAndCache() + private synchronized CoAuthorshipData getQueryResultAndCache() throws MalformedQueryParametersException { - CollaborationData data = getCachedData(this.egoURI); + CoAuthorshipData data = getCachedData(this.egoURI); if (data != null) { return data; } @@ -531,7 +531,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner { private static class CollaborationDataCacheEntry { String uri; - CollaborationData data; + CoAuthorshipData data; long creationTime; long accessTime; diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/coauthorship/CoAuthorshipRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/coauthorship/CoAuthorshipRequestHandler.java index 17b50129..a938ba81 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/coauthorship/CoAuthorshipRequestHandler.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/coauthorship/CoAuthorshipRequestHandler.java @@ -63,8 +63,8 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler { String visMode = vitroRequest.getParameter( VisualizationFrameworkConstants .VIS_MODE_KEY); - - QueryRunner queryManager = + + CoAuthorshipQueryRunner queryManager = new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log); CollaborationData authorNodesAndEdges = diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorRequestHandler.java index 4bfd9eaa..c2a4fa3d 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorRequestHandler.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorRequestHandler.java @@ -100,7 +100,7 @@ public class ModelConstructorRequestHandler implements parseModelIdentifier.getType()); ModelConstructorUtilities.getOrConstructModel(parseModelIdentifier.getUri(), - parseModelIdentifier.getType(), dataSource); + parseModelIdentifier.getType(), vitroRequest.getRDFService()); refreshedModels.add(parseModelIdentifier); } catch (IllegalConstructedModelIdentifierException e) { diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorUtilities.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorUtilities.java index 285b2647..9ad6b0ff 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorUtilities.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/ModelConstructorUtilities.java @@ -4,54 +4,40 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor; import java.util.HashMap; import java.util.Map; -import com.hp.hpl.jena.query.Dataset; import com.hp.hpl.jena.rdf.model.Model; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException; import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.ModelFactoryInterface; -import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationAssociatedPeopleModelWithTypesFactory; -import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationModelWithTypesFactory; -import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationToGrantsForSubOrganizationsFactory; -import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationToPublicationsForSubOrganizationsFactory; -import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.PeopleToGrantsFactory; -import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.PeopleToPublicationsFactory; import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.PersonToGrantsFactory; -import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.PersonToPublicationsFactory; -import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.SubOrganizationWithinModelFactory; @SuppressWarnings("serial") public class ModelConstructorUtilities { private static final Map modelTypeIdentifierToFactory = new HashMap() {{ - put(PersonToPublicationsModelConstructor.MODEL_TYPE, new PersonToPublicationsFactory()); - put(PeopleToPublicationsModelConstructor.MODEL_TYPE, new PeopleToPublicationsFactory()); +// put(PersonToPublicationsModelConstructor.MODEL_TYPE, new PersonToPublicationsFactory()); +// put(PeopleToPublicationsModelConstructor.MODEL_TYPE, new PeopleToPublicationsFactory()); put(PersonToGrantsModelConstructor.MODEL_TYPE, new PersonToGrantsFactory()); - put(PeopleToGrantsModelConstructor.MODEL_TYPE, new PeopleToGrantsFactory()); - put(OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToPublicationsForSubOrganizationsFactory()); - put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToGrantsForSubOrganizationsFactory()); - put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, new OrganizationAssociatedPeopleModelWithTypesFactory()); - put(OrganizationModelWithTypesConstructor.MODEL_TYPE, new OrganizationModelWithTypesFactory()); - put(SubOrganizationWithinModelConstructor.MODEL_TYPE, new SubOrganizationWithinModelFactory()); +// put(PeopleToGrantsModelConstructor.MODEL_TYPE, new PeopleToGrantsFactory()); +// put(OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToPublicationsForSubOrganizationsFactory()); +// put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToGrantsForSubOrganizationsFactory()); +// put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, new OrganizationAssociatedPeopleModelWithTypesFactory()); +// put(OrganizationModelWithTypesConstructor.MODEL_TYPE, new OrganizationModelWithTypesFactory()); +// put(SubOrganizationWithinModelConstructor.MODEL_TYPE, new SubOrganizationWithinModelFactory()); }}; public static final Map modelTypeToHumanReadableName = new HashMap() {{ - put(PersonToPublicationsModelConstructor.MODEL_TYPE, PersonToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE); - put(PeopleToPublicationsModelConstructor.MODEL_TYPE, PeopleToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE); +// put(PersonToPublicationsModelConstructor.MODEL_TYPE, PersonToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE); +// put(PeopleToPublicationsModelConstructor.MODEL_TYPE, PeopleToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE); put(PersonToGrantsModelConstructor.MODEL_TYPE, PersonToGrantsModelConstructor.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); +// 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, Dataset dataset) - throws MalformedQueryParametersException { - return modelTypeIdentifierToFactory.get(modelType).getOrCreateModel(uri, dataset); - } - public static Model getOrConstructModel(String uri, String modelType, RDFService rdfService) throws MalformedQueryParametersException { return modelTypeIdentifierToFactory.get(modelType).getOrCreateModel(uri, rdfService); diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/ModelFactoryInterface.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/ModelFactoryInterface.java index 500c4aa8..ea687fe9 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/ModelFactoryInterface.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/ModelFactoryInterface.java @@ -9,7 +9,5 @@ import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryP public interface ModelFactoryInterface { - public Model getOrCreateModel(String uri, Dataset dataset) throws MalformedQueryParametersException; - public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException; } diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationAssociatedPeopleModelWithTypesFactory.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationAssociatedPeopleModelWithTypesFactory.java deleted file mode 100644 index dd07f169..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationAssociatedPeopleModelWithTypesFactory.java +++ /dev/null @@ -1,52 +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.OrganizationAssociatedPeopleModelWithTypesConstructor; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor; - -public class OrganizationAssociatedPeopleModelWithTypesFactory implements - ModelFactoryInterface { - - @Override - public Model getOrCreateModel(String uri, Dataset dataset) - throws MalformedQueryParametersException { - - Model candidateModel = ConstructedModelTracker.getModel( - ConstructedModelTracker - .generateModelIdentifier( - uri, - OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE)); - - if (candidateModel != null) { - - return candidateModel; - - } else { - - ModelConstructor model = new OrganizationAssociatedPeopleModelWithTypesConstructor(uri, dataset); - - Model constructedModel = model.getConstructedModel(); - ConstructedModelTracker.trackModel( - ConstructedModelTracker - .generateModelIdentifier( - uri, - OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE), - constructedModel); - - return constructedModel; - } - - } - - @Override - public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException { - return null; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationModelWithTypesFactory.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationModelWithTypesFactory.java deleted file mode 100644 index 22c357e3..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationModelWithTypesFactory.java +++ /dev/null @@ -1,48 +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.OrganizationModelWithTypesConstructor; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor; - -public class OrganizationModelWithTypesFactory implements ModelFactoryInterface { - - @Override - public Model getOrCreateModel(String uri, Dataset dataset) throws MalformedQueryParametersException { - - Model candidateModel = ConstructedModelTracker.getModel( - ConstructedModelTracker - .generateModelIdentifier( - null, - OrganizationModelWithTypesConstructor.MODEL_TYPE)); - - if (candidateModel != null) { - - return candidateModel; - - } else { - - ModelConstructor model = new OrganizationModelWithTypesConstructor(dataset); - Model constructedModel = model.getConstructedModel(); - - ConstructedModelTracker.trackModel( - ConstructedModelTracker - .generateModelIdentifier( - null, - OrganizationModelWithTypesConstructor.MODEL_TYPE), - constructedModel); - - return constructedModel; - } - } - - @Override - public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException { - return null; - } -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToGrantsForSubOrganizationsFactory.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToGrantsForSubOrganizationsFactory.java deleted file mode 100644 index fce2b153..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToGrantsForSubOrganizationsFactory.java +++ /dev/null @@ -1,52 +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.OrganizationToGrantsForSubOrganizationsModelConstructor; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor; - -public class OrganizationToGrantsForSubOrganizationsFactory implements - ModelFactoryInterface { - - @Override - public Model getOrCreateModel(String uri, Dataset dataset) - throws MalformedQueryParametersException { - - Model candidateModel = ConstructedModelTracker.getModel( - ConstructedModelTracker - .generateModelIdentifier( - uri, - OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE)); - - if (candidateModel != null) { - - return candidateModel; - - } else { - - ModelConstructor model = new OrganizationToGrantsForSubOrganizationsModelConstructor(uri, dataset); - - Model constructedModel = model.getConstructedModel(); - ConstructedModelTracker.trackModel( - ConstructedModelTracker - .generateModelIdentifier( - uri, - OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE), - constructedModel); - - return constructedModel; - } - - } - - @Override - public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException { - return null; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToPublicationsForSubOrganizationsFactory.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToPublicationsForSubOrganizationsFactory.java deleted file mode 100755 index b5a97869..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/OrganizationToPublicationsForSubOrganizationsFactory.java +++ /dev/null @@ -1,70 +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.OrganizationToPublicationsForSubOrganizationsModelConstructor; -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; - -public class OrganizationToPublicationsForSubOrganizationsFactory implements - ModelFactoryInterface { - private static final Log log = LogFactory.getLog(OrganizationToPublicationsForSubOrganizationsFactory.class.getName()); - @Override - public Model getOrCreateModel(String uri, Dataset dataset) - throws MalformedQueryParametersException { - - Model candidateModel = ConstructedModelTracker.getModel( - ConstructedModelTracker - .generateModelIdentifier( - uri, - 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 OrganizationToPublicationsForSubOrganizationsModelConstructor(uri, dataset); - - Model constructedModel = model.getConstructedModel(); - ConstructedModelTracker.trackModel( - ConstructedModelTracker - .generateModelIdentifier( - uri, - OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE), - constructedModel); - return constructedModel; - } finally { - customLock.unlock(); - } - } - else - { - log.info("The Model construction process is going on"); - return null; - } - } - } - - @Override - public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException { - return null; - } - -} - - diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToGrantsFactory.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToGrantsFactory.java deleted file mode 100644 index 7c23ad12..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToGrantsFactory.java +++ /dev/null @@ -1,49 +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.PeopleToGrantsModelConstructor; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor; - -public class PeopleToGrantsFactory implements ModelFactoryInterface { - - @Override - public Model getOrCreateModel(String uri, Dataset dataset) - throws MalformedQueryParametersException { - - Model candidateModel = ConstructedModelTracker.getModel( - ConstructedModelTracker - .generateModelIdentifier( - null, - PeopleToGrantsModelConstructor.MODEL_TYPE)); - - if (candidateModel != null) { - - return candidateModel; - - } else { - - ModelConstructor model = new PeopleToGrantsModelConstructor(dataset); - - Model constructedModel = model.getConstructedModel(); - ConstructedModelTracker.trackModel( - ConstructedModelTracker - .generateModelIdentifier( - null, - PeopleToGrantsModelConstructor.MODEL_TYPE), - constructedModel); - - return constructedModel; - } - } - - @Override - public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException { - return null; - } -} \ No newline at end of file diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToPublicationsFactory.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToPublicationsFactory.java deleted file mode 100644 index f6984672..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PeopleToPublicationsFactory.java +++ /dev/null @@ -1,51 +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.PeopleToPublicationsModelConstructor; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor; - -public class PeopleToPublicationsFactory implements ModelFactoryInterface { - - @Override - public Model getOrCreateModel(String uri, Dataset dataset) - throws MalformedQueryParametersException { - - Model candidateModel = ConstructedModelTracker.getModel( - ConstructedModelTracker - .generateModelIdentifier( - null, - PeopleToPublicationsModelConstructor.MODEL_TYPE)); - - if (candidateModel != null) { - - return candidateModel; - - } else { - - ModelConstructor model = new PeopleToPublicationsModelConstructor(dataset); - - Model constructedModel = model.getConstructedModel(); - ConstructedModelTracker.trackModel( - ConstructedModelTracker - .generateModelIdentifier( - null, - PeopleToPublicationsModelConstructor.MODEL_TYPE), - constructedModel); - - return constructedModel; - } - - } - - @Override - public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException { - return null; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToGrantsFactory.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToGrantsFactory.java index 75cf7656..20cc00b1 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToGrantsFactory.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToGrantsFactory.java @@ -12,11 +12,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor; public class PersonToGrantsFactory implements ModelFactoryInterface { - @Override - public Model getOrCreateModel(String uri, Dataset dataset) { - return null; - } - @Override public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException { diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToPublicationsFactory.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToPublicationsFactory.java deleted file mode 100644 index eb069bbb..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/PersonToPublicationsFactory.java +++ /dev/null @@ -1,51 +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.PersonToPublicationsModelConstructor; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor; - -public class PersonToPublicationsFactory implements ModelFactoryInterface { - - @Override - public Model getOrCreateModel(String uri, Dataset dataset) - throws MalformedQueryParametersException { - - Model candidateModel = ConstructedModelTracker.getModel( - ConstructedModelTracker - .generateModelIdentifier( - uri, - PersonToPublicationsModelConstructor.MODEL_TYPE)); - - if (candidateModel != null) { - - return candidateModel; - - } else { - - ModelConstructor model = new PersonToPublicationsModelConstructor(uri, dataset); - - Model constructedModel = model.getConstructedModel(); - ConstructedModelTracker.trackModel( - ConstructedModelTracker - .generateModelIdentifier( - uri, - PersonToPublicationsModelConstructor.MODEL_TYPE), - constructedModel); - - return constructedModel; - } - - } - - @Override - public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException { - return null; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/SubOrganizationWithinModelFactory.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/SubOrganizationWithinModelFactory.java deleted file mode 100644 index 57a33b30..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/modelconstructor/factory/SubOrganizationWithinModelFactory.java +++ /dev/null @@ -1,48 +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.SubOrganizationWithinModelConstructor; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor; - -public class SubOrganizationWithinModelFactory implements ModelFactoryInterface { - - @Override - public Model getOrCreateModel(String uri, Dataset dataset) throws MalformedQueryParametersException { - - Model candidateModel = ConstructedModelTracker.getModel( - ConstructedModelTracker - .generateModelIdentifier( - null, - SubOrganizationWithinModelConstructor.MODEL_TYPE)); - - if (candidateModel != null) { - - return candidateModel; - - } else { - - ModelConstructor model = new SubOrganizationWithinModelConstructor(dataset); - Model constructedModel = model.getConstructedModel(); - - ConstructedModelTracker.trackModel( - ConstructedModelTracker - .generateModelIdentifier( - null, - SubOrganizationWithinModelConstructor.MODEL_TYPE), - constructedModel); - - return constructedModel; - } - } - - @Override - public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException { - return null; - } -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/personlevel/PersonLevelRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/personlevel/PersonLevelRequestHandler.java index 0e27a351..e2b68935 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/personlevel/PersonLevelRequestHandler.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/personlevel/PersonLevelRequestHandler.java @@ -169,26 +169,12 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler { } else { - QueryRunner coAuthorshipQueryManager = + CoAuthorshipQueryRunner coAuthorshipQueryManager = new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log); - - CollaborationData coAuthorshipData = coAuthorshipQueryManager.getQueryResult(); - /* - * When the front-end for the person level vis has to be displayed we render couple of - * sparklines. This will prepare all the data for the sparklines & other requested - * files. - * */ - SubEntity person = new SubEntity(egoURI, - UtilityFunctions - .getIndividualLabelFromDAO(vitroRequest, egoURI)); + CoAuthorshipData coAuthorshipData = coAuthorshipQueryManager.getQueryResult(); - Map publicationsToURI; - if (coAuthorshipData instanceof CoAuthorshipData) { - publicationsToURI = ((CoAuthorshipData)coAuthorshipData).getDocuments(); - } else { - publicationsToURI = SelectOnModelUtilities.getPublicationsForPerson(dataset, person, false); - } + Map publicationsToURI = coAuthorshipData.getDocuments(); /* * Create a map from the year to number of publications. Use the BiboDocument's diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/SelectOnModelUtilities.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/SelectOnModelUtilities.java index d810cf39..5542b3ca 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/SelectOnModelUtilities.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/SelectOnModelUtilities.java @@ -36,435 +36,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.MapOfScienceA import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SubEntity; public class SelectOnModelUtilities { - - public static Entity getSubjectOrganizationHierarchy(Dataset dataset, - String subjectEntityURI) throws MalformedQueryParametersException { - Model organizationModel = ModelConstructorUtilities - .getOrConstructModel( - null, - OrganizationModelWithTypesConstructor.MODEL_TYPE, - dataset); - - 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(dataset, subjectEntityURI); - - entityWithSubOrganizations.addParents(entityWithParentOrganizations.getParents()); - - return entityWithSubOrganizations; - } - - public static Entity getAllParentOrganizations(Dataset dataset, - String subjectEntityURI) throws MalformedQueryParametersException { - Model organizationModel = ModelConstructorUtilities - .getOrConstructModel( - null, - SubOrganizationWithinModelConstructor.MODEL_TYPE, - dataset); - - 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()); - } - - 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; - } - - 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; - } - - public static Entity getSubjectOrganizationAssociatedPeople(Dataset dataset, - String subjectEntityURI) throws MalformedQueryParametersException { - Model associatedPeopleModel = ModelConstructorUtilities - .getOrConstructModel( - subjectEntityURI, - OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, - dataset); - - 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()); - } - - 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; - } - - public static Map getPublicationsForAllSubOrganizations( - Dataset dataset, Entity organizationEntity) - throws MalformedQueryParametersException { - Map allDocumentURIToVOs = new HashMap(); - - for (SubEntity subOrganization : organizationEntity.getSubEntities()) { - - Model subOrganizationPublicationsModel = ModelConstructorUtilities - .getOrConstructModel( - subOrganization.getIndividualURI(), - OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, - dataset); - -// 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; - } - - public static Map getPublicationsWithJournalForAllSubOrganizations( - Dataset dataset, Entity organizationEntity) - throws MalformedQueryParametersException { - Map allDocumentURIToVOs = new HashMap(); - - for (SubEntity subOrganization : organizationEntity.getSubEntities()) { - - Model subOrganizationPublicationsModel = ModelConstructorUtilities - .getOrConstructModel( - subOrganization.getIndividualURI(), - OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, - dataset); - -// 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; - } - - 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); - } - - 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); - } - public static String getLastCachedAtForEntity(ResultSet queryResult) { String lastCachedAtDateTime = null; @@ -529,85 +100,6 @@ public class SelectOnModelUtilities { subEntity.addActivities(currentEntityGrants); } - - public static Map getGrantsForAllSubOrganizations( - Dataset dataset, 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(), - OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, - dataset); - -// 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; - } private static String getLastCachedAtDateTimeForEntityInModel( SubEntity entity, Model subOrganizationGrantsModel) @@ -631,23 +123,6 @@ public class SelectOnModelUtilities { String lastCachedAtForEntity = getLastCachedAtForEntity(entityLastCachedAtQuery.getQueryResult()); return lastCachedAtForEntity; } - - public static Map getGrantsForAssociatedPeople( - Dataset dataset, Collection people) - throws MalformedQueryParametersException { - Map allGrantURIToVOs = new HashMap(); - - Model peopleGrantsModel = ModelConstructorUtilities - .getOrConstructModel( - null, - PeopleToGrantsModelConstructor.MODEL_TYPE, - dataset); - - for (SubEntity person : people) { - updateGrantsForPerson(person, allGrantURIToVOs, peopleGrantsModel); - } - return allGrantURIToVOs; - } /** * This method side-effects person and the central grants map. @@ -742,152 +217,4 @@ public class SelectOnModelUtilities { return allGrantURIToVOs; } - - - public static Map getPublicationsForPerson( - Dataset dataset, 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(), - PersonToPublicationsModelConstructor.MODEL_TYPE, - dataset); - } else { - - ModelConstructor model = new PersonToPublicationsModelConstructor(person.getIndividualURI(), dataset); - personPublicationsModel = model.getConstructedModel(); - } - - - updatePublicationsForPerson(person, allPublicationURIToVOs, personPublicationsModel); - - return allPublicationURIToVOs; - } - - public static Map getPublicationsForAssociatedPeople( - Dataset dataset, Collection people) - throws MalformedQueryParametersException { - Map allDocumentURIToVOs = new HashMap(); - - Model peoplePublicationsModel = ModelConstructorUtilities - .getOrConstructModel( - null, - PeopleToPublicationsModelConstructor.MODEL_TYPE, - dataset); - - 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 - */ - 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); - } - - public static Map getPublicationsWithJournalForAssociatedPeople( - Dataset dataset, Collection people) - throws MalformedQueryParametersException { - Map allDocumentURIToVOs = new HashMap(); - - Model peoplePublicationsModel = ModelConstructorUtilities - .getOrConstructModel( - null, - PeopleToPublicationsModelConstructor.MODEL_TYPE, - dataset); - - 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; - } - }