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
|
@ -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,23 +173,19 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
.equalsIgnoreCase(visMode)) {
|
||||
|
||||
|
||||
if (isIndividualURIBasedOnDefaultNamespace(individualURI, vitroRequest)) {
|
||||
|
||||
try {
|
||||
|
||||
Individual individual = vitroRequest.getWebappDaoFactory().getIndividualDao().getIndividualByURI(individualURI);
|
||||
|
||||
String individualLocalName = UtilityFunctions.getIndividualLocalName(
|
||||
individualURI,
|
||||
vitroRequest);
|
||||
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.COAUTHORSHIP_VIS_SHORT_URL
|
||||
+ "/" + individual.getLocalName();
|
||||
|
||||
} catch(Exception e) {
|
||||
/*
|
||||
* In case of exception dont do anything let it create long form urls.
|
||||
* */
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(individualLocalName)) {
|
||||
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.COAUTHORSHIP_VIS_SHORT_URL
|
||||
+ "/" + individualLocalName;
|
||||
|
||||
}
|
||||
|
||||
ParamMap coAuthorProfileURLParams = new ParamMap(
|
||||
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
|
||||
individualURI,
|
||||
|
@ -226,21 +202,16 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
.equalsIgnoreCase(visMode)) {
|
||||
|
||||
|
||||
if (isIndividualURIBasedOnDefaultNamespace(individualURI, vitroRequest)) {
|
||||
|
||||
try {
|
||||
|
||||
Individual individual = vitroRequest.getWebappDaoFactory().getIndividualDao().getIndividualByURI(individualURI);
|
||||
String individualLocalName = UtilityFunctions.getIndividualLocalName(
|
||||
individualURI,
|
||||
vitroRequest);
|
||||
|
||||
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.
|
||||
* */
|
||||
}
|
||||
if (StringUtils.isNotBlank(individualLocalName)) {
|
||||
|
||||
return UrlBuilder.getUrl(VisualizationFrameworkConstants.SHORT_URL_VISUALIZATION_REQUEST_PREFIX)
|
||||
+ "/" + VisualizationFrameworkConstants.COINVESTIGATOR_VIS_SHORT_URL
|
||||
+ "/" + individualLocalName;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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);
|
||||
|
||||
if (StringUtils.isNotBlank(individualLocalName)) {
|
||||
|
||||
try {
|
||||
|
||||
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;
|
||||
|
@ -260,5 +261,32 @@ public class UtilityFunctions {
|
|||
.getIndividualByURI(subentity.getIndividualURI())
|
||||
.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
Add a link
Reference in a new issue