Remove redundant code
This commit is contained in:
parent
75203eb716
commit
bb65147db0
16 changed files with 30 additions and 1159 deletions
|
@ -52,7 +52,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator
|
||||||
*
|
*
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
*/
|
*/
|
||||||
public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
|
public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
|
||||||
|
|
||||||
private static final int MAX_AUTHORS_PER_PAPER_ALLOWED = 100;
|
private static final int MAX_AUTHORS_PER_PAPER_ALLOWED = 100;
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
|
||||||
edgeUniqueIdentifierToVO);
|
edgeUniqueIdentifierToVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CollaborationData getCollaborationData() {
|
public CoAuthorshipData getCollaborationData() {
|
||||||
return new CoAuthorshipData(egoNode, nodes, edges, biboDocumentURLToVO);
|
return new CoAuthorshipData(egoNode, nodes, edges, biboDocumentURLToVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,10 +441,10 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
|
||||||
return sparqlConstruct;
|
return sparqlConstruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CollaborationData getQueryResult()
|
public CoAuthorshipData getQueryResult()
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
CollaborationData data = getCachedData(this.egoURI);
|
CoAuthorshipData data = getCachedData(this.egoURI);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
|
||||||
return getQueryResultAndCache();
|
return getQueryResultAndCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollaborationData getCachedData(String egoURI) {
|
private CoAuthorshipData getCachedData(String egoURI) {
|
||||||
CollaborationDataCacheEntry entry = collaborationDataCache.get(egoURI);
|
CollaborationDataCacheEntry entry = collaborationDataCache.get(egoURI);
|
||||||
if (entry != null && !entry.hasExpired()) {
|
if (entry != null && !entry.hasExpired()) {
|
||||||
entry.accessTime = new Date().getTime();
|
entry.accessTime = new Date().getTime();
|
||||||
|
@ -463,10 +463,10 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized CollaborationData getQueryResultAndCache()
|
private synchronized CoAuthorshipData getQueryResultAndCache()
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
CollaborationData data = getCachedData(this.egoURI);
|
CoAuthorshipData data = getCachedData(this.egoURI);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
|
||||||
|
|
||||||
private static class CollaborationDataCacheEntry {
|
private static class CollaborationDataCacheEntry {
|
||||||
String uri;
|
String uri;
|
||||||
CollaborationData data;
|
CoAuthorshipData data;
|
||||||
long creationTime;
|
long creationTime;
|
||||||
long accessTime;
|
long accessTime;
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
|
||||||
String visMode = vitroRequest.getParameter(
|
String visMode = vitroRequest.getParameter(
|
||||||
VisualizationFrameworkConstants
|
VisualizationFrameworkConstants
|
||||||
.VIS_MODE_KEY);
|
.VIS_MODE_KEY);
|
||||||
|
|
||||||
QueryRunner<CollaborationData> queryManager =
|
CoAuthorshipQueryRunner queryManager =
|
||||||
new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log);
|
new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log);
|
||||||
|
|
||||||
CollaborationData authorNodesAndEdges =
|
CollaborationData authorNodesAndEdges =
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class ModelConstructorRequestHandler implements
|
||||||
parseModelIdentifier.getType());
|
parseModelIdentifier.getType());
|
||||||
|
|
||||||
ModelConstructorUtilities.getOrConstructModel(parseModelIdentifier.getUri(),
|
ModelConstructorUtilities.getOrConstructModel(parseModelIdentifier.getUri(),
|
||||||
parseModelIdentifier.getType(), dataSource);
|
parseModelIdentifier.getType(), vitroRequest.getRDFService());
|
||||||
refreshedModels.add(parseModelIdentifier);
|
refreshedModels.add(parseModelIdentifier);
|
||||||
|
|
||||||
} catch (IllegalConstructedModelIdentifierException e) {
|
} catch (IllegalConstructedModelIdentifierException e) {
|
||||||
|
|
|
@ -4,54 +4,40 @@ package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.ModelFactoryInterface;
|
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.ModelFactoryInterface;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.OrganizationAssociatedPeopleModelWithTypesFactory;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.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.PersonToGrantsFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.PersonToPublicationsFactory;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor.factory.SubOrganizationWithinModelFactory;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ModelConstructorUtilities {
|
public class ModelConstructorUtilities {
|
||||||
|
|
||||||
private static final Map<String, ModelFactoryInterface> modelTypeIdentifierToFactory = new HashMap<String, ModelFactoryInterface>() {{
|
private static final Map<String, ModelFactoryInterface> modelTypeIdentifierToFactory = new HashMap<String, ModelFactoryInterface>() {{
|
||||||
put(PersonToPublicationsModelConstructor.MODEL_TYPE, new PersonToPublicationsFactory());
|
// put(PersonToPublicationsModelConstructor.MODEL_TYPE, new PersonToPublicationsFactory());
|
||||||
put(PeopleToPublicationsModelConstructor.MODEL_TYPE, new PeopleToPublicationsFactory());
|
// put(PeopleToPublicationsModelConstructor.MODEL_TYPE, new PeopleToPublicationsFactory());
|
||||||
put(PersonToGrantsModelConstructor.MODEL_TYPE, new PersonToGrantsFactory());
|
put(PersonToGrantsModelConstructor.MODEL_TYPE, new PersonToGrantsFactory());
|
||||||
put(PeopleToGrantsModelConstructor.MODEL_TYPE, new PeopleToGrantsFactory());
|
// put(PeopleToGrantsModelConstructor.MODEL_TYPE, new PeopleToGrantsFactory());
|
||||||
put(OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToPublicationsForSubOrganizationsFactory());
|
// put(OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToPublicationsForSubOrganizationsFactory());
|
||||||
put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToGrantsForSubOrganizationsFactory());
|
// put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToGrantsForSubOrganizationsFactory());
|
||||||
put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, new OrganizationAssociatedPeopleModelWithTypesFactory());
|
// put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, new OrganizationAssociatedPeopleModelWithTypesFactory());
|
||||||
put(OrganizationModelWithTypesConstructor.MODEL_TYPE, new OrganizationModelWithTypesFactory());
|
// put(OrganizationModelWithTypesConstructor.MODEL_TYPE, new OrganizationModelWithTypesFactory());
|
||||||
put(SubOrganizationWithinModelConstructor.MODEL_TYPE, new SubOrganizationWithinModelFactory());
|
// put(SubOrganizationWithinModelConstructor.MODEL_TYPE, new SubOrganizationWithinModelFactory());
|
||||||
}};
|
}};
|
||||||
|
|
||||||
public static final Map<String, String> modelTypeToHumanReadableName = new HashMap<String, String>() {{
|
public static final Map<String, String> modelTypeToHumanReadableName = new HashMap<String, String>() {{
|
||||||
put(PersonToPublicationsModelConstructor.MODEL_TYPE, PersonToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
// put(PersonToPublicationsModelConstructor.MODEL_TYPE, PersonToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
||||||
put(PeopleToPublicationsModelConstructor.MODEL_TYPE, PeopleToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
// put(PeopleToPublicationsModelConstructor.MODEL_TYPE, PeopleToPublicationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
||||||
put(PersonToGrantsModelConstructor.MODEL_TYPE, PersonToGrantsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
put(PersonToGrantsModelConstructor.MODEL_TYPE, PersonToGrantsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
||||||
put(PeopleToGrantsModelConstructor.MODEL_TYPE, PeopleToGrantsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
// put(PeopleToGrantsModelConstructor.MODEL_TYPE, PeopleToGrantsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
||||||
put(OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
// put(OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE, OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
||||||
put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
// put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE_HUMAN_READABLE);
|
||||||
put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE_HUMAN_READABLE);
|
// put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE_HUMAN_READABLE);
|
||||||
put(OrganizationModelWithTypesConstructor.MODEL_TYPE, OrganizationModelWithTypesConstructor.MODEL_TYPE_HUMAN_READABLE);
|
// put(OrganizationModelWithTypesConstructor.MODEL_TYPE, OrganizationModelWithTypesConstructor.MODEL_TYPE_HUMAN_READABLE);
|
||||||
put(SubOrganizationWithinModelConstructor.MODEL_TYPE, SubOrganizationWithinModelConstructor.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)
|
public static Model getOrConstructModel(String uri, String modelType, RDFService rdfService)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
return modelTypeIdentifierToFactory.get(modelType).getOrCreateModel(uri, rdfService);
|
return modelTypeIdentifierToFactory.get(modelType).getOrCreateModel(uri, rdfService);
|
||||||
|
|
|
@ -9,7 +9,5 @@ import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryP
|
||||||
|
|
||||||
public interface ModelFactoryInterface {
|
public interface ModelFactoryInterface {
|
||||||
|
|
||||||
public Model getOrCreateModel(String uri, Dataset dataset) throws MalformedQueryParametersException;
|
|
||||||
|
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException;
|
public Model getOrCreateModel(String uri, RDFService rdfService) throws MalformedQueryParametersException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -12,11 +12,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
||||||
|
|
||||||
public class PersonToGrantsFactory implements ModelFactoryInterface {
|
public class PersonToGrantsFactory implements ModelFactoryInterface {
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model getOrCreateModel(String uri, Dataset dataset) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getOrCreateModel(String uri, RDFService rdfService)
|
public Model getOrCreateModel(String uri, RDFService rdfService)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -169,26 +169,12 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
QueryRunner<CollaborationData> coAuthorshipQueryManager =
|
CoAuthorshipQueryRunner coAuthorshipQueryManager =
|
||||||
new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log);
|
new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log);
|
||||||
|
|
||||||
CollaborationData coAuthorshipData = coAuthorshipQueryManager.getQueryResult();
|
|
||||||
|
|
||||||
/*
|
CoAuthorshipData 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));
|
|
||||||
|
|
||||||
Map<String, Activity> publicationsToURI;
|
Map<String, Activity> publicationsToURI = coAuthorshipData.getDocuments();
|
||||||
if (coAuthorshipData instanceof CoAuthorshipData) {
|
|
||||||
publicationsToURI = ((CoAuthorshipData)coAuthorshipData).getDocuments();
|
|
||||||
} else {
|
|
||||||
publicationsToURI = SelectOnModelUtilities.getPublicationsForPerson(dataset, person, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a map from the year to number of publications. Use the BiboDocument's
|
* Create a map from the year to number of publications. Use the BiboDocument's
|
||||||
|
|
|
@ -36,435 +36,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.MapOfScienceA
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SubEntity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SubEntity;
|
||||||
|
|
||||||
public class SelectOnModelUtilities {
|
public class SelectOnModelUtilities {
|
||||||
|
|
||||||
public static Entity getSubjectOrganizationHierarchy(Dataset dataset,
|
|
||||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
|
||||||
Model organizationModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
null,
|
|
||||||
OrganizationModelWithTypesConstructor.MODEL_TYPE,
|
|
||||||
dataset);
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("subOrganization", QueryFieldLabels.SUBORGANIZATION_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("subOrganizationLabel", QueryFieldLabels.SUBORGANIZATION_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("subOrganizationTypeLabel", QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + subjectEntityURI + "> <http://purl.obolibrary.org/obo/BFO_0000051> ?subOrganization . "
|
|
||||||
+ " ?subOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
|
||||||
+ " ?subOrganization rdf:type ?subOrgType . "
|
|
||||||
+ " ?subOrgType rdfs:label ?subOrganizationTypeLabel . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationsWithTypesQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
organizationModel);
|
|
||||||
|
|
||||||
Entity entityWithSubOrganizations = getEntityWithSubOrganizations(subjectEntityURI,
|
|
||||||
subOrganizationsWithTypesQuery.getQueryResult());
|
|
||||||
|
|
||||||
Entity entityWithParentOrganizations = getAllParentOrganizations(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<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("parentOrganization", QueryFieldLabels.PARENT_ORGANIZATION_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("parentOrganizationLabel", QueryFieldLabels.PARENT_ORGANIZATION_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + subjectEntityURI + "> <http://purl.obolibrary.org/obo/BFO_0000050> ?parentOrganization . "
|
|
||||||
+ " ?parentOrganization rdf:type foaf:Organization . "
|
|
||||||
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> parentOrganizationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
organizationModel);
|
|
||||||
|
|
||||||
return getEntityWithParentOrganizations(subjectEntityURI,
|
|
||||||
parentOrganizationsQuery.getQueryResult());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Entity getEntityWithParentOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
|
||||||
|
|
||||||
Entity entity = new Entity(subjectEntityURI);
|
|
||||||
Map<String, Individual> parentOrganizationURIToVO = new HashMap<String, Individual>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
if (organizationLabelNode != null) {
|
|
||||||
entity.setIndividualLabel(organizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode parentOrganizationNode = solution.get(QueryFieldLabels.PARENT_ORGANIZATION_URL);
|
|
||||||
|
|
||||||
Individual parent;
|
|
||||||
|
|
||||||
if (!parentOrganizationURIToVO.containsKey(parentOrganizationNode.toString())) {
|
|
||||||
|
|
||||||
parent = new Individual(parentOrganizationNode.toString());
|
|
||||||
|
|
||||||
parentOrganizationURIToVO.put(parentOrganizationNode.toString(), parent);
|
|
||||||
|
|
||||||
RDFNode parentOrganizationLabelNode = solution.get(QueryFieldLabels.PARENT_ORGANIZATION_LABEL);
|
|
||||||
if (parentOrganizationLabelNode != null) {
|
|
||||||
parent.setIndividualLabel(parentOrganizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.addParents(parentOrganizationURIToVO.values());
|
|
||||||
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Entity getEntityWithSubOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
|
||||||
|
|
||||||
Entity entity = new Entity(subjectEntityURI);
|
|
||||||
Map<String, SubEntity> subOrganizationURIToVO = new HashMap<String, SubEntity>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
if (organizationLabelNode != null) {
|
|
||||||
|
|
||||||
entity.setEntityLabel(organizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode subOrganizationNode = solution.get(QueryFieldLabels.SUBORGANIZATION_URL);
|
|
||||||
|
|
||||||
SubEntity subEntity;
|
|
||||||
|
|
||||||
if (subOrganizationURIToVO.containsKey(subOrganizationNode.toString())) {
|
|
||||||
|
|
||||||
subEntity = subOrganizationURIToVO.get(subOrganizationNode.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
subEntity = new SubEntity(subOrganizationNode.toString());
|
|
||||||
|
|
||||||
subEntity.setEntityClass(VOConstants.EntityClassType.ORGANIZATION);
|
|
||||||
|
|
||||||
subOrganizationURIToVO.put(subOrganizationNode.toString(), subEntity);
|
|
||||||
|
|
||||||
RDFNode subOrganizationLabelNode = solution.get(QueryFieldLabels.SUBORGANIZATION_LABEL);
|
|
||||||
if (subOrganizationLabelNode != null) {
|
|
||||||
subEntity.setIndividualLabel(subOrganizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode subOrganizationTypeLabelNode = solution.get(QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL);
|
|
||||||
if (subOrganizationTypeLabelNode != null) {
|
|
||||||
subEntity.addEntityTypeLabel(subOrganizationTypeLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.addSubEntitities(subOrganizationURIToVO.values());
|
|
||||||
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Entity getSubjectOrganizationAssociatedPeople(Dataset dataset,
|
|
||||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
|
||||||
Model associatedPeopleModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
subjectEntityURI,
|
|
||||||
OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE,
|
|
||||||
dataset);
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("person", QueryFieldLabels.PERSON_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("personLabel", QueryFieldLabels.PERSON_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("personTypeLabel", QueryFieldLabels.PERSON_TYPE_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + subjectEntityURI + "> vivosocnet:hasPersonWithActivity ?person . "
|
|
||||||
+ " ?person rdfs:label ?personLabel . "
|
|
||||||
+ " ?person rdf:type ?personType . "
|
|
||||||
+ " ?personType rdfs:label ?personTypeLabel . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> associatedPeopleWithTypesQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
associatedPeopleModel);
|
|
||||||
|
|
||||||
return getEntityWithAssociatedPeopleSubEntitities(subjectEntityURI, associatedPeopleWithTypesQuery.getQueryResult());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Entity getEntityWithAssociatedPeopleSubEntitities(
|
|
||||||
String subjectEntityURI, ResultSet queryResult) {
|
|
||||||
|
|
||||||
Entity entity = new Entity(subjectEntityURI);
|
|
||||||
Map<String, SubEntity> associatedPeopleURIToVO = new HashMap<String, SubEntity>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
|
||||||
if (organizationLabelNode != null) {
|
|
||||||
entity.setIndividualLabel(organizationLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode personNode = solution.get(QueryFieldLabels.PERSON_URL);
|
|
||||||
|
|
||||||
SubEntity subEntity;
|
|
||||||
|
|
||||||
if (associatedPeopleURIToVO.containsKey(personNode.toString())) {
|
|
||||||
|
|
||||||
subEntity = associatedPeopleURIToVO.get(personNode.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
subEntity = new SubEntity(personNode.toString());
|
|
||||||
subEntity.setEntityClass(VOConstants.EntityClassType.PERSON);
|
|
||||||
associatedPeopleURIToVO.put(personNode.toString(), subEntity);
|
|
||||||
|
|
||||||
RDFNode personLabelNode = solution.get(QueryFieldLabels.PERSON_LABEL);
|
|
||||||
if (personLabelNode != null) {
|
|
||||||
subEntity.setIndividualLabel(personLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode personTypeLabelNode = solution.get(QueryFieldLabels.PERSON_TYPE_LABEL);
|
|
||||||
if (personTypeLabelNode != null) {
|
|
||||||
subEntity.addEntityTypeLabel(personTypeLabelNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.addSubEntitities(associatedPeopleURIToVO.values());
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Activity> getPublicationsForAllSubOrganizations(
|
|
||||||
Dataset dataset, Entity organizationEntity)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
|
||||||
|
|
||||||
Model subOrganizationPublicationsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
subOrganization.getIndividualURI(),
|
|
||||||
OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
|
||||||
dataset);
|
|
||||||
|
|
||||||
// System.out.println("getting publications for " + subOrganization.getIndividualLabel());
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPersonWithPublication ?document . "
|
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationPublicationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
subOrganizationPublicationsModel);
|
|
||||||
|
|
||||||
getPublicationForEntity(subOrganizationPublicationsQuery.getQueryResult(),
|
|
||||||
subOrganization,
|
|
||||||
allDocumentURIToVOs);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
subOrganization,
|
|
||||||
subOrganizationPublicationsModel);
|
|
||||||
|
|
||||||
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
|
|
||||||
}
|
|
||||||
return allDocumentURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Activity> getPublicationsWithJournalForAllSubOrganizations(
|
|
||||||
Dataset dataset, Entity organizationEntity)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
|
||||||
|
|
||||||
Model subOrganizationPublicationsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
subOrganization.getIndividualURI(),
|
|
||||||
OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
|
||||||
dataset);
|
|
||||||
|
|
||||||
// System.out.println("getting publications for " + subOrganization.getIndividualLabel());
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
fieldLabelToOutputFieldLabel.put("journalLabel", QueryFieldLabels.DOCUMENT_JOURNAL_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPersonWithPublication ?document . "
|
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:hasPublicationVenue ?journal . "
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . } ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationPublicationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
subOrganizationPublicationsModel);
|
|
||||||
|
|
||||||
getPublicationWithJournalForEntity(subOrganizationPublicationsQuery.getQueryResult(),
|
|
||||||
subOrganization,
|
|
||||||
allDocumentURIToVOs);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
subOrganization,
|
|
||||||
subOrganizationPublicationsModel);
|
|
||||||
|
|
||||||
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
|
|
||||||
}
|
|
||||||
return allDocumentURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void getPublicationForEntity(
|
|
||||||
ResultSet queryResult,
|
|
||||||
SubEntity subEntity,
|
|
||||||
Map<String, Activity> allDocumentURIToVOs) {
|
|
||||||
|
|
||||||
Set<Activity> currentEntityPublications = new HashSet<Activity>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(subEntity.getLastCachedAtDateTime())) {
|
|
||||||
|
|
||||||
RDFNode lastCachedAtNode = solution.get(QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
|
||||||
if (lastCachedAtNode != null) {
|
|
||||||
subEntity.setLastCachedAtDateTime(lastCachedAtNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
Activity biboDocument;
|
|
||||||
|
|
||||||
if (allDocumentURIToVOs.containsKey(documentNode.toString())) {
|
|
||||||
biboDocument = allDocumentURIToVOs.get(documentNode.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
biboDocument = new Activity(documentNode.toString());
|
|
||||||
allDocumentURIToVOs.put(documentNode.toString(), biboDocument);
|
|
||||||
|
|
||||||
RDFNode publicationDateNode = solution.get(QueryFieldLabels
|
|
||||||
.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
if (publicationDateNode != null) {
|
|
||||||
biboDocument.setActivityDate(publicationDateNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentEntityPublications.add(biboDocument);
|
|
||||||
}
|
|
||||||
subEntity.addActivities(currentEntityPublications);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void getPublicationWithJournalForEntity(
|
|
||||||
ResultSet queryResult,
|
|
||||||
SubEntity subEntity,
|
|
||||||
Map<String, Activity> allDocumentURIToVOs) {
|
|
||||||
|
|
||||||
Set<Activity> currentEntityPublications = new HashSet<Activity>();
|
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(subEntity.getLastCachedAtDateTime())) {
|
|
||||||
|
|
||||||
RDFNode lastCachedAtNode = solution.get(QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
|
||||||
if (lastCachedAtNode != null) {
|
|
||||||
subEntity.setLastCachedAtDateTime(lastCachedAtNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
Activity biboDocument;
|
|
||||||
|
|
||||||
if (allDocumentURIToVOs.containsKey(documentNode.toString())) {
|
|
||||||
biboDocument = allDocumentURIToVOs.get(documentNode.toString());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
biboDocument = new MapOfScienceActivity(documentNode.toString());
|
|
||||||
allDocumentURIToVOs.put(documentNode.toString(), biboDocument);
|
|
||||||
|
|
||||||
RDFNode publicationDateNode = solution.get(QueryFieldLabels
|
|
||||||
.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
if (publicationDateNode != null) {
|
|
||||||
biboDocument.setActivityDate(publicationDateNode.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFNode publicationJournalNode = solution.get(QueryFieldLabels
|
|
||||||
.DOCUMENT_JOURNAL_LABEL);
|
|
||||||
|
|
||||||
if (publicationJournalNode != null) {
|
|
||||||
((MapOfScienceActivity) biboDocument).setPublishedInJournal(publicationJournalNode.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentEntityPublications.add(biboDocument);
|
|
||||||
|
|
||||||
}
|
|
||||||
subEntity.addActivities(currentEntityPublications);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLastCachedAtForEntity(ResultSet queryResult) {
|
public static String getLastCachedAtForEntity(ResultSet queryResult) {
|
||||||
|
|
||||||
String lastCachedAtDateTime = null;
|
String lastCachedAtDateTime = null;
|
||||||
|
@ -529,85 +100,6 @@ public class SelectOnModelUtilities {
|
||||||
|
|
||||||
subEntity.addActivities(currentEntityGrants);
|
subEntity.addActivities(currentEntityGrants);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Activity> getGrantsForAllSubOrganizations(
|
|
||||||
Dataset dataset, Entity organizationEntity)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allGrantURIToVO = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
|
||||||
|
|
||||||
// System.out.println("constructing grants for " + subOrganization.getIndividualLabel() + " :: " + subOrganization.getIndividualURI());
|
|
||||||
|
|
||||||
long before = System.currentTimeMillis();
|
|
||||||
|
|
||||||
Model subOrganizationGrantsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
subOrganization.getIndividualURI(),
|
|
||||||
OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
|
||||||
dataset);
|
|
||||||
|
|
||||||
// System.out.println("\t construct -> " + (System.currentTimeMillis() - before));
|
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
|
|
||||||
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ "{"
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasInvestigatorWithGrant ?grant . "
|
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
|
||||||
+ "}"
|
|
||||||
+ "UNION"
|
|
||||||
+ "{"
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPIWithGrant ?grant . "
|
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
|
||||||
+ "}"
|
|
||||||
+ "UNION"
|
|
||||||
+ "{"
|
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hascoPIWithGrant ?grant . "
|
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationGrantsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
subOrganizationGrantsModel);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This method side-affects the subOrganization entity & the map containing all the grants for
|
|
||||||
* the subject organization.
|
|
||||||
* */
|
|
||||||
getGrantForEntity(subOrganizationGrantsQuery.getQueryResult(), subOrganization, allGrantURIToVO);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
subOrganization,
|
|
||||||
subOrganizationGrantsModel);
|
|
||||||
|
|
||||||
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
|
|
||||||
// System.out.println("\t select -> " + (System.currentTimeMillis() - before));
|
|
||||||
}
|
|
||||||
return allGrantURIToVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getLastCachedAtDateTimeForEntityInModel(
|
private static String getLastCachedAtDateTimeForEntityInModel(
|
||||||
SubEntity entity, Model subOrganizationGrantsModel)
|
SubEntity entity, Model subOrganizationGrantsModel)
|
||||||
|
@ -631,23 +123,6 @@ public class SelectOnModelUtilities {
|
||||||
String lastCachedAtForEntity = getLastCachedAtForEntity(entityLastCachedAtQuery.getQueryResult());
|
String lastCachedAtForEntity = getLastCachedAtForEntity(entityLastCachedAtQuery.getQueryResult());
|
||||||
return lastCachedAtForEntity;
|
return lastCachedAtForEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Activity> getGrantsForAssociatedPeople(
|
|
||||||
Dataset dataset, Collection<SubEntity> people)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
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.
|
* This method side-effects person and the central grants map.
|
||||||
|
@ -742,152 +217,4 @@ public class SelectOnModelUtilities {
|
||||||
|
|
||||||
return allGrantURIToVOs;
|
return allGrantURIToVOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Map<String, Activity> getPublicationsForPerson(
|
|
||||||
Dataset dataset, SubEntity person, boolean doCache)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
Map<String, Activity> allPublicationURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
Model personPublicationsModel = null;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we dont want to cache the results then create the model directly without
|
|
||||||
* using the ModelConstructorUtilities. Use case is the co-author ego-centric
|
|
||||||
* visualization.
|
|
||||||
* */
|
|
||||||
if (doCache) {
|
|
||||||
personPublicationsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
person.getIndividualURI(),
|
|
||||||
PersonToPublicationsModelConstructor.MODEL_TYPE,
|
|
||||||
dataset);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ModelConstructor model = new PersonToPublicationsModelConstructor(person.getIndividualURI(), dataset);
|
|
||||||
personPublicationsModel = model.getConstructedModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
updatePublicationsForPerson(person, allPublicationURIToVOs, personPublicationsModel);
|
|
||||||
|
|
||||||
return allPublicationURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Activity> getPublicationsForAssociatedPeople(
|
|
||||||
Dataset dataset, Collection<SubEntity> people)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
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<String, Activity> allDocumentURIToVOs,
|
|
||||||
Model peoplePublicationsModel)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasPublication ?document . "
|
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> personPublicationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
peoplePublicationsModel);
|
|
||||||
|
|
||||||
getPublicationForEntity(personPublicationsQuery.getQueryResult(),
|
|
||||||
person,
|
|
||||||
allDocumentURIToVOs);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
person,
|
|
||||||
peoplePublicationsModel);
|
|
||||||
|
|
||||||
person.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Activity> getPublicationsWithJournalForAssociatedPeople(
|
|
||||||
Dataset dataset, Collection<SubEntity> people)
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
|
||||||
|
|
||||||
Model peoplePublicationsModel = ModelConstructorUtilities
|
|
||||||
.getOrConstructModel(
|
|
||||||
null,
|
|
||||||
PeopleToPublicationsModelConstructor.MODEL_TYPE,
|
|
||||||
dataset);
|
|
||||||
|
|
||||||
for (SubEntity person : people) {
|
|
||||||
|
|
||||||
// System.out.println("getting publications for " + person.getIndividualLabel());
|
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
|
||||||
fieldLabelToOutputFieldLabel.put("journalLabel", QueryFieldLabels.DOCUMENT_JOURNAL_LABEL);
|
|
||||||
|
|
||||||
String whereClause = ""
|
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasPublication ?document . "
|
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . "
|
|
||||||
+ " OPTIONAL { "
|
|
||||||
+ " ?document core:hasPublicationVenue ?journal . "
|
|
||||||
+ " ?journal rdfs:label ?journalLabel . } ";
|
|
||||||
|
|
||||||
QueryRunner<ResultSet> personPublicationsQuery =
|
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
|
||||||
"",
|
|
||||||
whereClause,
|
|
||||||
"",
|
|
||||||
peoplePublicationsModel);
|
|
||||||
|
|
||||||
getPublicationWithJournalForEntity(personPublicationsQuery.getQueryResult(),
|
|
||||||
person,
|
|
||||||
allDocumentURIToVOs);
|
|
||||||
|
|
||||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
|
||||||
person,
|
|
||||||
peoplePublicationsModel);
|
|
||||||
|
|
||||||
person.setLastCachedAtDateTime(lastCachedAtForEntity);
|
|
||||||
|
|
||||||
}
|
|
||||||
return allDocumentURIToVOs;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue