1. Complete fix for the short-url for visualization feature.
2. Refactored vis related code to make use of rebecca's isURIUsingDefaultNamespace function.
This commit is contained in:
parent
87581aeefe
commit
692a94b44a
15 changed files with 116 additions and 92 deletions
|
@ -763,7 +763,7 @@ function getVIVOURL(entityURI){
|
|||
|
||||
function getTemporalVisURL(entityURI) {
|
||||
|
||||
return temporalGraphCommonURL + "&uri=" + entityURI ;
|
||||
return temporalGraphCommonURL + "?uri=" + entityURI ;
|
||||
}
|
||||
|
||||
function getVIVOProfileURL(given_uri) {
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#assign standardVisualizationURLRoot ="/visualization">
|
||||
<#assign shortVisualizationURLRoot ="/vis">
|
||||
|
||||
<#assign organizationVivoProfileURL = "${urls.base}/individual?uri=${organizationURI}">
|
||||
<#assign temporalGraphURL = '${urls.base}${standardVisualizationURLRoot}?vis=${otherVisType}&uri=${organizationURI}&labelField=label'>
|
||||
|
||||
<#if organizationLocalName?has_content >
|
||||
<#assign temporalGraphURL = '${urls.base}${shortVisualizationURLRoot}/${otherVisType}/${organizationLocalName}'>
|
||||
<#else>
|
||||
<#assign temporalGraphURL = '${urls.base}${shortVisualizationURLRoot}/${otherVisType}/?uri=${organizationURI}'>
|
||||
</#if>
|
||||
|
||||
<div id="error-container">
|
||||
|
||||
|
|
|
@ -3,19 +3,30 @@
|
|||
<#assign standardVisualizationURLRoot ="/visualization">
|
||||
<#assign ajaxVisualizationURLRoot ="/visualizationAjax">
|
||||
<#assign dataVisualizationURLRoot ="/visualizationData">
|
||||
<#assign shortVisualizationURLRoot ="/vis">
|
||||
|
||||
<#assign organizationURI ="${organizationURI?url}">
|
||||
<#assign organizationVivoProfileURL = "${urls.base}/individual?uri=${organizationURI}">
|
||||
|
||||
<#assign subOrganizationVivoProfileURL = "${urls.base}/individual?">
|
||||
|
||||
<#assign subOrganizationGrantTemporalGraphCommonURL = "${urls.base}${standardVisualizationURLRoot}?vis=entity_grant_count">
|
||||
<#assign subOrganizationPublicationTemporalGraphCommonURL = "${urls.base}${standardVisualizationURLRoot}?vis=entity_comparison">
|
||||
<#assign subOrganizationGrantTemporalGraphCommonURL = "${urls.base}${shortVisualizationURLRoot}/grant-graph/">
|
||||
<#assign subOrganizationPublicationTemporalGraphCommonURL = "${urls.base}${shortVisualizationURLRoot}/publication-graph/">
|
||||
|
||||
|
||||
<#if organizationLocalName?has_content >
|
||||
|
||||
<#assign organizationPublicationTemporalGraphURL = '${urls.base}${shortVisualizationURLRoot}/publication-graph/${organizationLocalName}'>
|
||||
<#assign organizationGrantTemporalGraphURL = "${urls.base}${shortVisualizationURLRoot}/grant-graph/${organizationLocalName}">
|
||||
|
||||
<#else>
|
||||
|
||||
<#assign organizationPublicationTemporalGraphURL = '${urls.base}${shortVisualizationURLRoot}/publication-graph/?uri=${organizationURI}'>
|
||||
<#assign organizationGrantTemporalGraphURL = "${urls.base}${shortVisualizationURLRoot}/grant-graph/?uri=${organizationURI}">
|
||||
|
||||
</#if>
|
||||
|
||||
<#assign organizationPublicationTemporalGraphURL = "${urls.base}${standardVisualizationURLRoot}?vis=entity_comparison&uri=${organizationURI}">
|
||||
<#assign organizationPublicationTemporalGraphDataURL = "${urls.base}${dataVisualizationURLRoot}?vis=entity_comparison&uri=${organizationURI}&vis_mode=json">
|
||||
|
||||
<#assign organizationGrantTemporalGraphURL = "${urls.base}${standardVisualizationURLRoot}?vis=entity_grant_count&uri=${organizationURI}">
|
||||
<#assign organizationGrantTemporalGraphDataURL = "${urls.base}${dataVisualizationURLRoot}?vis=entity_grant_count&uri=${organizationURI}&vis_mode=json">
|
||||
|
||||
<#assign temporalGraphSmallIcon = '${urls.images}/visualization/temporal_vis_small_icon.jpg'>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#assign otherVisType = "entity_comparison">
|
||||
<#assign otherVisType = "publication-graph">
|
||||
<#assign textForOtherEntityComparisonType = "publications">
|
||||
<#assign textForCurrentEntityComparisonType = "grants">
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#assign otherVisType = "entity_grant_count">
|
||||
<#assign otherVisType = "grant-graph">
|
||||
<#assign textForOtherEntityComparisonType = "grants">
|
||||
<#assign textForCurrentEntityComparisonType = "publications">
|
||||
|
||||
|
|
|
@ -8,7 +8,17 @@
|
|||
<#assign egoURI ="${egoURIParam?url}">
|
||||
<#assign egoCoAuthorshipDataFeederURL = '${urls.base}${dataVisualizationURLRoot}?vis=coauthorship&uri=${egoURI}&vis_mode=coauthor_network_stream&labelField=label'>
|
||||
|
||||
<#assign coprincipalinvestigatorURL = '${urls.base}${shortVisualizationURLRoot}/investigator-network/?uri=${egoURI}'>
|
||||
<#if egoLocalName?has_content >
|
||||
|
||||
<#assign coprincipalinvestigatorURL = '${urls.base}${shortVisualizationURLRoot}/investigator-network/${egoLocalName}'>
|
||||
|
||||
<#else>
|
||||
|
||||
<#assign coprincipalinvestigatorURL = '${urls.base}${shortVisualizationURLRoot}/investigator-network/?uri=${egoURI}'>
|
||||
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
<#assign egoCoAuthorsListDataFileURL = '${urls.base}${dataVisualizationURLRoot}?vis=coauthorship&uri=${egoURI}&vis_mode=coauthors'>
|
||||
<#assign egoCoAuthorshipNetworkDataFileURL = '${urls.base}${dataVisualizationURLRoot}?vis=coauthorship&uri=${egoURI}&vis_mode=coauthor_network_download'>
|
||||
|
|
|
@ -10,6 +10,16 @@
|
|||
|
||||
<#assign coauthorshipURL = '${urls.base}${shortVisualizationURLRoot}/author-network/?uri=${egoURI}'>
|
||||
|
||||
<#if egoLocalName?has_content >
|
||||
|
||||
<#assign coauthorshipURL = '${urls.base}${shortVisualizationURLRoot}/author-network/${egoLocalName}'>
|
||||
|
||||
<#else>
|
||||
|
||||
<#assign coauthorshipURL = '${urls.base}${shortVisualizationURLRoot}/author-network/?uri=${egoURI}'>
|
||||
|
||||
</#if>
|
||||
|
||||
<#assign egoCoInvestigatorsListDataFileURL = '${urls.base}${dataVisualizationURLRoot}?vis=coprincipalinvestigator&uri=${egoURI}&vis_mode=copis'>
|
||||
<#assign egoCoInvestigationNetworkDataFileURL = '${urls.base}${dataVisualizationURLRoot}?vis=coprincipalinvestigator&uri=${egoURI}&vis_mode=copi_network_download'>
|
||||
|
||||
|
|
|
@ -261,6 +261,7 @@ public class EntityPublicationCountRequestHandler implements
|
|||
body.put("portalBean", portal);
|
||||
body.put("title", organizationLabel + " - Temporal Graph Visualization");
|
||||
body.put("organizationURI", entityURI);
|
||||
body.put("organizationLocalName", UtilityFunctions.getIndividualLocalName(entityURI, vreq));
|
||||
body.put("organizationLabel", organizationLabel);
|
||||
|
||||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
|
|
|
@ -292,6 +292,7 @@ public class TemporalGrantVisualizationRequestHandler implements
|
|||
body.put("portalBean", portal);
|
||||
body.put("title", organizationLabel + " - Temporal Graph Visualization");
|
||||
body.put("organizationURI", entityURI);
|
||||
body.put("organizationLocalName", UtilityFunctions.getIndividualLocalName(entityURI, vreq));
|
||||
body.put("organizationLabel", organizationLabel);
|
||||
|
||||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
|
|
|
@ -284,6 +284,7 @@ public class TemporalPublicationVisualizationRequestHandler implements
|
|||
body.put("portalBean", portal);
|
||||
body.put("title", organizationLabel + " - Temporal Graph Visualization");
|
||||
body.put("organizationURI", entityURI);
|
||||
body.put("organizationLocalName", UtilityFunctions.getIndividualLocalName(entityURI, vreq));
|
||||
body.put("organizationLabel", organizationLabel);
|
||||
|
||||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
|
|
|
@ -259,6 +259,7 @@ public class EntityGrantCountRequestHandler implements
|
|||
body.put("portalBean", portal);
|
||||
body.put("title", organizationLabel + " - Temporal Graph Visualization");
|
||||
body.put("organizationURI", entityURI);
|
||||
body.put("organizationLocalName", UtilityFunctions.getIndividualLocalName(entityURI, vreq));
|
||||
body.put("organizationLabel", organizationLabel);
|
||||
|
||||
return new TemplateResponseValues(standaloneTemplate, body);
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.hp.hpl.jena.rdf.model.Model;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
|
||||
|
@ -234,6 +235,8 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
|
|||
|
||||
body.put("egoURIParam", egoURI);
|
||||
|
||||
body.put("egoLocalName", UtilityFunctions.getIndividualLocalName(egoURI, vitroRequest));
|
||||
|
||||
String title = "";
|
||||
|
||||
if (coAuthorshipVO.getCollaborators() != null
|
||||
|
@ -270,6 +273,8 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
|
|||
|
||||
body.put("egoURIParam", egoURI);
|
||||
|
||||
body.put("egoLocalName", UtilityFunctions.getIndividualLocalName(egoURI, vitroRequest));
|
||||
|
||||
String title = "";
|
||||
|
||||
if (coPIVO.getCollaborators() != null && coPIVO.getCollaborators().size() > 0) {
|
||||
|
|
|
@ -7,8 +7,6 @@ import java.util.Map;
|
|||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.openrdf.model.URI;
|
||||
import org.openrdf.model.impl.URIImpl;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.hp.hpl.jena.iri.IRI;
|
||||
|
@ -19,7 +17,6 @@ import com.hp.hpl.jena.query.QuerySolution;
|
|||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
|
@ -33,6 +30,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Ge
|
|||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.AllPropertiesQueryRunner;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.GenericQueryRunner;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||
|
||||
/**
|
||||
|
@ -47,24 +45,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.Visual
|
|||
*/
|
||||
public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||
|
||||
/**
|
||||
* TODO: Remove this method once Rebecca creates one. Right now it is the exact copy of the method found in
|
||||
* BaseIndividualTemplateModel.getRdfUrl
|
||||
* @return
|
||||
*/
|
||||
private boolean isIndividualURIBasedOnDefaultNamespace(String givenURI, VitroRequest vitroRequest) {
|
||||
URI uri = new URIImpl(givenURI);
|
||||
String namespace = uri.getNamespace();
|
||||
|
||||
// Individuals in the default namespace
|
||||
// e.g., http://vivo.cornell.edu/individual/n2345/n2345.rdf
|
||||
// where default namespace = http://vivo.cornell.edu/individual/
|
||||
// Other individuals: http://some.other.namespace/n2345?format=rdfxml
|
||||
String defaultNamespace = vitroRequest.getWebappDaoFactory().getDefaultNamespace();
|
||||
return (defaultNamespace.equals(namespace)) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
public Object generateAjaxVisualization(VitroRequest vitroRequest,
|
||||
Log log,
|
||||
Dataset dataset)
|
||||
|
@ -193,21 +173,17 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
.equalsIgnoreCase(visMode)) {
|
||||
|
||||
|
||||
if (isIndividualURIBasedOnDefaultNamespace(individualURI, vitroRequest)) {
|
||||
|
||||
try {
|
||||
String individualLocalName = UtilityFunctions.getIndividualLocalName(
|
||||
individualURI,
|
||||
vitroRequest);
|
||||
|
||||
Individual individual = vitroRequest.getWebappDaoFactory().getIndividualDao().getIndividualByURI(individualURI);
|
||||
if (StringUtils.isNotBlank(individualLocalName)) {
|
||||
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.COAUTHORSHIP_VIS_SHORT_URL
|
||||
+ "/" + individual.getLocalName();
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.COAUTHORSHIP_VIS_SHORT_URL
|
||||
+ "/" + individualLocalName;
|
||||
|
||||
} catch(Exception e) {
|
||||
/*
|
||||
* In case of exception dont do anything let it create long form urls.
|
||||
* */
|
||||
}
|
||||
}
|
||||
|
||||
ParamMap coAuthorProfileURLParams = new ParamMap(
|
||||
|
@ -226,21 +202,16 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
.equalsIgnoreCase(visMode)) {
|
||||
|
||||
|
||||
if (isIndividualURIBasedOnDefaultNamespace(individualURI, vitroRequest)) {
|
||||
String individualLocalName = UtilityFunctions.getIndividualLocalName(
|
||||
individualURI,
|
||||
vitroRequest);
|
||||
|
||||
try {
|
||||
if (StringUtils.isNotBlank(individualLocalName)) {
|
||||
|
||||
Individual individual = vitroRequest.getWebappDaoFactory().getIndividualDao().getIndividualByURI(individualURI);
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.COINVESTIGATOR_VIS_SHORT_URL
|
||||
+ "/" + individualLocalName;
|
||||
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.COINVESTIGATOR_VIS_SHORT_URL
|
||||
+ "/" + individual.getLocalName();
|
||||
|
||||
} catch(Exception e) {
|
||||
/*
|
||||
* In case of exception dont do anything let it create long form urls.
|
||||
* */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -376,21 +347,15 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"),
|
||||
organizationNode.toString());
|
||||
|
||||
if (isIndividualURIBasedOnDefaultNamespace(organizationNode.toString(), vitroRequest)) {
|
||||
String individualLocalName = UtilityFunctions.getIndividualLocalName(
|
||||
organizationNode.toString(),
|
||||
vitroRequest);
|
||||
|
||||
try {
|
||||
if (StringUtils.isNotBlank(individualLocalName)) {
|
||||
|
||||
Individual individual = vitroRequest.getWebappDaoFactory().getIndividualDao().getIndividualByURI(organizationNode.toString());
|
||||
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.PUBLICATION_TEMPORAL_VIS_SHORT_URL
|
||||
+ "/" + individual.getLocalName();
|
||||
|
||||
} catch(Exception e) {
|
||||
/*
|
||||
* In case of exception dont do anything let it create long form urls.
|
||||
* */
|
||||
}
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.PUBLICATION_TEMPORAL_VIS_SHORT_URL
|
||||
+ "/" + individualLocalName;
|
||||
}
|
||||
|
||||
ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.joda.time.format.DateTimeFormatter;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
|
@ -261,4 +262,31 @@ public class UtilityFunctions {
|
|||
.isVClass("http://xmlns.com/foaf/0.1/Person");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* This method will test whether the current uri is based off of default namespace. If so,
|
||||
* go ahead & provide local name.
|
||||
* @param givenURI
|
||||
* @param vitroRequest
|
||||
* @return
|
||||
*/
|
||||
public static String getIndividualLocalName(String givenURI, VitroRequest vitroRequest) {
|
||||
|
||||
if (UrlBuilder.isUriInDefaultNamespace(givenURI, vitroRequest)) {
|
||||
|
||||
try {
|
||||
|
||||
Individual individual = vitroRequest.getWebappDaoFactory().getIndividualDao()
|
||||
.getIndividualByURI(givenURI);
|
||||
|
||||
return individual.getLocalName();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -52,23 +52,6 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel {
|
|||
return getVisUrl(coauthorVisURL);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Remove this method once Rebecca creates one. Right now it is the exact copy of the method found in
|
||||
* BaseIndividualTemplateModel.getRdfUrl
|
||||
* @return
|
||||
*/
|
||||
private boolean isIndividualURIBasedOnDefaultNamespace() {
|
||||
URI uri = new URIImpl(getUri());
|
||||
String namespace = uri.getNamespace();
|
||||
|
||||
// Individuals in the default namespace
|
||||
// e.g., http://vivo.cornell.edu/individual/n2345/n2345.rdf
|
||||
// where default namespace = http://vivo.cornell.edu/individual/
|
||||
// Other individuals: http://some.other.namespace/n2345?format=rdfxml
|
||||
String defaultNamespace = vreq.getWebappDaoFactory().getDefaultNamespace();
|
||||
return (defaultNamespace.equals(namespace)) ? true : false;
|
||||
}
|
||||
|
||||
public String getCoInvestigatorVisUrl() {
|
||||
|
||||
String coinvestigatorVisURL = getBaseVisUrl() + "/" + VisualizationFrameworkConstants.COINVESTIGATOR_VIS_SHORT_URL + "/";
|
||||
|
@ -77,7 +60,9 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel {
|
|||
}
|
||||
|
||||
private String getVisUrl(String coinvestigatorVisURL) {
|
||||
boolean isUsingDefaultNameSpace = isIndividualURIBasedOnDefaultNamespace();
|
||||
boolean isUsingDefaultNameSpace = UrlBuilder.isUriInDefaultNamespace(
|
||||
getUri(),
|
||||
vreq);
|
||||
|
||||
if (isUsingDefaultNameSpace) {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue