Small fix to having no collaborations in co-author and co-investigator networks.

This commit is contained in:
Graham Triggs 2015-11-09 18:11:17 +00:00
parent 6e173e5815
commit f397d53ba2
7 changed files with 50 additions and 49 deletions

View file

@ -246,15 +246,6 @@ $(document).ready(function(){
<div class="sub_headings"><h2><a href="${egoVivoProfileURL}" title="${i18n().author_name}"><span id="ego_label"></span></a><br />${i18n().co_author_network} </h2></div>
<#if (numOfCoAuthorShips?? && numOfCoAuthorShips > 0) || (numOfAuthors?? && numOfAuthors > 0) >
<div class = "graphml-file-link">(<a href="${egoCoAuthorshipNetworkDataFileURL}" title="GraphML ${i18n().file}">GraphML ${i18n().file}</a>)</div>
<#else>
<#if numOfAuthors?? && numOfAuthors <= 0 >
<#assign authorsText = "multi-author" />
</#if>
<div id="no_coauthorships">${i18n().currently_no_papers_for(authorsText!)}
<a href="${egoVivoProfileURL}" title="${i18n().co_authorship}"><span id="no_coauthorships_person" class="author_name">${i18n().this_author}</span></a> ${i18n().in_the_vivo_db}
</div>
</#if>
<div class = "toggle_visualization">

View file

@ -254,23 +254,8 @@ $(document).ready(function(){
<#if (numOfCoInvestigations?? && numOfCoInvestigations > 0) || (numOfInvestigators?? && numOfInvestigators > 0) >
<div class = "graphml-file-link"><a href="${egoCoInvestigationNetworkDataFileURL}" title="${i18n().co_investigator}">(GraphML ${i18n().file_capitalized})</a></div>
<#else>
<#if numOfInvestigators?? && numOfInvestigators <= 0 >
<#assign investigatorsText = "multi-investigator" />
</#if>
<span id="no_coinvestigations">${i18n().currently_no_grants_for(investigatorsText!)}
<a href="${egoVivoProfileURL}" title="${i18n().investigator_name}"><span id="no_coinvestigations_person" class="investigator_name">${i18n().this_investigator}</span></a> ${i18n().in_the_vivo_db}
</span>
</#if>
<#else>
<span id="no_coinvestigations">${i18n().no_grants_for}
<a href="${egoVivoProfileURL}" title="${i18n().co_investigator}"><span id="no_coinvestigations_person" class="investigator_name">${i18n().this_investigator}</span></a> ${i18n().in_the_vivo_db}
</span>
</#if>
<div class = "toggle_visualization">
@ -290,6 +275,14 @@ $(document).ready(function(){
<div id="bodyPannel">
<div id="chord" style="float: right;"></div>
</div>
<#else>
<#if numOfInvestigators?? && numOfInvestigators <= 0 >
<#assign investigatorsText = "multi-investigator" />
</#if>
<span id="no_coinvestigations">${i18n().currently_no_grants_for(investigatorsText!)}
<a href="${egoVivoProfileURL}" title="${i18n().investigator_name}"><span id="no_coinvestigations_person" class="investigator_name">${i18n().this_investigator}</span></a> ${i18n().in_the_vivo_db}
</span>
</#if>

View file

@ -16,10 +16,12 @@ import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
import edu.cornell.mannlib.vitro.webapp.rdfservice.ResultSetConsumer;
import edu.cornell.mannlib.vitro.webapp.visualization.utilities.VisualizationCaches;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.jena.iri.IRI;
@ -60,13 +62,15 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
private RDFService rdfService;
private VitroRequest vitroRequest;
private Log log;
public CoAuthorshipQueryRunner(String egoURI,
RDFService rdfService, Log log) {
public CoAuthorshipQueryRunner(String egoURI, VitroRequest vreq, Log log) {
this.egoURI = egoURI;
this.rdfService = rdfService;
this.rdfService = vreq.getRDFService();
this.vitroRequest = vreq;
this.log = log;
}
@ -541,6 +545,10 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
}
}
if (consumer.egoNode == null) {
consumer.egoNode = makeEgoNode();
}
data = consumer.getCollaborationData();
if (cacheTime != null) {
data.setBuiltFromCacheTime(cacheTime);
@ -561,6 +569,13 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
return data;
}
private Collaborator makeEgoNode() {
Collaborator collab = new Collaborator(egoURI, new UniqueIDGenerator());
collab.setCollaboratorName(UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, egoURI));
return collab;
}
private synchronized void expireCache() {
for (String key : collaborationDataCache.keySet()) {
CollaborationDataCacheEntry entry = collaborationDataCache.get(key);

View file

@ -65,7 +65,7 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
.VIS_MODE_KEY);
CoAuthorshipQueryRunner queryManager =
new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log);
new CoAuthorshipQueryRunner(egoURI, vitroRequest, log);
CollaborationData authorNodesAndEdges =
queryManager.getQueryResult();

View file

@ -12,9 +12,11 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
import edu.cornell.mannlib.vitro.webapp.rdfservice.ResultSetConsumer;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -50,6 +52,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
private String egoURI;
private RDFService rdfService;
private VitroRequest vitroRequest;
private Log log = LogFactory.getLog(CoPIGrantCountQueryRunner.class.getName());
@ -78,11 +81,11 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "}";
public CoPIGrantCountQueryRunner(String egoURI,
RDFService rdfService, Log log) {
public CoPIGrantCountQueryRunner(String egoURI, VitroRequest vreq, Log log) {
this.egoURI = egoURI;
this.rdfService = rdfService;
this.rdfService = vreq.getRDFService();
this.vitroRequest = vreq;
// this.log = log;
}
@ -283,6 +286,9 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
try {
QueryResultConsumer consumer = new QueryResultConsumer();
rdfService.sparqlSelectQuery(generateEgoCoPIquery(this.egoURI), consumer);
if (consumer.egoNode == null) {
consumer.egoNode = makeEgoNode();
}
data = consumer.getData();
} catch (RDFServiceException e) {
log.error("Unable to execute query", e);
@ -306,6 +312,13 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
return data;
}
private Collaborator makeEgoNode() {
Collaborator collab = new Collaborator(egoURI, new UniqueIDGenerator());
collab.setCollaboratorName(UtilityFunctions.getIndividualLabelFromDAO(vitroRequest, egoURI));
return collab;
}
private synchronized void expireCache() {
for (String key : collaborationDataCache.keySet()) {
CollaborationDataCacheEntry entry = collaborationDataCache.get(key);
@ -656,6 +669,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
}
}
/** END QUERY RESULT CONSUMER **/
}
}

View file

@ -58,7 +58,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<CollaborationData> queryManager =
new CoPIGrantCountQueryRunner(egoURI, vitroRequest.getRDFService(), log);
new CoPIGrantCountQueryRunner(egoURI, vitroRequest, log);
CollaborationData investigatorNodesAndEdges = queryManager.getQueryResult();

View file

@ -105,19 +105,10 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
String visMode) throws MalformedQueryParametersException {
if (VisualizationFrameworkConstants.COPI_VIS_MODE.equalsIgnoreCase(visMode)) {
CoPIGrantCountQueryRunner coPIQueryManager = new CoPIGrantCountQueryRunner(egoURI, vitroRequest.getRDFService(), log);
CoPIGrantCountQueryRunner coPIQueryManager = new CoPIGrantCountQueryRunner(egoURI, vitroRequest, log);
CoInvestigationData coPIData = coPIQueryManager.getQueryResult();
/*
* grants over time sparkline
*/
SubEntity person = new SubEntity(egoURI,
UtilityFunctions
.getIndividualLabelFromDAO(vitroRequest, egoURI));
// Map<String, Activity> grantsToURI = SelectOnModelUtilities.getGrantsForPerson(vitroRequest.getRDFService(), person, false);
Map<String, Activity> grantsToURI = coPIData.getGrants();
/*
@ -136,8 +127,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
yearToGrantCount,
log);
SparklineData grantSparklineVO = personGrantCountVisCodeGenerator
.getValueObjectContainer();
SparklineData grantSparklineVO = personGrantCountVisCodeGenerator.getValueObjectContainer();
/*
@ -151,9 +141,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
UtilityFunctions.getActivityYearToCollaborators(coPIData),
log);
SparklineData uniqueCopisSparklineVO = uniqueCopisVisCodeGenerator
.getValueObjectContainer();
SparklineData uniqueCopisSparklineVO = uniqueCopisVisCodeGenerator.getValueObjectContainer();
return prepareCoPIStandaloneResponse(
egoURI,
@ -165,7 +153,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
} else {
CoAuthorshipQueryRunner coAuthorshipQueryManager =
new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log);
new CoAuthorshipQueryRunner(egoURI, vitroRequest, log);
CoAuthorshipData coAuthorshipData = coAuthorshipQueryManager.getQueryResult();