Skip to content

Commit

Permalink
Merge commit 'f397d53ba2575567a175229831fd0fb8c3f5027c' into maint-re…
Browse files Browse the repository at this point in the history
…l-1.8
  • Loading branch information
grahamtriggs committed Nov 9, 2015
2 parents 2dbc5be + f397d53 commit a64b579
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
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;
Expand Down Expand Up @@ -59,14 +61,16 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
private String egoURI;

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;

}
Expand Down Expand Up @@ -541,6 +545,10 @@ private synchronized CoAuthorshipData getQueryResultAndCache()
}
}

if (consumer.egoNode == null) {
consumer.egoNode = makeEgoNode();
}

data = consumer.getCollaborationData();
if (cacheTime != null) {
data.setBuiltFromCacheTime(cacheTime);
Expand All @@ -561,6 +569,13 @@ private synchronized CoAuthorshipData getQueryResultAndCache()
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Map<String, String> generateDataVisualization(
.VIS_MODE_KEY);

CoAuthorshipQueryRunner queryManager =
new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log);
new CoAuthorshipQueryRunner(egoURI, vitroRequest, log);

CollaborationData authorNodesAndEdges =
queryManager.getQueryResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
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;
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -283,6 +286,9 @@ private synchronized CoInvestigationData getQueryResultAndCache()
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);
Expand All @@ -306,6 +312,13 @@ private synchronized CoInvestigationData getQueryResultAndCache()
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);
Expand Down Expand Up @@ -656,6 +669,7 @@ private String getEdgeUniqueIdentifier(int nodeID1, int nodeID2) {
}

}

/** END QUERY RESULT CONSUMER **/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Map<String, String> generateDataVisualization(
Model constructedModel = constructQueryRunner.getConstructedModel();

QueryRunner<CollaborationData> queryManager =
new CoPIGrantCountQueryRunner(egoURI, vitroRequest.getRDFService(), log);
new CoPIGrantCountQueryRunner(egoURI, vitroRequest, log);

CollaborationData investigatorNodesAndEdges = queryManager.getQueryResult();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,10 @@ private ResponseValues generateStandardVisualizationForPersonLevelVis(
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();

/*
Expand All @@ -136,8 +127,7 @@ private ResponseValues generateStandardVisualizationForPersonLevelVis(
yearToGrantCount,
log);

SparklineData grantSparklineVO = personGrantCountVisCodeGenerator
.getValueObjectContainer();
SparklineData grantSparklineVO = personGrantCountVisCodeGenerator.getValueObjectContainer();


/*
Expand All @@ -151,10 +141,8 @@ private ResponseValues generateStandardVisualizationForPersonLevelVis(
UtilityFunctions.getActivityYearToCollaborators(coPIData),
log);

SparklineData uniqueCopisSparklineVO = uniqueCopisVisCodeGenerator
.getValueObjectContainer();


SparklineData uniqueCopisSparklineVO = uniqueCopisVisCodeGenerator.getValueObjectContainer();

return prepareCoPIStandaloneResponse(
egoURI,
grantSparklineVO,
Expand All @@ -165,7 +153,7 @@ private ResponseValues generateStandardVisualizationForPersonLevelVis(
} else {

CoAuthorshipQueryRunner coAuthorshipQueryManager =
new CoAuthorshipQueryRunner(egoURI, vitroRequest.getRDFService(), log);
new CoAuthorshipQueryRunner(egoURI, vitroRequest, log);

CoAuthorshipData coAuthorshipData = coAuthorshipQueryManager.getQueryResult();

Expand Down

0 comments on commit a64b579

Please sign in to comment.