NIHVIVO-2508 Change template properties to methods so not pre-computed.
This commit is contained in:
parent
6379ec4cad
commit
69b315effe
7 changed files with 50 additions and 56 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<#assign qrCodeWidth = "150">
|
<#assign qrCodeWidth = "150">
|
||||||
|
|
||||||
<h2>Export QR Code <em>(<a href="${individual.doQrData().aboutQrCodesUrl}" title="More info on QR codes">What is this?</a>)</em></h2>
|
<h2>Export QR Code <em>(<a href="${individual.qrData().aboutQrCodesUrl}" title="More info on QR codes">What is this?</a>)</em></h2>
|
||||||
|
|
||||||
<#assign thumbUrl = individual.thumbUrl! "${urls.images}/placeholders/person.thumbnail.jpg" >
|
<#assign thumbUrl = individual.thumbUrl! "${urls.images}/placeholders/person.thumbnail.jpg" >
|
||||||
<img class="qrCode" src="${thumbUrl}" width="160" />
|
<img class="qrCode" src="${thumbUrl}" width="160" />
|
||||||
|
|
|
@ -27,14 +27,14 @@
|
||||||
-->
|
-->
|
||||||
<#macro renderCode display="icon" width="125">
|
<#macro renderCode display="icon" width="125">
|
||||||
<#if hasValidVCard()>
|
<#if hasValidVCard()>
|
||||||
<#assign qrCodeLinkedImage><a title="Export QR codes" href="${individual.doQrData().exportQrCodeUrl}"><@qrCodeVCard qrCodeWidth=width /></a></#assign>
|
<#assign qrCodeLinkedImage><a title="Export QR codes" href="${individual.qrData().exportQrCodeUrl}"><@qrCodeVCard qrCodeWidth=width /></a></#assign>
|
||||||
|
|
||||||
<#if (display == "full")>
|
<#if (display == "full")>
|
||||||
<h5 class="qrCode">vCard QR</h5>
|
<h5 class="qrCode">vCard QR</h5>
|
||||||
${qrCodeLinkedImage}
|
${qrCodeLinkedImage}
|
||||||
<#elseif (display == "icon")>
|
<#elseif (display == "icon")>
|
||||||
<li role="listitem">
|
<li role="listitem">
|
||||||
<a id="qrIcon" title="vCard QR Code" href="${individual.doQrData().exportQrCodeUrl}"><img class="middle" src="${urls.images}/individual/qr_icon.png" alt="qr icon" /></a>
|
<a id="qrIcon" title="vCard QR Code" href="${individual.qrData().exportQrCodeUrl}"><img class="middle" src="${urls.images}/individual/qr_icon.png" alt="qr icon" /></a>
|
||||||
<span id="qrCodeImage" class="hidden">${qrCodeLinkedImage} <a class="qrCloseLink" href="#">Close</a></span>
|
<span id="qrCodeImage" class="hidden">${qrCodeLinkedImage} <a class="qrCloseLink" href="#">Close</a></span>
|
||||||
</li>
|
</li>
|
||||||
<#else>
|
<#else>
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
<#function getQrCodeUrlForVCard qrCodeWidth>
|
<#function getQrCodeUrlForVCard qrCodeWidth>
|
||||||
|
|
||||||
<#local qrData = individual.doQrData() >
|
<#local qrData = individual.qrData() >
|
||||||
|
|
||||||
<#local core = "http://vivoweb.org/ontology/core#">
|
<#local core = "http://vivoweb.org/ontology/core#">
|
||||||
<#local foaf = "http://xmlns.com/foaf/0.1/">
|
<#local foaf = "http://xmlns.com/foaf/0.1/">
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
|
|
||||||
<#function getQrCodeUrlForLink qrCodeWidth>
|
<#function getQrCodeUrlForLink qrCodeWidth>
|
||||||
|
|
||||||
<#local qrData = individual.doQrData() >
|
<#local qrData = individual.qrData() >
|
||||||
|
|
||||||
<#local url = qrData.externalUrl! >
|
<#local url = qrData.externalUrl! >
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
|
|
||||||
<#function hasValidVCard>
|
<#function hasValidVCard>
|
||||||
|
|
||||||
<#local qrData = individual.doQrData() >
|
<#local qrData = individual.qrData() >
|
||||||
|
|
||||||
<#local firstName = qrData.firstName! >
|
<#local firstName = qrData.firstName! >
|
||||||
<#local lastName = qrData.lastName! >
|
<#local lastName = qrData.lastName! >
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
<#if isAuthor>
|
<#if isAuthor>
|
||||||
<#assign coAuthorIcon = "${urls.images}/visualization/co_author_icon.png">
|
<#assign coAuthorIcon = "${urls.images}/visualization/co_author_icon.png">
|
||||||
<#assign mapOfScienceIcon = "${urls.images}/visualization/mapofscience/vivo-scimap.png">
|
<#assign mapOfScienceIcon = "${urls.images}/visualization/mapofscience/vivo-scimap.png">
|
||||||
<#assign coAuthorVisUrl = individual.coAuthorVisUrl>
|
<#assign coAuthorVisUrl = individual.coAuthorVisUrl()>
|
||||||
<#assign mapOfScienceVisUrl = individual.mapOfScienceUrl>
|
<#assign mapOfScienceVisUrl = individual.mapOfScienceUrl()>
|
||||||
|
|
||||||
<#assign googleJSAPI = "https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22packages%22%3A%5B%22imagesparkline%22%5D%7D%5D%7D">
|
<#assign googleJSAPI = "https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22packages%22%3A%5B%22imagesparkline%22%5D%7D%5D%7D">
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#if isInvestigator>
|
<#if isInvestigator>
|
||||||
<#assign coInvestigatorVisUrl = individual.coInvestigatorVisUrl>
|
<#assign coInvestigatorVisUrl = individual.coInvestigatorVisUrl()>
|
||||||
<#assign coInvestigatorIcon = "${urls.images}/visualization/co_investigator_icon.png">
|
<#assign coInvestigatorIcon = "${urls.images}/visualization/co_investigator_icon.png">
|
||||||
|
|
||||||
<div id="coinvestigator_link_container" class="collaboratorship-link-container">
|
<div id="coinvestigator_link_container" class="collaboratorship-link-container">
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
<#-- Map Of Science visualization -->
|
<#-- Map Of Science visualization -->
|
||||||
|
|
||||||
<div id="map-of-science">
|
<div id="map-of-science">
|
||||||
<h3><img src="${urls.images}/visualization/mapofscience/vivo-scimap.png" width="25px" height="25px" /><a href="${individual.mapOfScienceUrl}">Map of Science</a></h3>
|
<h3><img src="${urls.images}/visualization/mapofscience/vivo-scimap.png" width="25px" height="25px" /><a href="${individual.mapOfScienceUrl()}">Map of Science</a></h3>
|
||||||
</div>
|
</div>
|
|
@ -3,5 +3,5 @@
|
||||||
<#-- Temporal graph visualization -->
|
<#-- Temporal graph visualization -->
|
||||||
|
|
||||||
<div id="temporal-graph">
|
<div id="temporal-graph">
|
||||||
<h3><img src="${urls.images}/visualization/temporal_vis_icon.jpg" width="25px" height="25px" /><a href="${individual.temporalGraphUrl}">Temporal Graph</a></h3>
|
<h3><img src="${urls.images}/visualization/temporal_vis_icon.jpg" width="25px" height="25px" /><a href="${individual.temporalGraphUrl()}">Temporal Graph</a></h3>
|
||||||
</div>
|
</div>
|
|
@ -31,17 +31,15 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel {
|
||||||
private static final String CORE = "http://vivoweb.org/ontology/core#";
|
private static final String CORE = "http://vivoweb.org/ontology/core#";
|
||||||
private static final String PERSON_CLASS = FOAF + "Person";
|
private static final String PERSON_CLASS = FOAF + "Person";
|
||||||
private static final String ORGANIZATION_CLASS = FOAF + "Organization";
|
private static final String ORGANIZATION_CLASS = FOAF + "Organization";
|
||||||
|
private static final String BASE_VISUALIZATION_URL =
|
||||||
|
UrlBuilder.getUrl(Route.VISUALIZATION_SHORT.path());
|
||||||
|
|
||||||
private Map<String, String> qrData = null;
|
private Map<String, String> qrData = null;
|
||||||
|
|
||||||
public IndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
public IndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
||||||
super(individual, vreq);
|
super(individual, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getBaseVisUrl() {
|
|
||||||
return getUrl(Route.VISUALIZATION_SHORT.path());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, String> generateQrData() {
|
private Map<String, String> generateQrData() {
|
||||||
|
|
||||||
Map<String,String> qrData = new HashMap<String,String>();
|
Map<String,String> qrData = new HashMap<String,String>();
|
||||||
|
@ -81,62 +79,60 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel {
|
||||||
return qrData;
|
return qrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getVisUrl(String visPath) {
|
||||||
|
String visUrl;
|
||||||
|
boolean isUsingDefaultNameSpace = UrlBuilder.isUriInDefaultNamespace(
|
||||||
|
getUri(),
|
||||||
|
vreq);
|
||||||
|
|
||||||
|
if (isUsingDefaultNameSpace) {
|
||||||
|
visUrl = visPath + getLocalName();
|
||||||
|
} else {
|
||||||
|
visUrl = UrlBuilder.addParams(
|
||||||
|
visPath,
|
||||||
|
new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, getUri()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return visUrl;
|
||||||
|
}
|
||||||
|
|
||||||
/* Template properties */
|
/* Template methods (for efficiency, not pre-computed) */
|
||||||
|
|
||||||
public boolean isPerson() {
|
public boolean person() {
|
||||||
return isVClass(PERSON_CLASS);
|
return isVClass(PERSON_CLASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOrganization() {
|
public boolean organization() {
|
||||||
return isVClass(ORGANIZATION_CLASS);
|
return isVClass(ORGANIZATION_CLASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCoAuthorVisUrl() {
|
public String coAuthorVisUrl() {
|
||||||
String coauthorVisURL = getBaseVisUrl() + "/" + VisualizationFrameworkConstants.COAUTHORSHIP_VIS_SHORT_URL + "/";
|
String url = BASE_VISUALIZATION_URL + "/" + VisualizationFrameworkConstants.COAUTHORSHIP_VIS_SHORT_URL + "/";
|
||||||
return getVisUrl(coauthorVisURL);
|
return getVisUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCoInvestigatorVisUrl() {
|
public String coInvestigatorVisUrl() {
|
||||||
String coinvestigatorVisURL = getBaseVisUrl() + "/" + VisualizationFrameworkConstants.COINVESTIGATOR_VIS_SHORT_URL + "/";
|
String url =
|
||||||
return getVisUrl(coinvestigatorVisURL);
|
BASE_VISUALIZATION_URL + "/" + VisualizationFrameworkConstants.COINVESTIGATOR_VIS_SHORT_URL + "/";
|
||||||
|
return getVisUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getVisUrl(String coinvestigatorVisURL) {
|
public String temporalGraphUrl() {
|
||||||
boolean isUsingDefaultNameSpace = UrlBuilder.isUriInDefaultNamespace(
|
String url =
|
||||||
getUri(),
|
BASE_VISUALIZATION_URL + "/" + VisualizationFrameworkConstants.PUBLICATION_TEMPORAL_VIS_SHORT_URL + "/";
|
||||||
vreq);
|
return getVisUrl(url);
|
||||||
|
|
||||||
if (isUsingDefaultNameSpace) {
|
|
||||||
return coinvestigatorVisURL + getLocalName();
|
|
||||||
} else {
|
|
||||||
return UrlBuilder.addParams(
|
|
||||||
coinvestigatorVisURL,
|
|
||||||
new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, getUri()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTemporalGraphUrl() {
|
|
||||||
if (!isOrganization()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String temporalVisURL = getBaseVisUrl() + "/" + VisualizationFrameworkConstants.PUBLICATION_TEMPORAL_VIS_SHORT_URL + "/";
|
|
||||||
return getVisUrl(temporalVisURL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMapOfScienceUrl() {
|
public String mapOfScienceUrl() {
|
||||||
String mapOfScienceVisURL = getBaseVisUrl() + "/" + VisualizationFrameworkConstants.MAP_OF_SCIENCE_VIS_SHORT_URL + "/";
|
String url =
|
||||||
return getVisUrl(mapOfScienceVisURL);
|
BASE_VISUALIZATION_URL + "/" + VisualizationFrameworkConstants.MAP_OF_SCIENCE_VIS_SHORT_URL + "/";
|
||||||
|
return getVisUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, String> qrData() {
|
||||||
/* Template methods */
|
|
||||||
|
|
||||||
public Map<String, String> doQrData() {
|
|
||||||
if(qrData == null)
|
if(qrData == null)
|
||||||
qrData = generateQrData();
|
qrData = generateQrData();
|
||||||
return qrData;
|
return qrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,10 @@ public class ListedIndividual extends BaseListedIndividual {
|
||||||
super(individual, vreq);
|
super(individual, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Access methods for templates */
|
/* Template properties */
|
||||||
|
|
||||||
public String getPreferredTitle() {
|
public String getPreferredTitle() {
|
||||||
return cleanTextForDisplay( individual.getDataValue(CORE + "preferredTitle") );
|
return cleanTextForDisplay( individual.getDataValue(CORE + "preferredTitle") );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add method to get core:webpages
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue