1. Person to grants was creating wrong models for each person. Fixed.
This commit is contained in:
parent
aee1d00801
commit
daa9d61d04
3 changed files with 517 additions and 513 deletions
|
@ -174,7 +174,7 @@ public class TemporalGrantVisualizationRequestHandler implements
|
||||||
if (organizationWithAssociatedPeople.getSubEntities() != null) {
|
if (organizationWithAssociatedPeople.getSubEntities() != null) {
|
||||||
|
|
||||||
grantURIForAssociatedPeopleToVO = SelectOnModelUtilities
|
grantURIForAssociatedPeopleToVO = SelectOnModelUtilities
|
||||||
.getPublicationsForAssociatedPeople(dataset, organizationWithAssociatedPeople.getSubEntities());
|
.getGrantsForAssociatedPeople(dataset, organizationWithAssociatedPeople.getSubEntities());
|
||||||
|
|
||||||
organizationEntity = EntityComparisonUtilityFunctions.mergeEntityIfShareSameURI(
|
organizationEntity = EntityComparisonUtilityFunctions.mergeEntityIfShareSameURI(
|
||||||
organizationEntity,
|
organizationEntity,
|
||||||
|
|
|
@ -44,21 +44,21 @@ private Set<String> constructPersonGrantsQueryTemplate(String constructProperty,
|
||||||
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
||||||
|
|
||||||
String justGrantsQuery = ""
|
String justGrantsQuery = ""
|
||||||
+ " CONSTRUCT { "
|
+ " CONSTRUCT { "
|
||||||
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
|
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
|
||||||
+ " <" + personURI + "> vivosocnet:" + constructProperty + " ?Grant . "
|
+ " <" + personURI + "> vivosocnet:" + constructProperty + " ?Grant . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
+ " ?Grant rdfs:label ?grantLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
+ " ?Person core:" + roleTypeProperty + " ?Role . "
|
+ " <" + personURI + "> core:" + roleTypeProperty + " ?Role . "
|
||||||
+ " ?Role core:roleIn ?Grant . "
|
+ " ?Role core:roleIn ?Grant . "
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
+ " ?Grant rdfs:label ?grantLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " LET(?now := afn:now()) "
|
+ " LET(?now := afn:now()) "
|
||||||
+ " } ";
|
+ " } ";
|
||||||
|
|
||||||
String justDateTimeOnGrantsQuery = ""
|
String justDateTimeOnGrantsQuery = ""
|
||||||
+ " CONSTRUCT { "
|
+ " CONSTRUCT { "
|
||||||
|
@ -68,7 +68,7 @@ private Set<String> constructPersonGrantsQueryTemplate(String constructProperty,
|
||||||
+ " "
|
+ " "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
+ " ?Person core:" + roleTypeProperty + " ?Role . "
|
+ " <" + personURI + "> core:" + roleTypeProperty + " ?Role . "
|
||||||
+ " ?Role core:roleIn ?Grant . "
|
+ " ?Role core:roleIn ?Grant . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
||||||
|
@ -91,7 +91,7 @@ private Set<String> constructPersonGrantsQueryTemplate(String constructProperty,
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
+ " ?Person core:" + roleTypeProperty + " ?Role . "
|
+ " <" + personURI + "> core:" + roleTypeProperty + " ?Role . "
|
||||||
+ " ?Role core:roleIn ?Grant . "
|
+ " ?Role core:roleIn ?Grant . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
||||||
|
@ -139,6 +139,7 @@ private Set<String> constructPersonGrantsQueryTemplate(String constructProperty,
|
||||||
|
|
||||||
for (String currentQuery : constructQueries) {
|
for (String currentQuery : constructQueries) {
|
||||||
|
|
||||||
|
|
||||||
Query query = null;
|
Query query = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -148,7 +149,8 @@ private Set<String> constructPersonGrantsQueryTemplate(String constructProperty,
|
||||||
+ "string. " + th.getMessage());
|
+ "string. " + th.getMessage());
|
||||||
log.error(currentQuery);
|
log.error(currentQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,494 +1,496 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils;
|
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.ModelConstructorUtilities;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.ModelConstructorUtilities;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationAssociatedPeopleModelWithTypesConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationAssociatedPeopleModelWithTypesConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationModelWithTypesConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationModelWithTypesConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationToGrantsForSubOrganizationsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationToGrantsForSubOrganizationsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PersonToGrantsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PersonToGrantsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PersonToPublicationsModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PersonToPublicationsModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Activity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Activity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||||
|
|
||||||
public class SelectOnModelUtilities {
|
public class SelectOnModelUtilities {
|
||||||
|
|
||||||
public static Entity getSubjectOrganizationHierarchy(Dataset dataset,
|
public static Entity getSubjectOrganizationHierarchy(Dataset dataset,
|
||||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
String subjectEntityURI) throws MalformedQueryParametersException {
|
||||||
Model organizationModel = ModelConstructorUtilities
|
Model organizationModel = ModelConstructorUtilities
|
||||||
.getOrConstructModel(
|
.getOrConstructModel(
|
||||||
null,
|
null,
|
||||||
OrganizationModelWithTypesConstructor.MODEL_TYPE,
|
OrganizationModelWithTypesConstructor.MODEL_TYPE,
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||||
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
||||||
fieldLabelToOutputFieldLabel.put("subOrganization", QueryFieldLabels.SUBORGANIZATION_URL);
|
fieldLabelToOutputFieldLabel.put("subOrganization", QueryFieldLabels.SUBORGANIZATION_URL);
|
||||||
fieldLabelToOutputFieldLabel.put("subOrganizationLabel", QueryFieldLabels.SUBORGANIZATION_LABEL);
|
fieldLabelToOutputFieldLabel.put("subOrganizationLabel", QueryFieldLabels.SUBORGANIZATION_LABEL);
|
||||||
fieldLabelToOutputFieldLabel.put("subOrganizationTypeLabel", QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL);
|
fieldLabelToOutputFieldLabel.put("subOrganizationTypeLabel", QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL);
|
||||||
|
|
||||||
String whereClause = ""
|
String whereClause = ""
|
||||||
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
||||||
+ " <" + subjectEntityURI + "> core:hasSubOrganization ?subOrganization . "
|
+ " <" + subjectEntityURI + "> core:hasSubOrganization ?subOrganization . "
|
||||||
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
||||||
+ " ?subOrganization rdf:type ?subOrgType . "
|
+ " ?subOrganization rdf:type ?subOrgType . "
|
||||||
+ " ?subOrgType rdfs:label ?subOrganizationTypeLabel . ";
|
+ " ?subOrgType rdfs:label ?subOrganizationTypeLabel . ";
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationsWithTypesQuery =
|
QueryRunner<ResultSet> subOrganizationsWithTypesQuery =
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
||||||
"",
|
"",
|
||||||
whereClause,
|
whereClause,
|
||||||
"",
|
"",
|
||||||
organizationModel);
|
organizationModel);
|
||||||
|
|
||||||
return getEntityWithSubOrganizations(subjectEntityURI,
|
return getEntityWithSubOrganizations(subjectEntityURI,
|
||||||
subOrganizationsWithTypesQuery.getQueryResult());
|
subOrganizationsWithTypesQuery.getQueryResult());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Entity getEntityWithSubOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
private static Entity getEntityWithSubOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
||||||
|
|
||||||
Entity entity = new Entity(subjectEntityURI);
|
Entity entity = new Entity(subjectEntityURI);
|
||||||
Map<String, SubEntity> subOrganizationURIToVO = new HashMap<String, SubEntity>();
|
Map<String, SubEntity> subOrganizationURIToVO = new HashMap<String, SubEntity>();
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
while (queryResult.hasNext()) {
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
QuerySolution solution = queryResult.nextSolution();
|
||||||
|
|
||||||
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
||||||
if (organizationLabelNode != null) {
|
if (organizationLabelNode != null) {
|
||||||
entity.setIndividualLabel(organizationLabelNode.toString());
|
entity.setIndividualLabel(organizationLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RDFNode subOrganizationNode = solution.get(QueryFieldLabels.SUBORGANIZATION_URL);
|
RDFNode subOrganizationNode = solution.get(QueryFieldLabels.SUBORGANIZATION_URL);
|
||||||
|
|
||||||
SubEntity subEntity;
|
SubEntity subEntity;
|
||||||
|
|
||||||
if (subOrganizationURIToVO.containsKey(subOrganizationNode.toString())) {
|
if (subOrganizationURIToVO.containsKey(subOrganizationNode.toString())) {
|
||||||
|
|
||||||
subEntity = subOrganizationURIToVO.get(subOrganizationNode.toString());
|
subEntity = subOrganizationURIToVO.get(subOrganizationNode.toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
subEntity = new SubEntity(subOrganizationNode.toString());
|
subEntity = new SubEntity(subOrganizationNode.toString());
|
||||||
|
|
||||||
subEntity.setEntityClass(VOConstants.EntityClassType.ORGANIZATION);
|
subEntity.setEntityClass(VOConstants.EntityClassType.ORGANIZATION);
|
||||||
|
|
||||||
subOrganizationURIToVO.put(subOrganizationNode.toString(), subEntity);
|
subOrganizationURIToVO.put(subOrganizationNode.toString(), subEntity);
|
||||||
|
|
||||||
RDFNode subOrganizationLabelNode = solution.get(QueryFieldLabels.SUBORGANIZATION_LABEL);
|
RDFNode subOrganizationLabelNode = solution.get(QueryFieldLabels.SUBORGANIZATION_LABEL);
|
||||||
if (subOrganizationLabelNode != null) {
|
if (subOrganizationLabelNode != null) {
|
||||||
subEntity.setIndividualLabel(subOrganizationLabelNode.toString());
|
subEntity.setIndividualLabel(subOrganizationLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RDFNode subOrganizationTypeLabelNode = solution.get(QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL);
|
RDFNode subOrganizationTypeLabelNode = solution.get(QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL);
|
||||||
if (subOrganizationTypeLabelNode != null) {
|
if (subOrganizationTypeLabelNode != null) {
|
||||||
subEntity.addEntityTypeLabel(subOrganizationTypeLabelNode.toString());
|
subEntity.addEntityTypeLabel(subOrganizationTypeLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.addSubEntitities(subOrganizationURIToVO.values());
|
entity.addSubEntitities(subOrganizationURIToVO.values());
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entity getSubjectOrganizationAssociatedPeople(Dataset dataset,
|
public static Entity getSubjectOrganizationAssociatedPeople(Dataset dataset,
|
||||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
String subjectEntityURI) throws MalformedQueryParametersException {
|
||||||
Model associatedPeopleModel = ModelConstructorUtilities
|
Model associatedPeopleModel = ModelConstructorUtilities
|
||||||
.getOrConstructModel(
|
.getOrConstructModel(
|
||||||
subjectEntityURI,
|
subjectEntityURI,
|
||||||
OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE,
|
OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE,
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||||
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
||||||
fieldLabelToOutputFieldLabel.put("person", QueryFieldLabels.PERSON_URL);
|
fieldLabelToOutputFieldLabel.put("person", QueryFieldLabels.PERSON_URL);
|
||||||
fieldLabelToOutputFieldLabel.put("personLabel", QueryFieldLabels.PERSON_LABEL);
|
fieldLabelToOutputFieldLabel.put("personLabel", QueryFieldLabels.PERSON_LABEL);
|
||||||
fieldLabelToOutputFieldLabel.put("personTypeLabel", QueryFieldLabels.PERSON_TYPE_LABEL);
|
fieldLabelToOutputFieldLabel.put("personTypeLabel", QueryFieldLabels.PERSON_TYPE_LABEL);
|
||||||
|
|
||||||
String whereClause = ""
|
String whereClause = ""
|
||||||
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
||||||
+ " <" + subjectEntityURI + "> vivosocnet:hasPersonWithActivity ?person . "
|
+ " <" + subjectEntityURI + "> vivosocnet:hasPersonWithActivity ?person . "
|
||||||
+ " ?person rdfs:label ?personLabel . "
|
+ " ?person rdfs:label ?personLabel . "
|
||||||
+ " ?person rdf:type ?personType . "
|
+ " ?person rdf:type ?personType . "
|
||||||
+ " ?personType rdfs:label ?personTypeLabel . ";
|
+ " ?personType rdfs:label ?personTypeLabel . ";
|
||||||
|
|
||||||
QueryRunner<ResultSet> associatedPeopleWithTypesQuery =
|
QueryRunner<ResultSet> associatedPeopleWithTypesQuery =
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
||||||
"",
|
"",
|
||||||
whereClause,
|
whereClause,
|
||||||
"",
|
"",
|
||||||
associatedPeopleModel);
|
associatedPeopleModel);
|
||||||
|
|
||||||
return getEntityWithAssociatedPeopleSubEntitities(subjectEntityURI, associatedPeopleWithTypesQuery.getQueryResult());
|
return getEntityWithAssociatedPeopleSubEntitities(subjectEntityURI, associatedPeopleWithTypesQuery.getQueryResult());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Entity getEntityWithAssociatedPeopleSubEntitities(
|
private static Entity getEntityWithAssociatedPeopleSubEntitities(
|
||||||
String subjectEntityURI, ResultSet queryResult) {
|
String subjectEntityURI, ResultSet queryResult) {
|
||||||
|
|
||||||
Entity entity = new Entity(subjectEntityURI);
|
Entity entity = new Entity(subjectEntityURI);
|
||||||
Map<String, SubEntity> associatedPeopleURIToVO = new HashMap<String, SubEntity>();
|
Map<String, SubEntity> associatedPeopleURIToVO = new HashMap<String, SubEntity>();
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
while (queryResult.hasNext()) {
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
QuerySolution solution = queryResult.nextSolution();
|
||||||
|
|
||||||
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
||||||
|
|
||||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
||||||
if (organizationLabelNode != null) {
|
if (organizationLabelNode != null) {
|
||||||
entity.setIndividualLabel(organizationLabelNode.toString());
|
entity.setIndividualLabel(organizationLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RDFNode personNode = solution.get(QueryFieldLabels.PERSON_URL);
|
RDFNode personNode = solution.get(QueryFieldLabels.PERSON_URL);
|
||||||
|
|
||||||
SubEntity subEntity;
|
SubEntity subEntity;
|
||||||
|
|
||||||
if (associatedPeopleURIToVO.containsKey(personNode.toString())) {
|
if (associatedPeopleURIToVO.containsKey(personNode.toString())) {
|
||||||
|
|
||||||
subEntity = associatedPeopleURIToVO.get(personNode.toString());
|
subEntity = associatedPeopleURIToVO.get(personNode.toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
subEntity = new SubEntity(personNode.toString());
|
subEntity = new SubEntity(personNode.toString());
|
||||||
subEntity.setEntityClass(VOConstants.EntityClassType.PERSON);
|
subEntity.setEntityClass(VOConstants.EntityClassType.PERSON);
|
||||||
associatedPeopleURIToVO.put(personNode.toString(), subEntity);
|
associatedPeopleURIToVO.put(personNode.toString(), subEntity);
|
||||||
|
|
||||||
RDFNode personLabelNode = solution.get(QueryFieldLabels.PERSON_LABEL);
|
RDFNode personLabelNode = solution.get(QueryFieldLabels.PERSON_LABEL);
|
||||||
if (personLabelNode != null) {
|
if (personLabelNode != null) {
|
||||||
subEntity.setIndividualLabel(personLabelNode.toString());
|
subEntity.setIndividualLabel(personLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RDFNode personTypeLabelNode = solution.get(QueryFieldLabels.PERSON_TYPE_LABEL);
|
RDFNode personTypeLabelNode = solution.get(QueryFieldLabels.PERSON_TYPE_LABEL);
|
||||||
if (personTypeLabelNode != null) {
|
if (personTypeLabelNode != null) {
|
||||||
subEntity.addEntityTypeLabel(personTypeLabelNode.toString());
|
subEntity.addEntityTypeLabel(personTypeLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.addSubEntitities(associatedPeopleURIToVO.values());
|
entity.addSubEntitities(associatedPeopleURIToVO.values());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Activity> getPublicationsForAllSubOrganizations(
|
public static Map<String, Activity> getPublicationsForAllSubOrganizations(
|
||||||
Dataset dataset, Entity organizationEntity)
|
Dataset dataset, Entity organizationEntity)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
||||||
|
|
||||||
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
||||||
|
|
||||||
Model subOrganizationPublicationsModel = ModelConstructorUtilities
|
Model subOrganizationPublicationsModel = ModelConstructorUtilities
|
||||||
.getOrConstructModel(
|
.getOrConstructModel(
|
||||||
subOrganization.getIndividualURI(),
|
subOrganization.getIndividualURI(),
|
||||||
OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
OrganizationToPublicationsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
System.out.println("getting publications for " + subOrganization.getIndividualLabel());
|
System.out.println("getting publications for " + subOrganization.getIndividualLabel());
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
||||||
fieldLabelToOutputFieldLabel.put("lastCachedDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
fieldLabelToOutputFieldLabel.put("lastCachedDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
||||||
|
|
||||||
String whereClause = ""
|
String whereClause = ""
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPersonWithPublication ?document . "
|
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPersonWithPublication ?document . "
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedDateTime . "
|
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedDateTime . "
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
+ " ?document rdfs:label ?documentLabel . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . ";
|
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . ";
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationPublicationsQuery =
|
QueryRunner<ResultSet> subOrganizationPublicationsQuery =
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
||||||
"",
|
"",
|
||||||
whereClause,
|
whereClause,
|
||||||
"",
|
"",
|
||||||
subOrganizationPublicationsModel);
|
subOrganizationPublicationsModel);
|
||||||
|
|
||||||
subOrganization.addActivities(getPublicationForEntity(
|
subOrganization.addActivities(getPublicationForEntity(
|
||||||
subOrganizationPublicationsQuery.getQueryResult(),
|
subOrganizationPublicationsQuery.getQueryResult(),
|
||||||
allDocumentURIToVOs));
|
allDocumentURIToVOs));
|
||||||
|
|
||||||
}
|
}
|
||||||
return allDocumentURIToVOs;
|
return allDocumentURIToVOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<Activity> getPublicationForEntity(
|
private static Collection<Activity> getPublicationForEntity(
|
||||||
ResultSet queryResult,
|
ResultSet queryResult,
|
||||||
Map<String, Activity> allDocumentURIToVOs) {
|
Map<String, Activity> allDocumentURIToVOs) {
|
||||||
|
|
||||||
Set<Activity> currentEntityPublications = new HashSet<Activity>();
|
Set<Activity> currentEntityPublications = new HashSet<Activity>();
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
while (queryResult.hasNext()) {
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
QuerySolution solution = queryResult.nextSolution();
|
||||||
|
|
||||||
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
||||||
Activity biboDocument;
|
Activity biboDocument;
|
||||||
|
|
||||||
if (allDocumentURIToVOs.containsKey(documentNode.toString())) {
|
if (allDocumentURIToVOs.containsKey(documentNode.toString())) {
|
||||||
biboDocument = allDocumentURIToVOs.get(documentNode.toString());
|
biboDocument = allDocumentURIToVOs.get(documentNode.toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
biboDocument = new Activity(documentNode.toString());
|
biboDocument = new Activity(documentNode.toString());
|
||||||
allDocumentURIToVOs.put(documentNode.toString(), biboDocument);
|
allDocumentURIToVOs.put(documentNode.toString(), biboDocument);
|
||||||
|
|
||||||
RDFNode publicationDateNode = solution.get(QueryFieldLabels
|
RDFNode publicationDateNode = solution.get(QueryFieldLabels
|
||||||
.DOCUMENT_PUBLICATION_DATE);
|
.DOCUMENT_PUBLICATION_DATE);
|
||||||
if (publicationDateNode != null) {
|
if (publicationDateNode != null) {
|
||||||
biboDocument.setActivityDate(publicationDateNode.toString());
|
biboDocument.setActivityDate(publicationDateNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentEntityPublications.add(biboDocument);
|
currentEntityPublications.add(biboDocument);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentEntityPublications;
|
return currentEntityPublications;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Collection<Activity> getGrantForEntity(
|
private static Collection<Activity> getGrantForEntity(
|
||||||
ResultSet queryResult,
|
ResultSet queryResult,
|
||||||
Map<String, Activity> allGrantURIToVO) {
|
Map<String, Activity> allGrantURIToVO) {
|
||||||
|
|
||||||
Set<Activity> currentEntityGrants = new HashSet<Activity>();
|
Set<Activity> currentEntityGrants = new HashSet<Activity>();
|
||||||
|
|
||||||
while (queryResult.hasNext()) {
|
while (queryResult.hasNext()) {
|
||||||
|
|
||||||
QuerySolution solution = queryResult.nextSolution();
|
QuerySolution solution = queryResult.nextSolution();
|
||||||
|
|
||||||
RDFNode grantNode = solution.get(QueryFieldLabels.GRANT_URL);
|
RDFNode grantNode = solution.get(QueryFieldLabels.GRANT_URL);
|
||||||
Activity coreGrant;
|
Activity coreGrant;
|
||||||
|
|
||||||
if (allGrantURIToVO.containsKey(grantNode.toString())) {
|
if (allGrantURIToVO.containsKey(grantNode.toString())) {
|
||||||
coreGrant = allGrantURIToVO.get(grantNode.toString());
|
coreGrant = allGrantURIToVO.get(grantNode.toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
coreGrant = new Activity(grantNode.toString());
|
coreGrant = new Activity(grantNode.toString());
|
||||||
allGrantURIToVO.put(grantNode.toString(), coreGrant);
|
allGrantURIToVO.put(grantNode.toString(), coreGrant);
|
||||||
|
|
||||||
RDFNode grantStartDateNode = solution.get(QueryFieldLabels.ROLE_START_DATE);
|
RDFNode grantStartDateNode = solution.get(QueryFieldLabels.ROLE_START_DATE);
|
||||||
|
|
||||||
if (grantStartDateNode != null) {
|
if (grantStartDateNode != null) {
|
||||||
coreGrant.setActivityDate(grantStartDateNode.toString());
|
coreGrant.setActivityDate(grantStartDateNode.toString());
|
||||||
} else {
|
} else {
|
||||||
grantStartDateNode = solution
|
grantStartDateNode = solution
|
||||||
.get(QueryFieldLabels.GRANT_START_DATE);
|
.get(QueryFieldLabels.GRANT_START_DATE);
|
||||||
if (grantStartDateNode != null) {
|
if (grantStartDateNode != null) {
|
||||||
coreGrant.setActivityDate(grantStartDateNode.toString());
|
coreGrant.setActivityDate(grantStartDateNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentEntityGrants.add(coreGrant);
|
currentEntityGrants.add(coreGrant);
|
||||||
}
|
}
|
||||||
return currentEntityGrants;
|
return currentEntityGrants;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Activity> getGrantsForAllSubOrganizations(
|
public static Map<String, Activity> getGrantsForAllSubOrganizations(
|
||||||
Dataset dataset, Entity organizationEntity)
|
Dataset dataset, Entity organizationEntity)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
Map<String, Activity> allGrantURIToVO = new HashMap<String, Activity>();
|
Map<String, Activity> allGrantURIToVO = new HashMap<String, Activity>();
|
||||||
|
|
||||||
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
for (SubEntity subOrganization : organizationEntity.getSubEntities()) {
|
||||||
|
|
||||||
System.out.println("constructing grants for " + subOrganization.getIndividualLabel() + " :: " + subOrganization.getIndividualURI());
|
System.out.println("constructing grants for " + subOrganization.getIndividualLabel() + " :: " + subOrganization.getIndividualURI());
|
||||||
|
|
||||||
Model subOrganizationGrantsModel = ModelConstructorUtilities
|
Model subOrganizationGrantsModel = ModelConstructorUtilities
|
||||||
.getOrConstructModel(
|
.getOrConstructModel(
|
||||||
subOrganization.getIndividualURI(),
|
subOrganization.getIndividualURI(),
|
||||||
OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||||
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
|
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
|
||||||
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
|
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
|
||||||
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
|
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
|
||||||
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
|
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
|
||||||
|
|
||||||
String whereClause = ""
|
String whereClause = ""
|
||||||
+ "{"
|
+ "{"
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasInvestigatorWithGrant ?grant . "
|
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasInvestigatorWithGrant ?grant . "
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
+ " ?grant rdfs:label ?grantLabel . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "UNION"
|
+ "UNION"
|
||||||
+ "{"
|
+ "{"
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPIWithGrant ?grant . "
|
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPIWithGrant ?grant . "
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
+ " ?grant rdfs:label ?grantLabel . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "UNION"
|
+ "UNION"
|
||||||
+ "{"
|
+ "{"
|
||||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hascoPIWithGrant ?grant . "
|
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hascoPIWithGrant ?grant . "
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
+ " ?grant rdfs:label ?grantLabel . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
QueryRunner<ResultSet> subOrganizationGrantsQuery =
|
QueryRunner<ResultSet> subOrganizationGrantsQuery =
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
||||||
"",
|
"",
|
||||||
whereClause,
|
whereClause,
|
||||||
"",
|
"",
|
||||||
subOrganizationGrantsModel);
|
subOrganizationGrantsModel);
|
||||||
|
|
||||||
subOrganization.addActivities(getGrantForEntity(
|
subOrganization.addActivities(getGrantForEntity(
|
||||||
subOrganizationGrantsQuery.getQueryResult(),
|
subOrganizationGrantsQuery.getQueryResult(),
|
||||||
allGrantURIToVO));
|
allGrantURIToVO));
|
||||||
|
|
||||||
}
|
}
|
||||||
return allGrantURIToVO;
|
return allGrantURIToVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Activity> getGrantsForAssociatedPeople(
|
public static Map<String, Activity> getGrantsForAssociatedPeople(
|
||||||
Dataset dataset, Collection<SubEntity> people)
|
Dataset dataset, Collection<SubEntity> people)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>();
|
Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>();
|
||||||
|
|
||||||
System.out.println("peopel for grants under consideration are ");
|
System.out.println("peopel for grants under consideration are ");
|
||||||
for (SubEntity person : people) {
|
for (SubEntity person : people) {
|
||||||
System.out.println(person.getIndividualURI() + " -- " + person.getIndividualLabel());
|
System.out.println(person.getIndividualURI() + " -- " + person.getIndividualLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SubEntity person : people) {
|
for (SubEntity person : people) {
|
||||||
|
|
||||||
System.out.println("constructing grants for " + person.getIndividualLabel() + " :: " + person.getIndividualURI());
|
System.out.println("constructing grants for " + person.getIndividualLabel() + " :: " + person.getIndividualURI());
|
||||||
|
|
||||||
long before = System.currentTimeMillis();
|
long before = System.currentTimeMillis();
|
||||||
|
|
||||||
Model personGrantsModel = ModelConstructorUtilities
|
Model personGrantsModel = ModelConstructorUtilities
|
||||||
.getOrConstructModel(
|
.getOrConstructModel(
|
||||||
person.getIndividualURI(),
|
person.getIndividualURI(),
|
||||||
PersonToGrantsModelConstructor.MODEL_TYPE,
|
PersonToGrantsModelConstructor.MODEL_TYPE,
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
System.out.print("\t construct took " + (System.currentTimeMillis() - before));
|
System.out.print("\t construct took " + (System.currentTimeMillis() - before));
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
before = System.currentTimeMillis();
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||||
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
|
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
|
||||||
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
|
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
|
||||||
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
|
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
|
||||||
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
|
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
|
||||||
|
|
||||||
String whereClause = ""
|
String whereClause = ""
|
||||||
+ "{"
|
+ "{"
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsAnInvestigator ?grant . "
|
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsAnInvestigator ?grant . "
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
+ " ?grant rdfs:label ?grantLabel . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "UNION"
|
+ "UNION"
|
||||||
+ "{"
|
+ "{"
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsPI ?grant . "
|
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsPI ?grant . "
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
+ " ?grant rdfs:label ?grantLabel . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "UNION"
|
+ "UNION"
|
||||||
+ "{"
|
+ "{"
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsCoPI ?grant . "
|
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsCoPI ?grant . "
|
||||||
+ " ?grant rdfs:label ?grantLabel . "
|
+ " ?grant rdfs:label ?grantLabel . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnGrant ?grantStartDate } . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
+ " ?grant vivosocnet:startDateTimeOnRole ?roleStartDate } . "
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
QueryRunner<ResultSet> personGrantsQuery =
|
QueryRunner<ResultSet> personGrantsQuery =
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
||||||
"",
|
"",
|
||||||
whereClause,
|
whereClause,
|
||||||
"",
|
"",
|
||||||
personGrantsModel);
|
personGrantsModel);
|
||||||
|
|
||||||
person.addActivities(getGrantForEntity(
|
person.addActivities(getGrantForEntity(
|
||||||
personGrantsQuery.getQueryResult(),
|
personGrantsQuery.getQueryResult(),
|
||||||
allGrantURIToVOs));
|
allGrantURIToVOs));
|
||||||
|
|
||||||
System.out.println("\t || select took " + (System.currentTimeMillis() - before));
|
System.out.println("\t || select took " + (System.currentTimeMillis() - before));
|
||||||
|
|
||||||
}
|
}
|
||||||
return allGrantURIToVOs;
|
return allGrantURIToVOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Activity> getPublicationsForAssociatedPeople(
|
public static Map<String, Activity> getPublicationsForAssociatedPeople(
|
||||||
Dataset dataset, Collection<SubEntity> people)
|
Dataset dataset, Collection<SubEntity> people)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
Map<String, Activity> allDocumentURIToVOs = new HashMap<String, Activity>();
|
||||||
|
|
||||||
for (SubEntity person : people) {
|
for (SubEntity person : people) {
|
||||||
|
|
||||||
Model personPublicationsModel = ModelConstructorUtilities
|
Model personPublicationsModel = ModelConstructorUtilities
|
||||||
.getOrConstructModel(
|
.getOrConstructModel(
|
||||||
person.getIndividualURI(),
|
person.getIndividualURI(),
|
||||||
PersonToPublicationsModelConstructor.MODEL_TYPE,
|
PersonToPublicationsModelConstructor.MODEL_TYPE,
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
System.out.println("getting publications for " + person.getIndividualLabel());
|
System.out.println("getting publications for " + person.getIndividualLabel());
|
||||||
|
|
||||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
||||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
||||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
||||||
|
|
||||||
String whereClause = ""
|
String whereClause = ""
|
||||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasPublication ?document . "
|
+ " <" + person.getIndividualURI() + "> vivosocnet:hasPublication ?document . "
|
||||||
+ " ?document rdfs:label ?documentLabel . "
|
+ " ?document rdfs:label ?documentLabel . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
||||||
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . ";
|
+ " ?dateTimeValue core:dateTime ?documentPublicationDate } . ";
|
||||||
|
|
||||||
QueryRunner<ResultSet> personPublicationsQuery =
|
QueryRunner<ResultSet> personPublicationsQuery =
|
||||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
||||||
"",
|
"",
|
||||||
whereClause,
|
whereClause,
|
||||||
"",
|
"",
|
||||||
personPublicationsModel);
|
personPublicationsModel);
|
||||||
|
|
||||||
person.addActivities(getPublicationForEntity(
|
person.addActivities(getPublicationForEntity(
|
||||||
personPublicationsQuery.getQueryResult(),
|
personPublicationsQuery.getQueryResult(),
|
||||||
allDocumentURIToVOs));
|
allDocumentURIToVOs));
|
||||||
}
|
|
||||||
return allDocumentURIToVOs;
|
}
|
||||||
}
|
return allDocumentURIToVOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue